From 22d25edf54dd8639f5988a000973f3f2054b0724 Mon Sep 17 00:00:00 2001 From: huahaiyan <3686255842@qq.com> Date: Tue, 6 Feb 2024 15:10:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lot/csvcode.h | 23 + XPlatForm.pro | 222 + XPlatForm.pro.user.37f85c8 | 297 + XPlatForm.pro.user.d0fd913 | 318 + bengal.qm | 1 + bengal.ts | 7072 ++++++++++++++++ chinese.qm | Bin 0 -> 90093 bytes chinese.ts | 7084 +++++++++++++++++ datafile/datafiledsr.cpp | 1021 +++ datafile/datafiledsr.h | 205 + datafile/datafiledst.cpp | 934 +++ datafile/datafiledst.h | 157 + datafile/datafilequi.cpp | 1014 +++ datafile/datafilequi.h | 130 + datafile/datafilequix.cpp | 1297 +++ datafile/datafilequix.h | 118 + datafile/dataoperat.cpp | 2304 ++++++ datafile/dataoperat.h | 83 + datafile/dsrcryption.cpp | 319 + datafile/dsrcryption.h | 33 + datafile/dxf/dxfhelper.cpp | 520 ++ datafile/dxf/dxfhelper.h | 110 + datafile/dxf/dxflib/dl_attributes.h | 237 + datafile/dxf/dxflib/dl_codes.h | 546 ++ datafile/dxf/dxflib/dl_creationadapter.h | 138 + datafile/dxf/dxflib/dl_creationinterface.h | 369 + datafile/dxf/dxflib/dl_dxf.cpp | 5332 +++++++++++++ datafile/dxf/dxflib/dl_dxf.h | 529 ++ datafile/dxf/dxflib/dl_entities.h | 1813 +++++ datafile/dxf/dxflib/dl_exception.h | 55 + datafile/dxf/dxflib/dl_extrusion.h | 143 + datafile/dxf/dxflib/dl_global.h | 13 + datafile/dxf/dxflib/dl_writer.h | 654 ++ datafile/dxf/dxflib/dl_writer_ascii.cpp | 156 + datafile/dxf/dxflib/dl_writer_ascii.h | 74 + datafile/dxf/dxfreader.cpp | 379 + datafile/dxf/dxfreader.h | 109 + datafile/embdata.cpp | 3800 +++++++++ datafile/embdata.h | 202 + datafile/hpgl/importhpgl.cpp | 2401 ++++++ datafile/hpgl/importhpgl.h | 294 + datafile/hpgl/marker.cpp | 262 + datafile/hpgl/marker.h | 418 + datafile/hpgl/plotbitmap.cpp | 79 + datafile/hpgl/plotbitmap.h | 64 + datafile/hpgl/typedef.h | 107 + datafile/hpgl/vectorfont.cpp | 918 +++ datafile/hpgl/vectorfont.h | 132 + denmark.qm | 1 + denmark.ts | 7072 ++++++++++++++++ english.qm | 1 + english.ts | 7080 ++++++++++++++++ items/assistitem.cpp | 43 + items/assistitem.h | 36 + items/cmdconfig.h | 218 + items/errorcodestateitem.cpp | 37 + items/errorcodestateitem.h | 33 + items/fileitem.cpp | 63 + items/fileitem.h | 48 + items/itemsmanage.cpp | 484 ++ items/itemsmanage.h | 96 + items/nineitem.cpp | 44 + items/nineitem.h | 30 + items/outctrlitem.cpp | 101 + items/outctrlitem.h | 68 + items/paraitem.cpp | 77 + items/paraitem.h | 90 + items/parasetitem.cpp | 44 + items/parasetitem.h | 36 + items/patternsetitem.cpp | 43 + items/patternsetitem.h | 36 + items/sensoritem.cpp | 46 + items/sensoritem.h | 35 + items/shortcutitem.cpp | 43 + items/shortcutitem.h | 35 + machine/comm/comm.cpp | 438 + machine/comm/comm.h | 205 + machine/comm/config.h | 16 + machine/comm/crc16.cpp | 159 + machine/comm/crc16.h | 60 + machine/comm/crc32.cpp | 74 + machine/comm/crc32.h | 33 + machine/comm/datadef.h | 395 + machine/comm/protocol.h | 1752 ++++ machine/comm/typedef.h | 107 + machine/comport.cpp | 157 + machine/comport.h | 43 + machine/error.cpp | 105 + machine/error.h | 12 + machine/gatewaytcpclient.cpp | 334 + machine/gatewaytcpclient.h | 72 + machine/lotmachine.cpp | 289 + machine/lotmachine.h | 73 + machine/machine.cpp | 1962 +++++ machine/machine.h | 299 + machine/qbindtcpsocket.cpp | 186 + machine/qbindtcpsocket.h | 53 + machine/qextserial/posix_qextserialport.cpp | 1117 +++ machine/qextserial/posix_qextserialport.h | 57 + machine/qextserial/qextserialbase.cpp | 250 + machine/qextserial/qextserialbase.h | 196 + machine/qextserial/qextserialport.cpp | 98 + machine/qextserial/qextserialport.h | 27 + machine/qextserial/win_qextserialport.cpp | 880 ++ machine/qextserial/win_qextserialport.h | 48 + machine/tcpclient.cpp | 501 ++ machine/tcpclient.h | 102 + main.cpp | 306 + main.h | 244 + mctype/machinetypefun.cpp | 188 + mctype/machinetypefun.h | 81 + mctype/mainwidgetfunction.cpp | 4098 ++++++++++ mctype/mainwidgetfunction.h | 230 + .../function/clothingmac.cpp | 1454 ++++ .../patternsingleboard/function/clothingmac.h | 39 + .../function/fiveheadprecisionsewing.cpp | 967 +++ .../function/fiveheadprecisionsewing.h | 227 + .../function/highsinglequilting.cpp | 1375 ++++ .../function/highsinglequilting.h | 35 + .../function/multineedlerotary.cpp | 412 + .../function/multineedlerotary.h | 39 + .../patternsingleboard/mainUI/mainwidget.cpp | 4395 ++++++++++ mctype/patternsingleboard/mainUI/mainwidget.h | 300 + .../patternsingleboard/mainUI/mainwidget.ui | 4524 +++++++++++ settings/lotsettings.h | 112 + settings/settings.cpp | 453 ++ settings/settings.h | 57 + sharedviews/brokenlinedialog.cpp | 159 + sharedviews/brokenlinedialog.h | 50 + sharedviews/brokenlinedialog.ui | 158 + sharedviews/controlactionwidget.cpp | 780 ++ sharedviews/controlactionwidget.h | 86 + sharedviews/controlactionwidget.ui | 1577 ++++ sharedviews/debuginfodialog.cpp | 246 + sharedviews/debuginfodialog.h | 47 + sharedviews/debuginfodialog.ui | 651 ++ sharedviews/fileselectdialog.cpp | 245 + sharedviews/fileselectdialog.h | 54 + sharedviews/fileselectdialog.ui | 330 + sharedviews/headspacingsheetdialog.cpp | 612 ++ sharedviews/headspacingsheetdialog.h | 90 + sharedviews/headspacingsheetdialog.ui | 264 + sharedviews/mcheaddialog.cpp | 233 + sharedviews/mcheaddialog.h | 64 + sharedviews/mcheaddialog.ui | 213 + sharedviews/mybutton.cpp | 367 + sharedviews/mybutton.h | 86 + sharedviews/numerinputdialog.cpp | 792 ++ sharedviews/numerinputdialog.h | 100 + sharedviews/numerinputdialog.ui | 1052 +++ sharedviews/parametersetdialog.cpp | 2210 +++++ sharedviews/parametersetdialog.h | 149 + sharedviews/parametersetdialog.ui | 543 ++ sharedviews/passworddialog.cpp | 312 + sharedviews/passworddialog.h | 50 + sharedviews/passworddialog.ui | 3930 +++++++++ sharedviews/patternmanagewidget.cpp | 1615 ++++ sharedviews/patternmanagewidget.h | 132 + sharedviews/patternmanagewidget.ui | 1026 +++ sharedviews/patternselectwidget.cpp | 947 +++ sharedviews/patternselectwidget.h | 115 + sharedviews/patternselectwidget.ui | 648 ++ sharedviews/promptdialog.cpp | 1067 +++ sharedviews/promptdialog.h | 135 + sharedviews/promptdialog.ui | 1064 +++ sharedviews/sensorinputwidget.cpp | 590 ++ sharedviews/sensorinputwidget.h | 99 + sharedviews/sensorinputwidget.ui | 520 ++ sharedviews/setcontrolstyle.cpp | 207 + sharedviews/setcontrolstyle.h | 37 + sharedviews/setworkarea.cpp | 190 + sharedviews/setworkarea.h | 63 + sharedviews/setworkarea.ui | 216 + sharedviews/systemmanagedialog.cpp | 748 ++ sharedviews/systemmanagedialog.h | 108 + sharedviews/systemmanagedialog.ui | 649 ++ sharedviews/wordsinputdialog.cpp | 360 + sharedviews/wordsinputdialog.h | 53 + sharedviews/wordsinputdialog.ui | 1880 +++++ spanish.qm | Bin 0 -> 13706 bytes spanish.ts | 7072 ++++++++++++++++ turkey.qm | Bin 0 -> 186538 bytes turkey.ts | 7008 ++++++++++++++++ 183 files changed, 130061 insertions(+) create mode 100644 Lot/csvcode.h create mode 100644 XPlatForm.pro create mode 100644 XPlatForm.pro.user.37f85c8 create mode 100644 XPlatForm.pro.user.d0fd913 create mode 100644 bengal.qm create mode 100644 bengal.ts create mode 100644 chinese.qm create mode 100644 chinese.ts create mode 100644 datafile/datafiledsr.cpp create mode 100644 datafile/datafiledsr.h create mode 100644 datafile/datafiledst.cpp create mode 100644 datafile/datafiledst.h create mode 100644 datafile/datafilequi.cpp create mode 100644 datafile/datafilequi.h create mode 100644 datafile/datafilequix.cpp create mode 100644 datafile/datafilequix.h create mode 100644 datafile/dataoperat.cpp create mode 100644 datafile/dataoperat.h create mode 100644 datafile/dsrcryption.cpp create mode 100644 datafile/dsrcryption.h create mode 100644 datafile/dxf/dxfhelper.cpp create mode 100644 datafile/dxf/dxfhelper.h create mode 100644 datafile/dxf/dxflib/dl_attributes.h create mode 100644 datafile/dxf/dxflib/dl_codes.h create mode 100644 datafile/dxf/dxflib/dl_creationadapter.h create mode 100644 datafile/dxf/dxflib/dl_creationinterface.h create mode 100644 datafile/dxf/dxflib/dl_dxf.cpp create mode 100644 datafile/dxf/dxflib/dl_dxf.h create mode 100644 datafile/dxf/dxflib/dl_entities.h create mode 100644 datafile/dxf/dxflib/dl_exception.h create mode 100644 datafile/dxf/dxflib/dl_extrusion.h create mode 100644 datafile/dxf/dxflib/dl_global.h create mode 100644 datafile/dxf/dxflib/dl_writer.h create mode 100644 datafile/dxf/dxflib/dl_writer_ascii.cpp create mode 100644 datafile/dxf/dxflib/dl_writer_ascii.h create mode 100644 datafile/dxf/dxfreader.cpp create mode 100644 datafile/dxf/dxfreader.h create mode 100644 datafile/embdata.cpp create mode 100644 datafile/embdata.h create mode 100644 datafile/hpgl/importhpgl.cpp create mode 100644 datafile/hpgl/importhpgl.h create mode 100644 datafile/hpgl/marker.cpp create mode 100644 datafile/hpgl/marker.h create mode 100644 datafile/hpgl/plotbitmap.cpp create mode 100644 datafile/hpgl/plotbitmap.h create mode 100644 datafile/hpgl/typedef.h create mode 100644 datafile/hpgl/vectorfont.cpp create mode 100644 datafile/hpgl/vectorfont.h create mode 100644 denmark.qm create mode 100644 denmark.ts create mode 100644 english.qm create mode 100644 english.ts create mode 100644 items/assistitem.cpp create mode 100644 items/assistitem.h create mode 100644 items/cmdconfig.h create mode 100644 items/errorcodestateitem.cpp create mode 100644 items/errorcodestateitem.h create mode 100644 items/fileitem.cpp create mode 100644 items/fileitem.h create mode 100644 items/itemsmanage.cpp create mode 100644 items/itemsmanage.h create mode 100644 items/nineitem.cpp create mode 100644 items/nineitem.h create mode 100644 items/outctrlitem.cpp create mode 100644 items/outctrlitem.h create mode 100644 items/paraitem.cpp create mode 100644 items/paraitem.h create mode 100644 items/parasetitem.cpp create mode 100644 items/parasetitem.h create mode 100644 items/patternsetitem.cpp create mode 100644 items/patternsetitem.h create mode 100644 items/sensoritem.cpp create mode 100644 items/sensoritem.h create mode 100644 items/shortcutitem.cpp create mode 100644 items/shortcutitem.h create mode 100644 machine/comm/comm.cpp create mode 100644 machine/comm/comm.h create mode 100644 machine/comm/config.h create mode 100644 machine/comm/crc16.cpp create mode 100644 machine/comm/crc16.h create mode 100644 machine/comm/crc32.cpp create mode 100644 machine/comm/crc32.h create mode 100644 machine/comm/datadef.h create mode 100644 machine/comm/protocol.h create mode 100644 machine/comm/typedef.h create mode 100644 machine/comport.cpp create mode 100644 machine/comport.h create mode 100644 machine/error.cpp create mode 100644 machine/error.h create mode 100644 machine/gatewaytcpclient.cpp create mode 100644 machine/gatewaytcpclient.h create mode 100644 machine/lotmachine.cpp create mode 100644 machine/lotmachine.h create mode 100644 machine/machine.cpp create mode 100644 machine/machine.h create mode 100644 machine/qbindtcpsocket.cpp create mode 100644 machine/qbindtcpsocket.h create mode 100644 machine/qextserial/posix_qextserialport.cpp create mode 100644 machine/qextserial/posix_qextserialport.h create mode 100644 machine/qextserial/qextserialbase.cpp create mode 100644 machine/qextserial/qextserialbase.h create mode 100644 machine/qextserial/qextserialport.cpp create mode 100644 machine/qextserial/qextserialport.h create mode 100644 machine/qextserial/win_qextserialport.cpp create mode 100644 machine/qextserial/win_qextserialport.h create mode 100644 machine/tcpclient.cpp create mode 100644 machine/tcpclient.h create mode 100644 main.cpp create mode 100644 main.h create mode 100644 mctype/machinetypefun.cpp create mode 100644 mctype/machinetypefun.h create mode 100644 mctype/mainwidgetfunction.cpp create mode 100644 mctype/mainwidgetfunction.h create mode 100644 mctype/patternsingleboard/function/clothingmac.cpp create mode 100644 mctype/patternsingleboard/function/clothingmac.h create mode 100644 mctype/patternsingleboard/function/fiveheadprecisionsewing.cpp create mode 100644 mctype/patternsingleboard/function/fiveheadprecisionsewing.h create mode 100644 mctype/patternsingleboard/function/highsinglequilting.cpp create mode 100644 mctype/patternsingleboard/function/highsinglequilting.h create mode 100644 mctype/patternsingleboard/function/multineedlerotary.cpp create mode 100644 mctype/patternsingleboard/function/multineedlerotary.h create mode 100644 mctype/patternsingleboard/mainUI/mainwidget.cpp create mode 100644 mctype/patternsingleboard/mainUI/mainwidget.h create mode 100644 mctype/patternsingleboard/mainUI/mainwidget.ui create mode 100644 settings/lotsettings.h create mode 100644 settings/settings.cpp create mode 100644 settings/settings.h create mode 100644 sharedviews/brokenlinedialog.cpp create mode 100644 sharedviews/brokenlinedialog.h create mode 100644 sharedviews/brokenlinedialog.ui create mode 100644 sharedviews/controlactionwidget.cpp create mode 100644 sharedviews/controlactionwidget.h create mode 100644 sharedviews/controlactionwidget.ui create mode 100644 sharedviews/debuginfodialog.cpp create mode 100644 sharedviews/debuginfodialog.h create mode 100644 sharedviews/debuginfodialog.ui create mode 100644 sharedviews/fileselectdialog.cpp create mode 100644 sharedviews/fileselectdialog.h create mode 100644 sharedviews/fileselectdialog.ui create mode 100644 sharedviews/headspacingsheetdialog.cpp create mode 100644 sharedviews/headspacingsheetdialog.h create mode 100644 sharedviews/headspacingsheetdialog.ui create mode 100644 sharedviews/mcheaddialog.cpp create mode 100644 sharedviews/mcheaddialog.h create mode 100644 sharedviews/mcheaddialog.ui create mode 100644 sharedviews/mybutton.cpp create mode 100644 sharedviews/mybutton.h create mode 100644 sharedviews/numerinputdialog.cpp create mode 100644 sharedviews/numerinputdialog.h create mode 100644 sharedviews/numerinputdialog.ui create mode 100644 sharedviews/parametersetdialog.cpp create mode 100644 sharedviews/parametersetdialog.h create mode 100644 sharedviews/parametersetdialog.ui create mode 100644 sharedviews/passworddialog.cpp create mode 100644 sharedviews/passworddialog.h create mode 100644 sharedviews/passworddialog.ui create mode 100644 sharedviews/patternmanagewidget.cpp create mode 100644 sharedviews/patternmanagewidget.h create mode 100644 sharedviews/patternmanagewidget.ui create mode 100644 sharedviews/patternselectwidget.cpp create mode 100644 sharedviews/patternselectwidget.h create mode 100644 sharedviews/patternselectwidget.ui create mode 100644 sharedviews/promptdialog.cpp create mode 100644 sharedviews/promptdialog.h create mode 100644 sharedviews/promptdialog.ui create mode 100644 sharedviews/sensorinputwidget.cpp create mode 100644 sharedviews/sensorinputwidget.h create mode 100644 sharedviews/sensorinputwidget.ui create mode 100644 sharedviews/setcontrolstyle.cpp create mode 100644 sharedviews/setcontrolstyle.h create mode 100644 sharedviews/setworkarea.cpp create mode 100644 sharedviews/setworkarea.h create mode 100644 sharedviews/setworkarea.ui create mode 100644 sharedviews/systemmanagedialog.cpp create mode 100644 sharedviews/systemmanagedialog.h create mode 100644 sharedviews/systemmanagedialog.ui create mode 100644 sharedviews/wordsinputdialog.cpp create mode 100644 sharedviews/wordsinputdialog.h create mode 100644 sharedviews/wordsinputdialog.ui create mode 100644 spanish.qm create mode 100644 spanish.ts create mode 100644 turkey.qm create mode 100644 turkey.ts diff --git a/Lot/csvcode.h b/Lot/csvcode.h new file mode 100644 index 0000000..feb95cb --- /dev/null +++ b/Lot/csvcode.h @@ -0,0 +1,23 @@ +#ifndef CSVCODE_H +#define CSVCODE_H + +#define CSV_MC_TYPE_01 0x01 //平绣机 +#define CSV_MC_TYPE_02 0x02 //带毛巾 +#define CSV_MC_TYPE_03 0x03 //带缠绕 + +#define CSV_00_CODE_1 0x0001 //通用-主轴点动 +#define CSV_00_CODE_2 0x0002 //通用-定起绣点 +#define CSV_00_CODE_3 0x0003 //通用-回起绣点 +#define CSV_00_CODE_4 0x0004 //通用-边框检查 +#define CSV_00_CODE_5 0x0005 //通用-手动换色 +#define CSV_00_CODE_6 0x0006 //通用-手动加油 +#define CSV_00_CODE_7 0x0007 //通用-匹绣 +#define CSV_00_CODE_8 0x0008 //通用-自动定软限位 +#define CSV_00_CODE_9 0x0009 //通用-遍历 +#define CSV_02_CODE_1 0x0001 //毛巾-毛巾M轴归零 +#define CSV_02_CODE_2 0x0002 //毛巾-毛巾打环轴归零 +#define CSV_03_CODE_1 0x0001 //缠绕-缠绕压脚电机归零 +#define CSV_03_CODE_2 0x0002 //缠绕-缠绕锯齿电机归零 + + +#endif // CSVCODE_H diff --git a/XPlatForm.pro b/XPlatForm.pro new file mode 100644 index 0000000..68a3c1a --- /dev/null +++ b/XPlatForm.pro @@ -0,0 +1,222 @@ +#------------------------------------------------- +# +# Project created by Qt5.9.1 2021-03-08T08:42:36 +# created by HUAHAIYAN +#------------------------------------------------- + +TEMPLATE = app + + +TARGET = XPlatForm + +CONFIG += c++11 +CONFIG += resources_big + +QT += core gui network +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +OBJECTS_DIR += obj +MOC_DIR += moc +UI_DIR += forms +RCC_DIR += rccs + +#昆仑通态操作屏设置时间的库 +unix:LIBS +=-L/usr/local/MCGS/sysroot-mcgs/usr/lib -lmcgs-hal + +FORMS += \ + sharedviews/controlactionwidget.ui \ + sharedviews/numerinputdialog.ui \ + sharedviews/parametersetdialog.ui \ + sharedviews/passworddialog.ui \ + sharedviews/patternmanagewidget.ui \ + sharedviews/patternselectwidget.ui \ + sharedviews/promptdialog.ui \ + sharedviews/sensorinputwidget.ui \ + sharedviews/systemmanagedialog.ui \ + sharedviews/wordsinputdialog.ui \ + mctype/patternsingleboard/mainUI/mainwidget.ui \ + sharedviews/brokenlinedialog.ui \ + sharedviews/setworkarea.ui \ + sharedviews/mcheaddialog.ui \ + sharedviews/headspacingsheetdialog.ui \ + sharedviews/fileselectdialog.ui \ + sharedviews/debuginfodialog.ui + + +HEADERS += \ + main.h \ + items/paraitem.h \ + items/sensoritem.h \ + machine/comport.h \ + machine/error.h \ + machine/machine.h \ + machine/qbindtcpsocket.h \ + machine/tcpclient.h \ + machine/comm/comm.h \ + machine/comm/config.h \ + machine/comm/crc16.h \ + machine/comm/crc32.h \ + machine/comm/datadef.h \ + machine/comm/protocol.h \ + machine/comm/typedef.h \ + machine/qextserial/qextserialbase.h \ + machine/qextserial/qextserialport.h \ + datafile/datafiledst.h \ + datafile/embdata.h \ + datafile/datafiledsr.h \ + items/outctrlitem.h \ + items/shortcutitem.h \ + items/cmdconfig.h \ + items/fileitem.h \ + settings/settings.h \ + sharedviews/controlactionwidget.h \ + sharedviews/numerinputdialog.h \ + sharedviews/parametersetdialog.h \ + sharedviews/passworddialog.h \ + sharedviews/patternmanagewidget.h \ + sharedviews/patternselectwidget.h \ + sharedviews/promptdialog.h \ + sharedviews/sensorinputwidget.h \ + sharedviews/systemmanagedialog.h \ + sharedviews/wordsinputdialog.h \ + sharedviews/mybutton.h \ + mctype/mainwidgetfunction.h \ + sharedviews/setcontrolstyle.h \ + datafile/dsrcryption.h \ + items/itemsmanage.h \ + items/assistitem.h \ + items/patternsetitem.h \ + mctype/patternsingleboard/mainUI/mainwidget.h \ + settings/lotsettings.h \ + machine/lotmachine.h \ + items/parasetitem.h \ + mctype/machinetypefun.h \ + machine/gatewaytcpclient.h \ + items/errorcodestateitem.h \ + mctype/patternsingleboard/function/highsinglequilting.h \ + sharedviews/brokenlinedialog.h \ + sharedviews/setworkarea.h \ + datafile/datafilequi.h \ + datafile/datafilequix.h \ + datafile/dataoperat.h \ + sharedviews/mcheaddialog.h \ + sharedviews/headspacingsheetdialog.h \ + mctype/patternsingleboard/function/fiveheadprecisionsewing.h \ + sharedviews/fileselectdialog.h \ + sharedviews/debuginfodialog.h \ + items/nineitem.h \ + mctype/patternsingleboard/function/clothingmac.h \ + mctype/patternsingleboard/function/multineedlerotary.h \ +# datafile/dxf/dxfhelper.h \ +# datafile/dxf/dxfreader.h \ +# datafile/dxf/dxflib/dl_attributes.h \ +# datafile/dxf/dxflib/dl_codes.h \ +# datafile/dxf/dxflib/dl_creationadapter.h \ +# datafile/dxf/dxflib/dl_creationinterface.h \ +# datafile/dxf/dxflib/dl_dxf.h \ +# datafile/dxf/dxflib/dl_entities.h \ +# datafile/dxf/dxflib/dl_exception.h \ +# datafile/dxf/dxflib/dl_extrusion.h \ +# datafile/dxf/dxflib/dl_global.h \ +# datafile/dxf/dxflib/dl_writer.h \ +# datafile/dxf/dxflib/dl_writer_ascii.h \ + datafile/hpgl/importhpgl.h \ + datafile/hpgl/marker.h \ + datafile/hpgl/typedef.h \ + datafile/hpgl/vectorfont.h + +SOURCES += \ + main.cpp \ + items/paraitem.cpp \ + items/sensoritem.cpp \ + machine/comport.cpp \ + machine/error.cpp \ + machine/machine.cpp \ + machine/qbindtcpsocket.cpp \ + machine/tcpclient.cpp \ + machine/comm/comm.cpp \ + machine/comm/crc16.cpp \ + machine/comm/crc32.cpp \ + machine/qextserial/qextserialbase.cpp \ + machine/qextserial/qextserialport.cpp \ + datafile/datafiledst.cpp \ + datafile/embdata.cpp \ + datafile/datafiledsr.cpp \ + items/outctrlitem.cpp \ + items/shortcutitem.cpp \ + items/fileitem.cpp \ + settings/settings.cpp \ + sharedviews/controlactionwidget.cpp \ + sharedviews/numerinputdialog.cpp \ + sharedviews/parametersetdialog.cpp \ + sharedviews/passworddialog.cpp \ + sharedviews/patternmanagewidget.cpp \ + sharedviews/patternselectwidget.cpp \ + sharedviews/promptdialog.cpp \ + sharedviews/sensorinputwidget.cpp \ + sharedviews/systemmanagedialog.cpp \ + sharedviews/wordsinputdialog.cpp \ + sharedviews/mybutton.cpp \ + mctype/mainwidgetfunction.cpp \ + sharedviews/setcontrolstyle.cpp \ + datafile/dsrcryption.cpp \ + items/itemsmanage.cpp \ + items/assistitem.cpp \ + items/patternsetitem.cpp \ + mctype/patternsingleboard/mainUI/mainwidget.cpp \ + machine/lotmachine.cpp \ + items/parasetitem.cpp \ + mctype/machinetypefun.cpp \ + machine/gatewaytcpclient.cpp \ + items/errorcodestateitem.cpp \ + mctype/patternsingleboard/function/highsinglequilting.cpp \ + sharedviews/brokenlinedialog.cpp \ + sharedviews/setworkarea.cpp \ + datafile/datafilequi.cpp \ + datafile/datafilequix.cpp \ + datafile/dataoperat.cpp \ + sharedviews/mcheaddialog.cpp \ + sharedviews/headspacingsheetdialog.cpp \ + mctype/patternsingleboard/function/fiveheadprecisionsewing.cpp \ + sharedviews/fileselectdialog.cpp \ + sharedviews/debuginfodialog.cpp \ + items/nineitem.cpp \ + mctype/patternsingleboard/function/clothingmac.cpp \ + mctype/patternsingleboard/function/multineedlerotary.cpp \ +# datafile/dxf/dxfhelper.cpp \ +# datafile/dxf/dxfreader.cpp \ +# datafile/dxf/dxflib/dl_dxf.cpp \ +# datafile/dxf/dxflib/dl_writer_ascii.cpp \ + datafile/hpgl/importhpgl.cpp \ + datafile/hpgl/marker.cpp \ + datafile/hpgl/vectorfont.cpp + +#windows下调用库 +#win32:LIBS += $$PWD/../../HMI-Widget/XPlatform/Dll/Machine.dll +#win32:LIBS += $$PWD/../../HMI-Widget/XPlatform/Dll/DataFileComb.dll + +#linux下调用库 +#unix:LIBS += $$PWD/../../HMI-Widget/XPlatform/Dll/Machine + +#RESOURCES += \ +# bf.qrc + +unix:INSTALLS += target +unix:target.path=/storage/oprt + +TRANSLATIONS += chinese.ts\ +english.ts\ +spanish.ts\ +bengal.ts\ +turkey.ts\ +denmark.ts + + +unix:HEADERS += machine/qextserial/posix_qextserialport.h +unix:SOURCES += machine/qextserial/posix_qextserialport.cpp +unix:DEFINES += _TTY_POSIX_ + +win32:HEADERS += machine/qextserial/win_qextserialport.h +win32:SOURCES += machine/qextserial/win_qextserialport.cpp +win32:DEFINES += _TTY_WIN_ + diff --git a/XPlatForm.pro.user.37f85c8 b/XPlatForm.pro.user.37f85c8 new file mode 100644 index 0000000..7227158 --- /dev/null +++ b/XPlatForm.pro.user.37f85c8 @@ -0,0 +1,297 @@ + + + + + + EnvironmentId + {37f85c89-6fa5-437b-ab42-a8f793baa331} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Arm + Arm + {5193437b-bed9-404f-9b07-632a0d6f24f0} + 0 + 0 + 0 + + /mnt/hgfs/sharefile/Quilting/quilting/Arm + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /mnt/hgfs/sharefile/Quilting/quilting/build-XPlatForm-Arm-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 2 + + + + true + Check for free disk space + + RemoteLinux.CheckForFreeDiskSpaceStep + + + + + + / + 5242880 + + + true + Upload files via SFTP + + RemoteLinux.DirectUploadStep + + + + + + false + true + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy to Remote Linux Host + + DeployToGenericLinux + + 1 + + + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 1 + + XPlatForm (on Remote Device) + + RemoteLinuxRunConfiguration:XPlatForm + + XPlatForm + + false + + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/XPlatForm.pro.user.d0fd913 b/XPlatForm.pro.user.d0fd913 new file mode 100644 index 0000000..3b96250 --- /dev/null +++ b/XPlatForm.pro.user.d0fd913 @@ -0,0 +1,318 @@ + + + + + + EnvironmentId + {d0fd913b-0ad1-48d3-b46a-051bc8e184a0} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.9.1 MinGW 32bit + Desktop Qt 5.9.1 MinGW 32bit + qt.591.win32_mingw53_kit + 0 + 0 + 0 + + D:/sharefile/Quilting/Windows + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + D:/sharefile/Quilting/build-XPlatForm-Desktop_Qt_5_9_1_MinGW_32bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + D:/sharefile/Quilting/build-XPlatForm-Desktop_Qt_5_9_1_MinGW_32bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + 构建 + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + 清理 + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + 在本地部署 + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + XPlatForm + + Qt4ProjectManager.Qt4RunConfiguration:D:/sharefile/Quilting/XPlatform/XPlatForm.pro + true + + XPlatForm.pro + false + + D:/sharefile/Quilting/Windows + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/bengal.qm b/bengal.qm new file mode 100644 index 0000000..be651ee --- /dev/null +++ b/bengal.qm @@ -0,0 +1 @@ + + + + + BrokenLineDialog + + + Form + + + + + + 1 + + + + + Broken Line Prompt + + + + + ClothingMac + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + Template recognition device + + + + + No device:0;Bar code:1;Coding hole:2;Multiple files:3 + + + + + X frame sensor coordinates + + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Y frame sensor coordinates + + + + + Spindle parking sensor angle + + + + + Lift sensor coordinates + + + + + Angle of spindle hook sensor + + + + + Spindle jog parking angle + + + + + X movable area negative boundary + + + + + X movable area positive boundary + + + + + Y movable area negative boundary + + + + + Y movable area positive boundary + + + + + X Sewing area negative boundary + + + + + X Sewing area positive boundary + + + + + Y Sewing area negative boundary + + + + + Y Sewing area positive boundary + + + + + XY start stop speed + + + + + + + + + + + mm/s + + + + + XY zero running speed + + + + + XY simulate running speed + + + + + XY movement acceleration + + + + + + mm/s2 + + + + + XY brake acceleration + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + XY maximum moving speed + + + + + Spindle start stop speed + + + + + + + + + + + + + + + + + r/min + + + + + Spindle zero reset speed + + + + + Spindle running speed + + + + + Spindle running acceleration + + + + + + + r/ss + + + + + Spindle brake acceleration + + + + + sewing maximum speed + + + + + Spindle zeroing compensation angle + + + + + X gap compensation + + + + + Y gap compensation + + + + + Sewing main shaft working speed + + + + + Spindle cutting speed + + + + + Spindle needle return speed + + + + + Spindle start slow speed + + + + + Reverse equivalent spindle speed + + + + + Sewing frame movement mode + + + + + XY continuous:0;XY intermittent:1 + + + + + Sewing frame start angle + + + + + Sewing frame steadiness angle + + + + + Slow stitch at beginning + + + + + + + Needle + + + + + Needle action, thread loosen allowed + + + + + + + + + + + + + + + + + + + + + + Not allow:0;allowed:1 + + + + + Needle action,tight bobbin spring allowed + + + + + Needle action, catch upper thread allowed + + + + + Cut thread allowed + + + + + Do not trim:0;Automatic:1;Last trimming:2;Data trimming:3 + + + + + Trimmer cutting angle + + + + + Trimming completion angle + + + + + Thread cut, upper thread loosen allowed + + + + + Thread cut, tensile thread allowed + + + + + Thread cut, catch upper thread allowed + + + + + Thread cut, presser foot lift allowed + + + + + Stitch detect if thread broken + + + + + Thread brake detection, main shaft angle + + + + + Bobbin change reminder function + + + + + Not enabled: 0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bobbin thread length + + + + + Bobbin thread correction per stitch + + + + + Bobbin change as per sewed pieces + + + + + + times + + + + + Oiling mode selection + + + + + No oil:0;Oiling by time:1;Oiling by stitches:2;Oiling continously:3 + + + + + Oiling interval by needle stitch + + + + + Oiling interval by working time + + + + + + + s + + + + + Needle Oiling sustained time + + + + + Stop position selection after work complete + + + + + Current:0;Start:1;Anchor:2;Feeding:3;Offset:4 + + + + + Valid flag for offset point coordinates + + + + + + invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate valid symbol + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Delay after pneumatic frame off + + + + + Sewing acceleration + + + + + Trimming frame displacement + + + + + Automatic move to threading point allowed + + + + + Large presser foot action allowed + + + + + Sewing move head up down + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Software limit XY move allowed + + + + + Number of Needle hooks + + + + + Trimming frame direction + + + + + No:0;left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Early speed reduction + + + + + Delayed speed step + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Pneumatic frame off + + + + + + Penumatic frame on + + + + + ms + + + + + Loop work allowed + + + + + Shuttle Oiling sustained time + + + + + Sewing operation speed 1 + + + + + Sewing operation speed 2 + + + + + Sewing operation speed 3 + + + + + Change the sewing needle count value + + + + + Enable + + + + + Disable + + + + + JogP + + + + + JogN + + + + + Zero + + + + + Open + + + + + Close + + + + + Up + + + + + Down + + + + + Extend + + + + + Back + + + + + Combine + + + + + Separate + + + + + X to move motor + + + + + Y to move motor + + + + + Spindle motor + + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + + + + + Frame + + + + + Big foot + + + + + Middle foot + + + + + Buckle the bottom line + + + + + Top and bottom lines + + + + + Lower scissors to cut thread + + + + + Sandwich line + + + + + Elastic thread + + + + + Elastic thread 2 + + + + + Laser control + + + + + Laser blow + + + + + Oil + + + + + Headlamp + + + + + Sewing Blow + + + + + Hookline ext + + + + + Hookline open and close + + + + + Sewing machine head lifting + + + + + Spindle clutch + + + + + Pen + + + + + All to zero + + + + + Needle shuttle reset + + + + + Back thread + + + + + Back offset + + + + + Back shuttle + + + + + Back work + + + + + Set anchor + + + + + Back anchor + + + + + + Back start + + + + + Forwrak or back + + + + + Bottom count reset + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + SoftwareSet + + + + + Authorization + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Select + + + + + Para + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ControlActionWidget + + + Form + + + + + Control action + 控制动作 + + + + + Control action < Auxiliary function + 控制动作 < 辅助功能 + + + + + PageNums: 1/1 + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PushButton + + + + + pageNum: + + + + + The machine is about to move, please pay attention to safety! + + + + + All to zero + + + + + DebugInfoDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + DebugInfo: + + + + + pageNum: 0/0 + + + + + pageNum: + + + + + FileSelectDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + pageNum: + + + + + FiveHeadPrecisionSewing + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + + + + + + + + + + + + + + + + + + + mm + + + + + Left + + + + + Front + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + Y Sewing area Negative boundary + + + + + sewing work speed + + + + + + r/min + + + + + Bobbin thread length + Bottom line length + + + + + Refueling method selection + + + + + Head 4 shuttle refueling + Refueling needles interval + + + + + Refueling duration + + + + + Production preset + + + + + Sewing machine head 2 - surface thread breakage inspection + Thread trimming moving frame direction + + + + + Pin 1 motor + + + + + Allow for needle starting and thread loosening + + + + + Allow for loose thread during thread cutting + + + + + Allow needle withdrawal during thread cutting + + + + + Automatically thread back points during sewing + + + + + Allow for loose lines when moving boxes + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + Shuttle 1 motor + + + + + Spindle 2 motor + + + + + Pin 2 motor + + + + + Shuttle 2 motor + + + + + Spindle 3 motor + + + + + Pin 3 motor + + + + + Shuttle 3 motor + + + + + Spindle 4 motor + + + + + Pin 4 motor + + + + + Spindle 5 motor + + + + + Pin 5 motor + + + + + Shuttle 5 motor + + + + + Head 1 Elastic thread + + + + + Head 2 Elastic thread + + + + + Head 3 Elastic thread + + + + + Head 4 Elastic thread + + + + + Head 5 Elastic thread + + + + + Head 1 blow + + + + + Head 2 blow + + + + + Head 3 blow + + + + + Head 4 blow + + + + + Head 5 blow + + + + + Head 1 trim + + + + + Head 2 trim + + + + + Head 3 trim + + + + + Head 4 trim + + + + + Head 5 trim + + + + + Head 1 needle refueling + + + + + Head 2 needle refueling + + + + + Head 3 needle refueling + + + + + Head 4 needle refueling + + + + + Head 5 needle refueling + + + + + Head 1 shuttle refueling + + + + + Head 2 shuttle refueling + + + + + Head 3 shuttle refueling + + + + + Head 5 shuttle refueling + + + + + Head 1 lifting + + + + + Head 2 lifting + + + + + Head 3 lifting + + + + + Head 4 lifting + + + + + Head 5 lifting + + + + + X Sewing area positive boundary + + + + + Y Sewing area positive boundary + + + + + Zero position coordinate of head 2 + + + + + Zero position coordinate of head 3 + + + + + Zero position coordinate of head 4 + + + + + Zero position coordinate of head 5 + + + + + Sewing motion frame method + + + + + Xy continuous moving box:0;Xy intermittent moving frame:1 + + + + + Thread cutting allowed + + + + + No. of stitch detect if thread broken + Number of thread breakage detection needles + + + + + Bobbin change reminder function + Change shuttle core reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + do not enable this feature:0;Count delay reminders by length:1;Count by number of pieces:2;Prompt immediately based on length:3 + + + + + Count of shuttle change pieces + + + + + Times + + + + + not refueling:0;Intermittent refueling according to worktime:1;Intermittent refueling according to the number of working stitches:2;Continuously refueling:3 + + + + + Interval between refueling stitches + + + + + + + second + + + + + Cutting and parting angle + + + + + Thread trimming completion angle + + + + + Software limit: xy movement + + + + + Automatic sewing speed regulation + Sewing speed reduction mode + + + + + Circular working function + + + + + Duration of shuttle refueling + + + + + Sewing and blowing time + + + + + Sewing hook angle + + + + + Continuous angle of sewing frame + + + + + Zero All + + + + + X to move motor + + + + + Y to move motor + + + + + Head moving motor + + + + + All spindle zero positions + + + + + Spindle 1 motor + Spindle motor + + + + + Shuttle 4 motor + Shuttle motor + + + + + Lock frame cylinder + + + + + Flap control + + + + + Barcode testing + + + + + AllSpleHook + AllSpindleJogs + + + + + Spindle thread cutting speed + + + + + Allowing for wire clamping during wire cutting + + + + + Number of stitches for surface thread clamping + + + + + Head 1 ThreadCuttingAction + + + + + Head 2 ThreadCuttingAction + + + + + Head 3 ThreadCuttingAction + + + + + Head 4 ThreadCuttingAction + + + + + Head 5 ThreadCuttingAction + + + + + Head 1 Clamp wire + + + + + Head 2 Clamp wire + + + + + Head 3 Clamp wire + + + + + Head 4 Clamp wire + + + + + Head 5 Clamp wire + + + + + MU_Canl + makeupCanl + + + + + Makeup1 + makeup1 + + + + + Makeup2 + makeup2 + + + + + Makeup3 + makeup3 + + + + + Makeup4 + makeup4 + + + + + Makeup5 + makeup5 + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + ThCutAct1 + + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Coordinate of threading point X + + + + + Coordinate of threading point Y + + + + + ThCutAct2 + + + + + ThCutAct3 + + + + + ThCutAct4 + + + + + ThCutAct5 + + + + + SetStart + + + + + ProcReset + + + + + Simulate + + + + + HeadLifting + + + + + GoFeedt + + + + + Back start + + + + + Select + + + + + X negative limit + + + + + Y negative limit + + + + + freedom from error + + + + + Not powered on + + + + + + Insufficient air pressure + + + + + + Safe Area Intervention + + + + + + The usage deadline has expired + + + + + Filling data error + + + + + + Working status not allowed + + + + + control error + + + + + Motion control chip version error + + + + + Waiting for button to lift timeout + + + + + FPGA reset error + + + + + Peripheral not ready + + + + + Transmission data error + + + + + Program version error + + + + + Production completed + + + + + forward limit + + + + + Reverse limit + + + + + Motion alarm + + + + + Motion limit + + + + + Exercise emergency stop + + + + + + Motion parameter error + + + + + + Machine parameter error + + + + + + Input parameter error + + + + + The file is correct + + + + + Waiting for files + + + + + Zero successfully + + + + + Zero error + + + + + + Coordinate system error + + + + + + Target position out of range + + + + + + X forward limit + + + + + + X reverse limit + + + + + + Y forward limit + + + + + + Y reverse limit + + + + + + No Data + + + + + data error + + + + + + Spindle not in zero position + + + + + + Rotary shuttle not in zero position + + + + + Needle shuttle out of sync + + + + + Rotation out of sync + + + + + The scissors are not returning to their original position + + + + + + Machine head not in high position + + + + + Machine head not in low position + + + + + Light curtain intervention + + + + + + Broken surface thread + + + + + Bottom line disconnection + + + + + + Head lifting timeout + + + + + + Replacing the shuttle core + + + + + Abnormal feeding pressure roller + + + + + Abnormal discharge pressure roller + + + + + Abnormal discharge and pressing + + + + + Tensioning device abnormal + + + + + Abnormal cloth clamping device + + + + + Edge cutting motor blocked + + + + + Cross cutting motor abnormality + + + + + Password set successfully + + + + + Password setting failed + + + + + Needle motor alarm + + + + + Shuttle motor alarm + + + + + X motor alarm + + + + + Y motor alarm + + + + + Needle motor reset failed + + + + + Shuttle motor reset failed + + + + + X motor reset failed + + + + + Y motor reset failed + + + + + Slave board communication timeout + + + + + X motor not in zero position + + + + + The safety door is not closed + + + + + The machine head is not in a safe area + + + + + Template not in place + + + + + Para + + + + + Starting angle of sewing frame + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + AllSpleJogs + + + + + N/S_Proof + + + + + AMShaftRun + + + + + Setting + + + + + Authorize + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Jog button 1 + + + + + Open frame button 1 + + + + + Manual operation button 1 + + + + + Be ready button 1 + + + + + Key button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + Template in position 1 + + + + + Template in position 2 + + + + + MOTOR_ALM1 + + + + + MOTOR_ALM9 + + + + + MOTOR_ALM17 + + + + + MOTOR_ALM25 + + + + + MOTOR_ALM33 + + + + + MOTOR_ALM41 + + + + + X zero position + + + + + Y zero position + + + + + X deceleration + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Sewing machine head 2 lifting upper limit + + + + + Sewing machine head 3 lifting upper limit + + + + + Sewing machine head 4 lifting upper limit + + + + + Lower lifting limit of sewing machine head 0 + + + + + Lower lifting limit of sewing machine head 1 + + + + + Lower lifting limit of sewing machine head 2 + + + + + Lower lifting limit of sewing machine head 3 + + + + + Moving up motor limit on head 1 + + + + + Moving down motor limit on head 1 + + + + + Sewing needle parking space 1 + + + + + Sewing needle parking space 2 + + + + + Sewing needle parking space 3 + + + + + Embroidery spindle zero position 9 + + + + + Embroidery spindle zero position 10 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing shuttle 2- parking space + + + + + Sewing shuttle 3- parking space + + + + + Sewing shuttle 4- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + Sewing machine head 3 - surface thread breakage inspection + + + + + Sewing machine head 4 - surface thread breakage inspection + + + + + Sewing thread trimming return 1 + + + + + Sewing thread trimming return 2 + + + + + Sewing thread trimming return 3 + + + + + Sewing thread trimming return 4 + + + + + GLOBAL + + + Language + + + + + Year + + + + + Month + + + + + Day + + + + + Hour + + + + + Minute + + + + + Second + + + + + Server IP settings + + + + + Server port settings + + + + + Local IP settings + + + + + Local port settings + + + + + Resolution + + + + + Communication method + + + + + Network:0;SerialPort:1 + + + + + Machine type + + + + + 001 McHighSingleQui:0;002 FiveHeadPrecisionSewing:1;003 ClothingMac:2;004 multineedlerotary:3 + + + + + Whether there is a Automatic shuttle change function + + + + + Is there a Richpeace logo + + + + + Product type + + + + + Chinese:0;English:1 + + + + + ProductNull: + + + + + Parameter is classified + + + + + HMI decrypt + + + + + Gateway connection method + + + + + Serial port:0; Network port:1 + Serial port1:0;Serial port2:1;Network port:2 + + + + + Input rack number + + + + + Network settings + + + + + Factory expects delivery time + + + + + Debugging progress + + + + + HeadSpacingSheetDialog + + + Dialog + + + + + PageNums: 0/0 + + + + + Sub title + + + + + Sub title < Title + + + + + pageNum: + + + + + PageNum: 0/0 + + + + + + + + Prompt + + + + + + USB flash drive is not detected! + + + + + Export successful + + + + + Import successful! + + + + + HighSingleQui + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + % + + + + + Step size + + + + + Reinforcement method + + + + + Tight locking:0;Reinforced locking:1 + + + + + Reinforcement needles + + + + + pin + + + + + Reinforcement frequency + + + + + Angle correction offset + + + + + Angle correction x positive + + + + + Angle correction x negative + + + + + Angle correction y positive + + + + + Angle correction y negative + + + + + Left + + + + + Front + + + + + Automatic shuttle changing device + + + + + + + + + + No:0;Have:1 + + + + + Infrared device + + + + + + + + + Normally closed:0;Normally open:1 + + + + + Pneumatic device + + + + + Power-on device + + + + + Safety door device + + + + + Manual and automatic button device + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + X Sewing area Positive margin + + + + + Y Sewing area Negative boundary + + + + + Y Sewing area Positive margin + + + + + Encoder coefficient molecule + + + + + Zero tangent distance + + + + + Feeding device + + + + + Crosscutting device + + + + + Cloth clamping device + + + + + Tensioning device + + + + + Edge cutting device + + + + + sewing work speed + + + + + + + + r/min + + + + + Spindle Back needle speed + + + + + Sewing moving frame + + + + + Continuous:0;Intermittent:1 + + + + + Sewing acceleration and deceleration mode + + + + + No acceleration or deceleration:0;Xy sine acceleration and deceleration:1 + + + + + Sewing machine head rotating manner + + + + + Continuous rotation:0;Xy intermittent rotation:1 + + + + + Sewing head deceleration mode + + + + + No acceleration or deceleration:0;Intermittent acceleration and deceleration:1 + + + + + + + + + + + Not allow:0;Allowed:1 + + + + + Cut lines allow + + + + + Equal ratio + + + + + Thread loosening is allowed during thread cutting + + + + + During thread cutting, the stay wire is allowed + + + + + Thread clamping is allowed during thread cutting + + + + + It is allowed to lift the presser foot during thread trimming + + + + + Lifting machine head thread cutting is allowed during thread cutting + + + + + The thread clamping of the lifting head is allowed during thread cutting + + + + + It is allowed to hook the thread at the foot of the presser during thread cutting + + + + + Needle withdrawal allowed during thread trimming + + + + + Buckle the thread allowed during thread trimming + + + + + Number of broken wires + + + + + + Needles + + + + + Change bobbin Reminder function + + + + + Not:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bottom line length + + + + + Number of shuttles + + + + + times + + + + + Refueling method selection + + + + + No:0; According to working hours:1; According to the number of working stitches:2; Persistent refueling:3 + + + + + Refueling needles interval + + + + + Refueling duration + + + + + + + s + + + + + Parking position selection after completion + + + + + Current:0;Starting:1;Anchor:2;Feeding:3;Offset:4 + + + + + Offset point coordinate valid flag + + + + + + Invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate effective mark + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Trimming frame displacement + + + + + Automatic threading back point is allowed during sewing + + + + + Lifting and lowering of frame crossing machine head in sewing room + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Frame moving and automatic frame pressing allowed + + + + + Allowed to move frame and thread + + + + + Software limit XY move allowed + + + + + Thread trimming moving frame direction + + + + + Fixed frame:0;Left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Auto Zero after power on + + + + + Automatic drawing is allowed + + + + + The opposite side is allowed when feeding + + + + + Allowing distribution during feeding + + + + + Medium cutting is allowed during feeding + + + + + During feeding, it is allowed to cut across the edge + + + + + The thread loosening is allowed when the head is lifting + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe input emergency door allowed + + + + + Manual and automatic safe input + + + + + Loop work allowed + + + + + Shuttle refueling duration + + + + + + Replace the punch count value + + + + + Starting angle of sewing frame + + + + + Trimming completion angle + + + + + Spindle parking sensor angle + + + + + Spindle thread cutting speed + + + + + Enable + + + + + Disable + + + + + JogP + + + + + JogN + + + + + Zero + + + + + Open + + + + + Close + + + + + X to move motor + + + + + Y to move motor + + + + + Spindle motor + + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + + + + + Lower scissors to cut thread + + + + + Buckle the bottom line + + + + + Elastic thread + + + + + oil + + + + + headlamp + + + + + Sewing machine head lifting + + + + + Sandwich line + + + + + Shuttle changing device grabbing + + + + + Shuttle changer swing + + + + + Shuttle changer rotation + + + + + Sewing Blow + + + + + AllToZero + + + + + BackThread + + + + + BackOffset + + + + + BackZero + + + + + CountReset + + + + + OutputReset + + + + + NeedZeroPos + + + + + ShutZeroPos + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + SoftwareSet + + + + + Authorization + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Select + + + + + Para + + + + + Width + + + + + Height + + + + + Allow for needle starting and thread loosening + + + + + Needle and thread clamping allowed + + + + + Do not trim:0;Automatic thread trim:1;Finally trim:2;Data trim:3 + Do not trim: 0;Automatic thread trim:1;Finally trim:2;Data trim:3 + + + + + Sewing speed reduction mode + + + + + Auto:0;Param:1;Not:2 + + + + + Front_Back + + + + + N/S_Proof + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ImportHPGL + + + Encrypted file parsing error! + + + + + MainWidget + + + Richpeace Embroidery Control System + 富怡绣花控制系统 + + + + + XPlatForm-RP-HMI-L1910-V210713 + + + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + PatternSet + + + + + Pattern + 花样设置 + + + + + Assist + 辅助功能 + + + + + ParaSet + 参数设定 + + + + + Shortcut + 快捷功能 + + + + + Main + 主界面 + + + + + 4999 + + + + + + + Not connected + Status:Not connected + 状态 + + + + + 2021/03/08 8:37:16 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + assist + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + shortcut + + + + + Forward or back + 快进快退 + + + + + + + + + + + + + + + + + + labelParaType + + + + + Init windows... + + + + + Init communication... + + + + + Richpeace Quilting Control System + + + + + Quilting Control System + + + + + FileName + + + + + Index + + + + + StartPoint + + + + + LocatePoint + + + + + Range + + + + + Position + + + + + Production + + + + + + Connected + Status:Connected + + + + + Connnecting... + Status:Connnecting... + + + + + Pattern selection + + + + + Pattern setting > Pattern selection + + + + + Sensor signal + + + + + Auxiliary function > Sensor signal + + + + + Control action + + + + + Auxiliary function > Control action + + + + + + Accessibility + + + + + Accessibility > Software setting + + + + + Accessibility > Network Manage + + + + + Time setting + + + + + Accessibility > Time setting + + + + + Spindle test + + + + + Accessibility > Spindle test + + + + + + + Root + + + + + + + Accessibility > Root + + + + + Pattern import + + + + + Pattern setting > Pattern import + + + + + Pattern export + + + + + Pattern setting > Pattern export + + + + + Pattern delete + + + + + Pattern setting > Pattern delete + + + + + Normal operation + + + + + Ready + Status:Ready + + + + + Working + Status: Working + + + + + Simulated sewing + + + + + Undefined error, + + + + + + Pattern para + + + + + Pattern setting > Head spacing + + + + + Pattern setting > Pattern para + + + + + Prompt + + + + + Loading patterns, please wait... + + + + + Setting workable area + + + + + + + Parameter setting + + + + + Limit parameter + + + + + Speed control parameters + + + + + Action settings + + + + + Operating parameters + + + + + Machine parameters + + + + + Parameter setting > + + + + + Parameter setting > Parameter setting + + + + + MainWidgetFunction + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Prompt + + + + + + + + USB flash drive is not detected! + + + + + The program is corrupted, please re-upgrade after replacing the program! + + + + + The file format is wrong, please select again! + + + + + File bytes are 0, please check the file! + + + + + + File size not match, invalid file! + + + + + Data check error, invalid file! + + + + + Parameters imported successfully! + + + + + File head not match, invalid file! + + + + + Parameter Import + + + + + Auxiliary Function > Parameter Import + + + + + + + + MC Upgrade + + + + + Auxiliary Function > MC Upgrade + + + + + + ssid is empty! + + + + + + Settings require screen restart to take effect! + + + + + IP input + + + + + Whether to exit the program? + + + + + HMI Upgrade + + + + + Auxiliary Function > HMI Upgrade + + + + + Parameters exported successfully! + + + + + All to zero + + + + + + + + + + + + + + + + + + + + + + + + + The machine is about to move, please pay attention to safety! + + + + + + All to reset + + + + + Whether to reset the output? + + + + + If all process to reset? + + + + + Spindle jog + + + + + Spindle rotate angle + + + + + Back work point + + + + + Back to origin + + + + + Set start point + Set embroidery point + + + + + + Whether to set the current point as the start point? + + + + + Back anchor point + + + + + Back embroidery point + + + + + Set offset point + + + + + Whether to set the current point as the offset point? + + + + + Back offset point + + + + + Border check + + + + + Password input + + + + + Whether to set to change a shuttle automatically? + + + + + The machine is about to cut the thread, please pay attention to safety! + + + + + Lower cutter + + + + + The scissors are about to move, please pay attention to safety! + + + + + Trim + + + + + Failed to initialize wlan0! + + + + + Failed to search for WiFi list. Please try again later! + + + + + dynamic + + + + + static + + + + + Failed to obtain IP. Please check the settings! + + + + + WIFI + + + + + Auxiliary Function > WIFI + + + + + Simulate frame + + + + + Process reset + + + + + The machine is about to reset, please pay attention to safety! + + + + + Manual oil + + + + + The machine is about to oil! + + + + + Goto zero pos + + + + + Set work range + + + + + If automatically set work range? + + + + + Bottom line detection + + + + + Face line detection + + + + + Exit successfully! + + + + + Shuttle count reset + Shuttle change + + + + + The machine is about to change the shuttle automatically! + + + + + System info + + + + + Production statistics + + + + + Auxiliary Function > Production statistics + + + + + Error Log + + + + + Auxiliary Function > Error Log + + + + + Breakage Log + + + + + Auxiliary Function > Breakage Log + + + + + ErrorLog + + + + + Auxiliary Function > ErrorLog + + + + + No connection + + + + + Warrant + + + + + Setting workable area + + + + + Debug Info + + + + + Auxiliary Function >Debug Info + + + + + Is the bottom line count reset? + + + + + Are you sure to ManualSwitch? + + + + + Are you sure to AutoSwitch? + + + + + Total number of patterns processed: + + + + + Total number of embroidery: + + + + + Pattern name: + + + + + Pattern break line num: + + + + + Head + + + + + break line num: + + + + + Day + + + + + Hour + + + + + Minutes + + + + + The remaining available time of the machine is + + + + + Undefined error, + + + + + Failed to upgrade the main control system! + + + + + The main control system has been successed, waiting until machine restart + + + + + System will restart %1 s later + + + + + Main control system is being upgraded... + + + + + Failed to send data file! + + + + + The data file is send successfully! + + + + + Data file sending... + + + + + Journal exported successfully! + + + + + Journal exported failed! + + + + + Password input * + + + + + Password input ** + + + + + Password input **** + + + + + + + The password is wrong,please re-enter! + + + + + reset parameters password successfully logged in! + + + + + HMI decrypt + + + + + The interface program is licensed, and then take effect after restarting, please restart manually! + + + + + Password error, interface program authorization failed! + + + + + Is the version restored? + + + + + Modify the first level password + + + + + The two passwords are inconsistent! + + + + + Password reset complete! + + + + + Do you delete the configuration file? + + + + + The settings take effect after restarting the interface! + + + + + Import csv file successful! + + + + + Do you delete the csv file? + + + + + Reset succeeded! + + + + + Whether to enter debug mode? + + + + + whether to exit debug mode? + + + + + Please log in to super user again! + + + + + Is the pattern clear? + + + + + Delete complete! + + + + + Simulated sewing + + + + + Whether to switch working status + + + + + Manual thread cutting + + + + + makeup sewing + + + + + Head lifting and lowering + + + + + Head lifting + + + + + Set anchor point + + + + + Back shuttle pos + + + + + Needle shuttle adjust + + + + + Whether to shut down the computer? + + + + + AllSpindleZeroPositions + + + + + AllSpindleHookLines + + + + + AllSpindleJogs + + + + + NeedleShuttleProofreading + + + + + AllMainShaftRun + + + + + McHeadDialog + + + Dialog + + + + + + + + + + + + PushButton + + + + + MultiNeedleRotary + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + startX + + + + + + + + mm + + + + + startrY + + + + + + + r/min + + + + + Sewing main shaft working speed + + + + + Main shaft zero reset speed + + + + + Main shaft running speed + + + + + + XY zero reset speed + + + + + + + + + mm/s + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + Work head selection 1 + + + + + + Not allow:0;allowed:1 + + + + + Work head selection 2 + + + + + Production preset + + + + + + No. of stitch detect if thread broken + + + + + Needle + + + + + + Bobbin thread length + + + + + Bobbin change reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe door allowed + + + + + X to move motor + + + + + Y to move motor + + + + + All spindle zero positions + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + Setting + + + + + Authorize + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Para + + + + + Select + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Jog button 1 + + + + + Open frame button 1 + + + + + NumerInputDialog + + + Dialog + + + + + C + + + + + (0~3000)rmp + + + + + Number input + + + + + ← + + + + + ParameterSetDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + Sub title + + + + + Sub title < Title + + + + + Repetitions + + + + + + pageNum: + + + + + HMI Configuration + + + + + Root > HMI Configuration + + + + + IOT Configuration + + + + + Root > IOT Configuration + + + + + Network Settings + + + + + IOT Configuration > Network Settings + + + + + Machine parameters + + + + + Root > Machine parameters + + + + + Work parameters + + + + + Root > Work parameters + + + + + Repetitions : 0 + + + + + Server IP settings + + + + + Server Port settings + + + + + + Local IP settings + + + + + Local Port settings + + + + + Board IP settings + + + + + + + Root + + + + + + + Accessibility > Root + + + + + Board port settings + + + + + Local port settings + + + + + + + + + + Network error + + + + + Input + + + + + + + read parameter... + + + + + + + No connection + + + + + + + + + + + Prompt + + + + + + The settings take effect after restarting the interface! + + + + + + Network settings are completed, re-establish after reboot + + + + + The time setting is completed and will take effect after restart + + + + + Unreasonable time setting, please reset + + + + + Time setting failed, please reset + + + + + Connection mode changes, take effect after the reboot! + + + + + Whether to recover the default parameters for the board? + + + + + PassWordDialog + + + Dialog + + + + + Password + + + + + 9 + + + + + 1 + + + + + 2 + + + + + ← + + + + + 3 + + + + + 6 + + + + + 8 + + + + + C + + + + + 0 + + + + + 5 + + + + + 7 + + + + + 4 + + + + + Prompt + + + + + IP settings are unreasonable! + + + + + PatternManageWidget + + + Form + + + + + PageNums: 0/0 + + + + + Sub title < Title + + + + + Sub title + + + + + + 1000.0 + + + + + W + + + + + 500.0 + + + + + 999 + + + + + H + + + + + 1000000 + + + + + Y + + + + + X + + + + + 800.0 + + + + + dst + + + + + C + + + + + N + + + + + pageNum: + + + + + + + + + + Prompt + + + + + Over 1.28 million stitches, can not be imported! + + + + + Format error, can not be imported! + + + + + This file already exists! + + + + + Rename + + + + + Importing + + + + + Exporting + + + + + Import complete + + + + + Export complete + + + + + USB flash drive is not detected! + + + + + Whether to delete the pattern? + + + + + Operation screen + + + + + USB + + + + + + + Pattern Import + + + + + + + Pattern Import < Pattern setting + + + + + Pattern Export + + + + + Pattern Export < Pattern setting + + + + + new folder + + + + + This folder already exists! + + + + + PatternSelectWidget + + + Form + + + + + Name: + 花样名: + + + + + N + + + + + H + C + + + + + W + + + + + + X + + + + + + Y + + + + + Width + + + + + NeedleNum + + + + + Name + + + + + Height + + + + + Pattern Select + 花样选择 + + + + + Pattern Select < Pattern Setting + 花样选择 < 花样设置 + + + + + PageNums: 0/0 + + + + + PageNum: 0/0 + + + + + pageNum: + + + + + Prompt + + + + + The number of stitches of the selected pattern has reached the upper limit (2 million stitches), and it cannot be embroidered! + + + + + PromptDialog + + + Dialog + + + + + Prompt + + + + + ID: + + + + + Password: + 密码: + + + + + ID + + + + + DecryptInfo + + + + + DecryptInfo: + 解密信息: + + + + + Spindle angle: + 主轴角度: + + + + + deg + + + + + + New Password: + 密码: + + + + + Confirm Password: + 解密信息: + + + + + X + + + + + + X - + + + + + Y + + + + + + Y - + + + + + Board + + + + + Build Time: + + + + + Unlimited time + + + + + Time has run out + + + + + Day + + + + + Hour + + + + + Minutes + + + + + ID: %1 + + + + + + Password: %1 + + + + + + Time: %1 + + + + + Warrant + + + + + HMI decrypt + + + + + Spindle angle rotation + + + + + New Password input + + + + + Confirm Password input + + + + + QObject + + + (0x0002)Insufficient air pressure + Insufficient air pressure + + + + + (0x0003)safe area error + safe area error + + + + + (0x0004)Expiration of use + Expiration of use + + + + + (0x0005)Driver alarm + Driver alarm + + + + + (0x0006)Fill data error + Fill data error + + + + + (0x0007)Not allowed to work + Not allowed to work + + + + + (0x0008)Control error + Control error + + + + + (0x0009)Motion control chip version error + Motion control chip version error + + + + + (0x000A)Waiting for button to lift timeout + Waiting for button to lift timeout + + + + + (0x000B)FPGA Reset + FPGA Reset + + + + + (0x000C)Peripheral Device not ready + Peripheral Device not ready + + + + + (0x000D)Transmission data error + Transmission data error + + + + + (0x000E)Program version error + Program version error + + + + + (0x000F)Complete output + Complete output + + + + + (0x0010)Positive limit + Positive limit + + + + + (0x0011)Negative limit + Negative limit + + + + + (0x0012)Motion alarm + Motion alarm + + + + + (0x0013)Motion limit + Motion limit + + + + + (0x0014)Emergency stop + Emergency stop + + + + + (0x0015)Motion parameters error + Motion parameters error + + + + + (0x0016)Machine parameters error + Machine parameters error + + + + + (0x0017)Input parameters error + Input parameters error + + + + + (0x001A)Not in work status error + Not in work status error + + + + + (0x001B)Prohibited frame moving state + Prohibited frame moving state + + + + + (0x001F)Zero success + Zero success + + + + + (0x0020)Return to zero error + Return to zero error + + + + + (0x0021)Coordinate system error + Coordinate system error + + + + + (0x0022)Target position out of bounds + Target position out of bounds + + + + + (0x0023)X Positive limit + X Positive limit + + + + + (0x0024)X Negative limit + X Negative limit + + + + + (0x0025)Y Positive limit + Y Positive limit + + + + + (0x0026)Y Negative limit + Y Negative limit + + + + + (0x002B)Safety door error + + + + + (0x002C)Entering the light curtain 1 + Entering the light curtain 1 + + + + + (0x002D)Entering the light curtain 2 + Entering the light curtain 2 + + + + + (0x0040)None data + None data + + + + + (0x0041)Data error + Data error + + + + + (0x0042)Graphics out of range + Graphics out of range + + + + + (0x0050)Spindle is not in zero position + Spindle is not in zero position + + + + + (0x0051)Rotary hook is not in zero position + + + + + (0x0054)Scissors are not in position + Scissors are not in position + + + + + (0x0056)Nose not in low position + + + + + (0x0058)Thread is broken + Thread is broken + + + + + (0x0059)Bottom thread disconnected + Bottom thread disconnected + + + + + (0x005D)Execution command timed out + Execution command timed out + + + + + (0x005F)Head lifting timeout + + + + + (0x00F0)Change the bobbin + Change the bobbin + + + + + (0x00F1)Replace bobbin A + Replace bobbin A + + + + + (0x00F2)Replace bobbin B + Replace bobbin B + + + + + (0x00F3)The machine is in the state of replacing the bobbin + The machine is in the state of replacing the bobbin + + + + + (0x002E)Insufficient air pressure + + + + + Normal stop + (0x0100)Normal stop + + + + + Find zero success + (0x0101)Find zero success + + + + + work pause + (0x0102)work pause + + + + + End of work + (0x0103)End of work + + + + + Work done + (0x0104)Work done + + + + + Complete production + (0x0105)Complete production + + + + + (0x0106)Execute success + Execute success + + + + + (0x0107)Execute false + Execute false + + + + + (0x0108)wait file + wait file + + + + + (0x0109)change the bobbin + change the bobbin + + + + + (0x010A)Execute finish + Execute finish + + + + + (0x010B)Execute runnibng + Execute runnibng + + + + + Enable + + + + + Disable + + + + + JogP + + + + + JogN + + + + + Turn + + + + + Zero + + + + + Open + + + + + Close + + + + + Ascending + + + + + descending + + + + + Trim + + + + + SensorInputWidget + + + Form + + + + + + Sensor + + + + + PageNums: 1/1 + + + + + pageNum: + + + + + SetWorkArea + + + Form + + + + + Prompt + + + + + X + + + + + + X - + + + + + Y + + + + + + Y - + + + + + SystemManageDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + + Update + + + + + 192.168.2.196 + + + + + StaticIP + + + + + DynamicIP + + + + + *Before setting the static IP, you need to first set the dynamic IP. After the dynamic IP is set, you need to return to this interface to continue setting the static IP + 设置静态IP前需要先设置动态IP,动态IP设置完成后需要返回此界面继续设置静态IP + + + + + pageNum: 0/0 + + + + + pageNum: + + + + + + + + Prompt + + + + + The upgrade needs to restart the program. Do you need to restart to upgrade? + + + + + Do you want to clear the production statistics? + + + + + Do you want to clear the journal? + + + + + Do you want to export journal? + + + + + WordsInputDialog + + + Dialog + + + + + Words input + + + + + Name: + + + + + ← + + + + + old + + + + diff --git a/chinese.qm b/chinese.qm new file mode 100644 index 0000000000000000000000000000000000000000..a1287ce42d02389745c7ee2473181fb45e3b70ab GIT binary patch literal 90093 zcmcFs34Bw<)}OR#lBQ`|O4+xt2_j231d4(zvM7|&R-m$`Y1#(bre*<(3WB0Y#exDV z?uvrXeHRySe=5%n_vdp(T%Q{%sHlAZGjnruZ*uQVitqcr-}fCG?wr}qoH^&rng5*h zNOk9zzQ1P6%e}krS#;wQAB<!8#J_GbG{QYmn zzWxE@^eU$&#}$H(KA)wY^CDyS|IEy9qb&0Z+W7%aP0k5|b~r)Mq7p%ecV^~8PlNYp zLEp&X)YPq*rFFoVrZo$?p^j5i!PB5m;`bW`-EbMFrh?B|+6iwmR(w>@4Ue<55oqtO z4J>U6=D)*xEUgCo(w7K&)f`Sug`-$n-D>>)oS;)46!fZZ1U=+sXgfe?a5f@4uU>>2J3tI0mdNzoL=9|22I4@ z53gr=;h~J}eUB9^@I$^rY(z#U#{O|48(EkQIqb?t{uAr2#}jNc|9dhUdjY;bv6hWp z3tD7nV=n~Fzmtu<2y|E}8+!xj;GfvIjn^@@Z8e*6+7`z8U(BXduVJR+YuVH}7cf(o zv)E}T;`fyQ3VQw+PEGj_vS~xoAgeAmeQO0{CkzsFeHJTucoAd!=Cjh%UO>CQVWqR5 zWhT=?R{GJ0XzyWG;oZsDvOTQg{PoP#FRPrPpRx|D&OgTLGRzj z&btZYdBKhBvd8fI%|Eeg{{p@2Eq2|gO^l6S%x)SAzS9c@y=DyC-WhBAnPzs&VEp@Q zAF$gUkn7d=vim>S!c2Kx*h4>}{Hg2MW4Attak@v)H8a`kw?U3ypU6IWY8u+HmVL9$ z!&uG>f_m>3^v>@EJ<^p^Q+k+v{{_A~YdibFxt6ii34#vnF6i1f1pRR+`}qPZW0%fj zhZ{lP>A{Y==Q8%vV)n)15+40+vPDm)H)Zt*>W-u;TH z$lnioC&zTkSTE+Y!8Ez|0miy*HO<^x#n{IyP1S57V=q2q^3}h?*aKgf7H>JoSYxxP z(Obk=#hIp1$9>Q<^GxT3&xG7gHMQ12=YBH6v~e}*@^1z05fb#A7fhRmd6>y^x@n8) zS^WEPrdxAAV(g8jraSB_8GH9EPED!TneM$Gy0h_N(EW`0+k<`v>IX&p{CiCgPTa%T zxen7~^YQmZ*O(r^YcOMrdYhhUg1oHx-t@wS=&xm%psnLg|ME{jb)TBvIq(41b0)<8RpJCMZ-1VlT&)mY;#+OV--#7*O<>VCe z2GsM;ft2hikgJd1Pic3>>(B!q3)(eLqT+8;>bv}JQ_*rkM}C;n?#kB~J9{>#rtE2g zc6>M`=c7Jo@8v1IuWVwb6EjkVJh>fu_uG{G^HQ;gl%|Z@H=Z%ud4gVkX3FSCFg`Di zO_}5@!dCrQ%A}s4Cw5MmG!%50DP__a(EJ4{lNNvu-kvh2wKro&_oXa4xRRNME>7{B z>tm)qOHyjT$Y<=pH7Rv|tb-eFN@;lNGRC^!oZ=t%Fk^j}r8JfI!+ecR37(AkDw&pY z?uXC|eVbBNHuT4yJ6h0-m#3^XV;tT;nsU+kxy;o2v6M@X-^|#i?kSfJISX=g2PpR9 zGg3jZZ=Z2y%B4HjGxqPdQ#SV5#7sF`Qnu!yeN%=C`pefTTd!!wo;*F}sw;Dt$>mMC zZq;nYZhI-^`hJj)r&g!jdh=j0{Jz+E9l6l z1YQ3@%KcY%XKd^vDSIC7!r1Y_l;@87gt6Q*L62Ms3OUTZPS7J?gQC7%iT-g?${Q0_ zGq(A(l()}(0QzHi$~)&i!%QhRro6N28LX#IQvN*z?d|hy%11lKGWN|)DWC1dzTfw; zlyA?#Jp5-~$}ejgvEIk0{F;70GZkz|`E`B;)@ez~@BY5fJ9nlW`80%n-IHpY1pP4V z*3|T@YhkMGOXYfDXy4R!IVsSqYf?M@S^DJ*+UwR=m zuj{F>*AAr?ZhDTfg>R>hq;e-dkvfXXjrb~cROdd7%{x7{_^U-2$5&G)(EjCkB6T9k z*?U`4PhC=m`MV-@vI+Y_cx`HF#$@b+#i^CgoDVtLk-9h^^)}s^x}5k9nVQ;6e20cp zR}^799=J}>zYeFa{+FAvaic)1K$n7gK<@{w2K@ol3;jPN_2M3o(`i|$7hklQnT9-; zx~*mnV{d1rUONu*u>IcDr|v-g4{k_(<{;$Odb^;T{+asH)7987Ur&8y5^TC_E=+xO zNSLvII#OT10_}DlFX$Qf3VPG;sju(A@3US=ef^(AovE)MCb}f`{XwuZrutGpAmi`9 z*{Of_H!=446=u`yO^p412`JXp?{ApXUb-Cm!_BFw+iT|ZJ{YH_dUN_{$W_{3f{tD- zXls_BKRM0LH%2gaRf?I*!SG^p=dW*J?A~k5J#sstzJulyyjL(b&}SaHcqa7f*XE(C zLEk&YTv*63FW;EOd~GzJGOPn*=ljg#pZ}S$^TOr{&5*Z$K4+frO)lF1s9DV0+vbY9 zoQyeM5VZ6aL2sM}x`46rWuTDbvdy5-3p4LE&)fYAGYtxv=e-Qt>p1hG)tDdeL36{$ zn7;{Mnj3x%W88lg^s-KW6Df2*tc?(-pse{JW~#HI_H z@uQ$!KN57rB0-CPH$QeC<0(pMLED#a#K{t01^yiDrFVC+9zb%5^&|rRb>1OE9 zOhE^A6?9#Tpg)GqU$?)Xu`33czxnfL##(YXHFY@8{GAuS_iPgM`v&tbf8NYY><{yi z_lg+1HY?3ceA6-nh1V`FzUaiM$vQEuGx;Ib96?WhP|%Gh2>R2hX??Ez7W!gWT7TDP z7^k}hz39EPq6*0Cgfr8`I(aMYlzEufW!I$f^>BKJw9~IYgRzw_rk#E_=&HGCr+@q= zg)Bzc1+UlLQ@=leX@<3dT;~mv#yHVeJm5U483B#+rMkU1QH>?BYApt~mkn=%^KR z##%vdI9bqNA5XjH%qnIox;^b0zZrJ4FYVghkn8OO)2{#Q9LSYT&@(?1^p=%^{gW5E&l3kwBZUo7a4x25ge>SgTl&(rR1#k@TEo}eF2O?&3QXzvrF)1KdX z3o{jWNPDR#+L`{Npi{mTbXyle4_%SA_l6_b4;Q4pI}rWI?j`80pQpWd3G~MYnQ8wy z2lbq{C+)*oN3ot~qy=t-Xc5bv}y!R~hi^G!nZ9m59PXaAstnN5V)|KZ$zW!_BdN=PpOZy4` zzg=C`r8*4E^qU@T1NHz3x4KLmXof$m$5hdScKeFSf*t`4_r9GGHuqSjNMXXS@=6* zC=(!|1Q`mJp}cAF6iA?SbU%1_l7?#^@Uqt-yN}p-^YGu zeb};ee>=uLt+ZV5?OkZ^4$C^i&3=31_H!C(IBNy~MoLytPG zmg}xw$yn`cmKzxU&KhpH;r5}7?S9H~W6t-Cy*$`*<2mSuxk1nq-W7Cxqo6;2!l{X^ zu-r7@FX)9wE%#lDb++>%%L4!;FYv366ZAT(<&By$ z#8n=#y!8j{*ul?PKCqX-53yK2F1{Z2`ee(;Uwn#vsH^4k3l5@R4$F~AG(W?vsgu^i zZ=7yT?==(p_z`R7FQ~ULVCC~V;tFfl_djD_zTDb_ejom-wfF7A8T)9mbqM`E^bzZ@ zy4S(?MQg#>5afA}wWt~P#3hHV!|&Vy|LHrcn8$_Ilj-~X4%YF*y2b@u0CMB@pr_no*ZbsmHvIiBvc?mG$vw-+=x0q4l+$koTvaw7x#h48Ocg z&^u4FzBjT1W1ct*b^|Jvs4!MaHqAZS06pg(wRXCmguUP`r9|BiU!=R<7XX_)t$cG+sW z+7S0S0E)Q4aVOd8Dy^_<>OnCMW9|lpyp1^siuR8kZVO(IdRCri3*HU7D#y0$?1>o9 zlWZ6KG=Q1%$Jj1$j)Q)_T+k`Y1ifmFpofOoHn@vm2mLDOj=ODJe!)0@y4QBaB@Z(; z`32imFTn17bGdEjY0!ViU1+;K^)tkc3vCa-hH~w?3VQqLwx_SYo3Za4w&y%IGWP0N z+lzCbf&J>U{p-#1VINGlz3%uC}&S&*ke>Dixbh8%>`JAUyY^wP-m;ZI{c7HkxBXJPuN-2M1| zK>DcO81IM1rJuAO@t50IrjL0t4EyLLK`)z^KKVdL=-GP&z3is+>Ag|!v}@AO=>078 z^z8I`*Ff)${VCo3fd}!xrRi16su`=QOt0?sPssC{^s~Q3JiF7N^p%JSvCnQvU;O~& zrvJ$FwY^GUw-lydcryCAa17`{(DmsT?u6X5J6+J*-v@=c*qJWoZDsm@ z-yMg2VwJtiGv8xAKC}1!{4)5--RynyUqPH}lb}mNg5DDV#eCM<>;o1} zhP`pQeb{js%;b8&Uew$d)H* z&OZ0gfmmlDLHnI4=ns$B=chb?_|d-vZQXD8cz$N==VH6>O!Av^?7n%J$Lq%0R|hx4 zF1Op)A3TMbMoqA<|Fax+Vj-udl&$TGb zf(Gvr^v@6MciGw_&iAYRt}(weQ+L08*MFa7Cfio~qj#acKQ6UD_DUJ_*4g$au7=(` zI>r9Xq*J!Svqr)7wz%(nlxBgTL7h4zDAnHdZH zW?^{XYjAT$>_Ekbjbr5-PVBCPRZzzQNT?7-_3CCh28LVO-A3v zGZ5$cXGXtVj7v*nMqayhh%0u;D9XMPe(28`<1hUO?30ZdGv3*OaXOSyHt}-!gHtmW zZi7AvewDGP&rz(0VS;x0x1i7bp5c4^7sx|J#*#y@+ctcj;U|4j?8*pEdjNLHxfy5o zxdDFse=^Q)K>XqD&oa*KjrH@@5ux^;zl# zJ?Sh#TUUdQ$G?97I)Sm1r)F^ZJJX!;?UqW!WnRhn&aw~lb$rH8_nnOOJtO1DS&I;N z%5|8}za0C=la4eG^hd9=9hM(|X6&aQ9M%@dmLlw-|y+|822guec+Rh@qezt zIm2MbM4Uab0h=7Bq2Fx6Hpjd(q2KM=;&?AR!o)v&gJbDKIM=a# zBIuPN(A!`?94F|Nk2#j_z<96w$+7&!)rdDg>^S?X5sW?E$8q+LkdHgga-92IBkU!M zV{IplU;9r5^<6LM-De7VWVT~%XZ(A|8G<%EDCoT>3i`)8jtwa0Poa;)Q)uN*g@ zig`R2^p~3;Z|6C-ul^D7p>~eDvLA$fa*5;KA0Y1!cXvGWYdPY%S2}imJr?`G3da-I z-3UK%z2o^;p)W7L)bZjC_%7!vL91UE^v=r#{e8CM720pEddTtWfeYYoe(8Ai7tp$W zjt`2V?-qRR_~5<@#PM!-9PoXC^WwbBlrD%%J$;6tU%4_J*B`)n*V@diZ(*-H{h96i zVqJxHWp;Y?IgI;bnOzI99(t!|_Bnuc(DA>S{rcp<4_zqej)9qDA1`98-}jlPKY;$7 z{hFX(?&Z|fzAkgtPhUZA4#=GIEb70cF|%$V_K)V4%q3qnG1m1aPEExtGtXMw0dWOa z<~aj#9@K4T=E`9hPtz}g_8pbEHWhOD+;5o|J@`88pgx%wufxB8bt$K&o+o5p@*Vy? z^KwCN>Xv!S+xK8z4h!0~LC|hJ1wH3@PEG0e3z~aS&@LkdE&4>z;z^lz{egMhkY)gesB&v>AYtjsP7(CR$DQ}yjNi+Dbl$t2sMERUgoCj6hdQ5spda?fZ0Cyy_F(_N z%=y*}kjtFUoF9FJcAeMTx!<3LdR7QJyT70}Z*_k8*aF!3(**tbapyOl3ot%wod130 z2aJ#3dFVpeU)`^F{*jAyJaTy!s{_5MI*ZT4lHamA3|k3%a$8oCma58>y$pLNRor(lOanl;6Ozh63(by`_Z*o#G3We$wrw^wE@`gSJ9=anqqotXb; z%CdZSgFe+Qi_7`hIh>k0hO^E;>0X?#UY@nVH3sJwKW1Il2XV75le4ZtT+`GqE$g~z zEzk=OX6@M38|}!=+EtGA`M~K}kM@J!$lfgIj)hr|O@N(edL!%c7Rck%k7qq`;1l?p z6SH=o{w&t>8(F*0`iwE(nOVC7pbbq~&+SHgF8DC(`D^iAm*s-)FVA}Z4mV@_U(edd zYT)M%&U$+U@%c~IJGr1M_Ga<@bIz|>-|V^ocI#$A4?mRk<3=;|8@itEL zHF_ud-1YuiQ!0M7dGB1g$MafqvHW$8_|8Qix=I87hNh5CaaASeN&Y~C&WBWwXGhtI zWjklglk2gJ^MrhUI#g#F6YBk;I$vY$bhk&eioR^wJ$IY@b-MVv+{+siSHNDMTi#Ol zWW(t!UoO&loG;*N3V4ITaKP)T_J+K?LKh#6I1aX%bsN82Shn?$Ts~u5eZ4E>cdhUS z{MxOYyKTnwrd@1~T*NxA(NpIS%rX4DGWK%{1Za#wtH0!sXIfKzrnzo~pV#*WB%SZPR6C*Pr*NT&~x6e^r&Q(dDUg zH`aPx0dIq^vDzDO)r1=j=54{2m3y|VT5zk(CRbt;stb7C)vkJPV{NETv%i)q50#cn zb{rq}EUEXpLUmqOl|K~nH@NB{lA2}BGlN^cl}n~UoPydP+Sc4#H=@k7wOanzGSOQP z(a>b;pf5K~U)AWns3a;E9YhJ2$KP1vt0md0@zrZHFjwX)hSWOI7j#$Yd}^s(dF}v3 z_noKKyMrO02mPm!(`=u4#wrDS%c+gJ+PE<4 z+b7lgnjl5ZI<2>br(ID+BPEw;H)Z-%*92*Z3))Q6zRQJE@GM5pxb)~HR+PnmbVu7UYI49$er34@&;<$ z9#SP$;aXRNU#EfQ@|Rod<#OiJ{Iw;Ttuin1#C%t(`JJtN^496$;k8i}ohfw|Z3y`T z+J&~3&X`{Qw6{raNcuEigD+I-4!AW7I2QgRc=!ARGv>`4*Yb#5sNFQbzsa@CA6VjY z*Vp@(d9?*GcU6y-x6{0^d}?e-2GuSz89WUI16aL$hCtB{m%qjp^e)4Uxf$UrL40Q9nDATCRL7FxkojTou~Vk(qLD)gG;<2*Mxd^LzBKf{L=T(%zQz!Av_DYoYjlUaF6~WO$t1cl>oU>as?Am93z^(#^Nc31j#*Rv z@{D;Z0kq@WfLni6a?PbGVb&K|`c9?e?ewjYo|j5Q^&&4}pd0NqYf9&N(l_6wu(O<{ z?l1(QDvUk4QD*_$8pf^2sLWI-1qVz^4{WnCFJ?<~er+W?Hobb~1ueVfk!^=E)nQ@9 zkzuD-aKqY_JHi92qT83b%WV6bV#_RdH&!q6dFu4nmR$eLsSD0f)!)0^>midw)L-wb zt-~S+2SRR`a=a1R8ps~$kYZl5IV+#s8Ew_fC3ItY)mQQ?S;}Eid31)GHj0W-^||ub z8RcRZ7?0gWQw$V)3mZZM<-N1+Nx68jR9wA@xQ4i3^z+SHGCZqbL@jZ{ko7e}mFiot zirV;2W>@WG$7|OX+1bKPSj}R8)9i{PvP}|exeML2m`W@)*<_cDZVeGD+OAvcH};ZQ z^^#d(x`TD@nh@W+N%8XyM3Y?(vGVS%yAu~mhLp~0tx>Gf2*Y3SlaW zepntSOS!MM(Os|EdfVdORUgri$X}&sk8k$o!;@GlVVNGX5xac{+wvD|O+^X6r(#y$Y(A_N@G(lCbUA#{v zK)L18ta$u^M#!?h)WAGy4aLlbR91g3a;Oj&F+L|Mz1uxfwJc!XMi_PmmX5t*SlQ0l z&8VC_-2|Ia)#+tBRkmb$1$VM0gtfJnW5ueKd*UpO9-Hetj+Mq=qKA!HCBgjJJcvj2O+B z-h4z}9o=LmHDu(vs(rzxdZ>m5Z=?2T+5%H*2haFqkzZzEodwHSHx@)%P9@n{v&kQU zm>AjAUD@*T@2ThI#j`(xr?o3QjSa*KJ%JrB*V}83OHxKypKi=z&=>MyZC3fijn(cz zv!;H?VROpAr)3^xEHiY?p~X#JxT_5uZEVgGk7}REo)c{hR~wowaj-cR?WiTHWtcUG zTp_Mw^cSLq&DnZLq32PE!dz0VI#IbCwwyK7+Mzm0-zbcQuB6x8jbV2^ubL)b@>#Ua zhIn2D@+j)_D$pE$D+ZsJcA@Z=ry{UIfi&`>JcbArV-Q3&T65PhD==DAq0A zF;W_f5U0ZgWDrVeQ&C7L?Yg~A_uigh$s)`$HSD<~Iki@r{r7-ME!VSSdBgIk&6=f?ZEyA@MCXM|+J**emvU5{QkzaT?DE{!8o9mpansAm*D4EhwbE%4 zYzPWTmj=8DPGatak--ZDqzskA{WYd<<#G%^8t4<|_M35g>BW z!DPf+n&S5_;b*l$*?8l-MzWlnc9rdvrLZe;jyUFv{k6x)Q)ODJc&d!d#O;*Vo2vhG zFk22CNnKAUV=@a>MU#3E%jw1+q_N{h8ZI2k?L6H3)NKz+{>VD zkF7IOHF3u*qC3=jnwDiggngo#TnwA|G08!*8KxK*j(4P}!uAx|3EcKHE*h75kRC}r z;2{R%!sK+T9G%`M>~DaR~w*t||Zhr+O>wp#acQ^V;kZ^`Y;8t)Exa9HdL zd2yhhgbdr~<*)oYCa%?PJmp}xtD9A!EyI@loy-nH#lFu`)t+-?+1}VpY7BO~Mq+Y;r6IMG;$r8^M z51(3A?or7=7X+O-LvEELc1_IX(|yDK^P@MtWG2IsZB1-4Wag~9v+RcYT_oLzO0SaV zwa3J;h-`7GmgXYhtqFUP$CboR-nuI?4_imiSs=6RdMctBG1E|0@AoVb$1{da&0e{G z&AsHmktK)YuBgx1_tb`}fZvA{8%Ia^szsbV zsdVx<>`;_?k>u)~vt;I}-X>3@icb!_brKI(wL9cak`vO^YFANcN*-{>qD3KzI&3RmH=3Ktk^3RmGV3l}(Q2v=cSgsVtXxQf~?TwtUrTt&wwTwtdoTt$CF zxWH9IxQf~$TwtLgTt#gZE^yHluA*ZVE-=&-uA*ZWE^yQkuA;UG*KkeY8s2u{0wYb~ z8h&iT1$H{ZHT-V~7r1H&*YLIo7g%Tr*YGw97r1B&*YIN%E-=&-uHnZlT;Ql7T*KQS zTr^G_)_S8CopQMu7)frWd<2|QCuhIKWhDvcKsuI?^O6iLlEfE%jEhTNZZx@Fap}jf zq=PcMDdSA#nRb{eQo18)XURIJlpB@sfi(^*?g0Na71w&Y{i z_RY7HcZub2y0;C{Z}a@m6;8c*nztsg=-McqzGUyrsK|7krplnll@f1YsYu93I9WDI z=~E>xs;^)f&W>%1scuqz?y6{pK>KNkak)f}rKcG&62z(!wjr9%o=403Z(Phu9Q}&c z^*^};W;i_2x(fbgzj#Vvl64jS&AJK`&X?g8HN#dWx~^te*iP~8s#{uW6q!Hv=`$*3 zlr0=LZ8}e>GA!?imS@phHyKe5BNFyJ%A$Y`m(@{}MZxekuqb5F4A3Zx!o=erZ3V6} zYP6y#@mNI1G8zDmj%5;o-txB_)~)ld>LFKeoqoo`3GT+kflTfomt@W!xb0m>D<6HY?NI@#bTzwy~G=CN@DhT;R3C~i8YO=xlpTcV$l_ai?j+CC7fVUc(_*K z#OuyZIpHyzb(iTP8QjnBH&Xth@_wM<`16wvQbzJDI;Q)13Zxt7uZaVQxpY!O#{p~Z z4os%I1}fp|E%A~L2Y_#Yi|tFr{exu1j4Dv&>qixGLCSm*RoB3s9mDJ>vh>P)!kW=S>afsFe@c?kr*gt|KgxN*xcwz*j1b1EosB1SiB$8ft%bb zYl+`A5$9|P>vT|-2EnV4zaSUyU*aFio6Y?KWU3Ovipv*CIB?-W6@W7dnNP#u3=0oz zIY0>)$Xw22qdn;aB0|Ud3l6n@MA#(wJ)eG$9QWhzg2;C(_Lhy7zKL%8-V$tdUXF-S zU7R->m>tNbmQhTqnk6Wb;{4GfUjV-}h8wDI=Zz+!9yzzc;)2mr8yb*+imQJ}EYc{P zSS#D=Z$!p0Yyx@IoYb%;LPWrY{$%z@N^GHnHr3b&(9dn;wZlb$* zRoP|N%hTMY)Ex{WSEw2}Z@3B-_RwYbnlLid63&IpP^E%8DH-xCkz^H6a(DI(`)IH1 z*s{BJ5GAI`JxPTpM$vs8EnU89_U;Zo

gotYJL{@TJora8(oj36c<9aidX=+Z=E<@!dCurMLU(@nOWu~+f}+;o_O`> zBV!oP7r_IN|EJ1;?@LG-lrJTnwD z36R4zj_&u0&}Nd+yQC2@3OO0Y89L{I5|!47;GH znTP-W4kAdB6%{1g#e$@PPLi!T*)Gb7C9W9IlO!uDOty=K|LZP_AZ`+~D5p0ZV;75( z?PAgYx{F20&Z2zC-li^!MGYJX+A3uo(N$X1aJMPkBMvIWhM7?7IO)#F=5+#mMiF@J zA@P(l+hk;rCW7Hh9E?-5jRFi9vP~SOQ?re_oQ7-@yNZ7ohsSW`MVUjnBmns-&_Loz zk~x-j0_KIs&KwIW0rR4^GUv*j62kvBRFUBT@hc#NVYqV7tPd&kTwXO1fFX11%Z%HUU1EVPU(_kTHu&Li&GEZrviCklo0p5%SAUUKpLmu)q$T%3Xp4_V?pYj+lK`#BS&N>6&(;L=@r^(Bu zdxaa9qA1i(s9vy0rC34$l_UIARw89pdM{U@J+Cn_~-c(7J?k%;RiZ zzN{Uj0^J9QA)=WA{I(j`kEzYX9B?+lB*MzT7A#}bY_gB#CXeDwBM9FFqDd@;ZOmg( zehQ)@gA%VI)B@(YUS5`odog2Gc%T=!o%0WtMX!POqzc190*bB1$v8bY;Hq;6UEbwQ zxX+gOu-8VjuL7RvC~gJG7gm8$5P?xQRF@oVkz)3$$eEN(&9i!Sfg26^8X!j+mQ!Jq z5!Pfdi6M5iULJSDvr`2$aIgWW?WC03a?R5aH`1{2*=J8(xRy>gtM1saOl7n6neE2z z08K}D9nv8ukhUo4IccNKM%-0TM6^?Kr4^ibuxv@eTpIS$S&~VjM~ngwEsCOzbtSw^ z>LZ|4LVy~eHI%FvaxV19C178XeM7%&`FY9Yg;~;X(QwtMInDf9y#!h!-RA(z z6jE&PPdq;!>wz!}$v5SSm0)^{6We|q>QqnDsPR_Yu4(>vu&#!KnFPeEVR<_PIBTq~ zscf^Zsf^b(gcaKsUBg+#YlR4#Hfn{x31VwFW;RwCs}(BSt`(93#WidP<}O|YjS+~Wx3HG*l260L=vu)-X&(c)2Kc^;u>|wk)SA!Q2lgta(#IH77W=MUd zC5Qp%r(MEmVlP9GxNlk$hI84 z&*%0asKDV>;qefx8AYj)5Sz^BaJv=xvJp(Q$PGbc&PJilc9+sgXQ&(|UA=c^*axx7%PVl{U>!q>^705!Lw?s2B9WJe;Ci?o z?lw=%5Af`Z>i1lptPSr@2Lg7sQpwl#22g+ zmZh@1jSgm1sR_9gREIIqqy%NLl*;JC5UCU0JWW^m?>2f8u=Rb#<7_z`2^(=I0P9ia zA`*OQb5s_}o`0Zx4c@T2v1I#(0jiX$9+LpL?nm|x zZl2-~2V%R0P-pE!<%j8>w9K%bxE~!L+)a^5A6v>?^5XuiDRu@~5qjvD@JT{e;s$NLJ zTZSG)2&a}(MmEKK;%1ANTk(DQepNZTc*`S;cvnWRB)_+L&e^kDqrO zDT}^wXPFLXN<2WS>}pD_P3Dz09f)N7)l}sd{33{|rP%yQ1zHDeSH2O~jUdXa_4tMPnk&{yLVK~q(` zOLkN|r5-CJ{?fZ{F0HXLdp~B;r!VQ*IQp~%ne@f6^KL1#wC)UEB#)cD%p3IAha;J~ z%0{TR3OsZsZ57H-a-<=`eH3ZfqJxE09~vTrn=wXtqg|1K=YMlwSINm)n^|__thzXf z%mEiHc_WdOipB|Lu2hsN)Sqs#;0QIBvXE7PrbV;skj#wA#mYmp-i_B9WSm|pV?u(? zR6hEv>{!ZzkUZGtO0PR!QP7mAG8x-gNi#5G>;vpAl_b%#4aq%@;a|KqyX!; zgNrwYOOAM@P{D=2i(te?_q_q>{fJ_h^xl9G6aMVL(XQApl}{EZo=Hf8hgtRDwgnq>~@;`$s*Wyix?p21ZhO4v3UO z8HGXDX{nQ5QScs`cgBKL)yY#o&X24UASolU45u6X#6`f6OD`+v@U+vZ(~R$ycog?V zI*sEH#nM3}KT+pTt?ICFL|9PNR@M^T;+QO#gEfg6E%6vK648OBe7n^ecDY4}7#T3a zO+YEAoUla*8yPZ6&?26wpWuymt&S{YwZ){>$#<9Q?@a33#hrINMgq;wFBwW#3^lm) zBo4wDpgo=JY&N`VNiVjgSJ;OQWqRWEw4Qb}U>=*B{* z`y`UI-$YMB^*GV4MHvcmAC*w@$}NgZx%^U!2D^?FS@x;`QiU=x$o9O9I6u}YW102g)-FBoT488v^vP1?A>enpM;*t9Jxh?BK%s!DC~mt>OQjbR;9lp>dD6tgrL}4Yxf23ccCTCtWqT(XgnUpzJW$dYo{7>8p z)u=C*>JxQ|LmpcAa?`s-YXNg*BuKad8VnsI6?9j-F-@V3?EG3a3~=#Cvqm`^0j;Z6 zcY6-89!X6z9JS(w^Gq{x}{CL32^(t{cNdU%Q5dlmntkc}405q*uO8s|+2Bd4a3 z4ERU}8q}M3Bm?0Jf@6jjC@vf=mTfT))M|AkF6ko+2~Ri~Mx;V$IUSib1aQ}=sI9Q= z8Z69}`RDy9&$e}a;Hp;YsAP2w{)0V`70RfNtClgZ+6gU1)~XzK>Rlk3TZSyN7yPQsG6wn>!nRk7z6#aeQ1mS^z>Us$AY+Y@GtXG1n0U*n92r5Ud3=;tbzE+mRd>!2Z&R6N zZmBFX-A`?#$4mluKXwb7t}#Ty9y`%E2<3gC;67c_U6}?AhCoOM*=FcJRqB8 z1Ox|NKpQM2e&}n1RYzLu7iQH(aj@)@>VYv63^nTxP&PRPw7|++>L#g#I)4(yR3c~T zMVhX$VTIv3iL<~-nNxDRd!T~Y!;qK3?OB(+E`{CZG&{wsJZ~C zE>j@Oh*PmSwdwr7Dav0d{WnGTVN_H&@Whw+*QlP(pV|nlM;{@i%pqkd{>UF)8U3SR zG@kaA|4C0Vccd-AduaB+@|M+IanlJ`epPZjb84(I=9hm-4M(g#g#YkYjUU-*IMSv6 z=AsQ%gA4p5;A*9-GjTbhA)eRDCsR{YjW{{35hBk|Q5COVU0(vj(_H>?YrQOnX24vQ z=rqlYXQ67N^>9qashfs z48CgM^h|j>T`4SMH2iX}x(mL+NYb=q_K3098=E-XJj?V6HV%z2z9g1?z+Zljw3u zg!ra0%C@<`ZC*!tFtWU75R@84JWBoiJWrz#59P-7xsQaw7LBh)9d=_=%Ceb*&B;x0 zNSt_voz93!4n^F%lzCEF#fy~36#huryiRV9Rq)gs4r2g0jq!7NKQ6mrW3Q@?GhgMQ zK^Ph$Lq+;K8a*fhpd7MFZxD~zIO+omRN8)7Lz2>mfOi>_s9Ci8gt`)Je{LaftI=7~$>@s&{A)io|Q zPlq;)IvmRf;i0Jim8_;HjGabWjtih&K^zBAg07qiByun`X5L9>uVh%(rmMy>gEwpn zZoBG6g}N^BEEq{aG{J!Wsw!W|RBU>e@F%Yk01&r?&{_Ex0Eaf}GS3w^9RzDqw<@+B z5TO=(GZ>B&QD$9Mr_~N3^g+SO!*K`8a>^`AFNj4REVF8350(exum|T;i2VN*b5LWh zv@sexMsWfK93ziV=&1$=1yLj2l=VqYlt)km-F3^0C>teivS}O9X|e z!JWgasRF4PGr}R59fpxqdg?%B+nSB6H~LZ)jfufZ)M}PgCh88yAS7y($)Ve86;1)! zv8qvpsdfU|$FC&G3B59=noAsBNr-d^a_fw)JvmrIjfUCiNd}cAnO)lG4T~3w4edr7 zA$h7wW|fi|KZI_w83p-manOB~$U=~ihVx2zeaIf$EsI+_DgA{`U&%Yx4X(Ed6i;J} zjtL4+kB`V*RlG8xfYfW`xqv}&bp(q~XSQu+H_ZBdNpFSw)~U?vYebr_hXWwMr}dr{ zrZ+H+7^t%6a@7o?iE|p=;MG$%7rR^blZx;tZ_` z4+_^oJ<{v77>KZ*@om!w@zZKK9VDsz2B(a!XXGfzE)uy)TfS8JG`%^d9`}Y6Z;$d@ zzs8nxZp81Rbu{CX^1~{&eH3i@*)=Vzps$wh^&0c#V0~M@RISV$;udOl@n#t=&g@95 zNH3^b)I;JSy2`^*VMvEBhf;<~{G9u(t&sd(lQkS=~@MCooAF;s+dk_C0kPa4!sWB3*I zB@5-2FNcz10Qof7a{#xvaA7xT*j1q?3XsCx(3wGw=|PN0$*AVAuNE_LHq9fB$XC{j z)M>-ZwU01V+$z**RTS$CSdj@3!}2u{!}LasA~B15D5 zj%l^76OkhPYHL$nzDt+=XZ(WpwCqvk15;nNMbfk71NXJjxdLl(~#iCA-WNyyMX} zozB>ek*TyMZ*lLck4TNmO-_&CQSn2rEjpar9KWcM|`&e&kF1HT%$(3OH^KWr28iRkV|Z2-rvTJV6vUM+r`V{Ahw!(hoJ* z=z$~EDH|}Yh#%6tbYvz+q;gUuEH3s0fuzDDC2=7!&%&C1_BOIj)F%2WfTT)DHMdLfmna zQfJ`)Hm;0DBa=je(I}Zbbc;seWB^+4unQ zxVXtm8LAwb4(d{pmMTQas`2)Oj=TU9WQj+WZjoIXEi5AiX|%?HM5%U>N6zH6o>eJd z$}zGD&8qttW}`g(t%u628$M`$Os=8>eeDWSt~%m>bYsWe=+U#1EN9i$IGg-(VH<7k zWO-;>=Nu&7h{E_&hK>DL#1pX)--QWuZ z{DIQqqR|cV_rs;X3R4GAi*QZjY~&62ogbDKaXvKgT5^p!iLiS%4M8XhT|wS)(#yyRI8f! z`>s?dL5IyMY)IQA;6auksaunOTcO-m_n67u2+KAf{u!p0Vh7#!?ss`t8)fwl|? zpE}L4h}%N)&}9(RL&#f7i3(Z`Nji%$R^Tipqbbi@uEJFBqu6xh@yLxU4XvZapkt(&foV8YYPn{o^ff}+^^kepLaHPUxex$j0Qz85D4L}q7xFb27NWtCo9Bo$uL<*{ zTaW5=5L3$gj|o*gjTb8l9clg2xQQ8|uohC+KaeZ#8Rf#`VVGD#g+Tb0!$N2^C59zc zpc-mdJj=*0`h%~*R5cX_O!X&6n`v~a44CRqo(5CZRBDW9r2Bf4tHDw=)qNujBtrv} z6#d0u^5Yi`Qi!C*r!f!mwR6dZcybd}Q7f&=lk2{&mmQUuO@FGW= zvAv5w6zg2xgo6g!m$}7AE0Ax4+PiF=*WrkqOX+zTmY5eK?fhD^zBLo)hBy+r9gf;T zbGMaDC8)%s4teCW&w#~QgUsn_fs{B{YZNUsVI@Q4Le|*=l|1fSl^@%4PAOj8fDPO* zq^xuZFw2Ha%O91WH)K{pe%^@u!nnek9KU?j<}6h?2C6xz&PeFcBAi5)#13z!OM0@fm~T>gy>C zC8z!A7M)qQ@k>=GDnlx|Lc+VzE9s~@1+SIIdb?RDO|2}iLuzJOnA@!hInWJ2x$Eu0 zK@#36c=K}_-HfNHOUR{Zmm-_M8RddocF8eNWkYm|GLUj2_{%VcoH`PQ7F|Cg@g-RO zGOMSGjg`CB4NuFun*Ct_QQS&rY0udLYhFuy{9JkQz=0BcUkw)XWh0& zlPjjWzJ^KD7!pEARNQJyazx_p#`V%+@u4Vw)xyh&`TTum3vYGzNJG_?(lCxp%! zpDc>T#WjVIqjtJ*JDWp)>CGz8cw&MB?RZWKqVmxF;^5Y(X(+#8*~7C{+c7GN z-jiNa6wcy>$uvu%-L1RoCe=MzdqD2DV?2TJHKiW&4;r;-dp&eK_^c*<=CU%XlR!Y(1Z)h2A z#<>yh%)^3gX$=2v8vKJx6LYo2ZI0@_?@Xm|!_E+)z_^G8sU9M6Q1{RBrGNGiv zMbNOqKGogN?SpRkSPk=)by`;!sdz%!(EpI6*9uciL2oO|c`r}@TYqoEa40 z4UIG*1c%&R3rpHXuLuSV>(8Op9a-sAw_;YiDC?tJvxJ*OOWv3xStb<9Ak!y?hnimtSB=FVQTrUbV}DNs+dM87E-KakEpTvg3*V(C!dl_v-4 zqcfDSFFlEAWl>3H`KV3P4fJduUKvk)YeYmGSG+uR0ES9d)w*~!NMKB|B1&xJxL0kh z$Oib1hg2?G=460b$gg%7?zM5|EXVdv!g5WF3a+;iSSWU@@NLt0oYt_FRHDRQK3P`V z4qir)j;L1|PF-Tae!3`&s^CqGnxF}5u3IT78x_F04ang#0)$>MzE6?=9dX|ku43n@ zHI#f!VDWS$E&K9`w>Jg-(NJk zF-@`icaV5CNhc5>zlpO`2U0{SW^W-#peo$ztaVA7P;~;^RV3yr(}obUYYbz=rR*WyPQ_*P zc905&M53?)gGi5uxy-WpdU-sp0>oXl&O54vt=uv9`Q=e5={4P7?W+L@B21GS zUmytNNW3HmHG!xlRx-c*q1T3Z2$c>3{KFOT@!Zvm!y@#VJdZAdhje2Grzw8iuH~oe zM(WiPe+EtSD?LnMRFWSktKu5jZ3$uUlVVzaF{`Dw%!EJSiU2=WVA2aF!j%KhE9@5~ zS8*`c7OvfC>VKtN~){rTV%>y@|8c6FS4&htDQv#CF zD>kZGwV~l~SV&mnZOsuW%v`R~vdm+alnh*hj3(KsWT9Y!qhmD_LoPW{E^LtaU%5H$ z<2Vg6wT@V|rDRb)2*pgKa3kMkQ5 z-!ncx$Za{i>1FRdOV3_-MkKjT;j#3QoFY83g2^XKBp62a2cAC0|Kl!-;T{zaXOIak z!Ht^4rxS4@#ttYOxjLC#G*R~mS5L>;H@&>7F-ARPml1w~Pzc^?>7fKY2DZ7|V#0yh zIBtaLnPfC@?zWgn9xtABAaCxrm|$WS)sDf!>mLcji1w)ID6bVKm5E()H^JXkKqiTA%7w{^haj{`&7Mv_8?tv=oPNUx2R;<|2MDa+OgEMmYD{vGI3nzDS ztT$f#YNF~0EF*FRyx91ZhTkTPLw=C2Me>W-$f=J2#pyO6?!rojNF;#LFbUE9`{%oYA~<3+tT~am2*pTZly_gc5GMyj z$fBe$X!6@W4`I}uv@nY{X$oPG7NrCjg_I7ZIw(d#aUQt(RLin}zp+*hWr#GWBsA$D zr4_)tGMGlG!pRrL;FiN=sM0Tr>Z_=FWGKd11ZYIP&x1r+Z}njA6T_f{YLBiK30X%P zYpgQ4xsl;-;Kp-(v*EhJb;Mb9<-vIt4$6r01;xHHikcPy5I}?6xTpbKS3qwI6n-=* zYMCniR>K;*Mrx#sSTrZ~U%Imhv_nzzWZjyn0jO3O_Hvh-0Ma^ozy>`&u>%UbyUI7*3PWL1fJ@2kpBYYsk?(~c>jKnH*x->?w0*H+_^tbxt zQu>H|f5z-mb}uzer7ot5M#TG!b#8JRA?cE3Pts2*zub+)?AFWjC`q}IX2BgsVV*}; zJ{ipPn_~IlE-B1#*=UU{eJR^G;2i>)N)X)bLw5iCgPw)6XHZ3i4n)6@hV z^4rA`s~<~>-ror~!IhB*9#uwywgNjV;H8_0GyoxLs_+;LMIo2QyUaHO4>gAeQd$rK zxY5j&VbtS*m!iSM)V&l@44z;`mscWS&5BiTIKqTjOWK3(66grrSgKD(u%#fetVjO# zD#|6PBBfiw^T=ZC4}P5*LM?0%Bi+e|R#w7>gWK7A4~bC4CCeLIw$p!=WR|eiKPyCv zZ(5;cep#$UXxs;={YD9`(Xa;RqS0l=EB6yXmC9e}UV(=~>J^BP(bMMy-ov8NGtVl! zVg3Q`)iiB-RmHYnEL$n|7L0^8z17C-&8o}PX1YmhBr|{O=`%gsrVXiVnk-ZaVdg}c z3TD+SPuAJ)0OGSe+fb7^U$NT&)u5EBQR}}`5H!zV5 zqm?{}N@s+mZuA(^k)c9yBxXp?6=mS+Fyz|==Lll}P=?(brKmOfVj_$MqgoYinPH_o1&q2V45<=U zG6=?0^jteXwwtmU<<>T$3~S4#fh9oJmK)E$qPAF3PakDHNDTpG+A23Wpf zfQ`rrx_T?EBgrpMt%7bQBV_5>I1`CFrTIdDn<80NP;-&pUl~mVfI)37Vu8L!V_l65 zgCLHTt4oSktWfOpPUNVfFhZ4h4AR&FH(yby7#ezF8tGR?Bg1tGEqe`J(ruYSm(bEr zQkBGCg|mnoh}4jF)9IaO5k@As!9a6T&p+xEb4JoqnM;*cN-rk5A|5d%mb!RmDRcl` z6UWwR&=dtvm51Gxcm}2Goba+S*=^&d$~aYVqwL$HxXEd_DqfVtTMjFeQdbQ+7XQ|z z4Fwk_D%FaMv#LER9f_vI%V4U$c+vcJ1tat1ww)9?m#BE zOM3Ew1IOr;jlX!Re*QzR7MRVU{5Xg1PB?%L*Q<}rECxO7NS3Gj`CaY+31jjRdaFt`r0={5jQ&Xli>yNot*C7bB`)S7Jg1JydMNe(Jar*QJ%UpfqO*mBlP zr#gf(#b2q3j!0L+XcY-e6zC)Hb7!k^fHGau<1TV$ zYc_uH2By+eXA_a0@2`zPmdY5Ix3VxVFYow(fE!Eny=ek9DbZIJQCBjbrhaIR*ysHCYpc;MsZcVnl#L^+}6S?cnnLablD!c$AVDB_&4= zYDyfN_JU2)(wHQsl4Z4)BI%~JSnSFl#%(CQVb{-{)2Yx>{&HpJ%Kh>%XW-EqFI@0QfK{&|2bCif zgri+qo?JRhQQB4P$}<`y11J%_N;^grzF7Bk(5uoToyq?qTp_JUnI6;5YNk=;BKIo7 zHcqP;buXr^aq*unQd_mdKzfah;Yyab%0cfaaplH$lPa>L$I@AwS$5;Bx;X8HH#q{h zEJ5lkDa9l4iBmnf5+AO@BFjv7HdU?3Y1z{8qo@#bL^?f_}d)G;>3d3?(YyY3g z0y?X$bHpPPs!1p&+TdkbJEa19HqX3}hKdf2WPQXlzj#hv{ARCAfJsz6&qzo98D*rX zlyq+;MvRnru1G~en{;OmBic36J%r+HAq&&0VZa%Ui01|UJfx=TY4Y`SrqfQk-&0ad z_S<#uwrrJ;*eEm_>yxiHN_Nz zW0O>SH1j6CNvL%xokFM9?3N?tZ&UZ;ZrQZsfzhVODvw;J(cxoZE=o_4B`qDuUeP-! z{JH?NMs>tERxKg`Kwg$vr*Z^HS?B9_7RBv^ok}be`FwW4fMS{YWmR)!CIl}1Z&6QfG-tXb^SnRl zfKZX#(1*$+QJP!kgIykXBflnHg*;{sOex*I&>jR;OH5M?n?a-HRgYHW9;d+YQ zycx8g1sfNJ#2O9*vyMCK--2NlgoV$GUMTML``{x&yhFGV9AjXONYkMQy;8) zaVtv5qG6XgB&CpHb`o{`^($o`^aD(det>&B=Vg1%<`CidVokf~kKZu{*2r08sC zozq!Qy?YJ063K#S$BuVmCF*{qPI-@P>1BB#gj_ykK>%kcEYx&PCZdv$TIZB!`&JzY zUN&`hQk|ERrNKwK-@bdbY;i*OYF|FwFr`-86P;jMmI_cx^Ys)ieB??Yr4`+fyu8Rt zq%)-a;=S0Ia9uW4Xg1;eHrd96Yb;zGL~GY{{J@;p{cTOS)0!i-ul=BxT0|>7@*2EX z>3c943}Lm;1-Z(ux9>HGhDuah8_7B9SgWa2nCurHg$u@~$mG(>)q-k^U z7qOn2gjfFFmAJxGNnBY_m?~M2bSY9{BZfSL`$a*;3|%ysN;~;+hxCpzy~Cw9IyK{$ zzB_~WeoGf2pFC~K_m6{CdJ$Jr;mq{ZqVN$NN@8javbW#*HFHph_i^|TkpRHKOtC50 z+X}#D!L93KiE~T!eD|Y^zZCp%{iXWC`mMF=5#6F&r!T5w8K~V>EuTPQJgw8Ni{75% z$gSh$32G@OB-nAPD&x1wkC0>5V>>P@c&bD5{9VgZqp|!|LlRr?jqE_|2_Yg}e3q z^7k5hMN)EBk==MOavJ9dXp!64)0sqwOc0iW?hyb9P3)s7e(BNX(8ae*^Pb?_Q?|UD z%`Dqm8YqfYCa(I*`xbZaXEpFqMUlrkznyuwOo1B?)Y&_m2-18odFjzqd>VgB z!woAOf|qrs7+U$k=;6rsw2-eDsCT|O_3*+{?Z@}x6jx7bxS}epBRwOXpyu@rP>N_H zftp=8H$l<);$b#y>4*XwUqc7y`&)WI2zD$`l>tg=?F1G*qlG)B$n|!<(OA7n`n}50 zMNVtw5FZZ|rA`p?eMZ9_S6B?0ncpwn3qrclKv5VtfxYpw^^?SuAV8G{9aU#mImCP+ z#D+`vS{6OZ6l4AmWyOca0!0zgm<`DCZ&lkufzBMm!VoWa#gU{vdKa zp7)`lNg2EGK!K2XGB_EG3BHVd`U~T#Jb7{~J4F%SP7h0cIuWS3!F%srJtR_Ed_m)! zP?Pob<+UYb8fs)q^&9Yh=9@r1^E<$DB9)-|+3g=X>h+w4E~zSFDmShzBajN$UCaUD z?_UW!5h#j=bO!Kq8g@cqePPO_^g)wqR>q{qovp}A5>A6M)Jzi!k^K*MYhq+73nMoS+;ym>8vQopK6j?rXb}5HT{7fDX%K^s|X|O5DA8ol;2}9@`Xs@{T4&E z4YrYRMBB9G$sdhyI%yejxOcI<8_?HJo#_(ij~6onsdcGe3pGPl07QoHr9r81>bFlOwamUf(`+7c2` z5>cDZsvPF&rf<0GnA9aqIdU+i08RrO>QY%z_*=vf;b?%3Lx*g}5ySK>3s}ghsrq$L zI?`IhKCA6Jvw&-QMQOl^5JzBYjVk0}4)CbD+(Zkrnq#+vkuT6*<;LHZc2Sa~``_C< zZJMn6vQSXfd1yTaMC)KkGB&g!;MBS7+9uT1w&8^U^D>xqtj>Pj3rE##oVVFOJ0%)s zXE5tno)B#qXl-ndM8gcF^u8^2EJQ1+xyO?Y6Em1gl5GTNZDg}I1%&_#emS`D2eOO7 zi?r+e(O<-v>rGl=Tun3E3?i+uUi+0uHX4g6g;)f6v4wm=56B5ML6jr(LPhsD4bHKS zfOzJ>=EFkDP-9hP`szVx*%yu8JHOovAHLa?}VKu#g4ch9uW;hAk(4qLeh!X4f z%+T42g{_yR;s`VV`94ET914u>bGqe8OQ(tf&IA;2Xf#UOlHzey)q#cRi8!_}QQ?aL zjs!$}EU-SWyLMECX(+;2MI`vffgsLMD^R6QV1m}J-aTD?z4B+V_t!h>BBtnTbZn%cR1@XGCG)rbD&aE9caS zm zHYdt8L#66e%gp7!{cnT4tF*j99A0j*vv;gw-4pDE>6Bte$F1L8y=(ycCt!G>&U7Yl zi#t2>y=5>$=*25ZQ8UvYY&Q&k29f^kS0j6NWuc|ar2BEosXY1hl{o!!f0$F*dmhZx zrY{HaXDN`{flMH)ltmJi>D$WfK4tJwa&|db-Uc^?$DV(8Bj0K}3ja#PD|KN-% z)3;bpR5kwel{c&da~~h)*5;inL-CSfp2+v=Or3nd^gfVV54d4Wg0BiaS9tQkBjC4* zZ2~ngp;o(xI$t$^OZxGSOWlr?d-HsOoA_qyluW!1Pbg{Kafi3zo`U|%@PvZyUAR+l zik^drGl(2Nr_K-q@3~j#H=AKA$tNr)i5Aad^^f ziIT%;&TIT528`~Yk7UEHj;2%?(m{F?)=wS9j3E5!KEHxS}1Ac>+Y8OFE?ao?EnA( literal 0 HcmV?d00001 diff --git a/chinese.ts b/chinese.ts new file mode 100644 index 0000000..b0b780b --- /dev/null +++ b/chinese.ts @@ -0,0 +1,7084 @@ + + + + + BrokenLineDialog + + + Form + + + + + + 1 + + + + + Broken Line Prompt + 断线提示 + + + + ClothingMac + + + HMI Configuration + 界面配置 + + + + Interface debug mode + 界面调试模式 + + + + Delete configure file + 删除配置文件 + + + + Machine parameters + 机器参数 + + + + Work parameters + 工作参数 + + + + Flip style + 翻转式样 + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + 旋转角度 + + + + Template recognition device + + + + + No device:0;Bar code:1;Coding hole:2;Multiple files:3 + + + + + X frame sensor coordinates + + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + 毫米 + + + + AnchorX + 定位点X + + + + AnchorY + 定位点Y + + + + startX + 起始点X + + + + startrY + 起始点Y + + + + Y frame sensor coordinates + + + + + Spindle parking sensor angle + 主轴停车传感器角度 + + + + Lift sensor coordinates + + + + + Angle of spindle hook sensor + + + + + Spindle jog parking angle + + + + + X movable area negative boundary + + + + + X movable area positive boundary + X可移动区域正边界 + + + + Y movable area negative boundary + + + + + Y movable area positive boundary + Y可移动区域正边界 + + + + X Sewing area negative boundary + + + + + X Sewing area positive boundary + x可缝纫区域正边界(X+) + + + + Y Sewing area negative boundary + + + + + Y Sewing area positive boundary + y可缝纫区域正边界(Y+) + + + + XY start stop speed + + + + + + + + + + + mm/s + 毫米/秒 + + + + XY zero running speed + + + + + XY simulate running speed + + + + + XY movement acceleration + + + + + + mm/s2 + + + + + XY brake acceleration + + + + + XY manual movement speed 1 + xy手动移动速度1 + + + + XY manual movement speed 2 + xy手动移动速度2 + + + + XY manual movement speed 3 + xy手动移动速度3 + + + + XY maximum moving speed + + + + + Spindle start stop speed + + + + + + + + + + + + + + + + + r/min + r/min + + + + Spindle zero reset speed + + + + + Spindle running speed + + + + + Spindle running acceleration + + + + + + + r/ss + + + + + Spindle brake acceleration + + + + + sewing maximum speed + + + + + Spindle zeroing compensation angle + + + + + X gap compensation + + + + + Y gap compensation + + + + + Sewing main shaft working speed + 主轴缝纫工作转速 + + + + Spindle cutting speed + + + + + Spindle needle return speed + + + + + Spindle start slow speed + + + + + Reverse equivalent spindle speed + + + + + Sewing frame movement mode + + + + + XY continuous:0;XY intermittent:1 + + + + + Sewing frame start angle + + + + + Sewing frame steadiness angle + + + + + Slow stitch at beginning + + + + + + + Needle + + + + + Needle action, thread loosen allowed + + + + + + + + + + + + + + + + + + + + + + Not allow:0;allowed:1 + + + + + Needle action,tight bobbin spring allowed + + + + + Needle action, catch upper thread allowed + + + + + Cut thread allowed + + + + + Do not trim:0;Automatic:1;Last trimming:2;Data trimming:3 + + + + + Trimmer cutting angle + + + + + Trimming completion angle + 缝纫动框起始角度 + + + + Thread cut, upper thread loosen allowed + + + + + Thread cut, tensile thread allowed + + + + + Thread cut, catch upper thread allowed + + + + + Thread cut, presser foot lift allowed + + + + + Stitch detect if thread broken + + + + + Thread brake detection, main shaft angle + + + + + Bobbin change reminder function + 换梭芯提醒功能 + + + + Not enabled: 0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bobbin thread length + 底线长度 + + + + Bobbin thread correction per stitch + + + + + Bobbin change as per sewed pieces + + + + + + times + + + + + Oiling mode selection + + + + + No oil:0;Oiling by time:1;Oiling by stitches:2;Oiling continously:3 + + + + + Oiling interval by needle stitch + + + + + Oiling interval by working time + + + + + + + s + s + + + + Needle Oiling sustained time + + + + + Stop position selection after work complete + + + + + Current:0;Start:1;Anchor:2;Feeding:3;Offset:4 + + + + + Valid flag for offset point coordinates + + + + + + invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + 偏移点坐标X + + + + Offset point coordinate Y + 偏移点坐标Y + + + + Threading point coordinate valid symbol + + + + + Threading point coordinates X + 穿线点坐标X + + + + Threading point coordinates Y + 穿线点坐标Y + + + + Production preset + 产量预设 + + + + Delay after pneumatic frame off + + + + + Sewing acceleration + + + + + Trimming frame displacement + 剪线动框位移 + + + + Automatic move to threading point allowed + + + + + Large presser foot action allowed + + + + + Sewing move head up down + + + + + Moving basket Loose line + 移框松线允许 + + + + Moving basket Clamp line + 移框夹线允许 + + + + Software limit XY move allowed + 软件限位XY移动允许 + + + + Number of Needle hooks + + + + + Trimming frame direction + + + + + No:0;left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + 主轴拐角转速 + + + + Minimum speed deviation angle + 降速最小偏差角度 + + + + Early speed reduction + + + + + Delayed speed step + + + + + Secure input light curtain allows + 安全输入光幕允许 + + + + Safety input pressure allowed + 安全输入气压允许 + + + + Pneumatic frame off + + + + + + Penumatic frame on + + + + + ms + + + + + Loop work allowed + 循环工作允许 + + + + Shuttle Oiling sustained time + + + + + Sewing operation speed 1 + + + + + Sewing operation speed 2 + + + + + Sewing operation speed 3 + + + + + Change the sewing needle count value + + + + + Enable + 使能 + + + + Disable + 失能 + + + + JogP + 正转 + + + + JogN + 反转 + + + + Zero + 归零 + + + + Open + 打开 + + + + Close + 关闭 + + + + Up + + + + + Down + + + + + Extend + + + + + Back + + + + + Combine + + + + + Separate + + + + + X to move motor + X向移动电机 + + + + Y to move motor + Y向移动电机 + + + + Spindle motor + 主轴电机 + + + + Needle motor + 针电机 + + + + Shuttle motor + 梭电机 + + + + Lifting motor + 升降电机 + + + + Frame + + + + + Big foot + + + + + Middle foot + + + + + Buckle the bottom line + 扣底线 + + + + Top and bottom lines + + + + + Lower scissors to cut thread + 下剪刀剪线 + + + + Sandwich line + 夹面线 + + + + Elastic thread + 松紧线 + + + + Elastic thread 2 + + + + + Laser control + + + + + Laser blow + + + + + Oil + + + + + Headlamp + + + + + Sewing Blow + 缝纫吹气 + + + + Hookline ext + + + + + Hookline open and close + + + + + Sewing machine head lifting + 缝纫机头升降 + + + + Spindle clutch + + + + + Pen + + + + + All to zero + 全部归零 + + + + Needle shuttle reset + + + + + Back thread + + + + + Back offset + + + + + Back shuttle + + + + + Back work + + + + + Set anchor + + + + + Back anchor + + + + + + Back start + 回起始点 + + + + Forwrak or back + + + + + Bottom count reset + + + + + HeadLifting + 机头上升 + + + + ThreadCut + 手动剪线 + + + + ProcessReset + 流程复位 + + + + Simulated + 模拟缝纫 + + + + Signal + 传感器信号 + + + + Action + 控制动作 + + + + HMIUpgrade + 界面升级 + + + + MCUpgrade + 主控升级 + + + + ParaImport + 参数导入 + + + + ParaExport + 参数导出 + + + + SoftwareSet + 软件设置 + + + + Authorization + 软件授权 + + + + Network + 网络管理 + + + + Time + 时间设置 + + + + Version + 版本信息 + + + + Root + 超级用户 + + + + Select + 花样选择 + + + + Para + 花样参数 + + + + Import + 花样导入 + + + + Export + 花样导出 + + + + Delete + 花样删除 + + + + OperatPara + 操作参数 + + + + ActionSet + 动作设定 + + + + SpeedPara + 速度参数 + + + + LimitPara + 限位参数 + + + + MCPara + 机器参数 + + + + Start button 1 + 启动按钮1 + + + + Pause button 1 + 暂停按钮1 + + + + Air pressure detection 1 + 气压检测1 + + + + Security input 1 + 安全输入1 + + + + X zero position + X零位 + + + + Y deceleration + Y降速 + + + + X positive limit + X正限位 + + + + Y positive limit + Y正限位 + + + + Sewing machine head 1 lifting upper limit + 缝纫机头1升降上限位 + + + + Lower lifting limit of sewing machine head 1 + 缝纫机头1升降下限位 + + + + Sewing spindle 1 needle - parking space + 缝纫主轴1针-停车位 + + + + Sewing shuttle 1- parking space + 缝纫旋梭1-停车位 + + + + Sewing machine head 1 - surface thread breakage inspection + 缝纫机头1-面线断检 + + + + ControlActionWidget + + + Form + + + + + Control action + 控制动作 + 控制动作 + + + + Control action < Auxiliary function + 控制动作 < 辅助功能 + 控制动作 < 辅助功能 + + + + PageNums: 1/1 + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PushButton + + + + + pageNum: + 页数: + + + + The machine is about to move, please pay attention to safety! + 机器即将运动,请注意安全! + + + + All to zero + 全部归零 + + + + DebugInfoDialog + + + Dialog + + + + + PageNums: 1/1 + 页数:1/1 + + + + DebugInfo: + + + + + pageNum: 0/0 + 页数: 0/0 + + + + pageNum: + 页数: + + + + FileSelectDialog + + + Dialog + + + + + PageNums: 1/1 + 页数:1/1 + + + + pageNum: + 页数: + + + + FiveHeadPrecisionSewing + + + HMI Configuration + 界面配置 + + + + Interface debug mode + 界面调试模式 + + + + Delete configure file + 删除配置文件 + + + + Machine parameters + 机器参数 + + + + Work parameters + 工作参数 + + + + + + + + + + + + + + + + + + + + + + mm + 毫米 + + + + Left + 左边 + + + + Front + 前边 + + + + X movable area positive boundary + X可移动区域正边界 + + + + Y movable area positive boundary + Y可移动区域正边界 + + + + X Sewing area Negative boundary + X可缝纫区域负边界 + + + + Y Sewing area Negative boundary + Y可缝纫区域负边界 + + + + sewing work speed + 主轴缝纫工作转速 + + + + + r/min + r/min + + + + Bobbin thread length + Bottom line length + 底线长度 + + + + Refueling method selection + 加油方式选择 + + + + Head 4 shuttle refueling + Refueling needles interval + 机头4 梭加油 + + + + Refueling duration + 加油持续时长 + + + + Production preset + 产量预设 + + + + Sewing machine head 2 - surface thread breakage inspection + Thread trimming moving frame direction + 缝纫机头2-面线断检 + + + + Pin 1 motor + 针1电机 + + + + Shuttle 1 motor + 梭1电机 + + + + Spindle 2 motor + 主轴2电机 + + + + Pin 2 motor + 针2电机 + + + + Shuttle 2 motor + 梭2电机 + + + + Spindle 3 motor + 主轴3电机 + + + + Pin 3 motor + 针3电机 + + + + Shuttle 3 motor + 梭3电机 + + + + Spindle 4 motor + 主轴4电机 + + + + Pin 4 motor + 针4电机 + + + + Spindle 5 motor + 主轴5电机 + + + + Pin 5 motor + 针5电机 + + + + Shuttle 5 motor + 梭5电机 + + + + Head 1 Elastic thread + 机头1 松紧线 + + + + Head 2 Elastic thread + 机头2 松紧线 + + + + Head 3 Elastic thread + 机头3 松紧线 + + + + Head 4 Elastic thread + 机头4 松紧线 + + + + Head 5 Elastic thread + 机头5 松紧线 + + + + Head 1 blow + 机头1 吹气 + + + + Head 2 blow + 机头2 吹气 + + + + Head 3 blow + 机头3 吹气 + + + + Head 4 blow + 机头4 吹气 + + + + Head 5 blow + 机头5 吹气 + + + + Head 1 trim + 机头1 剪线 + + + + Head 2 trim + 机头2 剪线 + + + + Head 3 trim + 机头3 剪线 + + + + Head 4 trim + 机头4 剪线 + + + + Head 5 trim + 机头5 剪线 + + + + Head 1 needle refueling + 机头1 针加油 + + + + Head 2 needle refueling + 机头2 针加油 + + + + Head 3 needle refueling + 机头3 针加油 + + + + Head 4 needle refueling + 机头4 针加油 + + + + Head 5 needle refueling + 机头5 针加油 + + + + Head 1 shuttle refueling + 机头1 梭加油 + + + + Head 2 shuttle refueling + 机头2 梭加油 + + + + Head 3 shuttle refueling + 机头3 梭加油 + + + + Head 5 shuttle refueling + 机头5 梭加油 + + + + Head 1 lifting + 机头1 升降 + + + + Head 2 lifting + 机头2 升降 + + + + Head 3 lifting + 机头3 升降 + + + + Head 4 lifting + 机头4 升降 + + + + Head 5 lifting + 机头5 升降 + + + + X Sewing area positive boundary + x可缝纫区域正边界(X+) + + + + Y Sewing area positive boundary + y可缝纫区域正边界(Y+) + + + + Zero position coordinate of head 2 + 机头2零位坐标 + + + + Zero position coordinate of head 3 + 机头3零位坐标 + + + + Zero position coordinate of head 4 + 机头4零位坐标 + + + + Zero position coordinate of head 5 + 机头5零位坐标 + + + + Xy continuous moving box:0;Xy intermittent moving frame:1 + xy连续动框:0;xy间歇式动框:1 + + + + Thread cutting allowed + 剪线允许 + + + + No. of stitch detect if thread broken + Number of thread breakage detection needles + 断线检测针数 + + + + Bobbin change reminder function + Change shuttle core reminder function + 换梭芯提醒功能 + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + do not enable this feature:0;Count delay reminders by length:1;Count by number of pieces:2;Prompt immediately based on length:3 + 不启用该功能:0;按长度计数延迟提醒:1;按片数计数:2;按长度立刻提醒:3 + + + + Count of shuttle change pieces + 换梭片数计数 + + + + Times + + + + + not refueling:0;Intermittent refueling according to worktime:1;Intermittent refueling according to the number of working stitches:2;Continuously refueling:3 + 不加油:0;按工作时间间歇加油:1;按工作针数间歇加油:2;持续不停加油:3 + + + + Interval between refueling stitches + 加油针数间隔 + + + + + + second + + + + + Software limit: xy movement + 软件限位:xy移动 + + + + Automatic sewing speed regulation + Sewing speed reduction mode + 缝纫降速 + + + + Circular working function + 循环工作功能 + + + + Duration of shuttle refueling + 梭加油持续时长 + + + + Sewing and blowing time + 缝纫吹气时间 + + + + X to move motor + X向移动电机 + + + + Y to move motor + Y向移动电机 + + + + Head moving motor + 机头移动电机 + + + + Spindle 1 motor + Spindle motor + 主轴1电机 + + + + Shuttle 4 motor + Shuttle motor + 梭4电机 + + + + Lock frame cylinder + 锁框气缸 + + + + Flap control + 翻板控制 + + + + Barcode testing + 条码测试 + + + + Signal + 传感器信号 + + + + Action + 控制动作 + + + + HMIUpgrade + 界面升级 + + + + MCUpgrade + 主控升级 + + + + ParaImport + 参数导入 + + + + ParaExport + 参数导出 + + + + Network + 网络管理 + + + + Time + 时间设置 + + + + Version + 版本信息 + + + + Root + 超级用户 + + + + Select + 花样选择 + + + + Para + 花样参数 + + + + Sewing motion frame method + 缝纫动框方式 + + + + Sewing hook angle + 缝纫勾线角度 + + + + All spindle zero positions + 所有主轴 零位 + + + + Allow for needle starting and thread loosening + 起针松线允许 + + + + Allow for loose thread during thread cutting + 剪线时松线允许 + + + + Allow needle withdrawal during thread cutting + 剪线时退针允许 + + + + Cutting and parting angle + 剪线分线角度 + + + + Thread trimming completion angle + 剪线完成角度 + + + + Automatically thread back points during sewing + 缝纫时自动回穿线点 + + + + Allow for loose lines when moving boxes + 移框时松线允许 + + + + Starting angle of sewing frame + 缝纫动框起始角度 + + + + Continuous angle of sewing frame + 缝纫动框持续角度 + + + + Zero All + 全部归零 + + + + All Spindle Hook Lines positions + 所有主轴 勾线 + + + + All spindle jogs positions + 所有主轴 点动 + + + + AllSpleHook + AllSpindleJogs + 所有主轴勾线 + + + + Spindle thread cutting speed + 主轴剪线转速 + + + + Allowing for wire clamping during wire cutting + 剪线时夹线允许 + + + + Number of stitches for surface thread clamping + 面线夹线针数 + + + + Head 1 ThreadCuttingAction + 机头1 剪线动作 + + + + Head 2 ThreadCuttingAction + 机头1 剪线动作 + + + + Head 3 ThreadCuttingAction + 机头3 剪线动作 + + + + Head 4 ThreadCuttingAction + 机头4 剪线动作 + + + + Head 5 ThreadCuttingAction + 机头5 剪线动作 + + + + Head 1 Clamp wire + 机头1 夹线 + + + + Head 2 Clamp wire + 机头2 夹线 + + + + Head 3 Clamp wire + 机头3 夹线 + + + + Head 4 Clamp wire + 机头4 夹线 + + + + Head 5 Clamp wire + 机头5 夹线 + + + + All_Zero + 全部归零 + + + + Front_Back + 快进快退 + + + + AllSpleZero + 所有主轴零位 + + + + AllSpleJogs + 所有主轴点动 + + + + N/S_Proof + 针梭校对 + + + + MU_Canl + makeupCanl + 取消补缝 + + + + Makeup1 + makeup1 + 机头1补缝 + + + + Makeup2 + makeup2 + 机头2补缝 + + + + Makeup3 + makeup3 + 机头3补缝 + + + + Makeup4 + makeup4 + 机头4补缝 + + + + Makeup5 + makeup5 + 机头5补缝 + + + + AMShaftRun + 所有主轴研车 + + + + Setting + 软件设置 + + + + Authorize + 软件授权 + + + + ThCutAct1 + 机头1剪线 + + + + AnchorX + 定位点X + + + + AnchorY + 定位点Y + + + + startX + 起始点X + + + + startrY + 起始点Y + + + + Coordinate of threading point X + 穿线点坐标X + + + + Coordinate of threading point Y + 穿线点坐标Y + + + + ThCutAct2 + 机头2剪线 + + + + ThCutAct3 + 机头3剪线 + + + + ThCutAct4 + 机头4剪线 + + + + ThCutAct5 + 机头5剪线 + + + + SetStart + 定起始点 + + + + ProcReset + 流程复位 + + + + Simulate + 模拟缝纫 + + + + HeadLifting + 机头上升 + + + + GoFeedt + 回穿线点 + + + + Back start + 回起针点 + + + + Import + 花样导入 + + + + Export + 花样导出 + + + + Delete + 花样删除 + + + + OperatPara + 操作参数 + + + + ActionSet + 动作设定 + + + + SpeedPara + 速度参数 + + + + LimitPara + 限位参数 + + + + MCPara + 机器参数 + + + + Start button 1 + 启动按钮1 + + + + Pause button 1 + 暂停按钮1 + + + + Jog button 1 + 点动按钮1 + + + + Open frame button 1 + 开框按钮1 + + + + Manual operation button 1 + 手动按钮1 + + + + Be ready button 1 + 就绪按钮1 + + + + Key button 1 + 钥匙按钮1 + + + + Air pressure detection 1 + 气压检测1 + + + + Security input 1 + 安全输入1 + + + + Template in position 1 + 模板到位1 + + + + Template in position 2 + 模板到位2 + + + + MOTOR_ALM1 + 电机报警1 + + + + MOTOR_ALM9 + 电机报警9 + + + + MOTOR_ALM17 + 电机报警17 + + + + MOTOR_ALM25 + 电机报警25 + + + + MOTOR_ALM33 + 电机报警33 + + + + MOTOR_ALM41 + 电机报警41 + + + + X zero position + X零位 + + + + Y zero position + Y零位 + + + + X deceleration + X降速 + + + + Y deceleration + Y降速 + + + + X positive limit + X正限位 + + + + Y positive limit + Y正限位 + + + + Sewing machine head 1 lifting upper limit + 缝纫机头1升降上限位 + + + + Sewing machine head 2 lifting upper limit + 缝纫机头2升降上限位 + + + + Sewing machine head 3 lifting upper limit + 缝纫机头3升降上限位 + + + + Sewing machine head 4 lifting upper limit + 缝纫机头4升降上限位 + + + + Lower lifting limit of sewing machine head 0 + 缝纫机头0升降下限位 + + + + Lower lifting limit of sewing machine head 1 + 缝纫机头1升降下限位 + + + + Lower lifting limit of sewing machine head 2 + 缝纫机头2升降下限位 + + + + Lower lifting limit of sewing machine head 3 + 缝纫机头3升降下限位 + + + + freedom from error + 没有错误 + + + + Not powered on + 没有上电 + + + + + Insufficient air pressure + 气压不足 + + + + + Safe Area Intervention + 安全区域介入 + + + + + The usage deadline has expired + 使用时限已到 + + + + Filling data error + 填充数据错误 + + + + + Working status not allowed + 不允许工作状态 + + + + control error + 控制错误 + + + + Motion control chip version error + 运动控制芯片版本错误 + + + + Waiting for button to lift timeout + 等待按钮抬起超时 + + + + FPGA reset error + FPGA复位错误 + + + + Peripheral not ready + 外设未就绪 + + + + Transmission data error + 传输数据错误 + + + + Program version error + 程序版本错误 + + + + Production completed + 完成产量 + + + + forward limit + 正向限位 + + + + Reverse limit + 反向限位 + + + + Motion alarm + 运动报警 + + + + Motion limit + 运动限位 + + + + Exercise emergency stop + 运动急停 + + + + + Motion parameter error + 运动参数错误 + + + + + Machine parameter error + 机器参数错误 + + + + + Input parameter error + 输入参数错误 + + + + The file is correct + 文件正确 + + + + Waiting for files + 等待文件 + + + + Zero successfully + 归零成功 + + + + Zero error + 归零错误 + + + + + Coordinate system error + 坐标系统错误 + + + + + Target position out of range + 目标位置越界 + + + + + X forward limit + X正向限位 + + + + + X reverse limit + X反向限位 + + + + + Y forward limit + Y正向限位 + + + + + Y reverse limit + Y反向限位 + + + + + No Data + 无数据 + + + + data error + 数据错误 + + + + + Spindle not in zero position + 主轴不在零位 + + + + + Rotary shuttle not in zero position + 旋梭不在零位 + + + + Needle shuttle out of sync + 针梭不同步 + + + + Rotation out of sync + 旋转不同步 + + + + The scissors are not returning to their original position + 剪刀不在回位 + + + + + Machine head not in high position + 机头不在高位 + + + + Machine head not in low position + 机头不在高位 + + + + Light curtain intervention + 光幕介入 + + + + + Broken surface thread + 面线断线 + + + + Bottom line disconnection + 底线断线 + + + + + Head lifting timeout + 机头升降超时 + + + + + Replacing the shuttle core + 更换梭芯 + + + + Abnormal feeding pressure roller + 进料压辊 异常 + + + + Abnormal discharge pressure roller + 出料压辊 异常 + + + + Abnormal discharge and pressing + 出料压料 异常 + + + + Tensioning device abnormal + 张紧装置 异常 + + + + Abnormal cloth clamping device + 夹布装置 异常 + + + + Edge cutting motor blocked + 边切电机 阻塞 + + + + Cross cutting motor abnormality + 横切电机 异常 + + + + Password set successfully + 密码设置成功 + + + + Password setting failed + 密码设置失败 + + + + Needle motor alarm + 针电机报警 + + + + Shuttle motor alarm + 梭电机报警 + + + + X motor alarm + X电机报警 + + + + Y motor alarm + Y电机报警 + + + + Needle motor reset failed + 针电机归零失败 + + + + Shuttle motor reset failed + 梭电机归零失败 + + + + X motor reset failed + X电机归零失败 + + + + Y motor reset failed + Y电机归零失败 + + + + Slave board communication timeout + 从板通讯超时 + + + + X motor not in zero position + X电机不在零位 + + + + The safety door is not closed + 安全门未关闭 + + + + The machine head is not in a safe area + 机头不在安全区域 + + + + Template not in place + 模版不到位 + + + + Moving up motor limit on head 1 + 机头1上移动电机 限位+ + + + + X negative limit + X负限位 + + + + Y negative limit + Y负限位 + + + + Moving down motor limit on head 1 + 机头1下移动电机 限位+ + + + + Sewing needle parking space 1 + 缝纫针停车位1 + + + + Sewing needle parking space 2 + 缝纫针停车位2 + + + + Sewing needle parking space 3 + 缝纫针停车位3 + + + + Embroidery spindle zero position 9 + 绣花主轴零位9 + + + + Embroidery spindle zero position 10 + 绣花主轴零位10 + + + + Sewing spindle 1 needle - parking space + 缝纫主轴1针-停车位 + + + + Sewing shuttle 1- parking space + 缝纫旋梭1-停车位 + + + + Sewing shuttle 2- parking space + 缝纫旋梭2-停车位 + + + + Sewing shuttle 3- parking space + 缝纫旋梭3-停车位 + + + + Sewing shuttle 4- parking space + 缝纫旋梭4-停车位 + + + + Sewing machine head 1 - surface thread breakage inspection + 缝纫机头1-面线断检 + + + + Sewing machine head 3 - surface thread breakage inspection + 缝纫机头3-面线断检 + + + + Sewing machine head 4 - surface thread breakage inspection + 缝纫机头4-面线断检 + + + + Sewing thread trimming return 1 + 缝纫下剪线回位1 + + + + Sewing thread trimming return 2 + 缝纫下剪线回位2 + + + + Sewing thread trimming return 3 + 缝纫下剪线回位3 + + + + Sewing thread trimming return 4 + 缝纫下剪线回位4 + + + + GLOBAL + + + Resolution + 分辨率 + + + + Language + 语言 + + + + Machine type + 机器类型 + + + + Product type + 产品类型 + + + + Year + + + + + Month + + + + + Day + + + + + Hour + + + + + Minute + + + + + Second + + + + + Communication method + 通讯方式 + + + + Network:0;SerialPort:1 + 网口:0;串口:1 + + + + Chinese:0;English:1 + 中文:0;英语:1 + + + + Server IP settings + Gateway server IP settings + 服务器IP设置 + + + + Server port settings + Gateway server port settings + 服务器端口设置 + + + + Local IP settings + 本地IP设置 + + + + Local port settings + 本地端口设置 + + + + 001 McHighSingleQui:0;002 FiveHeadPrecisionSewing:1;003 ClothingMac:2;004 multineedlerotary:3 + 001 高速单针机:0;002 五头精密缝:1;003 服装机:2;004 多针旋梭:3 + + + + Is there a Richpeace logo + 是否有富怡标志 + + + + Factory expects delivery time + 工厂预计交货时间 + + + + Debugging progress + 调试进度 + + + + ProductNull: + 无: + + + + Whether there is a Automatic shuttle change function + 是否有自动换梭功能 + + + + Parameter is classified + 参数是否分类显示 + + + + HMI decrypt + 界面解密 + + + + Gateway connection method + 网关连接方式 + + + + Serial port:0; Network port:1 + Serial port1:0;Serial port2:1;Network port:2 + 串口:0;网口:1 + + + + Input rack number + 机架号输入 + + + + Network settings + 网络设置 + + + + HeadSpacingSheetDialog + + + Dialog + + + + + PageNums: 0/0 + 页数:0/0 + + + + Sub title + + + + + Sub title < Title + + + + + pageNum: + 页数: + + + + PageNum: 0/0 + 页数: 0/0 + + + + + + + Prompt + 提示 + + + + + USB flash drive is not detected! + 未检测到优盘! + + + + Export successful + 导出成功! + + + + Import successful! + 导入成功! + + + + HighSingleQui + + + HMI Configuration + 界面配置 + + + + Interface debug mode + 界面调试模式 + + + + Delete configure file + 删除配置文件 + + + + Machine parameters + 机器参数 + + + + Work parameters + 工作参数 + + + + Flip style + 翻转式样 + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + 旋转角度 + + + + + + + + + + + + + + + + + + + + + + + + + + mm + % + + + + + Step size + 针步大小 + + + + Reinforcement method + 加固方式 + + + + Tight locking:0;Reinforced locking:1 + 密针锁针:0;加固锁针:1 + + + + Reinforcement needles + 加固针数 + + + + pin + + + + + Reinforcement frequency + 加固次数 + + + + Angle correction offset + 角度修正量 + + + + Angle correction x positive + 角度修正X正 + + + + Angle correction x negative + 角度修正X负 + + + + Angle correction y positive + 角度修正Y正 + + + + Angle correction y negative + 角度修正Y负 + + + + Left + 左边 + + + + Front + 前边 + + + + Automatic shuttle changing device + 自动换梭装置 + + + + + + + + + No:0;Have:1 + 无:0;有:1 + + + + Infrared device + 红外装置 + + + + + + + + Normally closed:0;Normally open:1 + 正常关闭:0;正常打开:1 + + + + Pneumatic device + 气压装置 + + + + Power-on device + 上电装置 + + + + Safety door device + 安全门装置 + + + + Manual and automatic button device + 手自动按钮装置 + + + + X movable area positive boundary + X可移动区域正边界 + + + + Y movable area positive boundary + Y可移动区域正边界 + + + + X Sewing area Negative boundary + X可缝纫区域负边界 + + + + X Sewing area Positive margin + X可缝纫区域正边界 + + + + Y Sewing area Negative boundary + Y可缝纫区域负边界 + + + + Y Sewing area Positive margin + Y可缝纫区域正边界 + + + + Encoder coefficient molecule + 进料编码器系数分子 + + + + Zero tangent distance + 零切距离 + + + + Feeding device + 进料装置 + + + + Crosscutting device + 横切装置 + + + + Cloth clamping device + 夹布装置 + + + + Tensioning device + 张紧装置 + + + + Edge cutting device + 边切装置 + + + + sewing work speed + 主轴缝纫工作转速 + + + + + + + r/min + r/min + + + + Spindle Back needle speed + 主轴回针转速 + + + + Sewing moving frame + 缝纫动框方式 + + + + Continuous:0;Intermittent:1 + 连续:0;间歇式:1 + + + + Sewing acceleration and deceleration mode + 缝纫加减速方式 + + + + No acceleration or deceleration:0;Xy sine acceleration and deceleration:1 + 无加速或减速:0;XY正弦加速度和减速度:1 + + + + Sewing machine head rotating manner + 缝纫机头旋转方式 + + + + Continuous rotation:0;Xy intermittent rotation:1 + 连续旋转:0;XY间歇旋转:1 + + + + Sewing head deceleration mode + 缝纫机头加减速方式 + + + + No acceleration or deceleration:0;Intermittent acceleration and deceleration:1 + 无加速或减速:0;间歇加减速:1 + + + + + + + + + + Not allow:0;Allowed:1 + 不允许:0;允许:1 + + + + Cut lines allow + 剪线允许 + + + + Equal ratio + + + + + Thread loosening is allowed during thread cutting + 剪线时松线允许 + + + + During thread cutting, the stay wire is allowed + 剪线时拉线允许 + + + + Thread clamping is allowed during thread cutting + 剪线时夹线允许 + + + + It is allowed to lift the presser foot during thread trimming + 剪线时提升压脚允许 + + + + Lifting machine head thread cutting is allowed during thread cutting + 剪线时提升机头剪线允许 + + + + The thread clamping of the lifting head is allowed during thread cutting + 剪线时提升机头夹线允许 + + + + It is allowed to hook the thread at the foot of the presser during thread cutting + 剪线时在压脚下勾线允许 + + + + Needle withdrawal allowed during thread trimming + 剪线时退针允许 + + + + Buckle the thread allowed during thread trimming + 剪线时扣线允许 + + + + Number of broken wires + 断线检测针数 + + + + + Needles + + + + + Change bobbin Reminder function + 换梭芯提醒功能 + + + + Not:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + 未启用:0;按长度划分的延迟提醒:1;按切片数计数:2;按长度立即提醒:3 + + + + Bottom line length + 底线长度 + + + + Number of shuttles + 换梭片数计数 + + + + times + + + + + Refueling method selection + 加油方式选择 + + + + No:0; According to working hours:1; According to the number of working stitches:2; Persistent refueling:3 + 不加油:0;按工作时间间断加油:1;按工作针数间歇加油:2;持续加油:3 + + + + Refueling needles interval + 加油针数间隔 + + + + Refueling duration + 加油持续时长 + + + + + + s + s + + + + Parking position selection after completion + 完成后停车位置选择 + + + + Current:0;Starting:1;Anchor:2;Feeding:3;Offset:4 + 当前点:0;起始点:1;定位点:2;上料点:3;偏移点:4 + + + + Offset point coordinate valid flag + 偏移点坐标有效标志 + + + + + Invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + 无效:0;X有效:1;Y有效:2;XY同时有效:3 + + + + Offset point coordinate X + 偏移点坐标X + + + + Offset point coordinate Y + 偏移点坐标Y + + + + Threading point coordinate effective mark + 穿线点坐标有效标志 + + + + Threading point coordinates X + 穿线点坐标X + + + + Threading point coordinates Y + 穿线点坐标Y + + + + Production preset + 产量预设 + + + + Trimming frame displacement + 剪线动框位移 + + + + Automatic threading back point is allowed during sewing + 缝纫时自动回穿线点允许 + + + + Lifting and lowering of frame crossing machine head in sewing room + 缝纫间越框机头升降 + + + + Moving basket Loose line + 移框松线允许 + + + + Moving basket Clamp line + 移框夹线允许 + + + + Frame moving and automatic frame pressing allowed + 移框自动压框允许 + + + + Allowed to move frame and thread + 移框扣线允许 + + + + Software limit XY move allowed + 软件限位XY移动允许 + + + + Thread trimming moving frame direction + 剪线动框方向 + + + + Fixed frame:0;Left:1;Forward:2;Right:3;Backward:4 + 不动框:0;向左:1;向前:2;向右:3;向后:4 + + + + Spindle corner speed + 主轴拐角转速 + + + + Minimum speed deviation angle + 降速最小偏差角度 + + + + Auto Zero after power on + 开机自动归零 + + + + Automatic drawing is allowed + 自动拉料允许 + + + + The opposite side is allowed when feeding + 进料时对边允许 + + + + Allowing distribution during feeding + 进料时展布允许 + + + + Medium cutting is allowed during feeding + 进料时中切允许 + + + + During feeding, it is allowed to cut across the edge + 进料时中切对边允许 + + + + The thread loosening is allowed when the head is lifting + 机头升降时松线允许 + + + + Secure input light curtain allows + 安全输入光幕允许 + + + + Safety input pressure allowed + 安全输入气压允许 + + + + Safe input power-on signal allowed + 安全输入上电信号允许 + + + + Safe input emergency door allowed + 安全输入安全门允许 + + + + Manual and automatic safe input + 安全输入手自动允许 + + + + Loop work allowed + 循环工作允许 + + + + Shuttle refueling duration + 梭加油持续时长 + + + + + Replace the punch count value + 更换冲头计数值 + + + + Starting angle of sewing frame + 缝纫动框起始角度 + + + + Trimming completion angle + 缝纫动框起始角度 + + + + Spindle parking sensor angle + 主轴停车传感器角度 + + + + Spindle thread cutting speed + 主轴剪线转速 + + + + Enable + 使能 + + + + Disable + 失能 + + + + JogP + 正转 + + + + JogN + 反转 + + + + Zero + 归零 + + + + Open + 打开 + + + + Close + 关闭 + + + + X to move motor + X向移动电机 + + + + Y to move motor + Y向移动电机 + + + + Spindle motor + 主轴电机 + + + + Needle motor + 针电机 + + + + Shuttle motor + 梭电机 + + + + Lifting motor + 升降电机 + + + + Lower scissors to cut thread + 下剪刀剪线 + + + + Buckle the bottom line + 扣底线 + + + + Elastic thread + 松紧线 + + + + oil + 加油 + + + + headlamp + 照明灯 + + + + Sewing machine head lifting + 缝纫机头升降 + + + + Sandwich line + 夹面线 + + + + Shuttle changing device grabbing + 换梭装置抓取 + + + + Shuttle changer swing + 换梭装置摆动 + + + + Shuttle changer rotation + 换梭装置旋转 + + + + Sewing Blow + 缝纫吹气 + + + + AllToZero + 全部归零 + + + + BackThread + 回穿线点 + + + + BackOffset + 回偏移点 + + + + BackZero + 回零点 + + + + CountReset + 底线计数清零 + + + + OutputReset + 产量清零 + + + + NeedZeroPos + 对针零位 + + + + ShutZeroPos + 对梭零位 + + + + Signal + 传感器信号 + + + + Action + 控制动作 + + + + HMIUpgrade + 界面升级 + + + + MCUpgrade + 主控升级 + + + + ParaImport + 参数导入 + + + + ParaExport + 参数导出 + + + + SoftwareSet + 软件设置 + + + + Authorization + 软件授权 + + + + Network + 网络管理 + + + + Time + 时间设置 + + + + Version + 版本信息 + + + + Root + 超级用户 + + + + Select + 花样选择 + + + + Para + 花样参数 + + + + Width + 宽度 + + + + Height + 高度 + + + + Allow for needle starting and thread loosening + 起针松线允许 + + + + Needle and thread clamping allowed + 起针夹线允许 + + + + Do not trim:0;Automatic thread trim:1;Finally trim:2;Data trim:3 + Do not trim: 0;Automatic thread trim:1;Finally trim:2;Data trim:3 + 不剪线:0;自动:1;最后剪线:2;数据剪线:3 + + + + Sewing speed reduction mode + 缝纫降速模式 + + + + Auto:0;Param:1;Not:2 + 自动:0;参数:1;不降速:2 + + + + Front_Back + 快进快退 + + + + N/S_Proof + 针梭校对 + + + + HeadLifting + 机头升降 + + + + ThreadCut + 手动剪线 + + + + ProcessReset + 流程复位 + + + + Simulated + 模拟缝纫 + + + + Import + 花样导入 + + + + Export + 花样导出 + + + + Delete + 花样删除 + + + + OperatPara + 操作参数 + + + + ActionSet + 动作设定 + + + + SpeedPara + 速度参数 + + + + LimitPara + 限位参数 + + + + MCPara + 机器参数 + + + + Start button 1 + 启动按钮1 + + + + Pause button 1 + 暂停按钮1 + + + + Air pressure detection 1 + 气压检测1 + + + + Security input 1 + 安全输入1 + + + + X zero position + X零位 + + + + Y deceleration + Y降速 + + + + X positive limit + X正限位 + + + + Y positive limit + Y正限位 + + + + Sewing machine head 1 lifting upper limit + 缝纫机头1升降上限位 + + + + Lower lifting limit of sewing machine head 1 + 缝纫机头1升降下限位 + + + + Sewing spindle 1 needle - parking space + 缝纫主轴1针-停车位 + + + + Sewing shuttle 1- parking space + 缝纫旋梭1-停车位 + + + + Sewing machine head 1 - surface thread breakage inspection + 缝纫机头1-面线断检 + + + + ImportHPGL + + + Encrypted file parsing error! + + + + + MainWidget + + + Richpeace Embroidery Control System + 富怡绣花控制系统 + 富怡绣花控制系统 + + + + 2021/03/08 8:37:16 + + + + + + + + + + + + + + + + + + PatternSet + 花样设置 + + + + Assist + 辅助功能 + 辅助功能 + + + + ParaSet + 参数设定 + 参数设定 + + + + Shortcut + 快捷功能 + 快捷功能 + + + + Main + 主界面 + 主界面 + + + + 4999 + + + + + XPlatForm-RP-HMI-L1910-V210713 + + + + + + + Root + 超级用户 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + shortcut + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + assist + 辅助功能 + + + + Pattern + 花样设置 + 花样设置 + + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + labelParaType + + + + + Forward or back + 快进快退 + 快进快退 + + + + Init windows... + 初始化窗体... + + + + Init communication... + 初始化通讯... + + + + Connnecting... + Status:Connnecting... + 连接中... + + + + + Connected + Status:Connected + 已连接 + + + + + + Not connected + Status:Not connected + 状态 + 未连接 + + + + Ready + Status:Ready + 已就绪 + + + + Working + Status: Working + 工作中 + + + + + Pattern para + 花样参数 + + + + Prompt + 提示 + + + + Loading patterns, please wait... + 正在加载花样,请等待... + + + + Setting workable area + 设置可工作区域 + + + + + + Parameter setting + 参数设置 + + + + Pattern selection + 花样选择 + + + + Pattern import + 花样导入 + + + + Pattern export + 花样导出 + + + + Pattern delete + 花样删除 + + + + Richpeace Quilting Control System + 富怡绗缝控制系统 + + + + Quilting Control System + 绗缝控制系统 + + + + FileName + 文件 + + + + Index + 索引 + + + + StartPoint + 起始点 + + + + LocatePoint + 定位点 + + + + Range + 范围 + + + + Position + 位置 + + + + Production + 产量 + + + + Pattern setting > Pattern selection + 花样设置 > 花样选择 + + + + Auxiliary function > Sensor signal + 辅助功能>传感器信号 + + + + Auxiliary function > Control action + 辅助功能 > 控制动作 + + + + Accessibility > Software setting + 辅助功能 > 软件设置 + + + + Accessibility > Network Manage + 辅助功能 > 网络管理 + + + + Accessibility > Time setting + 辅助功能 > 时间设置 + + + + Accessibility > Spindle test + 辅助功能 > 主轴研车 + + + + + + Accessibility > Root + 辅助功能 > 超级用户 + + + + Pattern setting > Pattern import + 花样设置 > 花样导入 + + + + Pattern setting > Pattern export + 花样设置 > 花样导出 + + + + Pattern setting > Pattern delete + 花样设置 > 花样删除 + + + + Simulated sewing + 模拟缝纫 + + + + Normal operation + 正常工作 + + + + Undefined error, + 未定义错误, + + + + Pattern setting > Head spacing + 花样设置 > 机头间距 + + + + Pattern setting > Pattern para + 花样设置 > 花样参数 + + + + Limit parameter + 限位参数 + + + + Speed control parameters + 速度参数 + + + + Action settings + 动作设定 + + + + Operating parameters + 操作参数 + + + + Machine parameters + 机器参数 + + + + Parameter setting > + 参数设置 > + + + + Parameter setting > Parameter setting + 参数设定 > 参数设定 + + + + Sensor signal + 传感器信号 + + + + Control action + 控制动作 + + + + + Accessibility + 辅助功能 + + + + Time setting + 时间设置 + + + + Spindle test + 主轴研车 + + + + MainWidgetFunction + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Prompt + 提示 + + + + + + + USB flash drive is not detected! + 未检测到优盘! + + + + The program is corrupted, please re-upgrade after replacing the program! + 程序已损坏,请更换程序后重新升级! + + + + The file format is wrong, please select again! + 文件格式错误,请重新选择! + + + + + File size not match, invalid file! + 文件大小不匹配,无效的参数文件! + + + + Data check error, invalid file! + 数据校验错误,无效的参数文件! + + + + Parameters imported successfully! + 参数导入成功! + + + + File head not match, invalid file! + 文件头不匹配,无效的参数文件! + + + + Parameter Import + 参数导入 + + + + Auxiliary Function > Parameter Import + Parameter Import < Auxiliary Function + 辅助功能 > 参数导入 + + + + + + + MC Upgrade + 主控升级 + + + + Auxiliary Function > MC Upgrade + MC Upgrade < Auxiliary Function + 辅助功能 > 主控升级 + + + + Error Log + 错误日志 + + + + Auxiliary Function > Error Log + 辅助功能 > 错误日志 + + + + Breakage Log + 断线日志 + + + + Auxiliary Function > Breakage Log + 辅助功能 > 断线日志 + + + + Debug Info + 调试信息 + + + + Auxiliary Function >Debug Info + 辅助功能 > 调试信息 + + + + ErrorLog + 错误日志 + + + + Auxiliary Function > ErrorLog + 辅助功能 > 错误日志 + + + + + ssid is empty! + ssid为空! + + + + + Settings require screen restart to take effect! + 设置需要重启屏幕才生效! + + + + IP input + IP输入 + + + + Journal exported successfully! + 文件日志导出成功! + + + + Journal exported failed! + 文件日志导出失败! + + + + Password input **** + 密码输入 **** + + + + reset parameters password successfully logged in! + 重置参数密码成功登入! + + + + Whether to exit the program? + 是否退出程序? + + + + Simulated sewing + 模拟缝纫 + + + + Whether to switch working status + 是否切换工作状态 + + + + Manual thread cutting + 手动剪线 + + + + makeup sewing + 索引 + + + + Head lifting and lowering + 机头升降 + + + + Head lifting + 机头上升 + + + + Set anchor point + 定定位点 + + + + Back shuttle pos + 回换梭位 + + + + Needle shuttle adjust + 针梭校对 + + + + AllSpindleZeroPositions + 所有主轴零位 + + + + AllSpindleHookLines + 所有主轴勾线 + + + + AllSpindleJogs + 所有主轴点动 + + + + NeedleShuttleProofreading + 针梭校对 + + + + AllMainShaftRun + 所有主轴研车 + + + + HMI Upgrade + 界面升级 + + + + Parameters exported successfully! + 参数导出成功! + + + + All to zero + 全部归零 + + + + + + + + + + + + + + + + + + + + + + + + The machine is about to move, please pay attention to safety! + 机器即将运动,请注意安全! + + + + + All to reset + 流程复位 + + + + Whether to reset the output? + 是否重置产量? + + + + If all process to reset? + 是否全部流程复位? + + + + Spindle jog + 主轴点动 + + + + Spindle rotate angle + 主轴旋转角度 + + + + Back work point + 回工作点 + + + + Back to origin + 回原点 + + + + Set start point + Set embroidery point + 定起绣点 + + + + + Whether to set the current point as the start point? + 是否将当前点设置为起绣点? + + + + Back anchor point + 回定位点 + + + + File bytes are 0, please check the file! + 文件字节为0,请检查文件! + + + + Back embroidery point + 回起绣点 + + + + Set offset point + 定偏移点 + + + + Whether to set the current point as the offset point? + 是否将当前点设置为偏移点? + + + + Back offset point + 回偏移点 + + + + Border check + 边框检查 + + + + Trim + 剪线 + + + + Whether to set to change a shuttle automatically? + 是否设置自动换一个梭? + + + + The machine is about to cut the thread, please pay attention to safety! + 机器即将剪线,请注意安全! + + + + Failed to initialize wlan0! + 初始化wlan0失败! + + + + Failed to search for WiFi list. Please try again later! + 搜索wifi列表失败,请稍后重试! + + + + dynamic + 动态 + + + + static + 静态 + + + + Failed to obtain IP. Please check the settings! + 获取IP失败,请检查设置! + + + + WIFI + + + + + Auxiliary Function > WIFI + 辅助功能 > WIFI + + + + Lower cutter + 下剪线 + + + + The scissors are about to move, please pay attention to safety! + 剪刀即将动作,请注意安全! + + + + Simulate frame + 空走边框 + + + + Process reset + 流程复位 + + + + The machine is about to reset, please pay attention to safety! + 机器即将流程复位,请注意安全! + + + + The machine is about to oil! + 机器即将加油! + + + + Goto zero pos + 框架归零 + + + + Set work range + 定工作范围 + + + + If automatically set work range? + 是否自动定工作范围? + + + + Manual oil + 手动加油 + + + + Bottom line detection + 底线检测 + + + + Face line detection + 面线检测 + + + + Exit successfully! + 成功退出! + + + + Shuttle count reset + Shuttle change + 梭盘计数复位 + + + + The machine is about to change the shuttle automatically! + 机器即将自动换梭! + + + + System info + 版本信息 + + + + Is the bottom line count reset? + Is the bottom line count reset ? + 是否底线计数复位? + + + + Are you sure to ManualSwitch? + Are you sure to ManualSwitch? + 是否手动工作状态切换? + + + + Are you sure to AutoSwitch? + Are you sure to AutoSwitch? + 是否自动工作状态切换? + + + + Undefined error, + 未定义错误, + + + + Password input * + Password input ※ + 密码输入 ※ + + + + Password input ** + Password input ※※ + 密码输入 ※※ + + + + Is the version restored? + 是否版本恢复? + + + + Modify the first level password + 修改一级密码 + + + + The two passwords are inconsistent! + 新密码和确认密码不一致! + + + + Password reset complete! + 密码修改成功! + + + + Do you delete the configuration file? + 是否删除配置文件? + + + + The settings take effect after restarting the interface! + 重启界面后设置生效! + + + + Import csv file successful! + 成功导入csv文件! + + + + Do you delete the csv file? + 是否删除csv文件? + + + + Reset succeeded! + 重置成功! + + + + Whether to enter debug mode? + 是否进入调试模式? + + + + whether to exit debug mode? + 是否退出调试模式? + + + + Please log in to super user again! + 请重新登录超级用户! + + + + Is the pattern clear? + 是否花样总清? + + + + Delete complete! + 删除完成! + + + + Whether to shut down the computer? + 是否关闭计算机? + + + + Production statistics + 生产统计 + + + + No connection + 未连接 + + + + Warrant + 授权 + + + + Total number of patterns processed: + 总共加工花样数量: + + + + Total number of embroidery: + 总刺绣针数: + + + + Pattern name: + 花样名称: + + + + Pattern break line num: + 花样断线次数: + + + + Head + 机头 + + + + break line num: + 断线次数: + + + + Day + + + + + Hour + + + + + Minutes + 分钟 + + + + The remaining available time of the machine is + 机器剩余可用时间为 + + + + Failed to upgrade the main control system! + 主控系统升级失败! + + + + Failed to send data file! + 发送数据文件失败! + + + + The main control system has been successed, waiting until machine restart + 主控系统升级成功,请等待机器重启 + + + + System will restart %1 s later + 系统将在 %1 秒后重启 + + + + The data file is send successfully! + 数据文件发送成功! + + + + Main control system is being upgraded... + 主控系统升级中... + + + + Auxiliary Function > HMI Upgrade + 辅助功能 > 界面升级 + + + + Auxiliary Function > Production statistics + 辅助功能 > 生产统计 + + + + Data file sending... + 数据文件发送中... + + + + Password input + 密码输入 + + + + Setting workable area + 设置可工作区域 + + + + + + The password is wrong,please re-enter! + 密码错误,请重新输入密码! + + + + HMI decrypt + 界面解密 + + + + The interface program is licensed, and then take effect after restarting, please restart manually! + 界面程序授权成功,重启后生效,请手动重启! + + + + Password error, interface program authorization failed! + 密码错误,界面程序授权失败! + + + + McHeadDialog + + + Dialog + + + + + + + + + + + + PushButton + + + + + MultiNeedleRotary + + + HMI Configuration + 界面配置 + + + + Interface debug mode + 界面调试模式 + + + + Delete configure file + 删除配置文件 + + + + Machine parameters + 机器参数 + + + + Work parameters + 工作参数 + + + + startX + 起始点X + + + + + + + mm + 毫米 + + + + startrY + 起始点Y + + + + + + r/min + 转/分钟 + + + + Sewing main shaft working speed + 主轴缝纫工作转速 + + + + Main shaft zero reset speed + 主轴归零转速 + + + + Main shaft running speed + 主轴运转转速 + + + + + XY zero reset speed + xy归零运行速度 + + + + + + + + mm/s + 毫米/秒 + + + + XY manual movement speed 1 + xy手动移动速度1 + + + + XY manual movement speed 2 + xy手动移动速度2 + + + + XY manual movement speed 3 + xy手动移动速度3 + + + + Work head selection 1 + 工作头选择1 + + + + + Not allow:0;allowed:1 + + + + + Work head selection 2 + 工作头选择2 + + + + Production preset + 产量预设 + + + + + No. of stitch detect if thread broken + 断线检测针数 + + + + Needle + + + + + + Bobbin thread length + 底线长度 + + + + Bobbin change reminder function + 换梭芯提醒功能 + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + 不启用该功能:0;按长度计数延迟提醒:1;按片数计数:2;按长度立刻提醒:3 + + + + Secure input light curtain allows + 安全输入光幕允许 + + + + Safety input pressure allowed + 安全输入气压允许 + + + + Safe input power-on signal allowed + 安全输入上电信号允许 + + + + Safe door allowed + + + + + X to move motor + X向移动电机 + + + + Y to move motor + Y向移动电机 + + + + All spindle zero positions + 所有主轴 零位 + + + + All Spindle Hook Lines positions + 所有主轴 勾线 + + + + All spindle jogs positions + 所有主轴 点动 + + + + All_Zero + 全部归零 + + + + Front_Back + 快进快退 + + + + AllSpleZero + 所有主轴零位 + + + + Signal + 传感器信号 + + + + Action + 控制动作 + + + + HMIUpgrade + 界面升级 + + + + MCUpgrade + 主控升级 + + + + ParaImport + 参数导入 + + + + ParaExport + 参数导出 + + + + Setting + 软件设置 + + + + Authorize + 软件授权 + + + + Network + 网络管理 + + + + Time + 时间设置 + + + + Version + 版本信息 + + + + Root + 超级用户 + + + + Para + 花样参数 + + + + Select + 花样选择 + + + + Import + 花样导入 + + + + Export + 花样导出 + + + + Delete + 花样删除 + + + + OperatPara + 操作参数 + + + + ActionSet + 动作设定 + + + + SpeedPara + 速度参数 + + + + LimitPara + 限位参数 + + + + MCPara + 机器参数 + + + + Start button 1 + 启动按钮1 + + + + Pause button 1 + 暂停按钮1 + + + + Jog button 1 + 点动按钮1 + + + + Open frame button 1 + 开框按钮1 + + + + NumerInputDialog + + + Dialog + + + + + C + + + + + (0~3000)rmp + + + + + Number input + 数字输入 + + + + ← + + + + + ParameterSetDialog + + + Dialog + + + + + PageNums: 1/1 + 页数:1/1 + + + + Sub title + + + + + Sub title < Title + + + + + Repetitions + 反复绣 + + + + + pageNum: + 页数: + + + + HMI Configuration + 界面配置 + + + + Root > HMI Configuration + 超级用户 > 界面配置 + + + + Machine parameters + 机器参数 + + + + Work parameters + 工作参数 + + + + Root > Machine parameters + 超级用户 > 机器参数 + + + + Input + 输入 + + + + Root > Work parameters + 超级用户 > 工作参数 + + + + Local port settings + 本地端口设置 + + + + + Local IP settings + 本地IP设置 + + + + IOT Configuration + 物联网配置 + + + + Root > IOT Configuration + Root >IOT Configuration + 超级用户 > 物联网配置 + + + + Network Settings + 网络设置 + + + + IOT Configuration > Network Settings + IOT Configuration >Network Settings + 物联网配置 > 网络设置 + + + + Repetitions : 0 + 反复次数:0 + + + + Server IP settings + 服务器IP设置 + + + + Server Port settings + 服务器端口设置 + + + + Local Port settings + 本口端口设置 + + + + Board IP settings + 主板IP设置 + + + + Board port settings + 主板端口设置 + + + + + + Root + 超级用户 + + + + + + Accessibility > Root + 辅助功能 > 超级用户 + + + + + + + + + Network error + 网络错误 + + + + + + read parameter... + 读取参数中... + + + + + + No connection + 未连接 + + + + + + + + + + Prompt + 提示 + + + + + The settings take effect after restarting the interface! + 重启界面后设置生效! + + + + + Network settings are completed, re-establish after reboot + 网络设置完成,需重启后重新建立连接 + + + + The time setting is completed and will take effect after restart + 时间设置完成,重启后生效 + + + + Unreasonable time setting, please reset + 时间设置不合理,请重新设置 + + + + Time setting failed, please reset + 时间设置失败,请重新设置 + + + + Connection mode changes, take effect after the reboot! + 连接方式改变,重启界面后生效! + + + + Whether to recover the default parameters for the board? + 是否恢复为主板默认参数? + + + + PassWordDialog + + + Dialog + + + + + Password + 密码 + + + + 9 + + + + + 1 + + + + + 2 + + + + + ← + + + + + 3 + + + + + 6 + + + + + 8 + + + + + C + + + + + 0 + + + + + 5 + + + + + 7 + + + + + 4 + + + + + Prompt + 提示 + + + + IP settings are unreasonable! + IP设置不合理! + + + + PatternManageWidget + + + Form + + + + + PageNums: 0/0 + 页数:0/0 + + + + Sub title < Title + + + + + Sub title + + + + + + 1000.0 + + + + + W + + + + + 500.0 + + + + + 999 + + + + + H + + + + + 1000000 + + + + + Y + + + + + X + + + + + 800.0 + + + + + dst + + + + + C + + + + + N + + + + + pageNum: + 页数: + + + + + + + + + Prompt + 提示 + + + + Over 1.28 million stitches, can not be imported! + 针数超过128万,不能导入! + + + + Format error, can not be imported! + 格式错误,不能导入! + + + + This file already exists! + 此文件已存在! + + + + Rename + 重命名 + + + + Importing + 正在导入 + + + + Exporting + 正在导出 + + + + Import complete + 导入完成 + + + + Export complete + 导出完成 + + + + USB flash drive is not detected! + 未检测到优盘! + + + + Whether to delete the pattern? + 是否删除花样? + + + + Operation screen + 操作屏 + + + + USB + 优盘 + + + + + + Pattern Import + 花样导入 + + + + + + Pattern Import < Pattern setting + 花样导入 < 花样设置 + + + + Pattern Export + 花样导出 + + + + Pattern Export < Pattern setting + 花样导出 < 花样设置 + + + + new folder + 新文件夹 + + + + This folder already exists! + 此文件夹已经存在! + + + + PatternSelectWidget + + + Form + + + + + Name: + 花样名: + 花样名: + + + + N + + + + + H + C + + + + + W + + + + + + X + + + + + + Y + + + + + Width + + + + + NeedleNum + 针杆数 + + + + Name + 名称 + + + + Height + + + + + Pattern Select + 花样选择 + 花样选择 + + + + Pattern Select < Pattern Setting + 花样选择 < 花样设置 + 花样选择 < 花样设置 + + + + PageNums: 0/0 + + + + + PageNum: 0/0 + 页数: 0/0 + + + + pageNum: + 页数: + + + + Prompt + 提示 + + + + The number of stitches of the selected pattern has reached the upper limit (2 million stitches), and it cannot be embroidered! + 所选花样针数已达上限(200万针),不可绣作! + + + + PromptDialog + + + Dialog + + + + + Prompt + 提示 + + + + ID: + + + + + Password: + 密码: + 密码: + + + + ID + + + + + DecryptInfo + 解密信息 + + + + DecryptInfo: + 解密信息: + 解密信息: + + + + Spindle angle: + 主轴角度: + 主轴角度: + + + + deg + + + + + + New Password: + 密码: + 新密码: + + + + Confirm Password: + 解密信息: + 确认密码: + + + + X + + X + + + + + X - + X - + + + + Y + + Y + + + + + Y - + Y - + + + + Board + 主板 + + + + Build Time: + 编译时间: + + + + Unlimited time + 无时间限制 + + + + Time has run out + 时间已用完 + + + + Day + + + + + Hour + + + + + Minutes + 分钟 + + + + ID: %1 + + + + + + Password: %1 + + 密码: %1 + + + + + Time: %1 + 时间: %1 + + + + Warrant + 授权 + + + + HMI decrypt + 界面解密 + + + + Spindle angle rotation + 主轴角度旋转 + + + + New Password input + 设置新密码 + + + + Confirm Password input + 确认新密码 + + + + QObject + + + (0x0002)Insufficient air pressure + Insufficient air pressure + (0x0002)气压不足 + + + + (0x0003)safe area error + safe area error + (0x0003)安全区域介入 + + + + (0x0004)Expiration of use + Expiration of use + (0x0004)使用时限已到 + + + + (0x0005)Driver alarm + Driver alarm + (0x0005)驱动器报警 + + + + (0x0006)Fill data error + Fill data error + (0x0006)填充数据错误 + + + + (0x0007)Not allowed to work + Not allowed to work + (0x0007)不允许工作状态 + + + + (0x0008)Control error + Control error + (0x0008)控制错误 + + + + (0x0009)Motion control chip version error + Motion control chip version error + (0x0009)运动控制芯片版本错误 + + + + (0x000A)Waiting for button to lift timeout + Waiting for button to lift timeout + (0x000A)等待按钮抬起超时 + + + + (0x000B)FPGA Reset + FPGA Reset + (0x000B)FPGA复位 + + + + (0x000C)Peripheral Device not ready + Peripheral Device not ready + (0x000C)外设未就绪 + + + + (0x000D)Transmission data error + Transmission data error + (0x000D)传输数据错误 + + + + (0x000E)Program version error + Program version error + (0x000E)程序版本错误 + + + + (0x000F)Complete output + Complete output + (0x000F)完成产量 + + + + (0x0010)Positive limit + Positive limit + (0x0010)正向限位 + + + + (0x0011)Negative limit + Negative limit + (0x0011)反向限位 + + + + (0x0012)Motion alarm + Motion alarm + (0x0012)运动报警 + + + + (0x0013)Motion limit + Motion limit + (0x0013)运动限位 + + + + (0x0014)Emergency stop + Emergency stop + (0x0014)运动急停 + + + + (0x0015)Motion parameters error + Motion parameters error + (0x0015)运动参数错误 + + + + (0x0016)Machine parameters error + Machine parameters error + (0x0016)机器参数错误 + + + + (0x0017)Input parameters error + Input parameters error + (0x0017)输入参数错误 + + + + (0x001A)Not in work status error + Not in work status error + (0x001A)不能工作状态 + + + + (0x001B)Prohibited frame moving state + Prohibited frame moving state + (0x001B)禁止移框状态 + + + + (0x001F)Zero success + Zero success + (0x001F)归零成功 + + + + (0x0020)Return to zero error + Return to zero error + (0x0020)归零错误 + + + + (0x0021)Coordinate system error + Coordinate system error + (0x0021)坐标系统错误 + + + + (0x0022)Target position out of bounds + Target position out of bounds + (0x0022)目标位置越界 + + + + (0x0023)X Positive limit + X Positive limit + (0x0023)X正向限位 + + + + (0x0024)X Negative limit + X Negative limit + (0x0024)X反向限位 + + + + (0x0025)Y Positive limit + Y Positive limit + (0x0025)Y正向限位 + + + + (0x0026)Y Negative limit + Y Negative limit + (0x0026)Y反向限位 + + + + (0x002B)Safety door error + (0x002B)开盖报警,安全门错误 + + + + (0x002C)Entering the light curtain 1 + Entering the light curtain 1 + (0x002C)光幕1介入 + + + + (0x002D)Entering the light curtain 2 + Entering the light curtain 2 + (0x002D)光幕2介入 + + + + (0x0040)None data + None data + (0x0040)无数据 + + + + (0x0041)Data error + Data error + (0x0041)数据错误 + + + + (0x0042)Graphics out of range + Graphics out of range + (0x0042)图形超出范围 + + + + (0x0050)Spindle is not in zero position + Spindle is not in zero position + (0x0050)主轴不在零位 + + + + (0x0051)Rotary hook is not in zero position + (0x0051)旋梭不在零位 + + + + (0x0054)Scissors are not in position + Scissors are not in position + (0x0054)剪刀不在回位 + + + + (0x0056)Nose not in low position + (0x0056)机头不在低位 + + + + (0x0058)Thread is broken + Thread is broken + (0x0058)断线 + + + + (0x0059)Bottom thread disconnected + Bottom thread disconnected + (0x0059)底线断线 + + + + (0x005D)Execution command timed out + Execution command timed out + (0x005D)执行命令超时 + + + + (0x005F)Head lifting timeout + (0x005F)机头升降超时 + + + + (0x00F0)Change the bobbin + Change the bobbin + (0x00F0)更换梭芯 + + + + (0x00F1)Replace bobbin A + Replace bobbin A + (0x00F1)更换梭芯A + + + + (0x00F2)Replace bobbin B + Replace bobbin B + (0x00F2)更换梭芯B + + + + (0x00F3)The machine is in the state of replacing the bobbin + The machine is in the state of replacing the bobbin + (0x00F3)机器处于更换梭芯状态 + + + + (0x002E)Insufficient air pressure + (0x002E)气压不足 + + + + Normal stop + (0x0100)Normal stop + 正常停止 + + + + Find zero success + (0x0101)Find zero success + 归零成功 + + + + work pause + (0x0102)work pause + 工作暂停 + + + + End of work + (0x0103)End of work + 工作结束 + + + + Work done + (0x0104)Work done + 工作完成 + + + + Complete production + (0x0105)Complete production + 完成产量 + + + + (0x0106)Execute success + Execute success + (0x0106)执行成功 + + + + (0x0107)Execute false + Execute false + (0x0107)执行失败 + + + + (0x0108)wait file + wait file + (0x0108)等待文件 + + + + (0x0109)change the bobbin + change the bobbin + (0x0109)更换梭芯 + + + + (0x010A)Execute finish + Execute finish + (0x010A)执行完成 + + + + (0x010B)Execute runnibng + Execute runnibng + (0x010B)执行过程中 + + + + Enable + 使能 + + + + Disable + 失能 + + + + JogP + 正转 + + + + JogN + 反转 + + + + Turn + 转动 + + + + Zero + 归零 + + + + Open + 打开 + + + + Close + 关闭 + + + + Ascending + 上升 + + + + descending + 下降 + + + + Trim + 剪线 + + + + SensorInputWidget + + + Form + + + + + + Sensor + 传感器信号 + + + + PageNums: 1/1 + + + + + pageNum: + 页数: + + + + SetWorkArea + + + Form + + + + + Prompt + 提示 + + + + X + + X + + + + + X - + X - + + + + Y + + Y + + + + + Y - + Y - + + + + SystemManageDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + + Update + 升级 + + + + 192.168.2.196 + + + + + StaticIP + 静态IP + + + + DynamicIP + 动态IP + + + + *Before setting the static IP, you need to first set the dynamic IP. After the dynamic IP is set, you need to return to this interface to continue setting the static IP + 设置静态IP前需要先设置动态IP,动态IP设置完成后需要返回此界面继续设置静态IP + 设置静态IP前需要先设置动态IP,动态IP设置完成后需要返回此界面继续设置静态IP + + + + pageNum: 0/0 + 页数: 0/0 + + + + pageNum: + 页数: + + + + Do you want to clear the journal? + 是否清空日志文件? + + + + Do you want to export journal? + 是否导出日志文件? + + + + + + + Prompt + 提示 + + + + The upgrade needs to restart the program. Do you need to restart to upgrade? + 升级需要重新启动程序,是否重启进行升级? + + + + Do you want to clear the production statistics? + 是否清空生产统计? + + + + WordsInputDialog + + + Dialog + + + + + Words input + 字符输入 + + + + Name: + 名称: + + + + ← + + + + + old + 旧名称 + + + diff --git a/datafile/datafiledsr.cpp b/datafile/datafiledsr.cpp new file mode 100644 index 0000000..8059e48 --- /dev/null +++ b/datafile/datafiledsr.cpp @@ -0,0 +1,1021 @@ +#include "datafiledsr.h" + +#include "main.h" + +DataFileDsr::DataFileDsr(): + m_HeadSpacingIndex(0) +{ + memset(&m_62HeadData, 0, sizeof(DsrHeadEx62)); +} + +DataFileDsr::~DataFileDsr() +{ +} + +void DataFileDsr::initFile(const QString &fullPathName) +{ + clear(); + QFileInfo file(fullPathName); + if (file.exists() && file.isFile()) + { + m_fileFullPathName = fullPathName; + m_fileName = fullPathName; + if(g_emMacType == MACHINE_FIVEHEADPRECISIONSEWING) + { + updateFileVersionTo6_2(); // 文件头中新增2048的数据 + } + } + else + { + qDebug() << "Init file failed path =" << m_fileFullPathName; + } +} + +//检查dsr文件版本,非5.2以上版本和错误格式返回-1 +int DataFileDsr::checkDsrVersion() +{ + loadFile(); // 如果数据未读取,重新读取 + + int size = m_fileData.size(); + if (size <= (int)(sizeof(DsrHead))) + { + qDebug("dsr size less then headsize"); + return -1; + } + DsrHead * dsrHead = (DsrHead *)(m_fileData.data()); + float ver = *((float*)(&dsrHead->verCode)) + 0.1; + if(ver < DSR_VERSION_5) //5.x以下版本 + { + return -1; + } + + if(ver >= DSR_VERSION_6_3) //6.3版本 + { + if(size <= (int)(sizeof(DsrHead63))) + { + qDebug() << "dsr size less then headsize"; + return -1; + } + } + + size -= dsrHead->dataBegin; + if (size <= 0) + { + qDebug("dsr dataBegin err"); + return -1; + } + int stepsize = size/sizeof(DsrStep); + if (stepsize <= 0) + { + qDebug("dsr data size err"); + return -1; + } + if (stepsize > PATTERN_LARGE_NEEDLES)//128万针 + { + qDebug("dsr data size big"); + return -2; + } + + return stepsize; +} + +// 转换为绝对数据 +void DataFileDsr::convertDataToEmbAbs() +{ + m_embAbsData.clear(); + + getDsrMinMax();//读取dsr源文件 + + int size = m_fileData.size(); + if (size <= (int)(sizeof(DsrHead))) + { + qDebug("dsr size less then headsize"); + return; + } + DsrHead * dsrHead = (DsrHead *)(m_fileData.data());//头文件的结构体 + size -= dsrHead->dataBegin; + + if (size <= 0) + { + qDebug("dsr dataBegin err"); + return; + } + int stepsize = size/sizeof(DsrStep); + if (stepsize <= 0) + { + qDebug("dsr data size err"); + return; + } + DsrStep * dsrDataBeg = (DsrStep *)((m_fileData.data() + dsrHead->dataBegin)); + + // 绝对坐标数据 + DataDs16FileHead dhead; + memset(&dhead, 0, sizeof(DataDs16FileHead)); + + QByteArray absData;//绝对坐标 + absData.clear(); + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + + DsrStep * dsrDataPtr = dsrDataBeg; + DsrStep * dsrDataPtrTemp = dsrDataBeg; + + int maxX = S32_MIN; + int maxY = S32_MIN; + int minY = S32_MAX; + int minX = S32_MAX; + + int stepidx = 0; + int runflag = 0; + BYTE ctrl,attr; + BYTE lastStatus = DATA_END_OLD; //上一针的状态; + double xfactor ; + double yfactor ; + double rfactor ; + if (dsrHead->xyUnit == 0) // 0:单位0.1mm; 1: 0.01mm; 2: mm + { + xfactor = DSR_EMB_DATADIRX*10; + yfactor = DSR_EMB_DATADIRY*10; + } + else if (dsrHead->xyUnit == 2) + { + xfactor = DSR_EMB_DATADIRX*100; + yfactor = DSR_EMB_DATADIRY*100; + } + else + { + xfactor = DSR_EMB_DATADIRX; + yfactor = DSR_EMB_DATADIRY; + } + if (dsrHead->rUnit == 0) // 0:单位0.36度; 1: 0.036度; 2: 度; 3, 1/10000弧度; + { + rfactor = 2*PI*10 * DSR_EMB_DATADIRR; + } + else if (dsrHead->rUnit == 1) + { + rfactor = 2*PI * DSR_EMB_DATADIRR; + } + else + { + rfactor = DSR_EMB_DATADIRR; + } + + int ax,ay,ar; + ax = ay = ar = 0; + int headSpacingIndex = 0; //机头间距索引 + + //都减去第一个点坐标,并转换为中间数据 + for (int i = 0; i < stepsize; i++) + { + ctrl = dsrDataPtr->ctrl; + attr = dsrDataPtr->attr; + ax = dsrDataPtr->dx; + ay = dsrDataPtr->dy; + ar = dsrDataPtr->dr; + + if (ctrl == DATA_PAUSE_OLD) // 暂停 + { + ctrl = DATA_PAUSE; + } + if (ctrl == DATA_ANGLE_OLD) // 拐点 + { + ctrl = DATA_ANGLE; + } + if (ctrl == DATA_CUT_OLD) // 剪线 + { + ctrl = DATA_CUTTRD; + } + if (ctrl == DATA_END_OLD) // 结束码 + { + ctrl = DATA_END; + } + if (ctrl == DATA_CHGND_OLD) // 换色功能码 + { + ctrl = DATA_CHGND; + } + +#if(1) + //判断是否要改变第一针的属性 + if(ctrl == DSR_JUMP) + { + if (runflag == 0) + { + runflag = 1; + } + runflag++; + } + else if(ctrl == DSR_SEWING)//第一针不转换为跳针 + { + if ((runflag == 0 || runflag > 3) && (i > 0)) // 第一个运针是入针 + { + ctrl = DATA_OFFSET; + runflag = 1; + } + //else if (i == 0 && ddx == 0 && ddy == 0) // 第一针,入针,向后扫描,如果有连续的三个跳针,则将第一针入针转换为跳针 ljs + else if (i == 0) // 20230511 第一针,入针,向后扫描,如果有连续的三个跳针,则将第一针入针转换为跳针 ljs + { + int count = 0; + do + { + dsrDataPtrTemp++; + if (dsrDataPtr->ctrl == DSR_JUMP) + { + count++; + if (dsrDataPtrTemp->dx == 0 && dsrDataPtrTemp->dy == 0) // 空跳,直接变成跳针 + { + count += 2; + } + } + else + { + break; + } + }while(1); + if (count >= 3) + { + ctrl = DATA_OFFSET; + runflag = 2; + } + else + { + runflag = 1; + } + } + else + { + runflag = 1; + } + } + else if (ctrl == DATA_CHGND) // 换色 + { + runflag = 10; + } + else + { + runflag = 0; + } +#endif + + //附加动作定义 记录每个针步的机头间距索引(机头间距表中对应的位置) + //缝纫动作结束,索引增加,起始为0 + //上一针为缝纫或剪线,这一针不是缝纫和剪线,则增加索引 + if(((lastStatus == DATA_SEWING || lastStatus == DATA_CUT_OLD ||lastStatus ==DATA_CUTTRD) + && (ctrl != DATA_SEWING && ctrl != DATA_CUT_OLD && ctrl != DATA_CUTTRD + && ctrl != DATA_END_OLD && ctrl != DATA_NULL))) + { + headSpacingIndex++; +// qDebug()<<"index add to ====================:"<action; + } + + lastStatus = ctrl; + absItem.ctrl = ctrl; + absItem.attr = attr; + absItem.ax = ax * xfactor; + absItem.ay = ay * yfactor; + absItem.ar = ar * rfactor; + + if (absItem.ax > maxX) + { + maxX = absItem.ax; + } + if (absItem.ax < minX) + { + minX = absItem.ax; + } + if (absItem.ay > maxY) + { + maxY = absItem.ay; + } + if (absItem.ay < minY) + { + minY = absItem.ay; + } + + absData.append((char*)(&absItem), sizeof(DsAbsItem)); + + stepidx++; + dsrDataPtr++; + } + + m_HeadSpacingIndex = headSpacingIndex; + qDebug()<<"m_HeadSpacingCount = headSpacingIndex =" <dx * xfactor - minX; +// int begY = dsrDataPtr->dy * yfactor - minY; + int begX = dsrHead->startX; + int begY = dsrHead->startY; + int anchorX = dsrHead->anchorX; + int anchorY = dsrHead->anchorY; + + int newstepnum = stepidx; // 转换后的数据长度 + + // 文件头转换 + QString name = getFileFullName(); + int namelen = name.size(); + if (namelen > HEAD_NAME_STR_LEN) + { + namelen = HEAD_NAME_STR_LEN; + } + memcpy(dhead.fileName, name.data(), namelen); // 文件名称 + dhead.dataSize = newstepnum*sizeof(DsAbsItem); // 数据字节数 + dhead.itemNums = newstepnum; // 数据项个数 + dhead.bytesPerItem = sizeof(DsAbsItem); // 每项占的字节数 + dhead.bytesPerBlk = MAX_EXDP_LEN; // 数据内容划分块大小 + dhead.dataChecksum = calcCheckSum32((u8 *)(absData.data()) , absData.length()); // 数据累加校验和 + dhead.checkCrc = calcCrc16((u8 *)(&dhead), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + u32 fileID = 0; + fileID = calcCheckSum32((u8 *)(absData.data()) , absData.length()); // 原始数据累加校验和 + dhead.fileid = fileID; //中间数据的 fileid = + + dhead.anchorX = anchorX; // 定位点坐标X + dhead.anchorY = anchorY; // 定位点坐标Y + dhead.beginX = begX; // 数据起点坐标X + dhead.beginY = begY; // 数据起点坐标Y + dhead.beginR = 0; + dhead.minX = minX-minX; + dhead.maxX = maxX-minX; + dhead.minY = minY-minY; + dhead.maxY = maxY-minY; // 轮廓范围,使用重新计算之后的值 + + // 保存文件头到数组中 + m_embAbsData.append((char *)(&dhead), sizeof(DataDs16FileHead)); + + // 保存数据到数组中 + m_embAbsData.append(absData); +} + +// 生成预览图片 +int DataFileDsr::createPreviewImage(QImage *pImg, int saveflag, int penwidth, int reDraw) +{ +#if(1) + if(reDraw == 0)//图片存在则不重画 + { + // 图片是否存在,存在则返回 + QString previewPath = getFileFullPathName() + ".preview.png"; + QFile imageFile(previewPath); + if (imageFile.exists()) + { + return 0; + } + } +#endif + + int newimgflag = 0; + QImage * pImage; + int width, height; + if (pImg == NULL) + { + width = DSR_PREVIEW_WIDTH; + height = DSR_PREVIEW_HEIGHT; + pImage = new QImage(width, height, IMAGE_TYPE); + newimgflag = 1; + } + else + { + pImage = pImg; + } + + width = pImage->width(); + height = pImage->height(); + + if (width <= DSR_PREVIEW_SIDE*2 || height <= DSR_PREVIEW_SIDE*2) + { + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + qDebug("preview img too small"); + return -1; + } + + memset(pImage->bits(), 0x00, pImage->byteCount()); + + QPainter painter(pImage); + QColor backcolor(255, 255, 255, 0); // 透明背景 + + // 背景 + QPen pen; + pen.setWidth(penwidth); + pen.setColor(backcolor); + painter.setPen(pen); + painter.setBrush(backcolor); + painter.drawRect(0, 0, width, height); + + getDsrMinMax(); + // 图形 + int size = m_fileData.size(); + if (size <= (int)(sizeof(DsrHead))) + { + qDebug("dsr size less then headsize"); + return -1; + } + DsrHead * dsrHead = (DsrHead *)(m_fileData.data()); + size -= dsrHead->dataBegin; + if (size <= 0) + { + qDebug("dsr dataBegin err"); + return -1; + } + int stepsize = size/sizeof(DsrStep); + if (stepsize <= 0) + { + qDebug("dsr data size err"); + return -1; + } + + DsrStep * dsrDataBeg = (DsrStep *)((m_fileData.data() + dsrHead->dataBegin)); + + // 图形显示区域 + int dpminx = DSR_PREVIEW_SIDE; + int dpmaxx = width - DSR_PREVIEW_SIDE; + int dpminy = DSR_PREVIEW_SIDE + DSR_PREVIEW_SIDE; + int dpmaxy = height - DSR_PREVIEW_SIDE; + + // 计算缩放系数 + double factor, temp; + factor = (double)(abs(m_maxX - m_minX)) / (dpmaxx - dpminx); // 按x计算的缩放系数 + temp = (double)(abs(m_maxY - m_minY)) / (dpmaxy - dpminy); // 按轮廓计算,最小能够放下重复次数个图形 + if (temp >= factor) // 使用较大的缩放系数 + { + factor = temp; + } + + // 计算显示参数,按照图形的实际位置显示(数据坐标零点对应图形中心) + int dpx = (int)((dpminx+dpmaxx)/2 - (((m_maxX+dsrHead->startX)+(m_minX+dsrHead->startX))/factor)/2); + int dpy = (int)((dpminy+dpmaxy)/2 - (((m_maxY+dsrHead->startY)+(m_minY+dsrHead->startY))/factor)/2); + + // 显示花样图形 + BYTE ctrlByte; + //BYTE attrByte; + QColor sewcolor = QColor(Qt::green); + pen.setColor(sewcolor); + painter.setPen(pen); + + double datposx, datposy; + int curx, cury, prex, prey; + curx = cury = prex = prey = 0; + + DsrStep * dsrDataPtr = dsrDataBeg; + + for (int i = 0; i < stepsize; i++) + { + // 读入一个针步数据 + ctrlByte = dsrDataPtr->ctrl; + //attrByte = dsrDataPtr->attr; + + prex = curx; + prey = cury; + + datposx = dsrDataPtr->dx + dsrHead->startX; + datposy = dsrDataPtr->dy + dsrHead->startY; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (DSR_SHOWDIRX == -1) + { + curx = (width)-curx; + } + if (DSR_SHOWDIRY == -1) + { + cury = (height)-cury; + } + + if(i == 0) + { + dsrDataPtr++; + continue; + } + + if ( ctrlByte == DSR_SEWING || + ctrlByte == DSR_EMB || + ctrlByte == DSR_CUTTING || + ctrlByte == DSR_LASER || + ctrlByte == DSR_JUMP) + { + painter.drawLine(prex, prey, curx, cury); + } + else + { + //qDebug("other type=0x%x", ctrlByte); + } + + dsrDataPtr++; + } + + // 保存成文件 + QString preview = getFileFullPathName(); + if (saveflag != 0 && preview.isEmpty() == false) + { +#if (1) + preview += ".preview.png"; + pImage->save(preview, "png"); +#endif + } + + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + + return 0; +} + +DsrHead *DataFileDsr::getDsrHead() +{ + if(m_fileData.size() <= 0) + { + loadFile(); // 如果数据未读取,重新读取 + } + + DsrHead * head = NULL; + int size = m_fileData.size(); + if (size <= (int)(sizeof(DsrHead))) + { + return head; + } + + head = (DsrHead *)(m_fileData.data()); + return head; +} + +void DataFileDsr::moveDataBeginPonit(s32 left, s32 front) +{ + if((u32)m_embAbsData.size() > sizeof(DataDs16FileHead)) + { + DataDs16FileHead *dhead = (DataDs16FileHead *)( m_embAbsData.data()); + dhead->beginX += left; + dhead->beginY += front; + dhead->maxX += left; + dhead->minX += left; + dhead->maxY += front; + dhead->minY += front; + } +} + +//dsr文件头中新增2048的拓展 用于存机头间距参数 +void DataFileDsr::updateFileVersionTo6_2() +{ + qDebug()<<"exec DataFileDsr::updateFileVersionTo6_2()"; + //1 读出数据 + //2 判断文件版本 + //3 插入数据 + //4 修改头文件信息 文件版本 和 数据起始位置 + + QFile file(m_fileFullPathName); + qDebug()<verCode)) + 0.1; + DWORD begin = dsrHead->dataBegin; + qDebug() << "file Version:" << ver; + qDebug()<< "dsr file data beign:" << begin; + + if(ver < 5.2 && begin != (sizeof(DsrHead) + sizeof(DsrHeadEx62))){ + file.remove();//删除文件 + QFile newFile(m_fileFullPathName); + if(newFile.open(QIODevice::ReadWrite | QIODevice::Truncate)){ + + QByteArray newFileBuffer; + + //添加原先的文件头 + newFileBuffer.append(oldFile.left(begin)); + qDebug()<<"append(oldFile.left(begin))" <dataBegin = sizeof(DsrHead) + sizeof(DsrHeadEx62); //3072 + qDebug()<<"newDsrHead:"<dataBegin; + + //添加数据区 + newFileBuffer.append(oldFile.right(oldFile.size() - begin)); + qDebug()<<"oldFile.right(oldFile.size() - begin)" <dataBegin; + + BYTE* pCryFactors = (BYTE*)(&dsrHead->dataBegin); + BYTE* pData = (BYTE*)((m_fileData.data() + dsrHead->dataBegin)); + + DsrCryption cry; + cry.InitDsrCryptionCtrl(-1, dsrHead->cryWord, pCryFactors); + + int rslt = cry.DeCryption(pData, size); + + if (rslt == 0) + { + dsrHead->cryWord = 0; + } + } + + return; +} + +void DataFileDsr::saveFile() +{ + QFile wrfile(m_fileFullPathName); + if(!wrfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + qDebug() << "open file fail when wirte, path =" << m_fileFullPathName; + return; + } + else + { + wrfile.write(m_fileData); + wrfile.close(); + } +} + +//写入定位点或起绣点到文件中 +void DataFileDsr::writePointToFile(int x, int y, int flag) +{ + if(m_fileData.size() <= 0) + { + return; + } + + DsrHead * pDsrHead = (DsrHead *)(m_fileData.data()); + if(flag == 0) + { + pDsrHead->startX = x; + pDsrHead->startY = y; + } + else + { + pDsrHead->anchorX = x; + pDsrHead->anchorY = y; + } + + QFile wfile(m_fileFullPathName); + if(!wfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + qDebug() << "open file fail when read, path =" << m_fileFullPathName; + return; + } + + wfile.write(m_fileData); + wfile.close(); + +#ifdef Q_OS_LINUX + system("sync"); +#endif +} + +void DataFileDsr::writePatternParaToFile(DsrHead *head) +{ + if(m_fileData.size() <= 0) + { + return; + } + + memcpy(m_fileData.data(),(char*)head,sizeof(DsrHead)); + + QFile wfile(m_fileFullPathName); + if(!wfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + qDebug() << "open file fail when read, path =" << m_fileFullPathName; + return; + } + + wfile.write(m_fileData); + wfile.close(); +} + +QString DataFileDsr::getFileFullPath() +{ + QFileInfo file(m_fileFullPathName); + return file.absoluteFilePath(); +} + +QString DataFileDsr::getFileFullName() +{ + QFileInfo file(m_fileFullPathName); + return file.fileName(); +} + +QString DataFileDsr::getFileName() +{ + QFileInfo file(m_fileFullPathName); + return file.completeBaseName(); +} + +QString DataFileDsr::getFileSuffix() +{ + QFileInfo file(m_fileFullPathName); + return file.suffix(); +} + +int DataFileDsr::getStitchNums() +{ + if(m_embAbsData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pDsrHead = (DataDs16FileHead *)((m_embAbsData.data())); + return pDsrHead->itemNums; +} + +int DataFileDsr::getDatWidth() +{ + if(m_embAbsData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pDsrHead = (DataDs16FileHead *)((m_embAbsData.data())); + return (pDsrHead->maxX - pDsrHead->minX); +} + +int DataFileDsr::getDatHeight() +{ + if(m_embAbsData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pDsrHead = (DataDs16FileHead *)((m_embAbsData.data())); + return (pDsrHead->maxY - pDsrHead->minY); +} + +int DataFileDsr::getMaxX() +{ + if(m_embAbsData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pDsrHead = (DataDs16FileHead *)((m_embAbsData.data())); + return pDsrHead->maxX; +} + +int DataFileDsr::getMinX() +{ + if(m_embAbsData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pDsrHead = (DataDs16FileHead *)((m_embAbsData.data())); + return pDsrHead->minX; +} + +int DataFileDsr::getMaxY() +{ + if(m_embAbsData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pDsrHead = (DataDs16FileHead *)((m_embAbsData.data())); + return pDsrHead->maxY; +} + +int DataFileDsr::getMinY() +{ + if(m_embAbsData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pDsrHead = (DataDs16FileHead *)((m_embAbsData.data())); + return pDsrHead->minY; +} + +int DataFileDsr::getBeginXYAndAnchorXY(int &beginX, int &beginY, int &anchorX, int &anchorY) +{ + int size = m_fileData.size(); + if (size <= (int)(sizeof(DsrHead))) + { + return -1; + } + + DsrHead * pDsrHead = (DsrHead *)((m_fileData.data())); + DsrStep * dsrDataBeg = (DsrStep *)((m_fileData.data() + pDsrHead->dataBegin)); + + anchorX = pDsrHead->anchorX; + anchorY = pDsrHead->anchorY; + //起始点坐标等于定位点+起始点+第一针的坐标 + beginX = pDsrHead->anchorX+pDsrHead->startX+dsrDataBeg->dx; + beginY = pDsrHead->anchorY+pDsrHead->startY+dsrDataBeg->dy; + + return 0; +} + +int DataFileDsr::getStepNums() +{ + int stepNums = m_HeadSpacingIndex +1; + return stepNums;//个数为index加一 +} + +void DataFileDsr::set62ExHead(DsrHeadEx62 data) +{ + m_62HeadData = data; +} + +DsrHeadEx62 &DataFileDsr::get62ExHead() +{ + return m_62HeadData; +} + +int DataFileDsr::checkFileCryption() +{ + int encryption = 0; + + int size = m_fileData.size(); + if (size <= (int)(sizeof(DsrHead))) + { + qDebug("dsr size less then headsize"); + return -1; + } + DsrHead * dsrHead = (DsrHead *)(m_fileData.data()); + size -= dsrHead->dataBegin; + if (size <= 0) + { + qDebug("dsr dataBegin err"); + return -1; + } + int stepsize = size/sizeof(DsrStep); + if (stepsize <= 0) + { + qDebug("dsr data size err"); + return -1; + } + + if (dsrHead->cryWord != 0) + { + encryption = 1; + } + + return encryption; +} + +void DataFileDsr::getDsrMinMax() +{ + loadFile(); // 如果数据未读取,重新读取 + + int size = m_fileData.size(); + if (size <= (int)(sizeof(DsrHead))) + { + qDebug("dsr size less then headsize"); + return; + } + + DsrHead * dsrHead = (DsrHead *)(m_fileData.data()); + + size -= dsrHead->dataBegin; + if (size <= 0) + { + qDebug("dsr dataBegin err"); + return; + } + + int stepsize = size/sizeof(DsrStep); + if (stepsize <= 0) + { + qDebug("dsr data size err"); + return; + } + + DsrStep * dsrDataBeg = (DsrStep *)((m_fileData.data() + dsrHead->dataBegin)); + DsrStep * dsrDataPtr = dsrDataBeg; + m_maxX = S32_MIN; + m_maxY = S32_MIN; + m_minY = S32_MAX; + m_minX = S32_MAX; + + BYTE ctrlByte; + + long curPitX = 0; + long curPitY = 0; + + int i = 0; + do + { + if (i < stepsize) + { + ctrlByte = dsrDataPtr->ctrl; + + if ( ctrlByte == DATA_EMB || + ctrlByte == DSR_SEWING || + ctrlByte == DATA_OFFSET || + 0 ) + { + curPitX = dsrDataPtr->dx; + curPitY = dsrDataPtr->dy; + } + dsrDataPtr++; + i++; + } + else + { + break; + } + + if (curPitX > m_maxX) + { + m_maxX = curPitX; + } + if (curPitX < m_minX) + { + m_minX = curPitX; + } + if (curPitY > m_maxY) + { + m_maxY = curPitY; + } + if (curPitY < m_minY) + { + m_minY = curPitY; + } + + }while(1); + + return; +} diff --git a/datafile/datafiledsr.h b/datafile/datafiledsr.h new file mode 100644 index 0000000..17897dc --- /dev/null +++ b/datafile/datafiledsr.h @@ -0,0 +1,205 @@ +#ifndef DATAFILEDSR_H +#define DATAFILEDSR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include "math.h" +#include + +#include "dsrcryption.h" +#include "machine/comm/datadef.h" +#include "machine/comm/crc16.h" + + +#define DSR_PREVIEW_SIDE (15) // 留边大小 +#define DSR_PREVIEW_WIDTH (156) // 默认预览图区域宽度 +#define DSR_PREVIEW_HEIGHT (164) // 默认预览图区域高度 + +#define DSR_VERSION_5 5.00f +#define DSR_VERSION_6_3 6.30f + +typedef struct strDsrHead +{ +// 0x00 十六进制表示 + DWORD verCode; // 文件版本 LSB + DWORD cryWord; // 加密字 + BYTE reserved1[8]; // 保留 8 字节 +// 0x10 + DWORD dataBegin; // 数据起始 LSB + DWORD stepSize; // 数据字段大小 + DWORD xyUnit; // 长度数据单位 + DWORD rUnit; // 角度数据单位 +// 0x20 + DWORD stitches; // 针数 LSB + DWORD fileID; // 文件id,和智能识别有关 = 0, 不能识别 + BYTE reserved2[8]; // 保留 8 字节 +// 0x30 + s32 rangeNx; // 范围 -X LSB + s32 rangePx; // 范围 +X LSB + s32 rangeNy; // 范围 -Y LSB + s32 rangePy; // 范围 +Y LSB +// 0x40 + long startX; // 起点坐标X LSB + long startY; // 起点坐标Y LSB + long anchorX; // 定位点X LSB + long anchorY; // 定位点Y LSB +// 0x50 + u8 reserved3[0x54-0x50]; // 保留字节 +// 0x54 + u8 rotateStyle; //旋转式样 + u8 horizontalStyle; //水平翻转式样 + u8 verticalStyle; //垂直翻转式样 + u8 rotateAngle; //旋转角度 + u8 reinMode; //加固方式 + u8 reinNeedles; //针数 + u8 reinNum; //次数 + s16 normalStep; //针步大小 + s16 angleCorrOffset; //角度修正量 + s16 angleCorrPosX; //角度修正量X正 + s16 angleCorrPosY; //角度修正量Y正 + s16 angleCorrNegX; //角度修正量X负 + s16 angleCorrNegY; //角度修正量Y负 + int scanX; //X向宽度 + int scanY; //Y向高度 + int left; //左边 + int front; //前边 +// 0x77 + BYTE reserved4[0x100-0x77]; // 保留字节 +// 0x100 + u8 reserved5[0x200-0x100]; //BYTE // 保留字节 +// 0x200 + u8 reserved6[0x400-0x200]; //BYTE + +}__attribute__ ((packed)) DsrHead; + +//dsr6.3版本的文件头扩展 +typedef struct strDsrHead63 +{ + //0x00 + u8 switchTable2[0x200-0x000]; //BYTE // 换色表2(扩展色序设定表),512个字节 + //0x200 + u8 towelHighTable[0x600-0x200]; //BYTE // 毛巾高度设定表, 支持1024个高度设定,每个字节对应一个高度等级(0,非有效高度。1--11, 有效的高度等级) +}__attribute__ ((packed)) DsrHead63; + + +//dsr6.2版本得文件头扩展 +typedef struct +{ + //支持128个表,每个表包含16个字节. + HeadTable headEnableSpacing[128]; +} DsrHeadEx62; + + +typedef struct strDsrStep +{ + BYTE ctrl; // 控制字节 + BYTE attr; // 属性字节 + WORD action;// 附加动作 + s32 dx; // X绝对偏移 + s32 dy; // Y绝对偏移 + s32 dr; // R角度 +}__attribute__ ((packed)) DsrStep; + + +//----------------------------------------------- + +#define DSR_NULL 0x00 // 文件结束 +#define DSR_SEWING 0x01 // 缝纫数据 +#define DSR_OFFSET 0x02 // 偏移数据 +#define DSR_CUTTING 0x03 // 切刀数据 +#define DSR_LASER 0x04 // 激光数据 +#define DSR_DRAWING 0x05 // 记号数据 +#define DSR_SEWING_R 0x06 // 第二缝纫数据 + +#define DSR_PAUSE 0x08 // 暂停 +#define DSR_ANGLE 0x09 // 拐点 +#define DSR_CUT 0x0A // 剪线 +#define DSR_JUMP 0x0B // 跳针 +#define DSR_EMB 0x0D // 绣花 +#define DSR_CHGND 0x0E // 换色 + +#define DSR_END 0x10 // 结束码 + +//----------------------------------------------- + +#define DSR_EMB_DATADIRX (-1) // X向数据坐标与下位机坐标系统的差异 +#define DSR_EMB_DATADIRY (-1) // Y向数据坐标与下位机坐标系统的差异 +#define DSR_EMB_DATADIRR (1) // R向数据坐标与下位机坐标系统的差异 + +#define DSR_SHOWDIRX (-1) // X向显示坐标和数据坐标的差异 +#define DSR_SHOWDIRY (1) // Y向显示坐标和数据坐标的差异 + +class DataFileDsr +{ +public: + DataFileDsr(); + ~DataFileDsr(); + +public: + void initFile(const QString & fullPathName); + int checkDsrVersion();//检查dsr文件版本,非5.2和6.3版本和错误格式返回-1 + void convertDataToEmbAbs(); // 转换为绝对数据 + //是否保存 //笔宽 + int createPreviewImage(QImage * pImg = NULL, int saveflag = 0, int penwidth = 1, int reDraw = 0); // 生成预览文件 + DsrHead *getDsrHead(); + void moveDataBeginPonit(s32 left, s32 front); //移动数据起始点 + void updateFileVersionTo6_2(); //更新文件版本至6.2 + +public: + void clear(); + void loadFile(); + void saveFile(); + void writePointToFile(int x, int y, int flag = 0);//写入起始点到文件中 + void writePatternParaToFile(DsrHead *head);//将花样参数配置写到文件中 + inline const QString & getFileFullPathName() const {return m_fileFullPathName;} // 文件路径名称 + inline QByteArray & getFileData() {return m_fileData;} // 得到文件数据 + inline QByteArray & getEmbAbsData() {return m_embAbsData;} // 得到转换后的数据 + QString getFileFullPath(); // 文件所在目录 + QString getFileFullName(); // 文件名称(包括扩展名) + QString getFileName(); // 文件名称(不包括扩展名) + QString getFileSuffix(); // 文件扩展名 + + int getStitchNums();//得到数据的针数 + int getDatWidth();//得到数据的图形宽度 + int getDatHeight();//得到数据的图形高度 + int getMaxX();//得到数据最大X+ + int getMinX();//得到数据最小X- + int getMaxY();//得到数据最大Y+ + int getMinY();//得到数据最小Y- + int getBeginXYAndAnchorXY(int &beginX, int &beginY, int &anchorX, int &anchorY); + + int getStepNums(); //获取换色数 + + void set62ExHead(DsrHeadEx62 data); + DsrHeadEx62 & get62ExHead(); + +protected: + QString m_fileFullPathName; // 文件路径 + QByteArray m_embAbsData; // 转换后的绝对坐标数据 + +private: + QByteArray m_fileData;// 文件数据内容(原始数据) + QString m_fileName; // 文件路径 + +public: + DsrHeadEx62 m_62HeadData; //6.2版本附加文件头数据 + +private: + int m_minX; + int m_maxX; + int m_minY; + int m_maxY; + int m_HeadSpacingIndex; //五头精密缝 机头间距表列数index + +private: + int checkFileCryption();//检查dsr文件是否加密 + void getDsrMinMax(); +}; + +#endif // DATAFILEDSR_H diff --git a/datafile/datafiledst.cpp b/datafile/datafiledst.cpp new file mode 100644 index 0000000..8b22b63 --- /dev/null +++ b/datafile/datafiledst.cpp @@ -0,0 +1,934 @@ +#include "datafiledst.h" + + +DataFileDst::DataFileDst() +{ +} + +DataFileDst::~DataFileDst() +{ +} + +void DataFileDst::clear() +{ + m_fileFullPathName.clear(); // 文件路径 + m_fileData.clear(); // 文件数据内容 + m_embAbsData.clear(); // 转换后的数据 +} + +void DataFileDst::initFile(const QString &fullPathName) +{ + clear(); + QFileInfo file(fullPathName); + if (file.exists() && file.isFile()) + { + m_fileFullPathName = fullPathName; + m_fileName = fullPathName; + qDebug()<<"m_fileFullPathName 1"<= 0) + { + ctrl = ds4Item.ctrl; + attr = ds4Item.attr; + + if ( ctrl == DATA_SEWING || + ctrl == DATA_OFFSET || + 0 ) + { + if(ctrl == DATA_OFFSET) + { + jumpNeedleNum++; + } + + dx = ds4Item.dx * DATAFACTOR; + dy = ds4Item.dy * DATAFACTOR; + + if ((attr & 0x80) != 0) + { + dx *= -1; + } + if ((attr & 0x40) != 0) + { + dy *= -1; + } + } + + memcpy(&(pData[stepidx]), &ds4Item, sizeof(Ds4Item)); + stepidx++; + } + + dstDataPtr++; + i++; + } + else + { + break; + } + }while(1); + + //qDebug()<<"Ds4Item end"; + //再将相对坐标转换为绝对坐标---开始 + ds4Data.append((char *)pData, stepidx*sizeof(Ds4Item));//相对坐标字节数组 + u32 fileID = 0; + fileID = calcCheckSum32((u8 *)(ds4Data.data()) , ds4Data.length()); // 原始数据累加校验和 + + QByteArray absItemAry; + absItemAry.clear(); + + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + u8 ctrlByte; + u8 attrByte; + int ddx, ddy; + + m_maxX = S32_MIN; + m_maxY = S32_MIN; + m_minY = S32_MAX; + m_minX = S32_MAX; + + Ds4Item * pDs4Data = (Ds4Item *)(ds4Data.data()); + Ds4Item * ds4DataPtr = pDs4Data; + + int begX = dstHead->startX;//起始点 + int begY = dstHead->startY; + int begR = 0; + int anchorX = dstHead->anchorX;//定位点 + int anchorY = dstHead->anchorY; + + s32 ax = 0;//第一个点 + s32 ay = 0; + s32 ar = 0; + + Ds4Item * ds4DataTemp = (Ds4Item *)(ds4Data.data()); // ljs + + int ds4StepSize = ds4Data.size()/sizeof(Ds4Item); + + int runflag = 0; + + int delStepNum = 0; // ljs + + for (int i = 0; i < ds4StepSize; i++) + { + // 读入一个针步数据 + ctrlByte = ds4DataPtr->ctrl; + attrByte = ds4DataPtr->attr; + ddx = ds4DataPtr->dx * DATAFACTOR; + ddy = ds4DataPtr->dy * DATAFACTOR; + + if ((attrByte & 0x80) != 0) + { + ddx *= -1; + } + if ((attrByte & 0x40) != 0) + { + ddy *= -1; + } + ddx *= DST_EMB_DATADIRX; + ddy *= DST_EMB_DATADIRY; + + ax += ddx; + ay += ddy; + //ar = atan2(ddy,ddx) * 10000; + double tar = atan2(ddy,ddx); + ar = (tar * 10000+0.5*(tar>0?1:-1)); + + if(ctrlByte == DATA_OFFSET) + { + if (runflag == 0) + { + runflag = 1; + } + runflag++; + } + else if(ctrlByte == DATA_SEWING)//第一针不转换为跳针 + { + if ((runflag == 0 || runflag > 3) && (i > 0)) // 第一个运针是入针 + { + ctrlByte = DATA_OFFSET; + runflag = 1; + } + //else if (i == 0 && ddx == 0 && ddy == 0) // 第一针,入针,向后扫描,如果有连续的三个跳针,则将第一针入针转换为跳针 ljs + else if (i == 0) // 20230511 第一针,入针,向后扫描,如果有连续的三个跳针,则将第一针入针转换为跳针 ljs + { + int count = 0; + do + { + ds4DataTemp++; + if (ds4DataTemp->ctrl == DATA_OFFSET) + { + count++; + if (ds4DataTemp->dx == 0 && ds4DataTemp->dy == 0) // 空跳,直接变成跳针 + { + count += 2; + } + } + else + { + break; + } + }while(1); + if (count >= 3) + { + ctrlByte = DATA_OFFSET; + runflag = 2; + } + else + { + runflag = 1; + } + } + else + { + runflag = 1; + } + } + else if (ctrlByte == DATA_CHGND) // 换色 + { + runflag = 10; + } + else + { + runflag = 0; + } + + //中间数据 + absItem.ctrl = ctrlByte; + absItem.attr = attrByte & ~(0x80|0x40); + absItem.ax = ax; + absItem.ay = ay; + absItem.ar = ar; + + if (ax > m_maxX) + { + m_maxX = ax; + } + if (ax < m_minX) + { + m_minX = ax; + } + if (ay > m_maxY) + { + m_maxY = ay; + } + if (ay < m_minY) + { + m_minY = ay; + } + + absItemAry.append((char*)&absItem,sizeof(DsAbsItem)); + + ds4DataPtr++; + } + + //int newstepnum = ds4StepSize; // 转换后的数据长度 + int newstepnum = ds4StepSize-delStepNum; // 转换后的数据长度 ljs + + //qDebug()<<"DsAbsItem end"; + + //再将相对坐标转换为绝对坐标---结束 + //qDebug()<<"dhead begin"; + // 文件头转换 + QString name = getFileFullName(); + int namelen = name.size(); + if (namelen > HEAD_NAME_STR_LEN) + { + namelen = HEAD_NAME_STR_LEN; + } + QByteArray array = name.toLocal8Bit().data(); + int asize = array.length(); + memcpy(dhead.fileName, array, asize); // 文件名称 + dhead.dataSize = newstepnum*sizeof(DsAbsItem); // 数据字节数 + dhead.itemNums = newstepnum; // 数据项个数 + dhead.bytesPerItem = sizeof(DsAbsItem); // 每项占的字节数 + dhead.bytesPerBlk = MAX_EXDP_LEN; // 数据内容划分块大小 + dhead.dataChecksum = calcCheckSum32((u8 *)(absItemAry.data()) , dhead.dataSize); // 数据累加校验和 + dhead.checkCrc = calcCrc16((u8 *)(&dhead), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + dhead.fileid = fileID; + //qDebug()<<"dhead 1"; + + dhead.anchorX = anchorX; // 定位点坐标X + dhead.anchorY = anchorY; // 定位点坐标Y + dhead.beginX = begX; // 数据起点坐标X + dhead.beginY = begY; // 数据起点坐标Y + dhead.beginR = begR; // 数据起点坐标R + dhead.minX = m_minX-m_minX; + dhead.maxX = m_maxX-m_minX; + dhead.minY = m_minY-m_minY; + dhead.maxY = m_maxY-m_minY; // 轮廓范围,使用重新计算之后的值 + + //qDebug()<<"m_maxX"<startX = x; + pDstHead->startY = y; + } + else + { + pDstHead->anchorX = x; + pDstHead->anchorY = y; + } + QFile wfile(m_fileFullPathName); + if(!wfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + qDebug() << "open file fail when read, path =" << m_fileFullPathName; + return; + } + + wfile.write(m_fileData); + wfile.close(); +} + +void DataFileDst::writePatternParaToFile(DstHead *head) +{ + if(m_fileData.size() <= 0) + { + return; + } + + memcpy(m_fileData.data(),(char*)head,sizeof(DstHead)); + + QFile wfile(m_fileFullPathName); + if(!wfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + qDebug() << "open file fail when read, path =" << m_fileFullPathName; + return; + } + + wfile.write(m_fileData); + wfile.close(); +} + +int DataFileDst::checkDstFile() +{ + loadFile(); // 如果数据未读取,重新读取 + + int size = m_fileData.size(); + if (size <= (int)(sizeof(DstHead))) + { + qDebug("dsr size less then headsize"); + return -1; + } + + size -= sizeof(DstHead); + int stepsize = size/sizeof(DstStep); + if (stepsize <= 0) + { + qDebug("dst data size err"); + return -1; + } + + if (stepsize > PATTERN_LARGE_NEEDLES)//128万针 + { + qDebug("dsr data size big"); + return -2; + } + + return stepsize; +} + +DstHead *DataFileDst::getDstHead() +{ + if(m_fileData.size() <= 0) + { + loadFile(); // 如果数据未读取,重新读取 + } + DstHead *head = NULL; + + int size = m_fileData.size(); + if (size <= (int)(sizeof(DstHead))) + { + return head; + } + + head = (DstHead *)((m_fileData.data())); + return head; +} + +void DataFileDst::moveDataBeginPonit(s32 left, s32 front) +{ + if((u32)m_embAbsData.size() > sizeof(DataDs16FileHead)) + { + DataDs16FileHead *dhead = (DataDs16FileHead *)( m_embAbsData.data()); + dhead->beginX += left; + dhead->beginY += front; + dhead->maxX += left; + dhead->minX += left; + dhead->maxY += front; + dhead->minY += front; + } +} +//----------------------------------------------------------------------- + +// 生成预览文件 +int DataFileDst::createPreviewImage(QImage * pImg, int saveflag, int penwidth, int reDraw) +{ +#if(1) + if(reDraw == 0)//图片存在则不重画 + { + // 图片是否存在,存在则返回 + QString previewPath = getFileFullPathName() + ".preview.png"; + QFile imageFile(previewPath); + if (imageFile.exists()) + { + return 0; + } + } +#endif + + int newimgflag = 0; + QImage * pImage; + int width, height; + if (pImg == NULL) + { + width = DST_PREVIEW_WIDTH; + height = DST_PREVIEW_HEIGHT; + pImage = new QImage(width, height, IMAGE_TYPE); + newimgflag = 1; + } + else + { + pImage = pImg; + } + + width = pImage->width(); + height = pImage->height(); + if (width <= DST_PREVIEW_SIDE*2 || height <= DST_PREVIEW_SIDE*2) + { + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + qDebug("preview img too small"); + return -1; + } + + memset(pImage->bits(), 0x00, pImage->byteCount()); + + QPainter painter(pImage); + QColor backcolor(255, 255, 255, 0); // 透明背景 + // 背景 + QPen pen; + pen.setWidth(penwidth); + pen.setColor(backcolor); + painter.setPen(pen); + painter.setBrush(backcolor); + painter.drawRect(0, 0, width, height); + + // 图形 + //qDebug()<<"convertDataToAbs defore"; + convertDataToAbs(); // 转换为绝对坐标数据 + //qDebug()<<"convertDataToAbs end"; + + // absdat数据 + int size = m_embAbsData.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("2 data less then head size"); + return -1; + } + DataDs16FileHead * pAbsHead = (DataDs16FileHead *)(m_embAbsData.data()); + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("absdat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("absdat data size err"); + return -1; + } + DsAbsItem * pData = (DsAbsItem *)(m_embAbsData.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; + //-------- + + // 图形显示区域 + int dpminx = DST_PREVIEW_SIDE; + int dpmaxx = width - DST_PREVIEW_SIDE; + int dpminy = DST_PREVIEW_SIDE; + int dpmaxy = height - DST_PREVIEW_SIDE; + + // 计算缩放系数 + double factor, temp; + if ((dpmaxx - dpminx) <= 0 || (dpmaxy - dpminy) <= 0) + { + return -1; + } + + factor = (double)(fabs(m_maxX - m_minX)) / (dpmaxx - dpminx); // 按x计算的缩放系数 + temp = (double)(fabs(m_maxY - m_minY)) / (dpmaxy - dpminy); // 按x计算的缩放系数 + + if (temp >= factor) // 使用较大的缩放系数 + { + factor = temp; + } + + // 计算显示参数,按照图形的实际位置显示(数据坐标零点对应图形中心) + int dpx = (int)((dpminx+dpmaxx)/2 - ((m_maxX+m_minX)/factor)/2); + int dpy = (int)((dpminy+dpmaxy)/2 - ((m_maxY+m_minY)/factor)/2); + + // 显示花样图形 + u8 ctrlByte; + int dx; + int dy; + + double datposx, datposy; + int curx, cury, prex, prey; + + datposx = pAbsHead->beginX; + datposy = pAbsHead->beginY; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (DST_SHOWDIRX == -1) + { + curx = (width)-curx; + } + if (DST_SHOWDIRY == -1) + { + cury = (height)-cury; + } + + absDataPtr = pData; + + QColor embcolor = QColor(Qt::green); + pen.setColor(embcolor); + painter.setPen(pen); + + for (int i = 0; i < stepsize; i++) + { + // 读入一个针步数据 + ctrlByte = absDataPtr->ctrl; + + if ( ctrlByte == DATA_SEWING || + 0 ) + { + prex = curx; + prey = cury; + + dx = absDataPtr->ax; + dy = absDataPtr->ay; + + datposx = dx; + datposy = dy; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (DST_SHOWDIRX == -1) + { + curx = (width)-curx; + } + if (DST_SHOWDIRY == -1) + { + cury = (height)-cury; + } + + if(i != 0) + { + painter.drawLine(prex, prey, curx, cury); + } + } + + + //如果连续两步都是跳针,则过滤掉 + else if (ctrlByte == DATA_OFFSET) + { + DsAbsItem * JumpAbsDataPtr = pData; + JumpAbsDataPtr = absDataPtr - 1; + u8 beforectrlByte = JumpAbsDataPtr->ctrl; + + JumpAbsDataPtr = absDataPtr + 2; + u8 nextctrlByte = JumpAbsDataPtr->ctrl; + + prex = curx; + prey = cury; + + dx = absDataPtr->ax; + dy = absDataPtr->ay; + + datposx = dx; + datposy = dy; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (DST_SHOWDIRX == -1) + { + curx = (width)-curx; + } + if (DST_SHOWDIRY == -1) + { + cury = (height)-cury; + } + + pen.setColor(embcolor); + painter.setPen(pen); + + if(beforectrlByte == DATA_OFFSET || nextctrlByte == DATA_OFFSET) + { + //该针上下两针都是跳针则不画线 + } + else + { + if(i != 0) + { + painter.drawLine(prex, prey, curx, cury); + } + } + } + + absDataPtr++; + } + + // 保存成文件 + QString preview = getFileFullPathName(); + if (saveflag != 0 && preview.isEmpty() == false) + { +#if (1) + preview += ".preview.png"; + pImage->save(preview, "png"); +#endif + } + + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + + return 0; +} + +#define EMB_DST_DAT_DIRX (-1) // X向DST数据坐标和绝对数据坐标的差异 +#define EMB_DST_DAT_DIRY (1) // Y向DST数据坐标和绝对数据坐标的差异 + +// 针步转换 +int DataFileDst::changeDstStep(DstStep * pDststep, Ds4Item & ds4step) +{ + int dx, dy; + u8 c1, c2, c3; + u8 ctrl, attr; + + if (pDststep == NULL) + { + return -1; + } + + c1 = pDststep->c1; + c2 = pDststep->c2; + c3 = pDststep->c3; + + dx = 0; + dy = 0; + + if ((c1&0x08) != 0) { dx -= 9; } + if ((c1&0x04) != 0) { dx += 9; } + if ((c1&0x02) != 0) { dx -= 1; } + if ((c1&0x01) != 0) { dx += 1; } + if ((c2&0x08) != 0) { dx -= 27; } + if ((c2&0x04) != 0) { dx += 27; } + if ((c2&0x02) != 0) { dx -= 3; } + if ((c2&0x01) != 0) { dx += 3; } + if ((c3&0x08) != 0) { dx -= 81; } + if ((c3&0x04) != 0) { dx += 81; } + + if ((c1&0x10) != 0) { dy -= 9; } + if ((c1&0x20) != 0) { dy += 9; } + if ((c1&0x40) != 0) { dy -= 1; } + if ((c1&0x80) != 0) { dy += 1; } + if ((c2&0x10) != 0) { dy -= 27; } + if ((c2&0x20) != 0) { dy += 27; } + if ((c2&0x40) != 0) { dy -= 3; } + if ((c2&0x80) != 0) { dy += 3; } + if ((c3&0x10) != 0) { dy -= 81; } + if ((c3&0x20) != 0) { dy += 81; } + + if (c3 == 0xF3 && dx == 0 && dy == 0) + { + ctrl = DATA_END; // 结束 + } + else if ((c3&0xc3) == 0x03) // 运针 + { + ctrl = DATA_SEWING; + } + else if ((c3&0xc3) == 0x83) // 偏移 + { + ctrl = DATA_OFFSET; + } + else if ((c3&0xc3) == 0xC3) // 换色 + { + ctrl = DATA_CHGND; + } + else if ((c3&0xc3) == 0x43) // 开关亮片码 + { + qDebug("Sequin switch, not support, c1=0x%x, c2=0x%x, c3=0x%x", c1, c2, c3); // 不合法的DST + return -2; + } + else + { + qDebug("not know dst step, c1=0x%x, c2=0x%x, c3=0x%x", c1, c2, c3); // 不合法的DST + return -3; + } + + // 添加针步 + attr = 0; + + dx *= EMB_DST_DAT_DIRX; // X向显示坐标和数据坐标的差异 + dy *= EMB_DST_DAT_DIRY; // Y向显示坐标和数据坐标的差异 + + if (dx < 0) { attr |= 0x80; } + if (dy < 0) { attr |= 0x40; } + + ds4step.ctrl = ctrl; + ds4step.attr = attr; + ds4step.dx = abs(dx); + ds4step.dy = abs(dy); + + return 0; +} diff --git a/datafile/datafiledst.h b/datafile/datafiledst.h new file mode 100644 index 0000000..0c17f34 --- /dev/null +++ b/datafile/datafiledst.h @@ -0,0 +1,157 @@ +#ifndef DATAFILEDST_H +#define DATAFILEDST_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include "math.h" +#include + +#include "machine/comm/datadef.h" +#include "machine/comm/crc16.h" +#include "datafile/dataoperat.h" + +#define DATAFACTOR 10 //dst绝对坐标数据转换为ds16前需要扩大10倍 + +#define DST_EMB_DATADIRX (-1) // X向数据坐标与下位机坐标系统的差异 +#define DST_EMB_DATADIRY (1) // Y向数据坐标与下位机坐标系统的差异 + +#define DST_SHOWDIRX (-1) // X向显示坐标和数据坐标的差异 +#define DST_SHOWDIRY (1) // Y向显示坐标和数据坐标的差异 + +#define DST_PREVIEW_SIDE (15) // 留边大小 +#define DST_PREVIEW_WIDTH (156) // 默认预览图区域宽度 +#define DST_PREVIEW_HEIGHT (164) // 默认预览图区域高度 + +// dst文件头 +#pragma pack(1)//设定为1字节对齐 +struct DstHead +{ +// 0 + char la[20]; + char st[11]; + char co[7]; + char xp[9]; + char xn[9]; + char yp[9]; + char yn[9]; + char ax[10]; + char ay[10]; + char mx[10]; + char my[10]; + char pd[10]; + char sub; + char reserved1[3]; + +// 128 + u8 rotateStyle; //旋转式样 + u8 horizontalStyle; //水平翻转式样 + u8 verticalStyle; //垂直翻转式样 + u8 rotateAngle; //旋转角度 + u8 reinMode; //加固方式 + u8 reinNeedles; //针数 + u8 reinNum; //次数 + s16 normalStep; //针步大小 + s16 angleCorrOffset; //角度修正量 + s16 angleCorrPosX; //角度修正量X正 + s16 angleCorrPosY; //角度修正量Y正 + s16 angleCorrNegX; //角度修正量X负 + s16 angleCorrNegY; //角度修正量Y负 + int scanX; //X向宽度 + int scanY; //Y向高度 + int left; //左边 + int front; //前边 + + // 163 + u8 reserved2[256-163]; //BYTE + +// 256 + s16 reserved3; + +// 258 + int anchorX; //定位点 + int anchorY; + +// 266 + s32 startX; //起始点 + s32 startY; + +// 274 + u8 reserved4[512-274]; //BYTE // 保留字节 +}; +#pragma pack(1)//恢复对齐状态 + + +// 针步数据 +typedef struct strDstStep +{ + u8 c1; ////BYTE + u8 c2; ////BYTE + u8 c3; ////BYTE +}__attribute__ ((packed)) DstStep; + + +class DataFileDst +{ +public: + DataFileDst(); + ~DataFileDst(); + +public: + void initFile(const QString & fullPathName); + int createPreviewImage(QImage * pImg = NULL, int saveflag = 0, int penwidth = 1, int reDraw = 0); // 生成预览文件 + void convertDataToAbs(); // 转换为绝对坐标数据 + void writePointToFile(int x, int y, int flag = 0);//写入起始点到文件中 + void writePatternParaToFile(DstHead *head);//将花样参数配置写到文件中 + void writeOffsetXYMoveToFile(s32 EnFlag,s32 offsetX,s32 offsetY); + int checkDstFile();//检查dst文件是否正确 + DstHead * getDstHead(); + void moveDataBeginPonit(s32 left, s32 front);//移动数据起始点 + +public: + void clear(); + void loadFile(); + void saveFile(); + inline const QString & getFileFullPathName() const {return m_fileFullPathName;} // 文件路径名称 + inline QByteArray & getFileData() {return m_fileData;} // 得到文件数据 + inline QByteArray & getEmbAbsData() {return m_embAbsData;} // 得到转换后的数据 + QString getFileFullPath(); // 文件所在目录 + QString getFileFullName(); // 文件名称(包括扩展名) + QString getFileName(); // 文件名称(不包括扩展名) + QString getFileSuffix(); // 文件扩展名 + + int getStitchNums();//得到数据的针数 + int getFileid();//得到fileid + int getDatWidth();//得到数据的图形宽度 + int getDatHeight();//得到数据的图形高度 + int getMaxX();//得到数据最大X+ + int getMinX();//得到数据最小X- + int getMaxY();//得到数据最大Y+ + int getMinY();//得到数据最小Y- + int getBeginXYAndAnchorXY(int &beginX, int &beginY, int &anchorX, int &anchorY); + +protected: + QString m_fileFullPathName; // 文件路径 + QByteArray m_embAbsData; // 转换后的绝对坐标数据 + +private: + QByteArray m_fileData;// 文件数据内容(原始数据) + QString m_fileName; // 文件路径 + +private: + double m_minX; + double m_maxX; + double m_minY; + double m_maxY; + +private: + int changeDstStep(DstStep * pDststep, Ds4Item & ds4step); + +}; + +#endif // DATAFILEDST_H diff --git a/datafile/datafilequi.cpp b/datafile/datafilequi.cpp new file mode 100644 index 0000000..bda5045 --- /dev/null +++ b/datafile/datafilequi.cpp @@ -0,0 +1,1014 @@ +#include "datafilequi.h" + + +DataFileQui::DataFileQui() +{ + clear(); +} + +void DataFileQui::convertDataToEmbAbs(s16 flag) +{ + m_absData.clear(); + getQuiMinMax(); + + QuiFileHead head; + + // 图形数据 + int i, datasize, idx; + BYTE ch1, ch2; + WORD tmpls,lsdata; + double deltx1, delty1, deltx2, delty2; + double threex[4], threey[4]; + s16 nmstep; + + double factorx, factory, unitmuti; + memcpy(&head, m_quiFileData.data(), sizeof(QuiFileHead)); + unitmuti = getMutiUnit(head.unit); + + double scanx = head.scanX * unitmuti; // 宽度 + double scany = head.scanY * unitmuti; // 长度 + + if (scanx < 1) + { + scanx = 1; + } + if (scany < 1) + { + scany = 1; + } + + // 计算缩放系数 + factorx = (double)((m_maxX-m_minX) / (scanx)); + factory = (double)((m_maxY-m_minY) / (scany)); + + if(factorx == 0){factorx = 1;} + if(factory == 0){factory = 1;} +// factorx = 1; +// factory = 1; + + if(flag != 1) + { + factorx = 1; + factory = 1; + } + + nmstep = head.normalStep * unitmuti; + if(nmstep == 0) + { + nmstep = 200; //单位0.01mm(2mm) + } + + i = sizeof(QuiFileHead); + datasize = m_quiFileData.size(); + + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + + //将第一个点加进来 + absItem.ctrl = m_firstPoint.ctrl; + absItem.ax = m_firstPoint.x / factorx; + absItem.ay = m_firstPoint.y / factory; + m_absData.append((char*)&absItem,sizeof(DsAbsItem)); + + while(i < datasize) + { + // 图元类型 + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + tmpls = (unsigned short) (ch2 * 256) + ch1; + + if(tmpls == 0xffff) // 结束 + { + break; + } + + switch(tmpls) + { + case QUI_TYPE_LINE: // 直线 + case QUI_TYPE_STEP: // 跨步 + case QUI_TYPE_HSTEP: // 翻头跨步 + { + //增加剪线 + if(tmpls == QUI_TYPE_STEP || tmpls == QUI_TYPE_HSTEP) + { + if((u32)m_absData.size() >= sizeof(DsAbsItem)) + { + memcpy((char*)&absItem,m_absData.data()+m_absData.size()-sizeof(DsAbsItem),sizeof(DsAbsItem)); + absItem.ctrl = DATA_CUTTRD; + m_absData.append((char*)&absItem,sizeof(DsAbsItem)); + } + } + + // 点个数 + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + lsdata = (unsigned short)ch2 * 256 + ch1; + + if (lsdata > 1) + { + // 第一个点 + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + deltx2 = (ch2 * 256.0 + ch1)/factorx; + + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + delty2 = (ch2 * 256.0 + ch1)/factory; + + for(idx = 1; idx < lsdata; idx++) // 其余的点 + { + deltx1 = deltx2; + delty1 = delty2; + + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + deltx2 = (ch2 * 256.0 + ch1)/factorx; + + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + delty2 = (ch2 * 256.0 + ch1)/factory; + + // 处理直线 + calcLine(deltx1, delty1, deltx2, delty2, nmstep, m_absData, tmpls); + } + if (idx != lsdata) + { + break; + } + } + break; + } + case QUI_TYPE_ARC: // 三点圆弧 + { + for (idx = 0; idx < 3; idx++) + { + // 点x + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + threex[idx] = (ch2 * 256.0 + ch1)/factorx; + + // 点y + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + threey[idx] = (ch2 * 256.0 + ch1)/factory; + } + + calcCurve(threex, threey, nmstep, m_absData); + + if (idx != 3) + { + break; + } + break; + } + case QUI_TYPE_BES: // 贝塞尔曲线 + { + for (idx = 0; idx < 4; idx++) + { + // 点x + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + threex[idx] = (ch2 * 256.0 + ch1)/factorx; + + // 点y + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + threey[idx] = (ch2 * 256.0 + ch1)/factory; + } + + // 处理贝塞尔曲线 + QList splineListXY;//拟合后的点 + splineListXY.clear(); + getBezierPointList(threex, threey, nmstep,splineListXY); + + QList splitListXY;//均分后的点 + splitListXY.clear(); + if(splineListXY.size() > 0) + { + getCurvePointFillLine(splineListXY,nmstep,splitListXY,0,OBJECT_STITCHLEN_NEW_SAMALL); + } + + //添加贝塞尔曲线数据点 + for(int i = 0; i < splitListXY.size(); i++) + { + memset(&absItem,0,sizeof(DsAbsItem)); + + deltx1 = splitListXY[i].x(); + delty1 = splitListXY[i].y(); + + absItem.ctrl = DATA_SEWING; + absItem.ax = deltx1; + absItem.ay = delty1; + m_absData.append((char*)&absItem,sizeof(DsAbsItem)); + } + //calcBezier(threex, threey, nmstep, m_absData); + + if (idx != 4) + { + break; + } + break; + } + default: + break; + } + } + + //生成绝对坐标数据的文件头 + creatAbsHeadAndAr(); +} + +void DataFileQui::creatAbsHeadAndAr() +{ + DataDs16FileHead dhead; + memset(&dhead, 0, sizeof(DataDs16FileHead)); + + int stepSize = m_absData.size()/sizeof(DsAbsItem); + if(stepSize <= 0) + { + return; + } + + DsAbsItem * absDataPtr = (DsAbsItem *)(m_absData.data()); + + double minX, maxX, minY, maxY; + minX = S32_MAX; + maxX = S32_MIN; + minY = S32_MAX; + maxY = S32_MIN; + + double prex,prey,curx,cury,dx,dy,ar; + prex = prey = curx = cury = dx = dy = ar = 0; + + //取反并求最大最小值 + for (int i = 0; i < stepSize; i++) + { + absDataPtr->ax *= QUI_DATADIRX; + absDataPtr->ay *= QUI_DATADIRY; + + curx = absDataPtr->ax; + cury = absDataPtr->ay; + + if(curx > maxX) + { + maxX = curx; + } + if(curx < minX) + { + minX = curx; + } + + if(cury > maxY) + { + maxY = cury; + } + if(cury < minY) + { + minY = cury; + } + + absDataPtr++; + } + + absDataPtr = (DsAbsItem *)(m_absData.data()); + double begX = absDataPtr->ax;//起始点 + double begY = absDataPtr->ay; + int begR = 0; + + //求dr并将每点坐标都减去第一点坐标 + for (int i = 0; i < stepSize; i++) + { + curx = absDataPtr->ax; + cury = absDataPtr->ay; + + dx = curx - prex; + dy = cury - prey; + + double tar = atan2(dy,dx); + ar = (tar*10000+0.5*(tar>0?1:-1)); + absDataPtr->ar = ar; + + prex = curx; + prey = cury; + + //将每个坐标都减去起始点坐标 + absDataPtr->ax -= begX; + absDataPtr->ay -= begY; + absDataPtr->ar -= begR; + + absDataPtr++; + } + + //增加结束码 + if((u32)m_absData.size() >= sizeof(DsAbsItem)) + { + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + memcpy((char*)&absItem,m_absData.data()+m_absData.size()-sizeof(DsAbsItem),sizeof(DsAbsItem)); + absItem.ctrl = DATA_NULL; + m_absData.append((char*)&absItem,sizeof(DsAbsItem)); + stepSize++; + } + + m_maxX = maxX-begX; + m_minX = minX-begX; + m_maxY = maxY-begY; + m_minY = minY-begY; + + //生成文件头 + dhead.maxX = maxX; + dhead.maxY = maxY; + dhead.minX = minX; + dhead.minY = minY; + dhead.beginX = begX-minX;//起始点减去最小值 + dhead.beginY = begY-minY;//起始点减去最小值 + dhead.beginR = begR; + dhead.anchorX = 0; + dhead.anchorY = 0; + dhead.itemNums = stepSize; + dhead.dataSize = stepSize*sizeof(DsAbsItem); // 数据字节数 + dhead.bytesPerItem = sizeof(DsAbsItem); // 每项占的字节数 + dhead.dataChecksum = calcCheckSum32((u8 *)(m_absData.data()) , dhead.dataSize);; // 数据累加校验和 + dhead.checkCrc = calcCrc16((u8 *)(&dhead), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + dhead.fileid = dhead.checkCrc; + m_absData.insert(0,(char*)&dhead,sizeof(DataDs16FileHead)); +} + +void DataFileQui::getQuiMinMax() +{ + QuiFileHead head; + memcpy(&head, m_quiFileData.data(), sizeof(QuiFileHead)); + + int i, idx, datasize; + unsigned char ch1, ch2; + unsigned short tmpls, lsdata; + double deltx, delty; + double threex[4], threey[4]; + + int first = 0; + double minx, maxx, miny, maxy; + + minx = S32_MAX; + maxx = S32_MIN; + miny = S32_MAX; + maxy = S32_MIN; + + i = sizeof(QuiFileHead); + datasize = m_quiFileData.size(); + while(i < datasize) + { + // 图元类型 + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + tmpls = (unsigned short) (ch2 * 256) + ch1; + + if(tmpls == 0xffff) // 结束 + { + break; + } + + switch(tmpls) + { + case QUI_TYPE_LINE: // 直线(折线) + case QUI_TYPE_STEP: // 跨步 + case QUI_TYPE_HSTEP: // 翻头跨步 + { + // 点个数 + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + lsdata = (unsigned short)ch2 * 256 + ch1; + + if (lsdata > 1) + { + for(idx = 0; idx < lsdata; idx++) // 点 + { + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + deltx = (ch2 * 256.0 + ch1); + + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + delty = (ch2 * 256.0 + ch1); + + if (first == 0) + { + m_firstPoint.x = deltx; + m_firstPoint.y = delty; + if(tmpls == QUI_TYPE_LINE) + { + m_firstPoint.ctrl = DATA_SEWING; + } + else + { + m_firstPoint.ctrl = DATA_OFFSET; + } + first = 1; + } + + if(deltx > maxx) + { + maxx = deltx; + } + if(deltx < minx) + { + minx = deltx; + } + + if(delty > maxy) + { + maxy = delty; + } + if(delty < miny) + { + miny = delty; + } + } + if (idx != lsdata) + { + break; + } + } + } + break; + case QUI_TYPE_ARC: // 三点圆弧 + { + for (idx = 0; idx < 3; idx++) + { + // 点x + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + threex[idx] = (ch2 * 256.0 + ch1); + + // 点y + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + threey[idx] = (ch2 * 256.0 + ch1); + + if (first == 0) + { + m_firstPoint.x = threex[0]; + m_firstPoint.y = threey[0]; + m_firstPoint.ctrl = DATA_SEWING; + first = 1; + } + } + if (idx != 3) + { + break; + } + + if(isThreePointOnALine(threex, threey) >= 1) // 3点共线 + { + // printf("three point on a line\n"); + if(threex[0] > maxx) maxx = threex[0]; + if(threex[1] > maxx) maxx = threex[1]; + if(threex[2] > maxx) maxx = threex[2]; + if(threex[0] < minx) minx = threex[0]; + if(threex[1] < minx) minx = threex[1]; + if(threex[2] < minx) minx = threex[2]; + + if(threey[0] > maxy) maxy = threey[0]; + if(threey[1] > maxy) maxy = threey[1]; + if(threey[2] > maxy) maxy = threey[2]; + if(threey[0] < miny) miny = threey[0]; + if(threey[1] < miny) miny = threey[1]; + if(threey[2] < miny) miny = threey[2]; + } + else + { + // printf("before GetArcMinMax\n"); + // printf("minx=%.2f,maxx=%.2f,miny=%.2f,maxy=%.2f\n", minx, maxx, miny, maxy); + getArcMinMax(threex, threey, &minx, &maxx, &miny, &maxy); + // printf("after GetArcMinMax\n"); + // printf("minx=%.2f,maxx=%.2f,miny=%.2f,maxy=%.2f\n", minx, maxx, miny, maxy); + } + } + break; + case QUI_TYPE_BES: // 贝塞尔曲线 + { + for (idx = 0; idx < 4; idx++) + { + // 点x + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + threex[idx] = (ch2 * 256.0 + ch1); + + // 点y + if (i >= datasize){break;} + ch1 = m_quiFileData.at(i++); + if (i >= datasize){break;} + ch2 = m_quiFileData.at(i++); + threey[idx] = (ch2 * 256.0 + ch1); + + if (first == 0) + { + m_firstPoint.x = threex[0]; + m_firstPoint.y = threey[0]; + m_firstPoint.ctrl = DATA_SEWING; + first = 1; + } + } + if (idx != 4) + { + break; + } + + getBezierMinMax(threex, threey, &minx, &maxx, &miny, &maxy); + } + break; + } + } + + if (first == 0) + { + minx = 0; + maxx = 0; + miny = 0; + maxy = 0; + + m_firstPoint.x = 0; + m_firstPoint.y = 0; + m_firstPoint.ctrl = 0; + } + + m_minX = minx; + m_maxX = maxx; + m_minY = miny; + m_maxY = maxy; + + return; +} + +int DataFileQui::checkFileHead() +{ + if (m_quiFileData.size() >= (int)sizeof(QuiFileHead)) + { + QuiFileHead * pHead; + pHead = (QuiFileHead *)(m_quiFileData.data()); + + if (pHead->normalStep < 1) + { + pHead->normalStep = 40; + } + + if (pHead->miniStep < 1) + { + pHead->miniStep = 40; + } + + if (pHead->scanX < 1) + { + pHead->scanX = m_maxX - m_minX; + } + + if (pHead->scanY < 1) + { + pHead->scanY = m_maxY - m_minY; + } + + QFile wrfile(m_fileFullPathName); + if(!wrfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + return -1; + } + else + { + wrfile.write(m_quiFileData); + wrfile.close(); + } + } + + return 0; +} + +double DataFileQui::getMutiUnit(int unit) +{ + double unitmuti; + if (unit == 0x00) // 0x00: 0.1mm; + { + unitmuti = 10; + } + else if (unit == 0x01) // 0x01: 1/1000inch; + { + unitmuti = 2.54; + } + else if (unit == 0x02) // 0x02: 0.04mm + { + unitmuti = 10; + } + else + { + unitmuti = 1; + } + return unitmuti; +} + +void DataFileQui::initFile(const QString &fullPathName) +{ + clear(); + QFileInfo file(fullPathName); + if (file.exists() && file.isFile()) + { + m_fileFullPathName = fullPathName; + } + else + { + qDebug() << "Init file failed path =" << m_fileFullPathName; + } + loadFile(); +} + +void DataFileQui::clear() +{ + m_firstPoint.x = 0; + m_firstPoint.y = 0; + m_firstPoint.ctrl = 0; + + m_minX = INT32_MAX; + m_maxX = INT32_MIN; + m_minY = INT32_MAX; + m_maxY = INT32_MIN; + + m_fileFullPathName.clear(); // 文件路径 + m_quiFileData.clear(); // 文件数据内容 + m_absData.clear(); // 转换后的数据 +} + +void DataFileQui::loadFile() +{ + QFile rdfile(m_fileFullPathName); + if(!rdfile.open(QIODevice::ReadOnly)) + { + qDebug() << "open file fail when read, path =" << m_fileFullPathName; + return; + } + + m_quiFileData = rdfile.readAll(); + rdfile.close(); +} + +int DataFileQui::createPreviewImage(QImage *pImg, int saveflag, int penwidth, int reDraw) +{ +#if(1) + s16 existFlag = 1; + + if(reDraw == 0)//图片存在则不重画 + { + existFlag = 0; + // 图片是否存在,存在则返回 + QString previewPath = getFileFullPathName() + ".preview.png"; + QFile imageFile(previewPath); + if (imageFile.exists()) + { + return 0; + } + } +#endif + + int newimgflag = 0; + QImage * pImage; + int width, height; + if (pImg == NULL) + { + width = QUI_PREVIEW_WIDTH; + height = QUI_PREVIEW_HEIGHT; + pImage = new QImage(width, height, IMAGE_TYPE); + newimgflag = 1; + } + else + { + pImage = pImg; + } + + width = pImage->width(); + height = pImage->height(); + if (width <= QUI_PREVIEW_SIDE*2 || height <= QUI_PREVIEW_SIDE*2) + { + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + qDebug("preview img too small"); + return -1; + } + + memset(pImage->bits(), 0x00, pImage->byteCount()); + + QPainter painter(pImage); + QColor backcolor(255, 255, 255, 0); // 透明背景 + // 背景 + QPen pen; + pen.setWidth(penwidth); + pen.setColor(backcolor); + painter.setPen(pen); + painter.setBrush(backcolor); + painter.drawRect(0, 0, width, height); + + // 图形 + //qDebug()<<"convertDataToAbs defore"; + convertDataToEmbAbs(existFlag); // 转换为绝对坐标数据 + //qDebug()<<"convertDataToAbs end"; + + // absdat数据 + int size = m_absData.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("2 data less then head size"); + return -1; + } + DataDs16FileHead * pAbsHead = (DataDs16FileHead *)(m_absData.data()); + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("absdat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("absdat data size err"); + return -1; + } + DsAbsItem * pData = (DsAbsItem *)(m_absData.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; + //-------- + + // 图形显示区域 + int dpminx = QUI_PREVIEW_SIDE; + int dpmaxx = width - QUI_PREVIEW_SIDE; + int dpminy = QUI_PREVIEW_SIDE; + int dpmaxy = height - QUI_PREVIEW_SIDE; + + // 计算缩放系数 + double factor, temp; + if ((dpmaxx - dpminx) <= 0 || (dpmaxy - dpminy) <= 0) + { + return -1; + } + + factor = (double)(fabs(m_maxX - m_minX)) / (dpmaxx - dpminx); // 按x计算的缩放系数 + temp = (double)(fabs(m_maxY - m_minY)) / (dpmaxy - dpminy); // 按x计算的缩放系数 + + if (temp >= factor) // 使用较大的缩放系数 + { + factor = temp; + } + + // 计算显示参数,按照图形的实际位置显示(数据坐标零点对应图形中心) + double dpx = (double)((dpminx+dpmaxx)/2 - ((m_maxX+m_minX)/factor)/2); + double dpy = (double)((dpminy+dpmaxy)/2 - ((m_maxY+m_minY)/factor)/2); + + // 显示花样图形 + u8 ctrlByte; + double dx; + double dy; + + double datposx, datposy; + double curx, cury, prex, prey; + + datposx = pAbsHead->beginX; + datposy = pAbsHead->beginY; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (QUI_SHOWDIRX == -1) + { + curx = (width)-curx; + } + if (QUI_SHOWDIRY == -1) + { + cury = (height)-cury; + } + + absDataPtr = pData; + + QColor color = QColor(Qt::green); + pen.setColor(color); + painter.setPen(pen); + + for (int i = 0; i < stepsize; i++) + { + // 读入一个针步数据 + ctrlByte = absDataPtr->ctrl; + + prex = curx; + prey = cury; + + dx = absDataPtr->ax; + dy = absDataPtr->ay; + + datposx = dx; + datposy = dy; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (QUI_SHOWDIRX == -1) + { + curx = (width)-curx; + } + if (QUI_SHOWDIRY == -1) + { + cury = (height)-cury; + } + + if(i == 0) + { + absDataPtr++; + continue; + } + + if ( ctrlByte == DATA_SEWING) + { + painter.drawLine(prex, prey, curx, cury); + } + else + { + //qDebug("other type=0x%x", ctrlByte); + } + + absDataPtr++; + } + + // 保存成文件 + QString preview = getFileFullPathName(); + if (saveflag != 0 && preview.isEmpty() == false) + { +#if (1) + preview += ".preview.png"; + pImage->save(preview, "png"); +#endif + } + + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + + return 0; +} + +QuiFileHead *DataFileQui::getQuiHead() +{ + if(m_quiFileData.size() <= 0) + { + loadFile(); + } + + QuiFileHead *head = NULL; + + int size = m_quiFileData.size(); + if (size <= (int)(sizeof(QuiFileHead))) + { + return head; + } + + head = (QuiFileHead *)(m_quiFileData.data()); + return head; +} + +void DataFileQui::writePatternParaToFile(QuiFileHead *head) +{ + if(m_quiFileData.size() <= 0) + { + return; + } + + memcpy(m_quiFileData.data(),(char*)head,sizeof(QuiFileHead)); + + QFile wfile(m_fileFullPathName); + if(!wfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + qDebug() << "open file fail when read, path =" << m_fileFullPathName; + return; + } + + wfile.write(m_quiFileData); + wfile.close(); +} + +void DataFileQui::moveDataBeginPonit(s32 left, s32 front) +{ + if((u32)m_absData.size() > sizeof(DataDs16FileHead)) + { + DataDs16FileHead *dhead = (DataDs16FileHead *)( m_absData.data()); + dhead->beginX += left; + dhead->beginY += front; + dhead->maxX += left; + dhead->minX += left; + dhead->maxY += front; + dhead->minY += front; + } +} + +int DataFileQui::getStitchNums() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->itemNums; +} + +int DataFileQui::getDatWidth() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return (pHead->maxX - pHead->minX); +} + +int DataFileQui::getDatHeight() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return (pHead->maxY - pHead->minY); +} + +int DataFileQui::getMaxX() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->maxX; +} + +int DataFileQui::getMinX() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->minX; +} + +int DataFileQui::getMaxY() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->maxY; +} + +int DataFileQui::getMinY() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->minY; +} diff --git a/datafile/datafilequi.h b/datafile/datafilequi.h new file mode 100644 index 0000000..5b8e435 --- /dev/null +++ b/datafile/datafilequi.h @@ -0,0 +1,130 @@ +#ifndef DATAFILEQUI_H +#define DATAFILEQUI_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include "math.h" +#include +#include "stdint.h" + +//#include "vectorsqrt.h" +#include "machine/comm/datadef.h" +#include "machine/comm/crc16.h" +#include "datafile/dataoperat.h" + +#define QUI_DATADIRX (1) // X向数据坐标与下位机坐标系统的差异 +#define QUI_DATADIRY (-1) // Y向数据坐标与下位机坐标系统的差异 +#define QUI_DATADIRR (-1) // R向数据坐标与下位机坐标系统的差异 + +#define QUI_SHOWDIRX (1) // X向显示坐标和数据坐标的差异 +#define QUI_SHOWDIRY (-1) // Y向显示坐标和数据坐标的差异 + +#define QUI_PREVIEW_SIDE (15) // 留边大小 +#define QUI_PREVIEW_WIDTH (156) // 默认预览图区域宽度 +#define QUI_PREVIEW_HEIGHT (164) // 默认预览图区域高度 + +typedef struct tagQuiltingFileHead +{ + char id[4]; // 0x00—0x03; 标志:=="RICH" + char name[8]; // 0x04—0x07; 文件名 + unsigned char reserve1[4]; // 0x0C—0x0F; 保留 + unsigned char ver; // 0x10; 版本号 + unsigned char unit; // 0x11; 单位 0x00: 0.1mm; 0x01: 1/1000inch; 0x02: 0.04mm;0x03: 0.01mm + unsigned char type; // 0x12; 类型, 0x00: 多针机英制; 0x01: 多针机公制; 0x10: 单头机英制; 0x11:单头机公制 + unsigned char reserve2[11]; // 0x13—0x1D; 保留 + unsigned short HStep; // 0x1E—0x1F; 水平方向针距 单位:0.1mm(绘制用,多针机) + unsigned short leftRightLen; // 0x20—0x21; 左针右针距离 单位:0.1mm(绘制用,多针机) + unsigned short VStep12; // 0x22—0x23; 第1 2排针距 单位:0.1mm(绘制用,多针机) + unsigned short VStep23; // 0x24—0x25; 第2 3排针距 单位:0.1mm(绘制用,多针机) + + // 排针每个字节:XXXX XXXX + // 针位n (0x00:无针,0x01:右针, 0x10:左针,0x11:左右针) + unsigned char arrayNeedle1[48]; // 0x26—0x55; 第1排排针(绘制用,多针机) + unsigned char arrayNeedle2[48]; // 0x56—0x85; 第2排排针(绘制用,多针机) + unsigned char arrayNeedle3[48]; // 0x86—0xB5; 第3排排针(绘制用,多针机) + unsigned char rotateStyle; // 0xB6; 旋转式样 + unsigned char rotateAngle; // 0xB7; 旋转角度 + unsigned char reinMode; // 0xB8; 加固方式 + unsigned char reinNum; // 0xB9; 次数 + unsigned char reserve3[4]; // 0xBA—0xBD; 保留 + unsigned short angleCorrOffset; // 0xBE ; 角度修正量 (中间数据后,可以修改,拐角补偿,单针机和多针机,新加-hhy) + unsigned char angleCorrPosX; // 0xC0 ; 角度修正x正(中间数据后,可以修改,拐角补偿,单针机和多针机) + unsigned char angleCorrPosY; // 0xC1 ; 角度修正y正(中间数据后,可以修改,拐角补偿,单针机和多针机) + unsigned char angleCorrNegX; // 0xC2 ; 角度修正x负(中间数据后,可以修改,拐角补偿,单针机和多针机) + unsigned char angleCorrNegY; // 0xC3 ; 角度修正y负(中间数据后,可以修改,拐角补偿,单针机和多针机) + unsigned char stepQui[2]; // 0xC4—0xC5; 跨步绗缝 + unsigned char reinNeedles; // 0xC6; 加固绗缝针数(中间数据后,可以修改,终点有跨步的才加,单针机和多针机) + unsigned char rollaYUpDn; // 0xC7; 罗拉补偿y上下(中间数据后,让图形闭合,可以修改,多针机) + unsigned char rollaYRev; // 0xC8; 罗拉补偿y预留 + unsigned char normalStep; // 0xC9; 针步大小(中间数据前,可以修改,单针机和多针机) + unsigned char miniStep; // 0xCA; 最小针步 + unsigned char reserve4[4]; // 0xCB—0xCE; 保留 + unsigned char saddleRatio[2]; // 0xCF—0xD0; 鞍架比例 + unsigned char rollaRatio[2]; // 0xD1—0xD2; 罗拉比例 + unsigned char reinQuiNeedleHigh; // 0xD3; 加固绗缝针数高字节 + unsigned short left; // 0xD4—0xD5; 左边 (中间数据后,可以修改,改变起始点,单针机) + unsigned short front; // 0xD6—0xD7; 前边 (中间数据后,可以修改,改变起始点,单针机) + unsigned short scanX; // 0xD8—0xD9; 缩放X (中间数据前,可以修改,单针机和多针机) + unsigned short scanY; // 0xDA—0xDB; 缩放Y (中间数据前,可以修改,单针机和多针机) + unsigned short totalOutput; // 0xDC—0xDD; 本花样累计总产量 + unsigned short currentOutput; // 0xDE—0xDF; 本花样当次产量 + unsigned short serWorkLa; // 0xE0-0xE1; 连续作业前留边 + unsigned short serWorkLb; // 0xE2-0xE3; 连续作业后留边 + unsigned char stepCompUpDn; // 0xE4; 跨步补偿y上下(多针机专业)(中间数据后,可以修改,多针机) + + unsigned char reserve6[27]; // 0xE5—0xFF; 保留 + +} __attribute__ ((packed)) QuiFileHead; + +class DataFileQui +{ +public: + DataFileQui(); + +protected: + QString m_fileFullPathName; // 文件路径 + QByteArray m_absData; // 转换后的绝对坐标数据 + QByteArray m_quiFileData;// 文件数据内容(原始数据) + +private: + double m_minX; + double m_maxX; + double m_minY; + double m_maxY; + QuiPoint m_firstPoint; + +private: + void creatAbsHeadAndAr();//生成绝对坐标数据文件头及ar + void getQuiMinMax(); + int checkFileHead(); + double getMutiUnit(int unit); + +public: + void initFile(const QString & fullPathName); + void clear(); + void loadFile(); + void convertDataToEmbAbs(s16 flag = 1); + int createPreviewImage(QImage * pImg = NULL, int saveflag = 0, int penwidth = 1, int reDraw = 0); // 生成预览文件 + inline const QString & getFileFullPathName() const {return m_fileFullPathName;} // 文件路径名称 + inline QByteArray & getEmbAbsData() {return m_absData;} // 得到转换后的数据 + QuiFileHead *getQuiHead(); + void writePatternParaToFile(QuiFileHead *head);//将花样参数配置写到文件中 + void moveDataBeginPonit(s32 left, s32 front);//移动数据起始点 + +public: + int getStitchNums();//得到数据的针数 + int getDatWidth();//得到数据的图形宽度 + int getDatHeight();//得到数据的图形高度 + int getMaxX();//得到数据最大X+ + int getMinX();//得到数据最小X- + int getMaxY();//得到数据最大Y+ + int getMinY();//得到数据最小Y- +}; + +#endif // DATAFILEQUI_H diff --git a/datafile/datafilequix.cpp b/datafile/datafilequix.cpp new file mode 100644 index 0000000..f2774a3 --- /dev/null +++ b/datafile/datafilequix.cpp @@ -0,0 +1,1297 @@ +#include "datafilequix.h" + + +DataFileQuix::DataFileQuix() +{ + clear(); +} + +void DataFileQuix::convertDataToEmbAbs(s16 flag) +{ + m_absData.clear(); + getQuixMinMax(); + + QuixFileHead head; + + // 图形数据 + u32 i, datasize, idx; + unsigned char ctrl, tmpls; + + u8 c1, c2, c3, c4; + u32 lsdata; + double deltx1, delty1, deltx2, delty2; + double threex[4], threey[4]; + s16 nmstep; + + double factorx, factory, unitmuti; + memcpy(&head, m_fileData.data(), sizeof(QuixFileHead)); + unitmuti = getMutiUnit(0); + + double scanx = head.scanX * unitmuti; // 宽度 + double scany = head.scanY * unitmuti; // 长度 + + if (scanx < 1) + { + scanx = 1; + } + if (scany < 1) + { + scany = 1; + } + + // 计算缩放系数 + factorx = (double)((m_maxX-m_minX) / (scanx)); + factory = (double)((m_maxY-m_minY) / (scany)); + + if(factorx == 0){factorx = 1;} + if(factory == 0){factory = 1;} +// factorx = 1; +// factory = 1; + + if(flag != 1) + { + factorx = 1; + factory = 1; + } + + nmstep = head.normalStep * unitmuti; + if(nmstep == 0) + { + nmstep = 200; //单位0.01mm(2mm) + } + + i = sizeof(QuixFileHead); + datasize = m_fileData.size(); + + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + + //将第一个点加进来 + absItem.ctrl = m_firstPoint.ctrl; + absItem.ax = m_firstPoint.x / factorx; + absItem.ay = m_firstPoint.y / factory; + m_absData.append((char*)&absItem,sizeof(DsAbsItem)); + + while(i < datasize) + { + // 功能控制字 + if (i >= datasize){break;} + ctrl = m_fileData.at(i++); + + // 图元类型 + if (i >= datasize){break;} + tmpls = m_fileData.at(i++); + + // 附加控制字 + if (i >= datasize){break;} + m_fileData.at(i++); + if (i >= datasize){break;} + m_fileData.at(i++); + + if(ctrl == 0x00) // 结束 + { + break; + } + + switch(tmpls) + { + case QUI_TYPE_LINE: // 直线 + case QUI_TYPE_STEP: // 跨步 + case QUI_TYPE_HSTEP: // 翻头跨步 + { + //增加剪线 + if(tmpls == QUI_TYPE_STEP || tmpls == QUI_TYPE_HSTEP) + { + if((u32)m_absData.size() >= sizeof(DsAbsItem)) + { + memcpy((char*)&absItem,m_absData.data()+m_absData.size()-sizeof(DsAbsItem),sizeof(DsAbsItem)); + absItem.ctrl = DATA_CUTTRD; + m_absData.append((char*)&absItem,sizeof(DsAbsItem)); + } + } + + // 点个数 + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + lsdata = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + if (lsdata > 1) + { + // 第一个点 + //点x + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + double x = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + deltx2 = x/factorx; + + //点y + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + double y = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + delty2 = y/factory; + + for(idx = 1; idx < lsdata; idx++) // 其余的点 + { + deltx1 = deltx2; + delty1 = delty2; + + //点x + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + x = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + deltx2 = x/factorx; + + //点y + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + y = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + delty2 = y/factory; + + // 处理直线 + calcLine(deltx1, delty1, deltx2, delty2, nmstep, m_absData, tmpls); + } + + if (idx != lsdata) + { + break; + } + } + break; + } + case QUI_TYPE_ARC: // 三点圆弧 + { + // 点个数 + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + lsdata = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + if(lsdata != 3) + { + break; + } + + for (idx = 0; idx < lsdata; idx++) + { + //点x + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + double x = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + threex[idx] = x/factorx; + + //点y + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + double y = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + threey[idx] = y/factory; + } + + calcCurve(threex, threey, nmstep, m_absData); + + if (idx != 3) + { + break; + } + break; + } + case QUI_TYPE_BES: // 贝塞尔曲线 + { + // 点个数 + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + lsdata = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + if(lsdata != 4) + { + break; + } + + for (idx = 0; idx < lsdata; idx++) + { + //点x + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + double x = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + threex[idx] = x/factorx; + + //点y + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + double y = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + threey[idx] = y/factory; + } + + // 处理贝塞尔曲线 + QList splineListXY;//拟合后的点 + splineListXY.clear(); + getBezierPointList(threex, threey, nmstep,splineListXY); + + QList splitListXY;//均分后的点 + splitListXY.clear(); + if(splineListXY.size() > 0) + { + getCurvePointFillLine(splineListXY,nmstep,splitListXY,0,OBJECT_STITCHLEN_NEW_SAMALL); + } + + //添加贝塞尔曲线数据点 + for(int i = 0; i < splitListXY.size(); i++) + { + memset(&absItem,0,sizeof(DsAbsItem)); + + deltx1 = splitListXY[i].x(); + delty1 = splitListXY[i].y(); + + absItem.ctrl = DATA_SEWING; + absItem.ax = deltx1; + absItem.ay = delty1; + m_absData.append((char*)&absItem,sizeof(DsAbsItem)); + } + //calcBezier(threex, threey, nmstep, m_absData); + + if (idx != 4) + { + break; + } + break; + } + case QUI_TYPE_SPLINE: // 样条 + { + QList quiListPoint;//样条拟合前的点集合 + quiListPoint.clear(); + + // 点个数 + if (i >= datasize){break;} + unsigned char c1 = m_fileData.at(i++); + if (i >= datasize){break;} + unsigned char c2 = m_fileData.at(i++); + if (i >= datasize){break;} + unsigned char c3 = m_fileData.at(i++); + if (i >= datasize){break;} + unsigned char c4 = m_fileData.at(i++); + lsdata = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + for(idx = 0; idx < lsdata; idx++) // 点 + { + //点x + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + double x = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + deltx1 = x/factorx; + + //点y + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + double y = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + delty1 = y/factory; + + QPointF point(deltx1,delty1); + quiListPoint.append(point); + } + + QList splineListXY;//拟合后的点 + splineListXY.clear(); + if(quiListPoint.size() <= 0) + { + break; + } + getSplineNew(quiListPoint,splineListXY); + + // 均分 + QList splitListXY;//均分后的点 + splitListXY.clear(); + if(splineListXY.size() > 0) + { + getCurvePointFillLine(splineListXY,nmstep,splitListXY,0,OBJECT_STITCHLEN_NEW_SAMALL); + } + + //添加样条曲线数据点 + for(int i = 0; i < splitListXY.size(); i++) + { + memset(&absItem,0,sizeof(DsAbsItem)); + + deltx1 = splitListXY[i].x(); + delty1 = splitListXY[i].y(); + + absItem.ctrl = DATA_SEWING; + absItem.ax = deltx1; + absItem.ay = delty1; + m_absData.append((char*)&absItem,sizeof(DsAbsItem)); + } + + if(idx != lsdata) + { + break; + } + break; + } + default: + break; + } + } + + //生成绝对坐标数据的文件头 + creatAbsHeadAndAr(); +} + +void DataFileQuix::creatAbsHeadAndAr() +{ + DataDs16FileHead dhead; + memset(&dhead, 0, sizeof(DataDs16FileHead)); + + int stepSize = m_absData.size()/sizeof(DsAbsItem); + if(stepSize <= 0) + { + return; + } + + DsAbsItem * absDataPtr = (DsAbsItem *)(m_absData.data()); + + double minX, maxX, minY, maxY; + minX = S32_MAX; + maxX = S32_MIN; + minY = S32_MAX; + maxY = S32_MIN; + + double prex,prey,curx,cury,dx,dy,ar; + prex = prey = curx = cury = dx = dy = ar = 0; + + //取反并求最大最小值 + for (int i = 0; i < stepSize; i++) + { + absDataPtr->ax *= QUIX_DATADIRX; + absDataPtr->ay *= QUIX_DATADIRY; + + curx = absDataPtr->ax; + cury = absDataPtr->ay; + + if(curx > maxX) + { + maxX = curx; + } + if(curx < minX) + { + minX = curx; + } + + if(cury > maxY) + { + maxY = cury; + } + if(cury < minY) + { + minY = cury; + } + + absDataPtr++; + } + + absDataPtr = (DsAbsItem *)(m_absData.data()); + double begX = absDataPtr->ax;//起始点 + double begY = absDataPtr->ay; + int begR = 0; + + //求dr并将每点坐标都减去第一点坐标 + for (int i = 0; i < stepSize; i++) + { + curx = absDataPtr->ax; + cury = absDataPtr->ay; + + dx = curx - prex; + dy = cury - prey; + + double tar = atan2(dy,dx); + ar = (tar*10000+0.5*(tar>0?1:-1)); + absDataPtr->ar = ar; + + prex = curx; + prey = cury; + + //将每个坐标都减去起始点坐标 + absDataPtr->ax -= begX; + absDataPtr->ay -= begY; + absDataPtr->ar -= begR; + + absDataPtr++; + } + + //增加结束码 + if((u32)m_absData.size() >= sizeof(DsAbsItem)) + { + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + memcpy((char*)&absItem,m_absData.data()+m_absData.size()-sizeof(DsAbsItem),sizeof(DsAbsItem)); + absItem.ctrl = DATA_NULL; + m_absData.append((char*)&absItem,sizeof(DsAbsItem)); + stepSize++; + } + + m_maxX = maxX-begX; + m_minX = minX-begX; + m_maxY = maxY-begY; + m_minY = minY-begY; + + //生成文件头 + dhead.maxX = maxX; + dhead.maxY = maxY; + dhead.minX = minX; + dhead.minY = minY; + dhead.beginX = begX-minX;//起始点减去最小值 + dhead.beginY = begY-minY;//起始点减去最小值 + dhead.beginR = begR; + dhead.anchorX = 0; + dhead.anchorY = 0; + dhead.itemNums = stepSize; + dhead.dataSize = stepSize*sizeof(DsAbsItem); // 数据字节数 + dhead.bytesPerItem = sizeof(DsAbsItem); // 每项占的字节数 + dhead.dataChecksum = calcCheckSum32((u8 *)(m_absData.data()) , dhead.dataSize);; // 数据累加校验和 + dhead.checkCrc = calcCrc16((u8 *)(&dhead), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + dhead.fileid = dhead.checkCrc; + m_absData.insert(0,(char*)&dhead,sizeof(DataDs16FileHead)); +} + +void DataFileQuix::getQuixMinMax() +{ + QuixFileHead head; + memcpy(&head, m_fileData.data(), sizeof(QuixFileHead)); + + u32 i, idx, datasize; + unsigned char ctrl, tmpls; + u8 c1, c2, c3, c4; + u32 lsdata; + double deltx, delty; + double threex[4], threey[4]; + + int first = 0; + double minx, maxx, miny, maxy; + + minx = S32_MAX; + maxx = S32_MIN; + miny = S32_MAX; + maxy = S32_MIN; + + i = sizeof(QuixFileHead); + datasize = m_fileData.size(); + while(i < datasize) + { + // 功能控制字 + if (i >= datasize){break;} + ctrl = m_fileData.at(i++); + + // 图元类型 + if (i >= datasize){break;} + tmpls = m_fileData.at(i++); + + // 附加控制字 + if (i >= datasize){break;} + m_fileData.at(i++); + if (i >= datasize){break;} + m_fileData.at(i++); + + if(ctrl == 0x00) // 结束 + { + break; + } + + switch(tmpls) + { + case QUI_TYPE_LINE: // 直线(折线) + case QUI_TYPE_STEP: // 跨步 + case QUI_TYPE_HSTEP: // 翻头跨步 + { + // 点个数 + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + lsdata = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + if (lsdata > 1) + { + for(idx = 0; idx < lsdata; idx++) // 点 + { + //点x + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + deltx = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + //点y + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + delty = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + if (first == 0) + { + m_firstPoint.x = deltx; + m_firstPoint.y = delty; + m_firstPoint.ctrl = ctrl; + first = 1; + } + + if(deltx > maxx) + { + maxx = deltx; + } + if(deltx < minx) + { + minx = deltx; + } + + if(delty > maxy) + { + maxy = delty; + } + if(delty < miny) + { + miny = delty; + } + } + if (idx != lsdata) + { + break; + } + } + } + break; + case QUI_TYPE_ARC: // 三点圆弧 + { + // 点个数 + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + lsdata = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + if(lsdata != 3) + { + break; + } + + for (idx = 0; idx < lsdata; idx++) + { + //点x + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + threex[idx] = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + //点y + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + threey[idx] = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + if (first == 0) + { + m_firstPoint.x = threex[0]; + m_firstPoint.y = threey[0]; + m_firstPoint.ctrl = ctrl; + first = 1; + } + } + if (idx != 3) + { + break; + } + + if(isThreePointOnALine(threex, threey) >= 1) // 3点共线 + { + // printf("three point on a line\n"); + if(threex[0] > maxx) maxx = threex[0]; + if(threex[1] > maxx) maxx = threex[1]; + if(threex[2] > maxx) maxx = threex[2]; + if(threex[0] < minx) minx = threex[0]; + if(threex[1] < minx) minx = threex[1]; + if(threex[2] < minx) minx = threex[2]; + + if(threey[0] > maxy) maxy = threey[0]; + if(threey[1] > maxy) maxy = threey[1]; + if(threey[2] > maxy) maxy = threey[2]; + if(threey[0] < miny) miny = threey[0]; + if(threey[1] < miny) miny = threey[1]; + if(threey[2] < miny) miny = threey[2]; + } + else + { + // printf("before GetArcMinMax\n"); + // printf("minx=%.2f,maxx=%.2f,miny=%.2f,maxy=%.2f\n", minx, maxx, miny, maxy); + getArcMinMax(threex, threey, &minx, &maxx, &miny, &maxy); + // printf("after GetArcMinMax\n"); + // printf("minx=%.2f,maxx=%.2f,miny=%.2f,maxy=%.2f\n", minx, maxx, miny, maxy); + } + } + break; + case QUI_TYPE_BES: // 贝塞尔曲线 + { + // 点个数 + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + lsdata = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + if(lsdata != 4) + { + break; + } + + for (idx = 0; idx < lsdata; idx++) + { + //点x + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + threex[idx] = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + //点y + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + threey[idx] = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + if (first == 0) + { + m_firstPoint.x = threex[0]; + m_firstPoint.y = threey[0]; + m_firstPoint.ctrl = ctrl; + first = 1; + } + } + if (idx != 4) + { + break; + } + + getBezierMinMax(threex, threey, &minx, &maxx, &miny, &maxy); + } + break; + case QUI_TYPE_SPLINE: // 样条 + { + QList quiListPoint;//样条拟合前的点集合 + quiListPoint.clear(); + + // 点个数 + if (i >= datasize){break;} + unsigned char c1 = m_fileData.at(i++); + if (i >= datasize){break;} + unsigned char c2 = m_fileData.at(i++); + if (i >= datasize){break;} + unsigned char c3 = m_fileData.at(i++); + if (i >= datasize){break;} + unsigned char c4 = m_fileData.at(i++); + lsdata = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + for(idx = 0; idx < lsdata; idx++) // 点 + { + //点x + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + deltx = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + //点y + if (i >= datasize){break;} + c1 = m_fileData.at(i++); + if (i >= datasize){break;} + c2 = m_fileData.at(i++); + if (i >= datasize){break;} + c3 = m_fileData.at(i++); + if (i >= datasize){break;} + c4 = m_fileData.at(i++); + delty = (c4 << 24) + (c3 << 16) + (c2 << 8) + (c1); + + QPointF point(deltx,delty); + quiListPoint.append(point); + + if (first == 0) + { + m_firstPoint.x = deltx; + m_firstPoint.y = delty; + m_firstPoint.ctrl = ctrl; + first = 1; + } + } + getSplineMinMax(quiListPoint, &minx, &maxx, &miny, &maxy); + } + break; + } + } + + if (first == 0) + { + minx = 0; + maxx = 0; + miny = 0; + maxy = 0; + + m_firstPoint.x = 0; + m_firstPoint.y = 0; + m_firstPoint.ctrl = 0; + } + + m_minX = minx; + m_maxX = maxx; + m_minY = miny; + m_maxY = maxy; + + return; +} + +int DataFileQuix::checkFileHead() +{ + if (m_fileData.size() >= (int)sizeof(QuixFileHead)) + { + QuixFileHead * pHead; + pHead = (QuixFileHead *)(m_fileData.data()); + + if (pHead->normalStep < 1) + { + pHead->normalStep = 40; + } + + if (pHead->scanX < 1) + { + pHead->scanX = m_maxX - m_minX; + } + + if (pHead->scanY < 1) + { + pHead->scanY = m_maxY - m_minY; + } + + QFile wrfile(m_fileFullPathName); + if(!wrfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + return -1; + } + else + { + wrfile.write(m_fileData); + wrfile.close(); + } + } + + return 0; +} + +double DataFileQuix::getMutiUnit(int unit) +{ + double unitmuti; + if (unit == 0x00) // 0x00: 0.1mm; + { + unitmuti = 10; + } + else if (unit == 0x01) // 0x01: 1/1000inch; + { + unitmuti = 2.54; + } + else if (unit == 0x02) // 0x02: 0.04mm + { + unitmuti = 10; + } + else + { + unitmuti = 1; + } + return unitmuti; +} + +void DataFileQuix::initFile(const QString &fullPathName) +{ + clear(); + QFileInfo file(fullPathName); + if (file.exists() && file.isFile()) + { + m_fileFullPathName = fullPathName; + } + else + { + qDebug() << "Init file failed path =" << m_fileFullPathName; + } + loadFile(); +} + +void DataFileQuix::clear() +{ + m_firstPoint.x = 0; + m_firstPoint.y = 0; + m_firstPoint.ctrl = 0; + + m_minX = INT32_MAX; + m_maxX = INT32_MIN; + m_minY = INT32_MAX; + m_maxY = INT32_MIN; + + m_fileFullPathName.clear(); // 文件路径 + m_fileData.clear(); // 文件数据内容 + m_absData.clear(); // 转换后的数据 +} + +void DataFileQuix::loadFile() +{ + QFile rdfile(m_fileFullPathName); + if(!rdfile.open(QIODevice::ReadOnly)) + { + qDebug() << "open file fail when read, path =" << m_fileFullPathName; + return; + } + + m_fileData = rdfile.readAll(); + rdfile.close(); +} + +int DataFileQuix::createPreviewImage(QImage *pImg, int saveflag, int penwidth, int reDraw) +{ +#if(1) + s16 existFlag = 1; + + if(reDraw == 0)//图片存在则不重画 + { + existFlag = 0; + // 图片是否存在,存在则返回 + QString previewPath = getFileFullPathName() + ".preview.png"; + QFile imageFile(previewPath); + if (imageFile.exists()) + { + return 0; + } + } +#endif + + int newimgflag = 0; + QImage * pImage; + int width, height; + if (pImg == NULL) + { + width = QUIX_PREVIEW_WIDTH; + height = QUIX_PREVIEW_HEIGHT; + pImage = new QImage(width, height, IMAGE_TYPE); + newimgflag = 1; + } + else + { + pImage = pImg; + } + + width = pImage->width(); + height = pImage->height(); + if (width <= QUIX_PREVIEW_SIDE*2 || height <= QUIX_PREVIEW_SIDE*2) + { + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + qDebug("preview img too small"); + return -1; + } + + memset(pImage->bits(), 0x00, pImage->byteCount()); + + QPainter painter(pImage); + QColor backcolor(255, 255, 255, 0); // 透明背景 + // 背景 + QPen pen; + pen.setWidth(penwidth); + pen.setColor(backcolor); + painter.setPen(pen); + painter.setBrush(backcolor); + painter.drawRect(0, 0, width, height); + + // 图形 + //qDebug()<<"convertDataToAbs defore"; + convertDataToEmbAbs(existFlag); // 转换为绝对坐标数据 + //qDebug()<<"convertDataToAbs end"; + + // absdat数据 + int size = m_absData.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("2 data less then head size"); + return -1; + } + DataDs16FileHead * pAbsHead = (DataDs16FileHead *)(m_absData.data()); + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("absdat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("absdat data size err"); + return -1; + } + DsAbsItem * pData = (DsAbsItem *)(m_absData.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; + //-------- + + // 图形显示区域 + int dpminx = QUIX_PREVIEW_SIDE; + int dpmaxx = width - QUIX_PREVIEW_SIDE; + int dpminy = QUIX_PREVIEW_SIDE; + int dpmaxy = height - QUIX_PREVIEW_SIDE; + + // 计算缩放系数 + double factor, temp; + if ((dpmaxx - dpminx) <= 0 || (dpmaxy - dpminy) <= 0) + { + return -1; + } + + factor = (double)(fabs(m_maxX - m_minX)) / (dpmaxx - dpminx); // 按x计算的缩放系数 + temp = (double)(fabs(m_maxY - m_minY)) / (dpmaxy - dpminy); // 按x计算的缩放系数 + + if (temp >= factor) // 使用较大的缩放系数 + { + factor = temp; + } + + // 计算显示参数,按照图形的实际位置显示(数据坐标零点对应图形中心) + double dpx = (double)((dpminx+dpmaxx)/2 - ((m_maxX+m_minX)/factor)/2); + double dpy = (double)((dpminy+dpmaxy)/2 - ((m_maxY+m_minY)/factor)/2); + + // 显示花样图形 + u8 ctrlByte; + double dx; + double dy; + + double datposx, datposy; + datposx = datposy = 0.; + double curx, cury, prex, prey; + curx = cury = prex = prey = 0; + + datposx = pAbsHead->beginX; + datposy = pAbsHead->beginY; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (QUIX_SHOWDIRX == -1) + { + curx = (width)-curx; + } + if (QUIX_SHOWDIRY == -1) + { + cury = (height)-cury; + } + + absDataPtr = pData; + + QColor color = QColor(Qt::green); + pen.setColor(color); + painter.setPen(pen); + + for (int i = 0; i < stepsize; i++) + { + // 读入一个针步数据 + ctrlByte = absDataPtr->ctrl; + + prex = curx; + prey = cury; + + dx = absDataPtr->ax; + dy = absDataPtr->ay; + + datposx = dx; + datposy = dy; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (QUIX_SHOWDIRX == -1) + { + curx = (width)-curx; + } + if (QUIX_SHOWDIRY == -1) + { + cury = (height)-cury; + } + + if(i == 0) + { + absDataPtr++; + continue; + } + + if (ctrlByte == DATA_SEWING) + { + painter.drawLine(prex, prey, curx, cury); + } + else + { + //painter.drawLine(prex, prey, curx, cury); + //qDebug("other type=0x%x", ctrlByte); + } + + absDataPtr++; + } + + // 保存成文件 + QString preview = getFileFullPathName(); + if (saveflag != 0 && preview.isEmpty() == false) + { +#if (1) + preview += ".preview.png"; + pImage->save(preview, "png"); +#endif + } + + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + + return 0; +} + +QuixFileHead *DataFileQuix::getQuixHead() +{ + if(m_fileData.size() <= 0) + { + loadFile(); + } + + QuixFileHead *head = NULL; + + int size = m_fileData.size(); + if (size <= (int)(sizeof(QuixFileHead))) + { + return head; + } + + head = (QuixFileHead *)(m_fileData.data()); + return head; +} + +void DataFileQuix::writePatternParaToFile(QuixFileHead *head) +{ + if(m_fileData.size() <= 0) + { + return; + } + + memcpy(m_fileData.data(),(char*)head,sizeof(QuixFileHead)); + + QFile wfile(m_fileFullPathName); + if(!wfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + qDebug() << "open file fail when read, path =" << m_fileFullPathName; + return; + } + + wfile.write(m_fileData); + wfile.close(); +} + +void DataFileQuix::moveDataBeginPonit(s32 left, s32 front) +{ + if((u32)m_absData.size() > sizeof(DataDs16FileHead)) + { + DataDs16FileHead *dhead = (DataDs16FileHead *)( m_absData.data()); + dhead->beginX += left; + dhead->beginY += front; + dhead->maxX += left; + dhead->minX += left; + dhead->maxY += front; + dhead->minY += front; + } +} + +int DataFileQuix::getStitchNums() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->itemNums; +} + +int DataFileQuix::getDatWidth() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return (pHead->maxX - pHead->minX); +} + +int DataFileQuix::getDatHeight() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return (pHead->maxY - pHead->minY); +} + +int DataFileQuix::getMaxX() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->maxX; +} + +int DataFileQuix::getMinX() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->minX; +} + +int DataFileQuix::getMaxY() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->maxY; +} + +int DataFileQuix::getMinY() +{ + if(m_absData.size() <= 0) + { + return 0; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)((m_absData.data())); + return pHead->minY; +} diff --git a/datafile/datafilequix.h b/datafile/datafilequix.h new file mode 100644 index 0000000..1c941c3 --- /dev/null +++ b/datafile/datafilequix.h @@ -0,0 +1,118 @@ +#ifndef DATAFILEQUIX_H +#define DATAFILEQUIX_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include "math.h" +#include +#include "stdint.h" + +//#include "vectorsqrt.h" +#include "machine/comm/datadef.h" +#include "machine/comm/crc16.h" +#include "datafile/dataoperat.h" + +#define QUIX_DATADIRX (1) // X向数据坐标与下位机坐标系统的差异 +#define QUIX_DATADIRY (-1) // Y向数据坐标与下位机坐标系统的差异 +#define QUIX_DATADIRR (-1) // R向数据坐标与下位机坐标系统的差异 + +#define QUIX_SHOWDIRX (1) // X向显示坐标和数据坐标的差异 +#define QUIX_SHOWDIRY (-1) // Y向显示坐标和数据坐标的差异 + +#define QUIX_PREVIEW_SIDE (15) // 留边大小 +#define QUIX_PREVIEW_WIDTH (156) // 默认预览图区域宽度 +#define QUIX_PREVIEW_HEIGHT (164) // 默认预览图区域高度 + +typedef struct tagQuixFileHead +{ + char id[7]; // 0x0000~0x0006; 标志:=="RICH" + char name[1]; // 0x0007; 文件名 + unsigned char reserve1[6]; // 0x0008~0x000D; 保留 + unsigned char rotateStyle; // 0x000E; 旋转式样 + unsigned char rotateAngle; // 0x000F; 旋转角度 + unsigned int left; // 0x0010~0x0013; 左边 (中间数据后,可以修改,改变起始点,单针机) + unsigned int front; // 0x0014~0x0017; 前边 (中间数据后,可以修改,改变起始点,单针机) + unsigned int scanX; // 0x0018~0x001B; 缩放X (中间数据前,可以修改,单针机和多针机) + unsigned int scanY; // 0x001C~0x001F; 缩放Y (中间数据前,可以修改,单针机和多针机) + unsigned int normalStep; // 0x0020~0x0023; 针步大小(中间数据前,可以修改,单针机和多针机) + unsigned int reinMode; // 0x0024~0x0027; 加固模式(中间数据后,可以修改,终点有跨步的才加,单针机和多针机) + unsigned int reinNeedles; // 0x0028~0x002B; 加固针数(中间数据后,可以修改,终点有跨步的才加,单针机和多针机) + unsigned int reinNum; // 0x002C~0x002F; 加固次数(中间数据后,可以修改,终点有跨步的才加,单针机和多针机) + unsigned int angleCorrPosX; // 0x0030~0x0033; 角度修正x正(中间数据后,可以修改,拐角补偿,单针机和多针机) + unsigned int angleCorrPosY; // 0x0034~0x0037; 角度修正y正(中间数据后,可以修改,拐角补偿,单针机和多针机) + unsigned int angleCorrNegX; // 0x0038~0x003B; 角度修正x负(中间数据后,可以修改,拐角补偿,单针机和多针机) + unsigned int angleCorrNegY; // 0x003C~0x003F; 角度修正y负(中间数据后,可以修改,拐角补偿,单针机和多针机) + unsigned int stepQuiCorrection; // 0x0040~0x0043; 跨步绗缝修正(中间数据后,可以修改,拐角补偿,单针机和多针机) + unsigned int rollaComp; // 0x0044~0x0047; 罗拉补偿(中间数据后,让图形闭合,可以修改,多针机) + unsigned short angleCorrOffset; // 0x0048~0x0049; 角度修正量 (中间数据后,可以修改,拐角补偿,单针机和多针机,新加-hhy) + unsigned char reserve2[6]; // 0x004A~0x004F; 保留 + unsigned int HStep; // 0x0050~0x0053; 水平方向针距 单位:0.1mm(绘制用,多针机) + unsigned int leftRightLen; // 0x0054~0x0057; 左针右针距离 单位:0.1mm(绘制用,多针机) + unsigned int VStep12; // 0x0058~0x005B; 第1 2排针距 单位:0.1mm(绘制用,多针机) + unsigned int VStep23; // 0x005C~0x005F; 第2 3排针距 单位:0.1mm(绘制用,多针机) + // 排针每个字节:XXXX XXXX + // 针位n (0x00:无针,0x01:右针, 0x10:左针,0x11:左右针) + unsigned char arrayNeedle1[48]; // 0x0060~0x008F; 第1排排针(绘制用,多针机) + unsigned char arrayNeedle2[48]; // 0x0090~0x00BF; 第2排排针(绘制用,多针机) + unsigned char arrayNeedle3[48]; // 0x00C0~0x00EF; 第3排排针(绘制用,多针机) + unsigned int firstPullLen; // 0x00F0~0x00F3; 一次拉料长度 + unsigned int secondPullLen; // 0x00F4~0x00F7; 二次拉料长度 + unsigned int triplePullLen; // 0x00F8~0x00FB; 三次拉料长度 + unsigned char reserve3[4]; // 0x00FC~0x00FF; 保留 + unsigned char reserve4[768]; // 0x0100~0x0400; 保留 + unsigned char reserve5[3072]; // 0x0401~0x1000; 保留 + +} __attribute__ ((packed)) QuixFileHead; + +class DataFileQuix +{ +public: + DataFileQuix(); + +protected: + QString m_fileFullPathName; // 文件路径 + QByteArray m_absData; // 转换后的绝对坐标数据 + QByteArray m_fileData;// 文件数据内容(原始数据) + +private: + double m_minX; + double m_maxX; + double m_minY; + double m_maxY; + QuiPoint m_firstPoint; + +private: + void creatAbsHeadAndAr();//生成绝对坐标数据文件头及ar + void getQuixMinMax(); + int checkFileHead(); + double getMutiUnit(int unit); + +public: + void initFile(const QString & fullPathName); + void clear(); + void loadFile(); + void convertDataToEmbAbs(s16 falg = 1); + int createPreviewImage(QImage * pImg = NULL, int saveflag = 0, int penwidth = 1, int reDraw = 0); // 生成预览文件 + inline const QString & getFileFullPathName() const {return m_fileFullPathName;} // 文件路径名称 + inline QByteArray & getEmbAbsData() {return m_absData;} // 得到转换后的数据 + QuixFileHead *getQuixHead(); + void writePatternParaToFile(QuixFileHead *head);//将花样参数配置写到文件中 + void moveDataBeginPonit(s32 left, s32 front);//移动数据起始点 + +public: + int getStitchNums();//得到数据的针数 + int getDatWidth();//得到数据的图形宽度 + int getDatHeight();//得到数据的图形高度 + int getMaxX();//得到数据最大X+ + int getMinX();//得到数据最小X- + int getMaxY();//得到数据最大Y+ + int getMinY();//得到数据最小Y- +}; + +#endif // DATAFILEQUI_H diff --git a/datafile/dataoperat.cpp b/datafile/dataoperat.cpp new file mode 100644 index 0000000..2d3a1af --- /dev/null +++ b/datafile/dataoperat.cpp @@ -0,0 +1,2304 @@ +#include "dataoperat.h" + +int isThreePointOnALine(const double threex[],const double threey[]) +{ + double k0,k1,k2; + + if (fabs(threex[0]-threex[1]) < 1e-6 + && fabs(threex[0]-threex[2]) < 1e-6 + && fabs(threex[2]-threex[1]) < 1e-6 + && fabs(threey[0]-threey[1]) < 1e-6 + && fabs(threey[0]-threey[2]) < 1e-6 + && fabs(threey[2]-threey[1]) < 1e-6 ) //三点几乎重合 + { + //printf("1.IsThreePointOnALine\n"); + return 1; + } + else if ((fabs(threex[0]-threex[1]) < 1e-6 && fabs(threey[0]-threey[1]) < 1e-6) + || (fabs(threex[0]-threex[2]) < 1e-6 && fabs(threey[0]-threey[2]) < 1e-6) + || (fabs(threex[2]-threex[1]) < 1e-6 && fabs(threey[2]-threey[1]) < 1e-6) ) + { + //三点间,有2点几乎重合 + if (fabs(threex[0]-threex[2]) < 1e-6 && fabs(threey[0]-threey[2]) < 1e-6) + { + //如果是两边2个点几乎重合,则将第2个点坐标->第3个点 + return 2; + } + else + { + //printf("2.IsThreePointOnALine\n"); + return 1; + } + } + else if (fabs(threex[0]-threex[1]) < 1e-6 + && fabs(threex[0]-threex[2]) < 1e-6 + && fabs(threex[2]-threex[1]) < 1e-6 ) + { + //三个点,X的差距极小 + //printf("3.IsThreePointOnALine\n"); + if (threey[0] < threey[2]) + { + if (threey[1] > threey[2]) + { + return 2; + } + } + else + { + if (threey[1] < threey[2]) + { + return 2; + } + } + return 1; + } + else if (fabs(threey[0]-threey[1]) < 1e-6 + && fabs(threey[0]-threey[2]) < 1e-6 + && fabs(threey[2]-threey[1]) < 1e-6 ) + { //三个点,Y的差距极小 + // printf("4.IsThreePointOnALine\n"); + if (threex[0] < threex[2]) + { + if (threex[1] > threex[2]) + { + return 2; + } + } + else + { + if (threex[1] < threex[2]) + { + return 2; + } + } + return 1; + } + else if (fabs(threex[2]-threex[1]) >= 1e-6 + && fabs(threex[2]-threex[0]) >= 1e-6 + && fabs(threex[1]-threex[0]) >= 1e-6 + && fabs(threey[2]-threey[1]) >= 1e-6 + && fabs(threey[2]-threey[0]) >= 1e-6 + && fabs(threey[1]-threey[0]) >= 1e-6 ) + { + k0 = (threey[2]-threey[1])/(threex[2]-threex[1]); + k1 = (threey[2]-threey[0])/(threex[2]-threex[0]); + k2 = (threey[1]-threey[0])/(threex[1]-threex[0]); + + if(fabs(k0-k1) < 1e-6 && fabs(k1-k2) < 1e-6) + { + //三个点,2点之间的斜率差极小 + //printf("5.IsThreePointOnALine\n"); + if ( (threex[0] < threex[1] && threex[1] < threex[2] ) + || (threex[0] > threex[1] && threex[1] > threex[2])) + { + } + else + { + return 2; + } + + return 1; + } + else + { + //printf("6.IsThreePointOnALine\n"); + return 0; + } + } + else + { + //printf("7.IsThreePointOnALine\n"); + return 0; + } +} + +int getArcCenter(const double x[], const double y[], double * pxc, double * pyc, double * pr) +{ +#if 0 + double x20, x21, xh0, xh1, y20, y21, yk0, yk1; + double x2y20, x2y21, xnyn, ykn; + + double xx0,xx1,xx2; + double yy0,yy1,yy2; + xx0=x[0]; + yy0=y[0]; + xx1=x[1]; + yy1=y[1]; + xx2=x[2]; + yy2=y[2]; + + if(fabs(xx0-xx1)<1e-6) + { + yc=(yy0+yy1)/2; + xc=(xx0*xx0-xx2*xx2+yy0*yy0-yy2*yy2+2*yy2*yc-2*yy0*yc)/(2*xx0-2*xx2); + r=sqrt((xx0-xc)*(xx0-xc)+(yy0-yc)*(yy0-yc)); + } + else if(fabs(xx0-xx2)<1e-6) + { + yc=(yy0+yy2)/2; + xc=(xx0*xx0-xx1*xx1+yy0*yy0-yy1*yy1+2*yy1*yc-2*yy0*yc)/(2*xx0-2*xx1); + r=sqrt((xx0-xc)*(xx0-xc)+(yy0-yc)*(yy0-yc)); + } + else if(fabs(xx1-xx2)<1e-6) + { + yc=(yy1+yy2)/2; + xc=(xx1*xx1-xx0*xx0+yy1*yy1-yy0*yy0+2*yy0*yc-2*yy1*yc)/(2*xx1-2*xx0); + r=sqrt((xx0-xc)*(xx0-xc)+(yy0-yc)*(yy0-yc)); + } + else if(fabs(yy0-yy1)<1e-6) + { + xc=(xx0+xx1)/2; + yc=(yy0*yy0-yy2*yy2+xx0*xx0-xx2*xx2+2*xx2*xc-2*xx0*xc)/(2*yy0-2*yy2); + r=sqrt((xx0-xc)*(xx0-xc)+(yy0-yc)*(yy0-yc)); + } + else if(fabs(yy0-yy2)<1e-6) + { + xc=(xx0+xx2)/2; + yc=(yy0*yy0-yy1*yy1+xx0*xx0-xx1*xx1+2*xx1*xc-2*xx0*xc)/(2*yy0-2*yy1); + r=sqrt((xx0-xc)*(xx0-xc)+(yy0-yc)*(yy0-yc)); + } + else if(fabs(yy1-yy2)<1e-6) + { + xc=(xx1+xx2)/2; + yc=(yy1*yy1-yy0*yy0+xx1*xx1-xx0*xx0+2*xx0*xc-2*xx1*xc)/(2*yy1-2*yy0); + r=sqrt((xx0-xc)*(xx0-xc)+(yy0-yc)*(yy0-yc)); + } + else + { + x20=xx0*xx0-xx1*xx1; + xh0=2*xx0-2*xx1; + y20=yy0*yy0-yy1*yy1; + yk0=2*yy0-2*yy1; + + x21=xx1*xx1-xx2*xx2; + xh1=2*xx1-2*xx2; + y21=yy1*yy1-yy2*yy2; + yk1=2*yy1-2*yy2; + + x2y20=x20+y20; + x2y21=x21+y21; + + xnyn=x2y20; + ykn=yk0; + + x2y20 *= xh1; + yk0 *= xh1; + + x2y21 *= xh0; + yk1 *= xh0; + + yc = (x2y20-x2y21)/(yk0-yk1); + xc = (xnyn-yc*ykn)/xh0; + + xx0 -= xc; + yy0 -= yc; + + r=sqrt(xx0*xx0+yy0*yy0); + } + +#else + + double a, b, c, d, e, f; + double xc, yc, r; + + if (isThreePointOnALine(x, y) >= 1) + { + return -1; + } + + a = 2 * (x[1]-x[0]); + b = 2 * (y[1]-y[0]); + c = x[1]*x[1] + y[1]*y[1] - x[0]*x[0] - y[0]*y[0]; + d = 2 * (x[2]-x[1]); + e = 2 * (y[2]-y[1]); + f = x[2]*x[2] + y[2]*y[2] - x[1]*x[1] - y[1]*y[1]; + + xc = (b*f-e*c)/(b*d-e*a); + yc = (d*c-a*f)/(b*d-e*a); + r = sqrt((xc-x[0])*(xc-x[0])+(yc-y[0])*(yc-y[0])); +#endif + + *pxc = xc; + *pyc = yc; + *pr = r; + + return 0; +} + +int getArcMinMax(const double x[], const double y[], double * pminx, double * pmaxx, double * pminy, double * pmaxy) +{ + double k, xc, yc, r; + int beg = 0; + int mid = 0; + int end = 0; + double minx, miny, maxx, maxy; + + getArcCenter(x, y, &xc, &yc, &r); + // printf("cx=%f, cy=%f, r=%f\n", xc, yc, r); + // 区分象限和方向 + k = (x[0]-x[1])*(x[2]-x[1]) + (y[0]-y[1])*(y[2]-y[1]); // 向量 01 和 向量 21 的夹角的余弦的符号-- + // > 0 小于90度 向量夹角小于90度, 说明弧是大于半圆 + // < 0 大于90度 向量夹角大于90度, 说明弧是小于半圆 + // = 0 90 度 向量夹角等于90度, 说明弧是半圆 + + if (x[0] > xc && y[0] > yc) // 起点在第一象限 + { + beg = 1; + } + else if (x[0] < xc && y[0] > yc) // 起点在第二象限 + { + beg = 2; + } + else if (x[0] < xc && y[0] < yc) // 起点在第三象限 + { + beg = 3; + } + else if (x[0] > xc && y[0] < yc) // 起点在第四象限 + { + beg = 4; + } + else if (fabs(y[0]-yc) < 1e-6) // 起点在x轴上 + { + if (x[0] > xc) + { + beg = 5; // x正半轴 + } + else + { + beg = 6; // x负半轴 + } + } + else if (fabs(x[0]-xc) < 1e-6) // 起点在y轴上 + { + if (y[0] > yc) + { + beg = 7; // y正半轴 + } + else + { + beg = 8; // y正半轴 + } + } + else + { + printf("this is an new selection for first point\n"); + } + + if (x[1] > xc && y[1] > yc) // 中点在第一象限 + { + mid = 1; + } + else if (x[1] < xc && y[1] > yc) // 中点在第二象限 + { + mid = 2; + } + else if (x[1] < xc && y[1] < yc) // 中点在第三象限 + { + mid = 3; + } + else if (x[1] > xc && y[1] < yc) // 中点在第四象限 + { + mid = 4; + } + else if (fabs(y[1]-yc)<1e-6) // 中点在x轴上 + { + if (x[1] > xc) {mid = 5;} // x正半轴 + else{ mid = 6; } // x负半轴 + } + else if (fabs(x[1]-xc)<1e-6) // 中点在y轴上 + { + if (y[1] > yc) // y正半轴 + { + mid = 7; + } + else { mid = 8; } // y负半轴 + } + else + { + printf("this is an new selection for second point\n"); + } + + if (x[2] > xc && y[2] > yc) // 终点在第一象限 + { + end = 1; + } + else if (x[2] < xc && y[2] > yc) // 终点在第二象限 + { + end = 2; + } + else if (x[2] < xc && y[2] < yc) // 终点在第三象限 + { + end = 3; + } + else if (x[2] > xc && y[2] < yc) // 终点在第四象限 + { + end = 4; + } + else if (fabs(y[2]-yc)<1e-6) // 终点在x轴上 + { + if (x[2] > xc) {end = 5;} // x正半轴 + else{end = 6;} // x负半轴 + } + else if (fabs(x[2]-xc)<1e-6) // 终点在y轴上 + { + if (y[2] > yc){ end = 7;} // y正半轴 + else{end = 8;} // y负半轴 + } + else + { + printf("this is an new selection for third point\n"); + } + + minx = S32_MAX; + maxx = S32_MIN; + miny = S32_MAX; + maxy = S32_MIN; + + switch (beg) + { + case 1: // 起点在第一象限内 + { + switch (end) + { + case 1: // 终点在第一象限内 + case 5: // 终点在x正半轴上 + case 7: // 终点在y正半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("1 Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 2: // 终点在第二象限内 + case 6: // 终点在x负半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else // 半弧 + { + printf("2 Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 3: // 终点在第三象限内 + if (mid == 2 || mid == 6 || mid == 7 || (mid == 1 && x[1] < x[0]) || (mid == 3 && x[1] < x[2])) // 逆时针方向 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else if (mid == 4 || mid == 5 || mid == 8 || (mid == 1 && x[1] > x[0]) || (mid == 3 && x[1] > x[2])) // 顺时针方向 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else + { + printf("3. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 4: // 终点在第四象限内 + case 8: // 终点在y负半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("4. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + default: + break; + } + + break; + } + case 2: // 起点在第二象限内 + { + switch (end) + { + case 1: // 终点在第一象限内 + case 5: // 终点在x正半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else // 半弧 + { + printf("5. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 2: // 终点在第二象限内 + case 6: // 终点在x负半轴上 + case 7: // 终点在y正半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("6. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 3: // 终点在第三象限内 + case 8: // 终点在y负半轴上 + if (k > 0) // 大半弧 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("7. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 4: // 终点在第四象限内 + if (mid == 3 || mid == 6 || mid == 8 || (mid == 2 && x[1] < x[0]) || (mid == 4 && x[1] < x[2])) // 逆时针方向 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else if (mid == 1 || mid == 5 || mid == 7 || (mid == 2 && x[1] > x[0]) || (mid == 4 && x[1] > x[2])) // 顺时针方向 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else + { + printf("8. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + default: + break; + } + break; + } + case 3: // 起点在第三象限内 + { + switch (end) + { + case 1: // 终点在第一象限内 + if (mid == 4 || mid == 5 || mid == 8 || (mid == 1 && x[1] > x[0]) || (mid == 3 && x[1] > x[2])) // 逆时针方向 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else if (mid == 2 || mid == 6 || mid == 7 || (mid == 1 && x[1] < x[0]) || (mid == 3 && x[1] < x[2])) // 顺时针方向 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else + { + printf("9. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 2: // 终点在第二象限内 + case 7: // 终点在y正半轴上 + if (k > 0) // 大半弧 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("10. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + case 3: // 终点在第三象限内 + case 6: // 终点在x负半轴上 + case 8: // 终点在y负半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("11. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + case 4: // 终点在第四象限内 + case 5: // 终点在x正半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("12. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + default: + break; + } + break; + } + case 4: // 起点在第四象限内 + { + switch (end) + { + case 1: // 终点在第一象限内 + case 7: // 终点在y正半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("13. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 2: // 终点在第二象限内 + if (mid == 1 || mid == 5 || mid == 7 || (mid == 2 && x[1] > x[0]) || (mid == 4 && x[1] > x[2])) // 逆时针方向 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else if (mid == 3 || mid == 6 || mid == 8 || (mid == 2 && x[1] < x[0]) || (mid == 4 && x[1] < x[2])) // 顺时针方向 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else + { + printf("14. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 3: // 终点在第三象限内 + case 6: // 终点在x负半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("15. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 4: // 终点在第四象限内 + case 5: // 终点在x正半轴上 + case 8: // 终点在y负半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("16. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + default: + break; + } + break; + } + case 5: // 起点在在x正半轴上 + { + maxx = xc + r; + + switch (end) + { + case 1: // 终点在第一象限内 + case 4: // 终点在第四象限内 + if (k > 0) // 大半弧 + { + minx = xc - r; + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("17. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 2: // 终点在第二象限内 + case 7: // 终点在y正半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else // 半弧 + { + printf("18. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 3: // 终点在第三象限内 + case 8: // 终点在y负半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("19. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 5: // 终点在x正半轴上 + printf("20. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + break; + + case 6: // 终点在x负半轴上 + minx = xc - r; + if (y[1] > yc) // 逆时针 + { + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else if (y[1] < yc) // 顺时针 + { + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else + { + printf("21. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + default: + break; + } + break; + } + case 6: // 起点在x负半轴上 + { + minx = xc - r; + + switch (end) + { + case 1: // 终点在第一象限内 + case 7: // 终点在y正半轴上 + if (k > 0) // 大半弧 + { + maxx = xc + r; + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else if (k < 0) // 小半弧 + { + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else // 半弧 + { + printf("22. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 2: // 终点在第二象限内 + case 3: // 终点在第三象限内 + if (k > 0) // 大半弧 + { + maxx = xc + r; + miny = yc - r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("23. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 4: // 终点在第四象限内 + case 8: // 终点在y负半轴上 + if (k > 0) // 大半弧 + { + maxx = xc + r; + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + maxx = MAX(x[0], x[2]); + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("24. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 5: // 终点在x正半轴上 + maxx = xc + r; + if (y[1] > yc) // 顺时针 + { + miny = MIN(y[0], y[2]); + maxy = yc + r; + } + else if (y[1] < yc) // 逆时针 + { + miny = yc - r; + maxy = MAX(y[0], y[2]); + } + else + { + printf("25. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 6: // 终点在x负半轴上 + printf("26. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + break; + + default: + break; + } + break; + } + + case 7: // 起点在y正半轴上 + { + maxy = yc + r; + + switch (end) + { + + case 1: // 终点在第一象限内 + case 2: // 终点在第二象限内 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + miny = yc - r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + } + else // 半弧 + { + printf("27. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 3: // 终点在第三象限内 + case 6: // 终点在x负半轴上 + if (k > 0) // 大半弧 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = yc - r; + } + else if (k < 0) // 小半弧 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = MIN(y[0], y[2]); + } + else // 半弧 + { + printf("28. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 4: // 终点在第四象限内 + case 5: // 终点在x正半轴上 + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + miny = yc - r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + miny = MIN(y[0], y[2]); + } + else // 半弧 + { + printf("29. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + + case 7: // 终点在y正半轴上 + printf("30. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + break; + + case 8: // 终点在y负半轴上 + miny = yc - r; + if (x[1] > xc) // 顺时针 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + } + else if (x[1] < xc) // 逆时针 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + } + else + { + printf("31. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + default: + break; + } + break; + } + case 8: // 起点在y负半轴上 + { + miny = yc - r; + switch (end) + { + case 1: // 终点在第一象限内 + case 5: // 终点在x正半轴上 + { + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("32. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + } + case 2: // 终点在第二象限内 + case 6: // 终点在x负半轴上 + { + if (k > 0) // 大半弧 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("33. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + } + case 3: // 终点在第三象限内 + case 4: // 终点在第四象限内 + { + if (k > 0) // 大半弧 + { + minx = xc - r; + maxx = xc + r; + maxy = yc + r; + } + else if (k < 0) // 小半弧 + { + minx = MIN(x[0], x[2]); + maxx = MAX(x[0], x[2]); + maxy = MAX(y[0], y[2]); + } + else // 半弧 + { + printf("34. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + } + case 7: // 终点在y正半轴上 + { + maxy = yc + r; + + if (x[1] > xc) // 逆时针 + { + minx = MIN(x[0], x[2]); + maxx = xc + r; + } + else if (x[1] < xc) // 顺时针 + { + minx = xc - r; + maxx = MAX(x[0], x[2]); + } + else + { + printf("35. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + } + break; + } + case 8: // 终点在y负半轴上 + { + printf("36. Impossible in GetMinMax. beg=%d, end=%d\n", beg, end); // 不可能出现的情况 + break; + } + default: + break; + } + break; + } + + default: + break; + } + + if (minx < *pminx) + { + *pminx = minx; + } + + if (miny < *pminy) + { + *pminy = miny; + } + + if (maxx > *pmaxx) + { + *pmaxx = maxx; + } + + if (maxy > *pmaxy) + { + *pmaxy = maxy; + } + + // printf("minx=%.2f, maxx=%.2f, miny=%.2f, maxy=%.2f\n", minx, maxx, miny, maxy); + return 0; +} + +void rotatec(double xin, double yin, double * px, double * py, double angle) +{ + *px=xin*cos(angle)-yin*sin(angle); + *py=xin*sin(angle)+yin*cos(angle); +} + +int arcDir(const double x[], const double y[]) +{ + double k; + if(x[1] > x[0]) + { + k = (y[1] - y[0]) / (x[1]-x[0]); + if (y[2] < (k*(x[2]-x[1]) + y[1])) + { + return -1; + } + else + { + return 1; + } + } + else if (x[1] < x[0]) + { + k = (y[1] - y[0]) / (x[1] - x[0]); + if (y[2] < (k * (x[2]-x[1]) + y[1])) + { + return 1; + } + else + { + return -1; + } + } + else if ( (x[2]>x[1] && y[1]x[1] && y[1]>y[0]) || (x[2]y[1]) ) + { + return -1; + } + else + { + printf("1. what's this case?\n"); + return 0; + } +} + +Point2D pointOnCubicBezier(Point2D* cp, double t) +{ +#if(1) + double ax, bx, cx; double ay, by, cy; + double tSquared, tCubed; Point2D result; + + /* 计算多项式系数 */ + cx = 3.0 * (cp[1].x - cp[0].x); + bx = 3.0 * (cp[2].x - cp[1].x) - cx; + ax = cp[3].x - cp[0].x - cx - bx; + cy = 3.0 * (cp[1].y - cp[0].y); + by = 3.0 * (cp[2].y - cp[1].y) - cy; + ay = cp[3].y - cp[0].y - cy - by; + + /* 计算t位置的点值 */ + tSquared = t * t; + tCubed = tSquared * t; + result.x =((ax * tCubed) + (bx * tSquared) + (cx * t) + cp[0].x); + result.y =((ay * tCubed) + (by * tSquared) + (cy * t) + cp[0].y); + return result; +#endif +} + +void computeBezier(Point2D* cp, long numberOfPoints, Point2D* curve) +{ + double dt; long i; + dt = 1.0 / ( numberOfPoints - 1 ); + for( i = 0; i < numberOfPoints; i++) + { + curve[i] = pointOnCubicBezier( cp, i*dt ); + } +} + +int getBezierMinMax(const double x[], const double y[], double * pminx, double * pmaxx, double * pminy, double * pmaxy) +{ + long k = 0; + double sx,sy; + long i = 0; + double minx, miny, maxx, maxy; + Point2D cp[4]; + + //传递参数 + for (i = 0; i <4;i++) + { + cp[i].x = x[i]; + cp[i].y = y[i]; + } + + //求控制点总长 + for (i = 0; i <3;i++) + { + sx = cp[i+1].x - cp[i].x; + sy = cp[i+1].y - cp[i].y ; + k += sqrt(sx*sx+sy*sy); //分割点数= 总长(精度为0.1mm) + } + if(k == 0) + { + return -1; + } + + if (k > 100) //对多100个点 + { + k = 100; + } + + Point2D curve[k]; + + computeBezier(cp, k, curve); //分割针步 + + minx = S32_MAX; + maxx = S32_MIN; + miny = S32_MAX; + maxy = S32_MIN; + + //判断始末点 + for (i = 0; i <4;i =i+3) + { + if (minx > cp[i].x) + { + minx = cp[i].x; + } + if (maxx < cp[i].x) + { + maxx = cp[i].x; + } + if (miny > cp[i].y) + { + miny = cp[i].y; + } + if (maxy < cp[i].y) + { + maxy = cp[i].y; + } + } + + for (i=0;i curve[i].x) + { + minx = curve[i].x; + } + if (maxx < curve[i].x) + { + maxx = curve[i].x; + } + if (miny > curve[i].y) + { + miny = curve[i].y; + } + if (maxy < curve[i].y) + { + maxy = curve[i].y; + } + } + + //printf("\n BSR minx = %f, maxx = %f, miny = %f, maxy = %f \n",minx,maxx,miny,maxy); + + if (minx < *pminx) + { + *pminx = minx; + } + + if (miny < *pminy) + { + *pminy = miny; + } + + if (maxx > *pmaxx) + { + *pmaxx = maxx; + } + + if (maxy > *pmaxy) + { + *pmaxy = maxy; + } + + return 0; +} + +int calcLine(double x0, double y0, double x1, double y1, s16 step, QByteArray &absAry, WORD datatype) +{ + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + + s32 dx, dy; + double length; + double tmp; + int count; + int i; + double stepx, stepy; + double sx, sy; + int actx, acty; + double k; + + if(x0 == x1 && y0 == y1) + { + return 0; + } + + if(x0 > x1) + { + sx = -1.0; // x反向 + } + else + { + sx = 1.0; + } + + if(y0 > y1) + { + sy = -1.0; // y反向 + } + else + { + sy = 1.0; + } + + if(datatype == QUI_TYPE_STEP || datatype == QUI_TYPE_HSTEP) // 跨步或翻头跨步 + { + absItem.ctrl = DATA_OFFSET; + } + else + { + absItem.ctrl = DATA_SEWING; // 其他 + } + + // 开始分割针步 + length = sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)); + + tmp = length/step; /* 实际针步数 */ + count = floor(tmp); /* 最少整针步数 */ + + if (tmp - count > 0.01) + { + count += 1; + } + + if (count == 0 && length > 0) // 短直线 + { + count = 1; + } + + tmp = 0; + actx = x0; + acty = y0; + + if (x1 != x0 && y1 == y0) // 横直线 + { + for (i = 0; i < count; i++) + { + tmp = ((i+1)*(length)/count)*sx+x0; // 实际针步 + + stepx = tmp - actx; + dx = (s32)(stepx+0.5*sx); + dy = 0; + actx += dx; + + absItem.ax = tmp; + absItem.ay = y0; + absAry.append((char*)&absItem,sizeof(DsAbsItem)); + } + } + else if (x1 == x0 && y1 != y0) // 竖直线 + { + for (i = 0; i < count; i++) + { + tmp = ((i+1)*(length)/count)*sy + y0; // 实际针步 + + stepy = tmp - acty; + + dx = 0; + dy = (s32)(stepy+0.5*sy); + acty += dy; + + absItem.ax = x0; + absItem.ay = tmp; + absAry.append((char*)&absItem,sizeof(DsAbsItem)); + } + } + else if(x1 != x0 && y1 != y0) // 任意斜线 + { + k = (y1-y0)/(x1-x0); + for (i = 0; i < count; i++) + { + tmp = ((i+1)*(length)/count); + + stepx = fabs(tmp*cos(atan(k)))*sx + x0; // 实际针步x + stepy = fabs(tmp*sin(atan(k)))*sy + y0; // 实际针步y + + dx = (s32)(stepx-actx+0.5*sx); + dy = (s32)(stepy-acty+0.5*sy); + + actx += dx; + acty += dy; + + absItem.ax = stepx; + absItem.ay = stepy; + absAry.append((char*)&absItem,sizeof(DsAbsItem)); + } + } + else + { + printf("what's this?\n"); + } + + return count; +} + +int calcCurve(double threex[], double threey[], s16 step, QByteArray &absAry) +{ + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + + BYTE dx, dy; + int count = 0; + int i; + s32 ar = 0; + + double distance, k; + double alph; + double increment; + double xc=0,yc=0,r=0; + int actx, acty; + int ddx, ddy; + + i = isThreePointOnALine(threex, threey); + if(i == 1) // 3点共线 + { + return calcLine(threex[0], threey[0], threex[2], threey[2], step, absAry, QUI_TYPE_LINE); // 作为直线 + } + else if (i == 2) + { + return calcLine(threex[0], threey[0], threex[1], threey[1], step, absAry, QUI_TYPE_LINE); // 作为直线 + } + + getArcCenter(threex, threey, &xc, &yc, &r); + + // printf("center=%.2f,%.2f,r=%.2f\n", xc, yc, r); + + // 计算弦长和圆心角 + distance = sqrt((threex[0]-threex[2])*(threex[0]-threex[2])+(threey[0]-threey[2])*(threey[0]-threey[2])); // 两点间距离就是弦长 + k = (r*r+r*r-distance*distance)/(r*r+r*r); + if (k < -1) + { + k = -1; + } + else if (k > 1) + { + k = 1; + } + + // printf("distance=%f, k=%f\n", distance, k); + + alph = acos(k); + + // 区分象限和方向 + k = (threex[0]-threex[1])*(threex[2]-threex[1]) + (threey[0]-threey[1])*(threey[2]-threey[1]); // 向量 01 和 向量 21 的夹角的余弦的符号-- > 0 小于90度. < 0 大于90度 = 0, 90 度 + if (k > 0) // 夹角小于90度, 说明弧是大于半圆 + { + alph = 2*PI-alph; + } + else // 夹角大于等于90度, 说明弧是小于等于半圆, 不需要处理 + { + } + + // printf("act alph=%f\n", alph); + + // 计算每个针步对应的弧心角大小 + if (fabs(2*r*r-step*step)/(2*r*r) > 1) + { + increment = alph; + } + else + { + increment = (acos((2*r*r-step*step)/(r*r+r*r))); + } + + // 计算分割针步数 + count = (int)(alph/increment+0.5); + if (count == 0) + { + count++; + } + + // printf("1.count=%d, increment=%f\n", count, increment); + + increment = alph/count; // 重新计算每个针步弧心角 + + increment *= arcDir(threex, threey); // 确定针步增加的角度和方向 + + // printf("2.count=%d, increment=%f\n", count, increment); + + double curx, cury, lastx, lasty; + double xrot, yrot; + + lastx = threex[0]; + lasty = threey[0]; + + i = 0; + + actx = (int)(lastx); + acty = (int)(lasty); + + do + { + if (i == count-1) + { + // 最后一个针步 + // printf("the last step\n"); + curx = threex[2]; + cury = threey[2]; + } + else + { + // 点 (lastx, lasty) 在圆上旋转 + // printf("before Rotatec point(%f, %f)\n", lastx, lasty); + + rotatec(lastx-xc, lasty-yc, &xrot, &yrot, increment); + curx = xrot + xc; + cury = yrot + yc; + } + + ddx = curx-actx; + ddy = cury-acty; + + dx = (s16)(curx-actx+(0.5*(ddx>=0?1:-1))); + dy = (s16)(cury-acty+(0.5*(ddy>=0?1:-1))); + + absItem.ctrl = DATA_SEWING; + absItem.ax = curx; + absItem.ay = cury; + + double tar = atan2(dy,dx); + ar = (tar * 10000+0.5*(tar>0?1:-1)); + absItem.ar = ar; + absAry.append((char*)&absItem,sizeof(DsAbsItem)); + + lastx = curx; + lasty = cury; + + actx += dx; + acty += dy; + i++; + + } while(i < count); + + return count; +} + +#define YUFENGE 20 //预分割步数 +#define YUFENGE_BEGIN (YUFENGE*7/10) //扫描起点 + +int calcBezier(double threex[], double threey[], s16 step, QByteArray &absAry) +{ + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + + int dx, dy; + long k = 0; + double sx,sy; + long i , l; + Point2D cp[4]; + int count = 0; + double curx, cury, lastx, lasty; + int actx, acty; + int ddx, ddy; + s32 ar = 0; + + //传递参数 + for (i = 0; i <4;i++) + { + cp[i].x = threex[i]; + cp[i].y = threey[i]; + } + + //求控制点总长 + for (i = 0; i <3;i++) + { + sx = cp[i+1].x - cp[i].x; + sy = cp[i+1].y - cp[i].y ; + k += sqrt(sx*sx+sy*sy); //分割点数= 总长(精度为0.1mm) + } + + k = (long)((k / step)+1) * YUFENGE; //预分割针步数,设置针步数*YUFENGE. + Point2D curve[k]; + + double dt; + dt = 1.0 / ( k - 1 ); //分割分辨率 + + lastx = cp[0].x; + lasty = cp[0].y; + + for (i = YUFENGE_BEGIN ;i < k ; ) + { + curve[i] = pointOnCubicBezier(cp, i*dt); + sx = curve[i].x - lastx; + sy = curve[i].y - lasty; + l = sqrt(sx*sx+sy*sy); //拟合针步长度 + + if(i == k-1) + { + //最后一针 + actx = (int)(lastx); + acty = (int)(lasty); + curx = (int)(cp[3].x); + cury = (int)(cp[3].y); + + ddx = curx-actx; + ddy = cury-acty; + + dx = (int)(abs(ddx)+0.5); + dy = (int)(abs(ddy)+0.5); + + lastx = curx; + lasty = cury; + + absItem.ctrl = DATA_SEWING; + absItem.ax = curx; + absItem.ay = cury; + + double tar = atan2(dy,dx); + ar = (tar * 10000+0.5*(tar>0?1:-1)); + absItem.ar = ar; + + absAry.append((char*)&absItem,sizeof(DsAbsItem)); + + count++; + break; + } + else if(l >= (step-1)) + { + actx = (int)(lastx); + acty = (int)(lasty); + curx = (int)(curve[i].x); + cury = (int)(curve[i].y); + + ddx = curx-actx; + ddy = cury-acty; + + dx = (int)(abs(ddx)+0.5); + dy = (int)(abs(ddy)+0.5); + + lastx = curx; + lasty = cury; + count++; + + if ((i + YUFENGE_BEGIN) >= k-1) + { + i = k-1; + } + else + { + i=i+YUFENGE_BEGIN; + } + + absItem.ctrl = DATA_SEWING; + absItem.ax = curx; + absItem.ay = cury; + + double tar = atan2(dy,dx); + ar = (tar * 10000+0.5*(tar>0?1:-1)); + absItem.ar = ar; + + absAry.append((char*)&absItem,sizeof(DsAbsItem)); + } + else + { + i++; + } + } + + return count; +} + +void getSplineNew(QList &ptList, QList &splineList) +{ + //读取样条线拟合控制点 + QPointF pSuPoint; + int i = 0; + int iCountPoint = ptList.size(); + + //绘制二次累加弦长曲线 + QPointF pPoint[iCountPoint]; + double dfMinX, dfMinY; + + dfMinX = dfMinY= 0; + + while (i < iCountPoint) + { + pSuPoint = ptList.at(i); + + pPoint[i].setX(pSuPoint.x()); + pPoint[i].setY(pSuPoint.y()); + if (i == 0) + { + dfMinX = pPoint[i].x(); + dfMinY = pPoint[i].y(); + } + else + { + if (dfMinX > pPoint[i].x()) + dfMinX = pPoint[i].x(); + + if (dfMinY > pPoint[i].y()) + dfMinY = pPoint[i].y(); + } + i++; + } + + for (i = 0; i < iCountPoint; i++) + { + double x = pPoint[i].x() - dfMinX; + double y = pPoint[i].y() - dfMinY; + pPoint[i].setX(x); + pPoint[i].setY(y); + } + + getShap(iCountPoint, pPoint, splineList, dfMinX, dfMinY); +} + +void getShap(int nCtrlPntNum, QPointF *pPoint, QList &splineList, double dfMinX, double dfMinY) +{ + int i,j,k,stp,leg, m = nCtrlPntNum-1; + double t0,t1,r0,r1, *o, *p, *q; + QPointF *u, *v; + + o = new double [nCtrlPntNum + 1]; + p = new double [nCtrlPntNum + 1]; + q = new double [nCtrlPntNum + 1]; + u = new QPointF [nCtrlPntNum + 1]; + v = new QPointF [nCtrlPntNum + 1]; + + do // 计算弦长 + { + j = 0; + for (i = 1; i<= m; i++) + { + t0 = pPoint[i].x() - pPoint[i-1].x(); + t1 = pPoint[i].y() - pPoint[i-1].y(); + o[i] = sqrt(t0 * t0 + t1 * t1); + if (o[i] < 2) + { + j = i; + break; + } + } + + if (j > 0) + { + for (i = j; i <= m; i++) + { + pPoint[i].setX(pPoint[i+1].x()); + pPoint[i].setY(pPoint[i+1].y()); + } + m--; + } + } while (j!=0); + + t0 = o[1] + o[2]; + t1 = 2*o[1] * o[2]; // 边界条件 m[o] 和 m[N] 的构造 + + u[0].setX((t0 * t0 * pPoint[1].x() - o[2] * o[2] * pPoint[0].x() - o[1] * o[1] * pPoint[2].y()) / t1 - pPoint[0].x()); + u[0].setY((t0 * t0 * pPoint[1].y() - o[2] * o[2] * pPoint[0].y() - o[1] * o[1] * pPoint[2].y()) / t1 - pPoint[0].y()); + t0 = sqrt(u[0].x() * u[0].x() + u[0].y() * u[0].y()); + + u[0].setX(u[0].x() / t0); + u[0].setY(u[0].y() / t0); + t0 = o[m-1] + o[m]; + t1 = 2*o[m-1] * o[m]; + + r0 = (t0 * t0 * pPoint[m-1].x() - o[m] * o[m] * pPoint[m-2].x() - o[m-1] * o[m-1] * pPoint[m].x()) / t1; + r1 = (t0 * t0 * pPoint[m-1].y() - o[m] * o[m] * pPoint[m-2].y() - o[m-1] * o[m-1] * pPoint[m].y()) / t1; + u[m].setX(pPoint[m].x() - r0); + u[m].setY(pPoint[m].y() - r1); + t0 = sqrt(u[m].x() * u[m].x() + u[m].y() * u[m].y()); + u[m].setX(u[m].x() / t0); + u[m].setY(u[m].y() / t0); + + //计算 m 连续方程系数 C[i] + p[1] = o[2] / (o[1] + o[2]); + q[1] = 3; + t0 = p[1] * (pPoint[1].x() - pPoint[0].x()) / o[1]; + t1 = p[1] * (pPoint[1].y() - pPoint[0].y()) / o[1]; + v[1].setX(4 * (t0 + (1-p[1]) * (pPoint[2].x() - pPoint[1].x()) / o[1+1])); + v[1].setY(4 * (t1 + (1-p[1]) * (pPoint[2].y() - pPoint[1].y()) / o[1+1])); + + for (i=2; i<= (m-1); i++) + { + p[i] = o[i+1] / (o[i]+o[i+1]); + q[i] = 3 - p[i] * (1 - p[i-1]) / q[i-1]; + + t0 = p[i] * (pPoint[i].x() - pPoint[i-1].x()) / o[i]; + t1 = p[i] * (pPoint[i].y() - pPoint[i-1].y()) / o[i]; + + v[i].setX(4 * (t0 + (1 - p[i]) * (pPoint[i+1].x() - pPoint[i].x()) / o[i+1])); + v[i].setY(4 * (t1 + (1 - p[i]) * (pPoint[i+1].y() - pPoint[i].y()) / o[i+1])); + } + + v[1].setX(v[1].x() - p[1] * u[0].x()); + v[1].setY(v[1].y() - p[1] * u[0].y()); + v[m-1].setX(v[m-1].x() - (1 - p[m-1]) * u[m].x()); + v[m-1].setY(v[m-1].y() - (1 - p[m-1]) * u[m].y()); + + // 求解 m 连续方程, 获得 m[i] + u[1].setX(v[1].x() / q[1]); + u[1].setY(v[1].y() / q[1]); + + for (i = 2; i <= m-1; i++) + { + u[i].setX((v[i].x() - p[i] * u[i-1].x()) / q[i]); + u[i].setY((v[i].y() - p[i] * u[i-1].y()) / q[i]); + } + + for (i = m-2; i >= 1; i--) + { + u[i].setX(u[i].x() - u[i+1].x() * (1 - p[i]) / q[i]); + u[i].setY(u[i].y() - u[i+1].y() * (1 - p[i]) / q[i]); + } + + // 求得 M[j] j=0,1,...,N + v[0].setX(4 * (pPoint[1].x() - pPoint[0].x()) / (o[1] * o[1]) - (3 * u[0].x() + u[1].x()) / o[1]); + v[0].setY(4 * (pPoint[1].y() - pPoint[0].y()) / (o[1] * o[1]) - (3 * u[0].y() + u[1].y()) / o[1]); + q[0]=0; + + for (i=1; i<= m; i++) + { + q[i] = 0; + t0 = o[i] * o[i]; + v[i].setX(-4 * (pPoint[i].x() - pPoint[i-1].x()) / t0 + (3 * u[i].x() + u[i-1].x()) / o[i]); + v[i].setY(-4 * (pPoint[i].y() - pPoint[i-1].y()) / t0 + (3 * u[i].y() + u[i-1].y()) / o[i]); + for (j=1; j<= i; j++) + q[i] = q[i] + o[j]; + } + + // o[j] j=0,1,...,N 表示半节点 + o[0] = q[0]; + o[m+1] = q[m]; + + for (i = 1; i<= m; i++) + o[i] = (q[i-1] + q[i]) / 2; + + // 显示或绘之曲线 + QPointF suPoint; + suPoint.setX(pPoint[0].x() + dfMinX); + suPoint.setY(pPoint[0].y() + dfMinY); + splineList.append(suPoint); + // pDC->MoveTo(lx1,ly1); + + for (i = 0; i< m; i++) + { + leg = (int)(o[i+1] - o[i]); + stp = leg / 10; + + if (leg> 600) + stp = leg / 60; + + if (leg> 900) + stp = leg / 80; + + if (leg>1200) + stp = leg / 100; + + if (leg > 2400) + stp = leg / 120; + + if (leg>4800) + stp = leg / 140; + + if (stp) + k = leg/stp; + else + k = 0; + + for (j = 0; j<= k; j++) + { + r0 = o[i] + stp * j - q[i]; + suPoint.setX(pPoint[i].x() + r0 * (u[i].x() + v[i].x() / 2 * r0) + dfMinX); + suPoint.setY(pPoint[i].y() + r0 * (u[i].y() + v[i].y() / 2 * r0) + dfMinY); + splineList.append(suPoint); + //pDC->LineTo(lx1,ly1); + } + } + + suPoint.setX(pPoint[m].x() + dfMinX); + suPoint.setY(pPoint[m].y() + dfMinY); + splineList.append(suPoint); + //pDC->LineTo(lx1,ly1); + + delete o; + delete p; + delete q; + delete u; + delete v; +} + +void getCurvePointFillLine(QList &inList, double indRunLen, QList &outList, int iSumParm, BYTE biLenLimit) +{ + QPointF dPoint1, dPoint2, dPoint3; + double dTatol, dLen1, dLen2, dSpace; + long lSum, lCount; + + //计算总的线段长 + int iCountPoint = inList.size(); + if(iCountPoint <= 0) + { + return; + } + + getTotalDistanceFillLine(&inList, dTatol); + if(dTatol == 0) + return; + + if (biLenLimit == ADJUSTLINE_ADD_DUAN_LIMIT) + { + lSum = iSumParm; + if (lSum < 1) + lSum = 1; + dSpace = dTatol / lSum; + } + else if (iSumParm > 2) + { + lSum = iSumParm; + dSpace = dTatol / (double)lSum; + } + else + { + if (biLenLimit == OBJECT_STITCHLEN_NEW_BIG) + { + lSum = int(dTatol / indRunLen); + dSpace = dTatol / lSum; + + if(lSum == 0) + lSum = 1; + } + else if (biLenLimit == OBJECT_STITCHLEN_NEW_SAMALL) + { + lSum = doubleToLong(dTatol / indRunLen + 0.1667); + dSpace = dTatol / (double)lSum; + if(lSum == 0) + lSum = 1; + } + else if (biLenLimit == OBJECT_STITCHLEN_NEW_SAME) + { + lSum = int(dTatol / indRunLen); + dSpace = indRunLen; + if(lSum == 0) + lSum = 1; + } + else if (biLenLimit == LINEDUAN_STITCHLEN_LIMIT || + biLenLimit == LINEDUAN_STITCHLEN_LIMIT_END) + { + lSum = int(dTatol / indRunLen); + dSpace = indRunLen; + } + else if (biLenLimit == LINEDUAN_NUM_LIMIT) + { + lSum = int(dTatol / indRunLen); + dSpace = dTatol / (double)lSum; + } + else + { + if (biLenLimit) + { + lSum = int(dTatol / indRunLen); + if (lSum < 1) + lSum = doubleToLong(dTatol / indRunLen + 0.1667); + } + else + lSum = doubleToLong(dTatol / indRunLen + 0.1667); + + if(lSum == 0) + lSum = 1; + + dSpace = dTatol / (double)lSum; + } + } + + dPoint1 = inList[0]; + outList.append(dPoint1);//添加第一个点 + + pointToPoint(dPoint1, dPoint2); + dLen1 = dSpace; + dLen2 = 0; + int i = 0; + for(lCount = 0; lCount < lSum; lCount++) + { + while(i < inList.size()-1 && dLen2 < dLen1) + { + dLen1 -= dLen2; + pointToPoint(dPoint2, dPoint1); + i++; + dPoint2 = inList[i]; + distPointToPoint(dPoint1, dPoint2, dLen2); + } + if(dLen1 < dLen2) + { + getPointInSectFillLine(dPoint1, dPoint2, dLen1, dPoint3); + } + else + { + dPoint3.setX(dPoint2.x()); + dPoint3.setY(dPoint2.y()); + } + outList.append(dPoint3); + dLen2 -= dLen1; + dLen1 = dSpace; + pointToPoint(dPoint3, dPoint1); + } + + if (biLenLimit == LINEDUAN_STITCHLEN_LIMIT_END || + biLenLimit == OBJECT_STITCHLEN_NEW_SAME) + { + if (fabs((lSum * indRunLen) - dTatol) > ZERO) + { + outList.append(inList.last()); + } + } +} + +int getTotalDistanceFillLine(QList *pPointList, double &dTotal) +{ + QPointF dPoint, dNext; + double d; + dTotal = 0; + int i = 0; + long lSum = (long)pPointList->count(); + if(lSum > 1) + { + while(i < pPointList->size()) + { + dPoint = pPointList->at(i); + i++; + if(i < pPointList->size()) + { + dNext = pPointList->at(i); + distPointToPoint(dPoint, dNext, d); + dTotal += d; + } + else + { + break; + } + } + } + return ERROR_NOTHING; +} + +void pointToPoint(const QPointF &inPoint, QPointF &outPoint) +{ + outPoint.setX(inPoint.x()); + outPoint.setY(inPoint.y()); +} + +long doubleToLong(double indValue) +{ + return (long)round(indValue); +} + +double round(double indValue) +{ + return floor(indValue + 0.5); +} + +void distPointToPoint(const QPointF &p1, const QPointF &p2, double &outd) +{ + outd = disPointToPoint(p1.x(), p1.y(), p2.x(), p2.y()); +} + +bool getPointInSectFillLine(const QPointF &p1, const QPointF &p2, const double &d, QPointF &outp) +{ + bool bRes; + QPointF dpoint[3]; + + dpoint[0].setX(p1.x()); + dpoint[0].setY(p1.y()); + dpoint[1].setX(p2.x()); + dpoint[1].setY(p2.y()); + dpoint[2].setX(outp.x()); + dpoint[2].setY(outp.y()); + + bRes = getPointAtSect(dpoint[0], dpoint[1], d, dpoint[2]); + outp.setX(dpoint[2].x()); + outp.setY(dpoint[2].y()); + + return bRes; +} + +bool getPointAtSect(const QPointF &p1, const QPointF &p2, const double &d, QPointF &outp) +{ + double s = disPointToPoint(p1.x(), p1.y(), p2.x(), p2.y()); + if(fabs(s) < ZERO) + { + if(d < ZERO) + { + outp.setX(p1.x()); + outp.setY(p1.y()); + } + return false; + } + outp.setX((p2.x() - p1.x()) * d / s + p1.x()); + outp.setY((p2.y() - p1.y()) * d / s + p1.y()); + + return true; +} + +double disPointToPoint(double x1, double y1, double x2, double y2) +{ + return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); +} + +void getBezierPointList(double threex[], double threey[], s16 step, QList &outList) +{ + long k = 0; + double sx,sy; + Point2D cp[4]; + + //传递参数 + for (s16 i = 0; i < 4; i++) + { + cp[i].x = threex[i]; + cp[i].y = threey[i]; + } + + //求控制点总长 + for (s16 i = 0; i < 3; i++) + { + sx = cp[i+1].x - cp[i].x; + sy = cp[i+1].y - cp[i].y ; + k += sqrt(sx*sx+sy*sy); //分割点数= 总长(精度为0.1mm) + } + + k = (long)((k / step)+1) * YUFENGE; //分割针步数 + Point2D curve; + + double dt; + dt = 1.0 / ( k - 1 ); //分割分辨率 + + QPointF p; + for (int i = 0; i < k; i++) + { + curve = pointOnCubicBezier(cp, i*dt); + p.setX(curve.x); + p.setY(curve.y); + outList.append(p); + } +} + +int getSplineMinMax(QList &ptList, double *pminx, double *pmaxx, double *pminy, double *pmaxy) +{ + QList splineListXY;//拟合后的点 + splineListXY.clear(); + + double minx, miny, maxx, maxy; + minx = S32_MAX; + maxx = S32_MIN; + miny = S32_MAX; + maxy = S32_MIN; + + //读取样条线拟合控制点 + QPointF pSuPoint; + int i = 0; + int iCountPoint = ptList.size(); + + //绘制二次累加弦长曲线 + QPointF pPoint[iCountPoint]; + double dfMinX, dfMinY; + + dfMinX = dfMinY= 0; + + while (i < iCountPoint) + { + pSuPoint = ptList.at(i); + + pPoint[i].setX(pSuPoint.x()); + pPoint[i].setY(pSuPoint.y()); + if (i == 0) + { + dfMinX = pPoint[i].x(); + dfMinY = pPoint[i].y(); + } + else + { + if (dfMinX > pPoint[i].x()) + dfMinX = pPoint[i].x(); + + if (dfMinY > pPoint[i].y()) + dfMinY = pPoint[i].y(); + } + i++; + } + + for (i = 0; i < iCountPoint; i++) + { + double x = pPoint[i].x() - dfMinX; + double y = pPoint[i].y() - dfMinY; + pPoint[i].setX(x); + pPoint[i].setY(y); + } + + getShap(iCountPoint, pPoint, splineListXY, dfMinX, dfMinY); + + for (i=0;i splineListXY[i].x()) + { + minx = splineListXY[i].x(); + } + if (maxx < splineListXY[i].x()) + { + maxx = splineListXY[i].x(); + } + if (miny > splineListXY[i].y()) + { + miny = splineListXY[i].y(); + } + if (maxy < splineListXY[i].y()) + { + maxy = splineListXY[i].y(); + } + } + + if (minx < *pminx) + { + *pminx = minx; + } + + if (miny < *pminy) + { + *pminy = miny; + } + + if (maxx > *pmaxx) + { + *pmaxx = maxx; + } + + if (maxy > *pmaxy) + { + *pmaxy = maxy; + } + + return 0; +} diff --git a/datafile/dataoperat.h b/datafile/dataoperat.h new file mode 100644 index 0000000..5a75e03 --- /dev/null +++ b/datafile/dataoperat.h @@ -0,0 +1,83 @@ +#ifndef DATAOPERAT_H +#define DATAOPERAT_H + +#include "machine/comm/datadef.h" +#include +#include +#include +#include +#include +#include + +#define QUI_TYPE_LINE 1 //直线 +#define QUI_TYPE_STEP 4 //跨步 +#define QUI_TYPE_HSTEP 5 //翻头跨步 +#define QUI_TYPE_ARC 2 //三点圆弧 +#define QUI_TYPE_BES 6 //贝塞尔曲线 +#define QUI_TYPE_SPLINE 7 //样条曲线 + +#define ERROR_NOTHING 0 //成功 +#define ZERO 1e-6 + +#define LINEDUAN_NUM_LIMIT 5 // 计算分段数固定:不进行特殊计算 +#define LINEDUAN_STITCHLEN_LIMIT 6 // 针迹步长固定 +#define LINEDUAN_STITCHLEN_LIMIT_END 7 // 针迹步长固定(最后线段) + +#define OBJECT_STITCHLEN_NEW_BIG 8 // 固定针迹长度(大等分) +#define OBJECT_STITCHLEN_NEW_SAME 9 // 固定针迹长度(等距分) +#define OBJECT_STITCHLEN_NEW_SAMALL 10 // 固定针迹长度(小等分) +#define ADJUSTLINE_ADD_DUAN_LIMIT 11 // 自动单针指定分段添加 + +typedef struct +{ + double x; + double y; +} Point2D; + +typedef struct +{ + double x; + double y; + int ctrl; +} QuiPoint; + +int isThreePointOnALine(const double threex[],const double threey[]); +int getArcCenter(const double x[], const double y[], double * pxc, double * pyc, double * pr); +int getArcMinMax(const double x[], const double y[], double * pminx, double * pmaxx, double * pminy, double * pmaxy); +void rotatec(double xin, double yin, double * px, double * py, double angle); +int arcDir(const double x[], const double y[]); + +Point2D pointOnCubicBezier(Point2D* cp, double t); +void computeBezier(Point2D* cp, long numberOfPoints, Point2D* curve); +int getBezierMinMax(const double x[], const double y[], double * pminx, double * pmaxx, double * pminy, double * pmaxy); +int getSplineMinMax(QList &ptList, double * pminx, double * pmaxx, double * pminy, double * pmaxy); + +int calcLine(double x0, double y0, double x1, double y1, s16 step, QByteArray &absAry, WORD datatype); +int calcCurve(double threex[], double threey[], s16 step, QByteArray &absAry); +int calcBezier(double threex[], double threey[], s16 step, QByteArray &absAry); +void getBezierPointList(double threex[], double threey[], s16 step, QList &outList); + +//样条拟合 +void getSplineNew(QList &ptList, QList &splineList); +void getShap(int nCtrlPntNum, QPointF *pPoint, QList &splineList, double dfMinX, double dfMinY); +//线段拟合 +void getCurvePointFillLine(QList &inList, double indRunLen, + QList &outList, int iSumParm, BYTE biLenLimit); +int getTotalDistanceFillLine(QList *pPointList, double &dTotal); +void pointToPoint(const QPointF &inPoint, QPointF &outPoint); +long doubleToLong(double indValue);//浮点数转整形 +double round(double indValue);//四舍五入 +void distPointToPoint(const QPointF &p1, const QPointF &p2, double &outd); +bool getPointInSectFillLine(const QPointF &p1, const QPointF &p2, const double &d, QPointF &outp); + +//距p1点距离为d的点 +// d > s : out_p在p2延长线上 +// s >= d >= 0 : out_p在p1、p2线段上 +// d < 0 : out_p在p1延长线上 +bool getPointAtSect(const QPointF &p1, const QPointF &p2, const double &d, QPointF &outp); + +// 两点间距离 +double disPointToPoint(double x1, double y1, double x2, double y2); + + +#endif // DATAOPERAT_H diff --git a/datafile/dsrcryption.cpp b/datafile/dsrcryption.cpp new file mode 100644 index 0000000..229c7d8 --- /dev/null +++ b/datafile/dsrcryption.cpp @@ -0,0 +1,319 @@ +#include "dsrcryption.h" +#include +#include + +DsrCryption::DsrCryption() +{ + m_initflag = 0; + m_cryword = 0; + memset(m_factors, 0, BYTES_OF_CRY_FACTORS); +} + +// 初始化加密控制, 生成加密字和加密因子 +int DsrCryption::InitDsrCryptionCtrl(int version, unsigned int cryword, const unsigned char * factors) +{ + int rslt = 0; + + m_initflag = 0; + m_cryword = 0; + memset(m_factors, 0, BYTES_OF_CRY_FACTORS); + + if (version >= 0) + { + rslt = CreateCryWord(version); + } + else + { + m_cryword = cryword; + } + + if (rslt == 0) + { + rslt = CreateCryFactors(factors); + } + + if (rslt == 0) + { + m_initflag++; + } + + return rslt; +} + +// 获取加密字 +unsigned int DsrCryption::GetDsrCryptionWord() +{ + return m_cryword; +} + +// 加密数据 +int DsrCryption::EnCryption(unsigned char * pData, int size) +{ + if (pData == NULL || size <= 0) + { + return -1; + } + + unsigned char thisfactors[BYTES_OF_CRY_FACTORS]; + unsigned char tempbuff[BYTES_OF_CRY_FACTORS]; + + memcpy(thisfactors, m_factors, BYTES_OF_CRY_FACTORS); // 拷贝临时的加密因子,做计算用 + + int i, j; + for (i = 0; i < size; i += BYTES_OF_CRY_FACTORS) + { + // 拷贝数据到临时buff + int mv = 0; + for (j = 0; j < BYTES_OF_CRY_FACTORS; j++) + { + if (i+j < size) + { + tempbuff[j] = pData[i+j]; // 拷贝数据 + } + else + { + tempbuff[j] = 0; + } + + mv += thisfactors[j]; // 累加因子,作为移动因子 + } + + // 移动数据 + if (i + BYTES_OF_CRY_FACTORS < size) + { + // 生成移动索引 + unsigned char mvidx[BYTES_OF_CRY_FACTORS]; + int idx, setdidx = BYTES_OF_CRY_FACTORS-1; + for (j = 0; j < BYTES_OF_CRY_FACTORS; j++) + { + idx = (mv >> j) & 0x1f; + for (int k = 0; k < j; k++) + { + if (mvidx[k] == idx) + { + idx = setdidx; + do + { + int kk; + for (kk = 0; kk < j; kk++) + { + if (mvidx[kk] == idx) + { + break; + } + } + if (kk < j) + { + idx--; + } + else + { + setdidx = idx-1; + break; + } + } while(1); + break; + } + } + mvidx[j] = idx; + } + + // 移动数据 + unsigned char tempdat[BYTES_OF_CRY_FACTORS]; + memcpy(tempdat, tempbuff, BYTES_OF_CRY_FACTORS); + + for (j = 0; j < BYTES_OF_CRY_FACTORS; j++) + { + tempbuff[j] = tempdat[mvidx[j]]; + } + } + + // 数据加密 + for (j = 0; i+j < size && j < BYTES_OF_CRY_FACTORS; j++) + { + tempbuff[j] ^= thisfactors[j]; // 异或加密 + pData[i+j] = tempbuff[j]; // 保存 + } + + // 下次的变幻因子 + int temp = 0; + for (j = 0; j < BYTES_OF_CRY_FACTORS; j++) + { + temp += thisfactors[j]; + temp *= 3; + temp += 1; + temp /= 2; + thisfactors[j] = temp; + } + } + + return 0; +} + +// 解密数据 +int DsrCryption::DeCryption(unsigned char * pData, int size) +{ + if (pData == NULL || size <= 0) + { + return -1; + } + + if (pData == NULL || size <= 0) + { + return -1; + } + + unsigned char thisfactors[BYTES_OF_CRY_FACTORS]; + unsigned char tempbuff[BYTES_OF_CRY_FACTORS]; + + memcpy(thisfactors, m_factors, BYTES_OF_CRY_FACTORS); + + int i, j; + for (i = 0; i < size; i += BYTES_OF_CRY_FACTORS) + { + // 拷贝数据到临时buff + int mv = 0; + for (j = 0; j < BYTES_OF_CRY_FACTORS; j++) + { + if (i+j < size) + { + tempbuff[j] = pData[i+j]; // 拷贝数据 + } + else + { + tempbuff[j] = 0; + } + + mv += thisfactors[j]; // 累加因子,作为移动因子 + } + + // 数据解密 + for (j = 0; i+j < size && j < BYTES_OF_CRY_FACTORS; j++) + { + tempbuff[j] ^= thisfactors[j]; + } + + // 数据移动回去 + if (i + BYTES_OF_CRY_FACTORS < size) + { + // 生成移动索引 + unsigned char mvidx[BYTES_OF_CRY_FACTORS]; + int idx, setdidx = BYTES_OF_CRY_FACTORS-1; + for (j = 0; j < BYTES_OF_CRY_FACTORS; j++) + { + idx = (mv >> j) & 0x1f; + for (int k = 0; k < j; k++) + { + if (mvidx[k] == idx) + { + idx = setdidx; + do + { + int kk; + for (kk = 0; kk < j; kk++) + { + if (mvidx[kk] == idx) + { + break; + } + } + if (kk < j) + { + idx--; + } + else + { + setdidx = idx-1; + break; + } + } while(1); + break; + } + } + mvidx[j] = idx; + } + + // 移动数据 + unsigned char tempdat[BYTES_OF_CRY_FACTORS]; + memcpy(tempdat, tempbuff, BYTES_OF_CRY_FACTORS); + + for (j = 0; j < BYTES_OF_CRY_FACTORS; j++) + { + tempbuff[mvidx[j]] = tempdat[j]; + } + } + + // 保存解密数据 + for (j = 0; i+j < size && j < BYTES_OF_CRY_FACTORS; j++) + { + pData[i+j] = tempbuff[j]; // 保存 + } + + // 下次的变幻因子 + int temp = 0; + for (j = 0; j < BYTES_OF_CRY_FACTORS; j++) + { + temp += thisfactors[j]; + temp *= 3; + temp += 1; + temp /= 2; + thisfactors[j] = temp; + } + } + + return 0; +} + +// 生成加密字 +int DsrCryption::CreateCryWord(int version) +{ + if (version < 0 || version > 250) + { + return -1; + } + + int rdw; + if (version == 0) + { + rdw = 0; + } + else + { + QTime time= QTime::currentTime(); + qsrand(time.msec()+time.second()*1000); + rdw = qrand(); // 产生随机数 + } + + m_cryword = rdw & 0xffffff; + m_cryword *= 251; + m_cryword += version; + + return 0; +} + +// 生成加密因子 +int DsrCryption::CreateCryFactors(const unsigned char * factors) +{ + if (factors == NULL) + { + return -1; + } + memcpy(m_factors, factors, BYTES_OF_CRY_FACTORS); + + int * pDat = (int*)m_factors; + + // 变幻加密因子,兼容非加密情况 + for (int i = 0; i < BYTES_OF_CRY_FACTORS; i+=sizeof(int)) + { + *pDat *= m_cryword; + pDat++; + } + return 0; +} + + + + + + + diff --git a/datafile/dsrcryption.h b/datafile/dsrcryption.h new file mode 100644 index 0000000..cc970f7 --- /dev/null +++ b/datafile/dsrcryption.h @@ -0,0 +1,33 @@ +#ifndef DSRCRYPTION_H +#define DSRCRYPTION_H + +#define CRY_VERSION1 0x01 +#define CRY_VERSION2 0x02 + +#define CUR_CRY_VERSION 0x01 // 当前的加密版本(取值范围为 0 -- 250),方便通过版本使用不同的加密方法。 +#define BYTES_OF_CRY_FACTORS 32 // 加密因子字节数 + + +class DsrCryption +{ +public: + DsrCryption(); + +public: + int InitDsrCryptionCtrl(int version, unsigned int cryword, const unsigned char * factors); // 初始化加密控制, 自动生成生成加密字和加密因子 + unsigned int GetDsrCryptionWord(); // 获取加密字 + + int EnCryption(unsigned char * pData, int size); // 加密数据,使用当前的加密字和加密因子 + int DeCryption(unsigned char * pData, int size); // 解密数据,使用当前的加密字和加密因子 + +private: + int CreateCryWord(int version); // 生成加密字 + int CreateCryFactors(const unsigned char * factors); // 生成加密因子 + +private: + int m_initflag; + unsigned int m_cryword; + unsigned char m_factors[BYTES_OF_CRY_FACTORS]; +}; + +#endif // DSRCRYPTION_H diff --git a/datafile/dxf/dxfhelper.cpp b/datafile/dxf/dxfhelper.cpp new file mode 100644 index 0000000..b2000fc --- /dev/null +++ b/datafile/dxf/dxfhelper.cpp @@ -0,0 +1,520 @@ +#include "dxfhelper.h" +#include "dxfreader.h" + +#include +#include + +DxfHelper::DxfHelper() +{ + +} + +double norm(double x, double y) +{ + return sqrt(x * x + y * y); +} + +QList DxfHelper::expandPolygon(QList polygon, float expand) +{ + QList new_polygon; + int len = polygon.length(); + if(len<3||qFuzzyIsNull(expand)) return polygon; + + bool repeatFlag = false; + if(polygon.first()==polygon.back()) { + repeatFlag = true; + polygon.removeLast(); + len = polygon.length(); + } + + int convertNum = 0; + for (int i = 0; i < len; i++) + { + QVector3D p = polygon[i]; + QVector3D p1 = polygon[i == 0 ? len - 1 : i - 1]; + QVector3D p2 = polygon[i == len - 1 ? 0 : i + 1]; + float v1x = p1.x() - p.x(); + float v1y = p1.y() - p.y(); + float n1 = norm(v1x, v1y); + float vv1x = v1x / n1; + float vv1y = v1y / n1; + float v2x = p2.x() - p.x(); + float v2y = p2.y() - p.y(); + float n2 = norm(v2x, v2y); + float vv2x = v2x / n2; + float vv2y = v2y / n2; + float vectorLen = -expand / sqrt((1 - (vv1x * vv2x + vv1y * vv2y)) / 2.0f); + float judge = v1x * v2y - v2x * v1y; + if (judge < 0) vectorLen *= -1; + if (judge < 0) convertNum++; + float vx = vv1x + vv2x; + float vy = vv1y + vv2y; + vectorLen = vectorLen / norm(vx, vy); + vx *= vectorLen; + vy *= vectorLen; + new_polygon.append(QVector3D(vx + p.x(), vy + p.y(), 0)); + } + if(convertNum==len) { + new_polygon.clear(); + for (int i = 0; i < len; i++) + { + QVector3D p = polygon[i]; + QVector3D p1 = polygon[i == 0 ? len - 1 : i - 1]; + QVector3D p2 = polygon[i == len - 1 ? 0 : i + 1]; + float v1x = p1.x() - p.x(); + float v1y = p1.y() - p.y(); + float n1 = norm(v1x, v1y); + float vv1x = v1x / n1; + float vv1y = v1y / n1; + float v2x = p2.x() - p.x(); + float v2y = p2.y() - p.y(); + float n2 = norm(v2x, v2y); + float vv2x = v2x / n2; + float vv2y = v2y / n2; + float vectorLen = -expand / sqrt((1 - (vv1x * vv2x + vv1y * vv2y)) / 2.0f); + float vx = vv1x + vv2x; + float vy = vv1y + vv2y; + vectorLen = vectorLen / norm(vx, vy); + vx *= vectorLen; + vy *= vectorLen; + new_polygon.append(QVector3D(vx + p.x(), vy + p.y(), 0)); + } + } + + if(repeatFlag) new_polygon.append(new_polygon.first()); + + return new_polygon; +} + +bool DxfHelper::generateDxf(const QString &fileName) +{ +// currentPos = QPointF(QRandomGenerator::global()->bounded(9999.99), QRandomGenerator::global()->bounded(9999.99)); + currentPos = QPointF(9999.99, 9999.99); + vertexIndex = 0; + controlIndex = 0; + dxfPaths.clear(); + + DxfReader dxfReader(fileName); + for(auto d: dxfReader.dxfText) { + //qDebug() << "text data:" << d.text.c_str() << d.angle << d.style.c_str() << d.height; + } + + for(auto d: dxfReader.dxfLinetypes) { + //qDebug() << "linetypes data:" << d.name.c_str() << d.flags << d.pattern << d.description.c_str() << d.patternLength << d.numberOfDashes; + } + + QVector linepath; + for(auto d: dxfReader.dxfLines) { + //qDebug() << "line data:" << d.x1 << d.y1 << d.z1 << "," << d.x2 << d.y2 << d.z2; + if(currentPos!=QPointF(d.x1, d.y1)) { + if(!linepath.isEmpty()) { + QList linelist; + foreach(auto point, linepath) linelist.append(QVector3D(point)); + linepath.clear(); + linelist = expandPolygon(linelist, expandOffset); + foreach(QVector3D point, linelist) { + double x = point.x(); + double y = point.y(); + linepath.append(QPointF(x, y)); + currentPos = QPointF(x, y); + } + dxfPaths.append(linepath); + linepath.clear(); + } + linepath.append(QPointF(d.x1, d.y1)); + linepath.append(QPointF(d.x2, d.y2)); + currentPos = QPointF(d.x2, d.y2); + } else { + linepath.append(QPointF(d.x2, d.y2)); + currentPos = QPointF(d.x2, d.y2); + } + } + if(!linepath.isEmpty()) { + QList linelist; + foreach(auto point, linepath) linelist.append(QVector3D(point)); + linepath.clear(); + linelist = expandPolygon(linelist, expandOffset); + foreach(QVector3D point, linelist) { + double x = point.x(); + double y = point.y(); + linepath.append(QPointF(x, y)); + currentPos = QPointF(x, y); + } + dxfPaths.append(linepath); + linepath.clear(); + } + + + for(auto d: dxfReader.dxfArcs) { + //qDebug() << "arcs data:" << d.cx << d.cy << d.cz << d.angle1 << d.angle2 << d.radius; + + + double cx = d.cx; + double cy = d.cy; +// double cz = d.cz; + double angle1 = d.angle1; + double angle2 = d.angle2; + double radius = d.radius; + + radius = radius + expandOffset; + + + QPainterPath path; + double startXPos = cx + cos(abs(angle1)*M_PI/180)*radius; + double startYPos = cy + sin(abs(angle1)*M_PI/180)*radius; + + path.moveTo(startXPos, startYPos); + + double angleStart ,anglePassed; + angleStart = angle1; + if(angleStart>=180) angleStart = angleStart-360; + anglePassed = angleStart-angle2; + if(angleStart<180) angleStart = -angleStart; + if(anglePassed<-360) anglePassed = anglePassed+360; + + QRectF rect(cx-radius, cy-radius, 2*radius, 2*radius); + path.arcTo(rect, angleStart, anglePassed); + + QVector arcpath; + for(double i = 0; i <= 1; i += 0.003) { // TODO: 步长随图片大小调整 + QPointF point = path.pointAtPercent(i); + double x = point.x(); + double y = point.y(); + arcpath.append(point); + currentPos=QPointF(x, y); + } + dxfPaths.append(arcpath); +// dxfPathList.append(path); + } + + for(auto d: dxfReader.dxfCircles) { + //qDebug() << "circle data:" << d.cx << d.cy << d.cz << d.radius; + + + double cx = d.cx; + double cy = d.cy; +// double cz = d.cz; + double radius = d.radius; + + radius = radius + expandOffset; + + + QPainterPath path; + path.moveTo(cx+radius, cy); + path.arcTo(cx-radius, cy-radius, 2*radius, 2*radius, 0, 360); + + QVector circlepath; + for(double i = 0; i <= 1; i += 0.003) { // TODO: 步长随图片大小调整 + QPointF point = path.pointAtPercent(i); + double x = point.x(); + double y = point.y(); + circlepath.append(point); + currentPos=QPointF(x, y); + } + dxfPaths.append(circlepath); +// dxfPathList.append(path); + } + + for(auto d: dxfReader.dxfEllipses) { // 起点角度要×ratio + //qDebug() << "ellipses data:" << d.cx << d.cy << d.cz << d.mx << d.my << d.mz << d.ratio << d.angle1 << d.angle2; + + double cx = d.cx; + double cy = d.cy; +// double cz = d.cz; + double mx = d.mx; + double my = d.my; +// double mz = d.mz; + double ratio = d.ratio; + double angle1 = d.angle1; + double angle2 = d.angle2; + + + double rab = sqrt((cx- mx)*(cx - mx) +(cy - my)*(cy - my)); + double resy = (expandOffset*(my-cy))/rab + my; + double resx = (expandOffset*(mx-cx))/rab + mx; + + mx = resx; + my = resy; + + + QPainterPath path; + double angle_1 = angle1; + double angle_2 = angle2; + while(angle_1>=3.14&&angle_2>=6.28) { + angle_1 -= M_PI; + angle_2 -= M_PI; + } + angle_1 = angle_1*180/M_PI; + angle_2 = angle_2*180/M_PI; + + double angleStart ,anglePassed; + angleStart = angle_1; + if(angleStart>=180) angleStart = angleStart-360; + anglePassed = angleStart-angle_2; + if(angleStart<180) angleStart = -angleStart; + if(anglePassed<-360) anglePassed = anglePassed+360; + + if(abs(anglePassed)<1) anglePassed = 360; + + double c_x = cx; + double c_y = cy; + double dl = sqrt(mx*mx+my*my); + double ds = dl*ratio; + + double rx; + double ry; + if(qFuzzyIsNull(mx)) { + rx = ds; ry = dl; + angleStart += 90; + } else { + rx = dl; ry = ds; + } + + double angle=angleStart; + if(angle<0) angle=-angle; + else if(angle>=0) angle = 360-angle; + //if(!qFuzzyCompare(abs(anglePassed),360)) angle *= ratio; + if(!qFuzzyCompare(float(anglePassed),(float)360)) angle *= ratio; + double a=qDegreesToRadians(angle); + double R=rx*ry/sqrt(pow(rx*sin(a),2)+pow(ry*cos(a),2)); //计算对应角度的半径 + double startXPos=c_x+R*cos(a); + double startYPos=c_y+R*sin(a); + path.moveTo(startXPos, startYPos); + + //qDebug() << c_x << c_y << rx << ry << angleStart << anglePassed << angle; + path.arcTo(c_x-rx, c_y-ry, 2*rx, 2*ry, angleStart, anglePassed); + + QVector ellipsepath; + for(double i = 0; i <= 1; i += 0.003) { // TODO: 步长随图片大小调整 + QPointF point = path.pointAtPercent(i); + double x = point.x(); + double y = point.y(); + ellipsepath.append(point); + currentPos=QPointF(x, y); + } + dxfPaths.append(ellipsepath); +// dxfPathList.append(path); + } + + for(auto d: dxfReader.dxfPolylines) { + //qDebug() << "polylines data:" << d.m << d.n << d.flags << d.number << d.elevation; + + QList pointlist; + QVector path; + for(unsigned int i = 0; i < d.number; i++) { + double x = dxfReader.dxfVertexs.at(vertexIndex).x; + double y = dxfReader.dxfVertexs.at(vertexIndex).y; + double z = dxfReader.dxfVertexs.at(vertexIndex).z; + pointlist.append(QVector3D(x, y, z)); + vertexIndex++; + } + + pointlist = expandPolygon(pointlist, expandOffset); + foreach(QVector3D point, pointlist) { + double x = point.x(); + double y = point.y(); + path.append(QPointF(x, y)); + currentPos = QPointF(x, y); + } + + if(d.flags) { + double x = pointlist.first().x(); + double y = pointlist.first().y(); + path.append(QPointF(x, y)); + currentPos = QPointF(x, y); + } + dxfPaths.append(path); + } + +// for(auto d: dxfReader.dxfVertexs) { +// qDebug() << "vertexs data:" << d.x << d.y << d.z << d.bulge; +// } + + for(auto d: dxfReader.dxfPoints) { + //qDebug() << "points data:" << d.x << d.y << d.z; + QVector path; + path.append(QPointF(d.x, d.y)); + dxfPaths.append(path); + currentPos = QPointF(d.x, d.y); + } + + for(auto d: dxfReader.dxfSplines) { + //qDebug() << "splines data:" << d.nFit << d.flags << d.degree << d.nKnots << d.nControl << d.tangentEndX << d.tangentEndY << d.tangentEndZ << d.tangentStartX << d.tangentStartY << d.tangentStartZ; + std::vector pointList; + for(unsigned int i = 0; i < d.nControl; i++) { + int x = dxfReader.dxfControlPoints.at(controlIndex).x; + int y = dxfReader.dxfControlPoints.at(controlIndex).y; + pointList.push_back(QVector2D(x, y)); + currentPos = QPointF(x, y); + controlIndex++; + } + + QList templist; + foreach(auto point, pointList) templist.append(point); + templist = expandPolygon(templist, expandOffset); + + QVector inputList; + foreach(auto point, templist) inputList.append(point.toVector2D()); + inputList.push_front(inputList.first()); + inputList.push_back(inputList.back()); +// std::vector finalList(inputList.begin(), inputList.end()); + +// SplineHelper splineHelper(finalList, TypeCubicBSpline); +// auto splinePath = splineHelper.getSplinePath(); + +// dxfPaths.append(splinePath); + } + +// for(auto d: dxfReader.dxfControlPoints) { +// qDebug() << "control points data:" << d.w << d.x << d.y << d.z; +// } + +// for(auto d: dxfReader.dxfXLines) { +// qDebug() << "XLines data:" << d.bx << d.by << d.bz << d.dx << d.dy << d.dz; +// } + +// for(auto d: dxfReader.dxfRays) { +// qDebug() << "rays data:" << d.bx << d.by << d.bz << d.dx << d.dy << d.dz; +// } + +// for(auto d: dxfReader.dxfFitPoints) { +// qDebug() << "fit points data:" << d.x << d.y << d.z; +// } + +// for(auto d: dxfReader.dxfHatchs) { +// qDebug() << "hatchs data:" << d.angle << d.scale << d.solid << d.originX << d.originY << d.pattern.c_str() << d.numLoops; +// } + +// for(auto d: dxfReader.dxfHatchLoops) { +// qDebug() << "hatchLoops data:" << d.numEdges; +// } + +// for(auto d: dxfReader.dxfHatchEdges) { +// qDebug() << "hatchEdges data:" << d.cx << d.cy << d.mx << d.my << d.x1 << d.y1 << d.x2 << d.y2 << d.ccw << d.nFit << d.ratio << d.angle1 << d.angle2 << d.degree << d.nKnots << d.radius << d.defined << d.weights << d.nControl << d.periodic << d.rational << d.vertices << d.fitPoints << d.endTangentX << d.endTangentY << d.endTangentY << d.controlPoints << d.startTangentX << d.startTangentY; +// } + + return true; +} + +void DxfHelper::matchDXFSize() +{ + double minx = __DBL_MAX__; + double maxx = __DBL_MIN__; + double miny = __DBL_MAX__; + double maxy = __DBL_MIN__; + foreach (QVector path, dxfPaths) { + for(int i = 0; i < path.length(); i++) { + QPointF point = path.at(i); + double x = point.x(); + double y = point.y(); + if(xmaxx) maxx = x; + if(ymaxy) maxy = y; + } + } + int width = maxx - minx; + int height = maxy - miny; + imageSize = QSize(width, height); + dxfBorderList.clear(); + dxfBorderList.append(minx); + dxfBorderList.append(miny); + dxfBorderList.append(maxx); + dxfBorderList.append(maxy); +} + +QImage DxfHelper::generateDXFImage() +{ + matchDXFSize(); + double minx = dxfBorderList.at(0); + double miny = dxfBorderList.at(1); + int penwidth = imageSize.width()/400; + int border = penwidth; + QImage image((imageSize.width()+2*border), (imageSize.height()+2*border), QImage::Format_ARGB32); + image.fill(Qt::white); + QPainter p(&image); + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); // 抗锯齿和使用平滑转换算法 + QPen pen; + if(penwidth<1) penwidth = 1; + pen.setWidth(penwidth); + pen.setColor(Qt::black); + p.setPen(pen); + QPainterPath painterpath; + foreach (QVector path, dxfPaths) { + for(int i = 0; i < path.length(); i++) { + double x = path.at(i).x()-minx; + double y = path.at(i).y()-miny; + y = imageSize.height()-y; + x += border; + y += border; + QPointF point(x, y); + if(i == 0) painterpath.moveTo(point); + else painterpath.lineTo(point); + } +// dxfPathList.append(painterpath); + } + //qDebug() << "[" << __FILE__ << ":" << __LINE__ << "]\t"<< "dxf path length:" < DxfHelper::getDxfBorderList() const +{ + return dxfBorderList; +} + +QSize DxfHelper::getImageSize() const +{ + return imageSize; +} + +QList DxfHelper::getDxfPathList() const +{ + return dxfPathList; +} + +QVector > DxfHelper::getDxfPaths() const +{ + return dxfPaths; +} + +QList DxfHelper::getDxfLineList() const +{ + return dxfLineList; +} + +QList DxfHelper::getDxfRectList() const +{ + return dxfRectList; +} + +QList DxfHelper::getDxfArcList() const +{ + return dxfArcList; +} + +QList DxfHelper::getDxfCircleList() const +{ + return dxfCircleList; +} + +QList DxfHelper::getDxfEllipseList() const +{ + return dxfEllipseList; +} + +QList DxfHelper::getDxfPolylineList() const +{ + return dxfPolylineList; +} + +QList DxfHelper::getDxfSplineList() const +{ + return dxfSplineList; +} + +void DxfHelper::setExpandOffset(double value) +{ + expandOffset = value; +} diff --git a/datafile/dxf/dxfhelper.h b/datafile/dxf/dxfhelper.h new file mode 100644 index 0000000..14e160a --- /dev/null +++ b/datafile/dxf/dxfhelper.h @@ -0,0 +1,110 @@ +#ifndef DXFHELPER_H +#define DXFHELPER_H + +#include +//#include +#include +#include +#include +#include +#include +//#include + +struct DXFLine { + double x1; + double y1; + double z1; + double x2; + double y2; + double z2; +}; + +struct DXFRect { + QList list; +}; + + +struct DXFArc { + double cx; + double cy; + double cz; + double angle1; + double angle2; + double radius; +}; + +struct DXFCircle { + double cx; + double cy; + double cz; + double radius; +}; + +struct DXFEllipse { + double cx; + double cy; + double cz; + double mx; + double my; + double mz; + double angle1; + double angle2; + double ratio; +}; + +struct DXFPolyline { + double flags; + double number; + QList list; +}; + +struct DXFSpline { + double nControl; + QList controlPoints; +}; + + +class DxfHelper +{ +public: + DxfHelper(); + QList expandPolygon(QList polygon, float expand); + bool generateDxf(const QString &fileName); + QVector> getDxfPaths() const; + + QList getDxfLineList() const; + QList getDxfRectList() const; + QList getDxfArcList() const; + QList getDxfCircleList() const; + QList getDxfEllipseList() const; + QList getDxfPolylineList() const; + QList getDxfSplineList() const; + + void setExpandOffset(double value); + + void matchDXFSize(); + QImage generateDXFImage(); + QList getDxfPathList() const; + QSize getImageSize() const; + QList getDxfBorderList() const; +private: + QPointF currentPos; + unsigned int vertexIndex = 0; + unsigned int controlIndex = 0; + QVector> dxfPaths; + QList dxfPathList; + + double expandOffset = 0; + + QList dxfLineList; + QList dxfRectList; + QList dxfArcList; + QList dxfCircleList; + QList dxfEllipseList; + QList dxfPolylineList; + QList dxfSplineList; + QList dxfBorderList; + QSize imageSize; +}; + +#endif // DXFHELPER_H diff --git a/datafile/dxf/dxflib/dl_attributes.h b/datafile/dxf/dxflib/dl_attributes.h new file mode 100644 index 0000000..00f9ddc --- /dev/null +++ b/datafile/dxf/dxflib/dl_attributes.h @@ -0,0 +1,237 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef DL_ATTRIBUTES_H +#define DL_ATTRIBUTES_H + +#include "dl_global.h" + +#include +#include + +#include "dl_codes.h" + +/** + * Storing and passing around attributes. Attributes + * are the layer name, color, width and line type. + * + * @author Andrew Mustun + */ +class DXFLIB_EXPORT DL_Attributes { + +public: + + /** + * Default constructor. + */ + DL_Attributes() : + layer(""), + color(0), + color24(-1), + width(0), + linetype("BYLAYER"), + linetypeScale(1.0), + handle(-1), + inPaperSpace(false) { + } + + /** + * Constructor for DXF attributes. + * + * @param layer Layer name for this entity or NULL for no layer + * (every entity should be on a named layer!). + * @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER. + * @param width Line thickness. Defaults to zero. -1 = BYLAYER, + * -2 = BYBLOCK, -3 = default width + * @param linetype Line type name or "BYLAYER" or "BYBLOCK". Defaults + * to "BYLAYER" + */ + DL_Attributes(const std::string& layer, + int color, int width, + const std::string& linetype, + double linetypeScale) : + layer(layer), + color(color), + color24(-1), + width(width), + linetype(linetype), + linetypeScale(linetypeScale), + handle(-1), + inPaperSpace(false) { + + } + + /** + * Constructor for DXF attributes. + * + * @param layer Layer name for this entity or NULL for no layer + * (every entity should be on a named layer!). + * @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER. + * @param color24 24 bit color (0x00RRGGBB, see DXF reference). + * @param width Line thickness. Defaults to zero. -1 = BYLAYER, + * -2 = BYBLOCK, -3 = default width + * @param linetype Line type name or "BYLAYER" or "BYBLOCK". Defaults + * to "BYLAYER" + */ + DL_Attributes(const std::string& layer, + int color, int color24, int width, + const std::string& linetype, + int handle=-1) : + layer(layer), + color(color), + color24(color24), + width(width), + linetype(linetype), + linetypeScale(1.0), + handle(handle), + inPaperSpace(false) { + } + + /** + * Sets the layer. If the given pointer points to NULL, the + * new layer name will be an empty but valid string. + */ + void setLayer(const std::string& layer) { + this->layer = layer; + } + + /** + * @return Layer name. + */ + std::string getLayer() const { + return layer; + } + + /** + * Sets the color. + * + * @see DL_Codes, dxfColors + */ + void setColor(int color) { + this->color = color; + } + + /** + * Sets the 24bit color. + * + * @see DL_Codes, dxfColors + */ + void setColor24(int color) { + this->color24 = color; + } + + /** + * @return Color. + * + * @see DL_Codes, dxfColors + */ + int getColor() const { + return color; + } + + /** + * @return 24 bit color or -1 if no 24bit color is defined. + * + * @see DL_Codes, dxfColors + */ + int getColor24() const { + return color24; + } + + /** + * Sets the width. + */ + void setWidth(int width) { + this->width = width; + } + + /** + * @return Width. + */ + int getWidth() const { + return width; + } + + /** + * Sets the line type. This can be any string and is not + * checked to be a valid line type. + */ + void setLinetype(const std::string& linetype) { + this->linetype = linetype; + } + + /** + * Sets the entity specific line type scale. + */ + void setLinetypeScale(double linetypeScale) { + this->linetypeScale = linetypeScale; + } + + double getLinetypeScale() const { + return linetypeScale; + } + + /** + * @return Line type. + */ + std::string getLinetype() const { + if (linetype.length()==0) { + return "BYLAYER"; + } else { + return linetype; + } + } + + void setHandle(int h) { + handle = h; + } + + int getHandle() const { + return handle; + } + + void setInPaperSpace(bool on) { + inPaperSpace = on; + } + + bool isInPaperSpace() const { + return inPaperSpace; + } + +private: + std::string layer; + int color; + int color24; + int width; + std::string linetype; + double linetypeScale; + int handle; + + // DXF code 67 (true: entity in paper space, false: entity in model space (default): + bool inPaperSpace; +}; + +#endif + +// EOF diff --git a/datafile/dxf/dxflib/dl_codes.h b/datafile/dxf/dxflib/dl_codes.h new file mode 100644 index 0000000..99ae5b6 --- /dev/null +++ b/datafile/dxf/dxflib/dl_codes.h @@ -0,0 +1,546 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** Copyright (C) 2001 Robert J. Campbell Jr. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +/** + * Defines common DXF codes and constants. + */ + +#ifndef DXF_CODES_H +#define DXF_CODES_H + +#include "dl_global.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +//#if defined(__OS2__)||defined(__EMX__) +//#define strcasecmp(s,t) stricmp(s,t) +//#endif + +//#if defined(_WIN32) +//#define strcasecmp(s,t) _stricmp(s,t) +//#endif + + +#ifdef _WIN32 +#undef M_PI +#define M_PI 3.14159265358979323846 +//#pragma warning(disable : 4800) +#endif + +#ifndef M_PI +#define M_PI 3.1415926535897932384626433832795 +#endif + +#define DL_DXF_MAXLINE 1024 +#define DL_DXF_MAXGROUPCODE 1100 + +// used to mark invalid vectors: +//#define DL_DXF_MAXDOUBLE 1.0E+10 + +/** + * Codes for colors and DXF versions. + */ +class DXFLIB_EXPORT DL_Codes { +public: + /** + * Standard DXF colors. + */ + enum color { + black = 250, + green = 3, + red = 1, + brown = 15, + yellow = 2, + cyan = 4, + magenta = 6, + gray = 8, + blue = 5, + l_blue = 163, + l_green = 121, + l_cyan = 131, + l_red = 23, + l_magenta = 221, + l_gray = 252, + white = 7, + bylayer = 256, + byblock = 0 + }; + + /** + * Version numbers for the DXF Format. + */ + enum version { + AC1009_MIN, // R12, minimalistic + AC1009, // R12 + AC1012, + AC1014, + AC1015 // R2000 + }; +}; + + +// Extended color palette: +// The first entry is only for direct indexing starting with [1] +// Color 1 is red (1,0,0) +const double dxfColors[][3] = { + {0,0,0}, // unused + {1,0,0}, // 1 + {1,1,0}, + {0,1,0}, + {0,1,1}, + {0,0,1}, + {1,0,1}, + {1,1,1}, // black or white + {0.5,0.5,0.5}, + {0.75,0.75,0.75}, + {1,0,0}, // 10 + {1,0.5,0.5}, + {0.65,0,0}, + {0.65,0.325,0.325}, + {0.5,0,0}, + {0.5,0.25,0.25}, + {0.3,0,0}, + {0.3,0.15,0.15}, + {0.15,0,0}, + {0.15,0.075,0.075}, + {1,0.25,0}, // 20 + {1,0.625,0.5}, + {0.65,0.1625,0}, + {0.65,0.4063,0.325}, + {0.5,0.125,0}, + {0.5,0.3125,0.25}, + {0.3,0.075,0}, + {0.3,0.1875,0.15}, + {0.15,0.0375,0}, + {0.15,0.0938,0.075}, + {1,0.5,0}, // 30 + {1,0.75,0.5}, + {0.65,0.325,0}, + {0.65,0.4875,0.325}, + {0.5,0.25,0}, + {0.5,0.375,0.25}, + {0.3,0.15,0}, + {0.3,0.225,0.15}, + {0.15,0.075,0}, + {0.15,0.1125,0.075}, + {1,0.75,0}, // 40 + {1,0.875,0.5}, + {0.65,0.4875,0}, + {0.65,0.5688,0.325}, + {0.5,0.375,0}, + {0.5,0.4375,0.25}, + {0.3,0.225,0}, + {0.3,0.2625,0.15}, + {0.15,0.1125,0}, + {0.15,0.1313,0.075}, + {1,1,0}, // 50 + {1,1,0.5}, + {0.65,0.65,0}, + {0.65,0.65,0.325}, + {0.5,0.5,0}, + {0.5,0.5,0.25}, + {0.3,0.3,0}, + {0.3,0.3,0.15}, + {0.15,0.15,0}, + {0.15,0.15,0.075}, + {0.75,1,0}, // 60 + {0.875,1,0.5}, + {0.4875,0.65,0}, + {0.5688,0.65,0.325}, + {0.375,0.5,0}, + {0.4375,0.5,0.25}, + {0.225,0.3,0}, + {0.2625,0.3,0.15}, + {0.1125,0.15,0}, + {0.1313,0.15,0.075}, + {0.5,1,0}, // 70 + {0.75,1,0.5}, + {0.325,0.65,0}, + {0.4875,0.65,0.325}, + {0.25,0.5,0}, + {0.375,0.5,0.25}, + {0.15,0.3,0}, + {0.225,0.3,0.15}, + {0.075,0.15,0}, + {0.1125,0.15,0.075}, + {0.25,1,0}, // 80 + {0.625,1,0.5}, + {0.1625,0.65,0}, + {0.4063,0.65,0.325}, + {0.125,0.5,0}, + {0.3125,0.5,0.25}, + {0.075,0.3,0}, + {0.1875,0.3,0.15}, + {0.0375,0.15,0}, + {0.0938,0.15,0.075}, + {0,1,0}, // 90 + {0.5,1,0.5}, + {0,0.65,0}, + {0.325,0.65,0.325}, + {0,0.5,0}, + {0.25,0.5,0.25}, + {0,0.3,0}, + {0.15,0.3,0.15}, + {0,0.15,0}, + {0.075,0.15,0.075}, + {0,1,0.25}, // 100 + {0.5,1,0.625}, + {0,0.65,0.1625}, + {0.325,0.65,0.4063}, + {0,0.5,0.125}, + {0.25,0.5,0.3125}, + {0,0.3,0.075}, + {0.15,0.3,0.1875}, + {0,0.15,0.0375}, + {0.075,0.15,0.0938}, + {0,1,0.5}, // 110 + {0.5,1,0.75}, + {0,0.65,0.325}, + {0.325,0.65,0.4875}, + {0,0.5,0.25}, + {0.25,0.5,0.375}, + {0,0.3,0.15}, + {0.15,0.3,0.225}, + {0,0.15,0.075}, + {0.075,0.15,0.1125}, + {0,1,0.75}, // 120 + {0.5,1,0.875}, + {0,0.65,0.4875}, + {0.325,0.65,0.5688}, + {0,0.5,0.375}, + {0.25,0.5,0.4375}, + {0,0.3,0.225}, + {0.15,0.3,0.2625}, + {0,0.15,0.1125}, + {0.075,0.15,0.1313}, + {0,1,1}, // 130 + {0.5,1,1}, + {0,0.65,0.65}, + {0.325,0.65,0.65}, + {0,0.5,0.5}, + {0.25,0.5,0.5}, + {0,0.3,0.3}, + {0.15,0.3,0.3}, + {0,0.15,0.15}, + {0.075,0.15,0.15}, + {0,0.75,1}, // 140 + {0.5,0.875,1}, + {0,0.4875,0.65}, + {0.325,0.5688,0.65}, + {0,0.375,0.5}, + {0.25,0.4375,0.5}, + {0,0.225,0.3}, + {0.15,0.2625,0.3}, + {0,0.1125,0.15}, + {0.075,0.1313,0.15}, + {0,0.5,1}, // 150 + {0.5,0.75,1}, + {0,0.325,0.65}, + {0.325,0.4875,0.65}, + {0,0.25,0.5}, + {0.25,0.375,0.5}, + {0,0.15,0.3}, + {0.15,0.225,0.3}, + {0,0.075,0.15}, + {0.075,0.1125,0.15}, + {0,0.25,1}, // 160 + {0.5,0.625,1}, + {0,0.1625,0.65}, + {0.325,0.4063,0.65}, + {0,0.125,0.5}, + {0.25,0.3125,0.5}, + {0,0.075,0.3}, + {0.15,0.1875,0.3}, + {0,0.0375,0.15}, + {0.075,0.0938,0.15}, + {0,0,1}, // 170 + {0.5,0.5,1}, + {0,0,0.65}, + {0.325,0.325,0.65}, + {0,0,0.5}, + {0.25,0.25,0.5}, + {0,0,0.3}, + {0.15,0.15,0.3}, + {0,0,0.15}, + {0.075,0.075,0.15}, + {0.25,0,1}, // 180 + {0.625,0.5,1}, + {0.1625,0,0.65}, + {0.4063,0.325,0.65}, + {0.125,0,0.5}, + {0.3125,0.25,0.5}, + {0.075,0,0.3}, + {0.1875,0.15,0.3}, + {0.0375,0,0.15}, + {0.0938,0.075,0.15}, + {0.5,0,1}, // 190 + {0.75,0.5,1}, + {0.325,0,0.65}, + {0.4875,0.325,0.65}, + {0.25,0,0.5}, + {0.375,0.25,0.5}, + {0.15,0,0.3}, + {0.225,0.15,0.3}, + {0.075,0,0.15}, + {0.1125,0.075,0.15}, + {0.75,0,1}, // 200 + {0.875,0.5,1}, + {0.4875,0,0.65}, + {0.5688,0.325,0.65}, + {0.375,0,0.5}, + {0.4375,0.25,0.5}, + {0.225,0,0.3}, + {0.2625,0.15,0.3}, + {0.1125,0,0.15}, + {0.1313,0.075,0.15}, + {1,0,1}, // 210 + {1,0.5,1}, + {0.65,0,0.65}, + {0.65,0.325,0.65}, + {0.5,0,0.5}, + {0.5,0.25,0.5}, + {0.3,0,0.3}, + {0.3,0.15,0.3}, + {0.15,0,0.15}, + {0.15,0.075,0.15}, + {1,0,0.75}, // 220 + {1,0.5,0.875}, + {0.65,0,0.4875}, + {0.65,0.325,0.5688}, + {0.5,0,0.375}, + {0.5,0.25,0.4375}, + {0.3,0,0.225}, + {0.3,0.15,0.2625}, + {0.15,0,0.1125}, + {0.15,0.075,0.1313}, + {1,0,0.5}, // 230 + {1,0.5,0.75}, + {0.65,0,0.325}, + {0.65,0.325,0.4875}, + {0.5,0,0.25}, + {0.5,0.25,0.375}, + {0.3,0,0.15}, + {0.3,0.15,0.225}, + {0.15,0,0.075}, + {0.15,0.075,0.1125}, + {1,0,0.25}, // 240 + {1,0.5,0.625}, + {0.65,0,0.1625}, + {0.65,0.325,0.4063}, + {0.5,0,0.125}, + {0.5,0.25,0.3125}, + {0.3,0,0.075}, + {0.3,0.15,0.1875}, + {0.15,0,0.0375}, + {0.15,0.075,0.0938}, + {0.33,0.33,0.33}, // 250 + {0.464,0.464,0.464}, + {0.598,0.598,0.598}, + {0.732,0.732,0.732}, + {0.866,0.866,0.866}, + {1,1,1} // 255 + } + ; + + +// AutoCAD VERSION aliases +#define DL_VERSION_R12 DL_Codes::AC1009 +#define DL_VERSION_LT2 DL_Codes::AC1009 +#define DL_VERSION_R13 DL_Codes::AC1012 // not supported yet +#define DL_VERSION_LT95 DL_Codes::AC1012 // not supported yet +#define DL_VERSION_R14 DL_Codes::AC1014 // not supported yet +#define DL_VERSION_LT97 DL_Codes::AC1014 // not supported yet +#define DL_VERSION_LT98 DL_Codes::AC1014 // not supported yet +#define DL_VERSION_2000 DL_Codes::AC1015 +#define DL_VERSION_2002 DL_Codes::AC1015 + + +// DXF Group Codes: + +// Strings +#define DL_STRGRP_START 0 +#define DL_STRGRP_END 9 + +// Coordinates +#define DL_CRDGRP_START 10 +#define DL_CRDGRP_END 19 + +// Real values +#define DL_RLGRP_START 38 +#define DL_RLGRP_END 59 + +// Short integer values +#define DL_SHOGRP_START 60 +#define DL_SHOGRP_END 79 + +// New in Release 13, +#define DL_SUBCLASS 100 + +// More coordinates +#define DL_CRD2GRP_START 210 +#define DL_CRD2GRP_END 239 + +// Extended data strings +#define DL_ESTRGRP_START 1000 +#define DL_ESTRGRP_END 1009 + +// Extended data reals +#define DL_ERLGRP_START 1010 +#define DL_ERLGRP_END 1059 + + +#define DL_Y8_COORD_CODE 28 +#define DL_Z0_COORD_CODE 30 +#define DL_Z8_COORD_CODE 38 + +#define DL_POINT_COORD_CODE 10 +#define DL_INSERT_COORD_CODE 10 + +#define DL_CRD2GRP_START 210 +#define DL_CRD2GRP_END 239 + +#define DL_THICKNESS 39 +#define DL_FIRST_REAL_CODE THICKNESS +#define DL_LAST_REAL_CODE 59 +#define DL_FIRST_INT_CODE 60 +#define DL_ATTFLAGS_CODE 70 +#define DL_PLINE_FLAGS_CODE 70 +#define DL_LAYER_FLAGS_CODE 70 +#define DL_FLD_LEN_CODE 73 // Inside ATTRIB resbuf +#define DL_LAST_INT_CODE 79 +#define DL_X_EXTRU_CODE 210 +#define DL_Y_EXTRU_CODE 220 +#define DL_Z_EXTRU_CODE 230 +#define DL_COMMENT_CODE 999 + +// Start and endpoints of a line +#define DL_LINE_START_CODE 10 // Followed by x coord +#define DL_LINE_END_CODE 11 // Followed by x coord + +// Some codes used by blocks +#define DL_BLOCK_FLAGS_CODE 70 // An int containing flags +#define DL_BLOCK_BASE_CODE 10 // Origin of block definition +#define DL_XREF_DEPENDENT 16 // If a block contains an XREF +#define DL_XREF_RESOLVED 32 // If a XREF resolved ok +#define DL_REFERENCED 64 // If a block is ref'd in DWG + +#define DL_XSCALE_CODE 41 +#define DL_YSCALE_CODE 42 +#define DL_ANGLE_CODE 50 +#define DL_INS_POINT_CODE 10 // Followed by x of ins pnt +#define DL_NAME2_CODE 3 // Second appearance of name + +// Some codes used by circle entities +#define DL_CENTER_CODE 10 // Followed by x of center +#define DL_RADIUS_CODE 40 // Followd by radius of circle + +#define DL_COND_OP_CODE -4 // Conditional op,ads_ssget + +// When using ads_buildlist you MUST use RTDXF0 instead of these +#define DL_ENTITY_TYPE_CODE 0 // Then there is LINE, 3DFACE.. +#define DL_SES_CODE 0 // Start End String Code +#define DL_FILE_SEP_CODE 0 // File separator +#define DL_SOT_CODE 0 // Start Of Table +#define DL_TEXTVAL_CODE 1 +#define DL_NAME_CODE 2 +#define DL_BLOCK_NAME_CODE 2 +#define DL_SECTION_NAME_CODE 2 +#define DL_ENT_HAND_CODE 5 // What follows is hexa string +#define DL_TXT_STYLE_CODE 7 // Inside attributes +#define DL_LAYER_NAME_CODE 8 // What follows is layer name +#define DL_FIRST_XCOORD_CODE 10 // Group code x of 1st coord +#define DL_FIRST_YCOORD_CODE 20 // Group code y of 1st coord +#define DL_FIRST_ZCOORD_CODE 30 // Group code z of 1st coord +#define DL_L_START_CODE 10 +#define DL_L_END_CODE 11 +#define DL_TXTHI_CODE 40 +#define DL_SCALE_X_CODE 41 +#define DL_SCALE_Y_CODE 42 +#define DL_SCALE_Z_CODE 43 +#define DL_BULGE_CODE 42 // Used in PLINE verts for arcs +#define DL_ROTATION_CODE 50 +#define DL_COLOUR_CODE 62 // What follows is a color int +#define DL_LTYPE_CODE 6 // What follows is a linetype + + +// Attribute flags +#define DL_ATTS_FOLLOW_CODE 66 +#define DL_ATT_TAG_CODE 2 +#define DL_ATT_VAL_CODE 1 +#define DL_ATT_FLAGS_CODE 70 // 4 1 bit flags as follows... +#define DL_ATT_INVIS_FLAG 1 +#define DL_ATT_CONST_FLAG 2 +#define DL_ATT_VERIFY_FLAG 4 // Prompt and verify +#define DL_ATT_PRESET_FLAG 8 // No prompt and no verify + +// PLINE defines +// Flags +#define DL_OPEN_PLINE 0x00 +#define DL_CLOSED_PLINE 0x01 +#define DL_POLYLINE3D 0x80 +#define DL_PFACE_MESH 0x40 +#define DL_PGON_MESH 0x10 +// Vertices follow entity, required in POLYLINES +#define DL_VERTS_FOLLOW_CODE 66 // Value should always be 1 +#define DL_VERTEX_COORD_CODE 10 + + +// LAYER flags +#define DL_FROZEN 1 +#define DL_FROZEN_BY_DEF 2 +#define DL_LOCKED 4 +#define DL_OBJECT_USED 64 // Object is ref'd in the dwg + +#define DL_BLOCK_EN_CODE -2 // Block entity definition +#define DL_E_NAME -1 // Entity name + +// Extended data codes +#define DL_EXTD_SENTINEL (-3) +#define DL_EXTD_STR 1000 +#define DL_EXTD_APP_NAME 1001 +#define DL_EXTD_CTL_STR 1002 +#define DL_EXTD_LYR_STR 1003 +#define DL_EXTD_CHUNK 1004 +#define DL_EXTD_HANDLE 1005 +#define DL_EXTD_POINT 1010 +#define DL_EXTD_POS 1011 +#define DL_EXTD_DISP 1012 +#define DL_EXTD_DIR 1013 +#define DL_EXTD_FLOAT 1040 +#define DL_EXTD_DIST 1041 +#define DL_EXTD_SCALE 1042 +#define DL_EXTD_INT16 1070 +#define DL_EXTD_INT32 1071 + +// UCS codes for use in ads_trans +#define DL_WCS_TRANS_CODE 0 +#define DL_UCS_TRANS_CODE 1 +#define DL_DCS_TRANS_CODE 2 +#define DL_PCS_TRANS_CODE 3 + +#endif + diff --git a/datafile/dxf/dxflib/dl_creationadapter.h b/datafile/dxf/dxflib/dl_creationadapter.h new file mode 100644 index 0000000..0d12ead --- /dev/null +++ b/datafile/dxf/dxflib/dl_creationadapter.h @@ -0,0 +1,138 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef DL_CREATIONADAPTER_H +#define DL_CREATIONADAPTER_H + +#include "dl_global.h" + +#include "dl_creationinterface.h" + +/** + * An abstract adapter class for receiving DXF events when a DXF file is being read. + * The methods in this class are empty. This class exists as convenience for creating + * listener objects. + * + * @author Andrew Mustun + */ +class DXFLIB_EXPORT DL_CreationAdapter : public DL_CreationInterface { +public: + DL_CreationAdapter() {} + virtual ~DL_CreationAdapter() {} + virtual void processCodeValuePair(unsigned int, const std::string&) {} + virtual void endSection() {} + virtual void addLayer(const DL_LayerData&) {} + virtual void addLinetype(const DL_LinetypeData&) {} + virtual void addLinetypeDash(double) {} + virtual void addBlock(const DL_BlockData&) {} + virtual void endBlock() {} + virtual void addTextStyle(const DL_StyleData&) {} + virtual void addPoint(const DL_PointData&) {} + virtual void addLine(const DL_LineData&) {} + virtual void addXLine(const DL_XLineData&) {} + virtual void addRay(const DL_RayData&) {} + + virtual void addArc(const DL_ArcData&) {} + virtual void addCircle(const DL_CircleData&) {} + virtual void addEllipse(const DL_EllipseData&) {} + + virtual void addPolyline(const DL_PolylineData&) {} + virtual void addVertex(const DL_VertexData&) {} + + virtual void addSpline(const DL_SplineData&) {} + virtual void addControlPoint(const DL_ControlPointData&) {} + virtual void addFitPoint(const DL_FitPointData&) {} + virtual void addKnot(const DL_KnotData&) {} + + virtual void addInsert(const DL_InsertData&) {} + + virtual void addMText(const DL_MTextData&) {} + virtual void addMTextChunk(const std::string&) {} + virtual void addText(const DL_TextData&) {} + virtual void addArcAlignedText(const DL_ArcAlignedTextData&) {} + virtual void addAttribute(const DL_AttributeData&) {} + + virtual void addDimAlign(const DL_DimensionData&, + const DL_DimAlignedData&) {} + virtual void addDimLinear(const DL_DimensionData&, + const DL_DimLinearData&) {} + virtual void addDimRadial(const DL_DimensionData&, + const DL_DimRadialData&) {} + virtual void addDimDiametric(const DL_DimensionData&, + const DL_DimDiametricData&) {} + virtual void addDimAngular(const DL_DimensionData&, + const DL_DimAngularData&) {} + virtual void addDimAngular3P(const DL_DimensionData&, + const DL_DimAngular3PData&) {} + virtual void addDimOrdinate(const DL_DimensionData&, + const DL_DimOrdinateData&) {} + virtual void addLeader(const DL_LeaderData&) {} + virtual void addLeaderVertex(const DL_LeaderVertexData&) {} + + virtual void addHatch(const DL_HatchData&) {} + + virtual void addTrace(const DL_TraceData&) {} + virtual void add3dFace(const DL_3dFaceData&) {} + virtual void addSolid(const DL_SolidData&) {} + + virtual void addImage(const DL_ImageData&) {} + virtual void linkImage(const DL_ImageDefData&) {} + virtual void addHatchLoop(const DL_HatchLoopData&) {} + virtual void addHatchEdge(const DL_HatchEdgeData&) {} + + virtual void addXRecord(const std::string&) {} + virtual void addXRecordString(int, const std::string&) {} + virtual void addXRecordReal(int, double) {} + virtual void addXRecordInt(int, int) {} + virtual void addXRecordBool(int, bool) {} + + virtual void addXDataApp(const std::string&) {} + virtual void addXDataString(int, const std::string&) {} + virtual void addXDataReal(int, double) {} + virtual void addXDataInt(int, int) {} + + virtual void addDictionary(const DL_DictionaryData&) {} + virtual void addDictionaryEntry(const DL_DictionaryEntryData&) {} + + virtual void endEntity() {} + + virtual void addComment(const std::string&) {} + + virtual void setVariableVector(const std::string&, double, double, double, int) {} + virtual void setVariableString(const std::string&, const std::string&, int) {} + virtual void setVariableInt(const std::string&, int, int) {} + virtual void setVariableDouble(const std::string&, double, int) {} +#ifdef DL_COMPAT + virtual void setVariableVector(const char*, double, double, double, int) {} + virtual void setVariableString(const char*, const char*, int) {} + virtual void setVariableInt(const char*, int, int) {} + virtual void setVariableDouble(const char*, double, int) {} + virtual void processCodeValuePair(unsigned int, char*) {} + virtual void addComment(const char*) {} + virtual void addMTextChunk(const char*) {} +#endif + virtual void endSequence() {} +}; + +#endif diff --git a/datafile/dxf/dxflib/dl_creationinterface.h b/datafile/dxf/dxflib/dl_creationinterface.h new file mode 100644 index 0000000..81bde52 --- /dev/null +++ b/datafile/dxf/dxflib/dl_creationinterface.h @@ -0,0 +1,369 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef DL_CREATIONINTERFACE_H +#define DL_CREATIONINTERFACE_H + +#include "dl_global.h" + +#include + +#include "dl_attributes.h" +#include "dl_codes.h" +#include "dl_entities.h" +#include "dl_extrusion.h" + +/** + * Abstract class (interface) for the creation of new entities. + * Inherit your class which takes care of the entities in the + * processed DXF file from this interface. + * + * Double arrays passed to your implementation contain 3 double + * values for x, y, z coordinates unless stated differently. + * + * @author Andrew Mustun + */ +class DXFLIB_EXPORT DL_CreationInterface { +public: + DL_CreationInterface() { + extrusion = new DL_Extrusion; + } + virtual ~DL_CreationInterface() { + delete extrusion; + } + + /** + * Called for every code / value tuple of the DXF file. The complete DXF file + * contents can be handled by the implemetation of this function. + */ + virtual void processCodeValuePair(unsigned int groupCode, const std::string& groupValue) = 0; + + /** + * Called when a section (entity, table entry, etc.) is finished. + */ + virtual void endSection() = 0; + + /** + * Called for every layer. + */ + virtual void addLayer(const DL_LayerData& data) = 0; + + /** + * Called for every linetype. + */ + virtual void addLinetype(const DL_LinetypeData& data) = 0; + + /** + * Called for every dash in linetype pattern + */ + virtual void addLinetypeDash(double length) = 0; + + /** + * Called for every block. Note: all entities added after this + * command go into this block until endBlock() is called. + * + * @see endBlock() + */ + virtual void addBlock(const DL_BlockData& data) = 0; + + /** Called to end the current block */ + virtual void endBlock() = 0; + + /** Called for every text style */ + virtual void addTextStyle(const DL_StyleData& data) = 0; + + /** Called for every point */ + virtual void addPoint(const DL_PointData& data) = 0; + + /** Called for every line */ + virtual void addLine(const DL_LineData& data) = 0; + + /** Called for every xline */ + virtual void addXLine(const DL_XLineData& data) = 0; + + /** Called for every ray */ + virtual void addRay(const DL_RayData& data) = 0; + + /** Called for every arc */ + virtual void addArc(const DL_ArcData& data) = 0; + + /** Called for every circle */ + virtual void addCircle(const DL_CircleData& data) = 0; + + /** Called for every ellipse */ + virtual void addEllipse(const DL_EllipseData& data) = 0; + + /** Called for every polyline start */ + virtual void addPolyline(const DL_PolylineData& data) = 0; + + /** Called for every polyline vertex */ + virtual void addVertex(const DL_VertexData& data) = 0; + + /** Called for every spline */ + virtual void addSpline(const DL_SplineData& data) = 0; + + /** Called for every spline control point */ + virtual void addControlPoint(const DL_ControlPointData& data) = 0; + + /** Called for every spline fit point */ + virtual void addFitPoint(const DL_FitPointData& data) = 0; + + /** Called for every spline knot value */ + virtual void addKnot(const DL_KnotData& data) = 0; + + /** Called for every insert. */ + virtual void addInsert(const DL_InsertData& data) = 0; + + /** Called for every trace start */ + virtual void addTrace(const DL_TraceData& data) = 0; + + /** Called for every 3dface start */ + virtual void add3dFace(const DL_3dFaceData& data) = 0; + + /** Called for every solid start */ + virtual void addSolid(const DL_SolidData& data) = 0; + + + /** Called for every multi Text entity. */ + virtual void addMText(const DL_MTextData& data) = 0; + + /** + * Called for additional text chunks for MTEXT entities. + * The chunks come at 250 character in size each. Note that + * those chunks come before the actual MTEXT entity. + */ + virtual void addMTextChunk(const std::string& text) = 0; + + /** Called for every text entity. */ + virtual void addText(const DL_TextData& data) = 0; + + /** Called for every arc aligned text entity. */ + virtual void addArcAlignedText(const DL_ArcAlignedTextData& data) = 0; + + /** Called for every block Attribute entity. */ + virtual void addAttribute(const DL_AttributeData& data) = 0; + + /** + * Called for every aligned dimension entity. + */ + virtual void addDimAlign(const DL_DimensionData& data, + const DL_DimAlignedData& edata) = 0; + /** + * Called for every linear or rotated dimension entity. + */ + virtual void addDimLinear(const DL_DimensionData& data, + const DL_DimLinearData& edata) = 0; + + /** + * Called for every radial dimension entity. + */ + virtual void addDimRadial(const DL_DimensionData& data, + const DL_DimRadialData& edata) = 0; + + /** + * Called for every diametric dimension entity. + */ + virtual void addDimDiametric(const DL_DimensionData& data, + const DL_DimDiametricData& edata) = 0; + + /** + * Called for every angular dimension (2 lines version) entity. + */ + virtual void addDimAngular(const DL_DimensionData& data, + const DL_DimAngularData& edata) = 0; + + /** + * Called for every angular dimension (3 points version) entity. + */ + virtual void addDimAngular3P(const DL_DimensionData& data, + const DL_DimAngular3PData& edata) = 0; + + /** + * Called for every ordinate dimension entity. + */ + virtual void addDimOrdinate(const DL_DimensionData& data, + const DL_DimOrdinateData& edata) = 0; + + /** + * Called for every leader start. + */ + virtual void addLeader(const DL_LeaderData& data) = 0; + + /** + * Called for every leader vertex + */ + virtual void addLeaderVertex(const DL_LeaderVertexData& data) = 0; + + /** + * Called for every hatch entity. + */ + virtual void addHatch(const DL_HatchData& data) = 0; + + /** + * Called for every image entity. + */ + virtual void addImage(const DL_ImageData& data) = 0; + + /** + * Called for every image definition. + */ + virtual void linkImage(const DL_ImageDefData& data) = 0; + + /** + * Called for every hatch loop. + */ + virtual void addHatchLoop(const DL_HatchLoopData& data) = 0; + + /** + * Called for every hatch edge entity. + */ + virtual void addHatchEdge(const DL_HatchEdgeData& data) = 0; + + /** + * Called for every XRecord with the given handle. + */ + virtual void addXRecord(const std::string& handle) = 0; + + /** + * Called for XRecords of type string. + */ + virtual void addXRecordString(int code, const std::string& value) = 0; + + /** + * Called for XRecords of type double. + */ + virtual void addXRecordReal(int code, double value) = 0; + + /** + * Called for XRecords of type int. + */ + virtual void addXRecordInt(int code, int value) = 0; + + /** + * Called for XRecords of type bool. + */ + virtual void addXRecordBool(int code, bool value) = 0; + + /** + * Called for every beginning of an XData section of the given application. + */ + virtual void addXDataApp(const std::string& appId) = 0; + + /** + * Called for XData tuples. + */ + virtual void addXDataString(int code, const std::string& value) = 0; + + /** + * Called for XData tuples. + */ + virtual void addXDataReal(int code, double value) = 0; + + /** + * Called for XData tuples. + */ + virtual void addXDataInt(int code, int value) = 0; + + /** + * Called for dictionary objects. + */ + virtual void addDictionary(const DL_DictionaryData& data) = 0; + + /** + * Called for dictionary entries. + */ + virtual void addDictionaryEntry(const DL_DictionaryEntryData& data) = 0; + + /** + * Called after an entity has been completed. + */ + virtual void endEntity() = 0; + + /** + * Called for every comment in the DXF file (code 999). + */ + virtual void addComment(const std::string& comment) = 0; + + /** + * Called for every vector variable in the DXF file (e.g. "$EXTMIN"). + */ + virtual void setVariableVector(const std::string& key, double v1, double v2, double v3, int code) = 0; + + /** + * Called for every string variable in the DXF file (e.g. "$ACADVER"). + */ + virtual void setVariableString(const std::string& key, const std::string& value, int code) = 0; + + /** + * Called for every int variable in the DXF file (e.g. "$ACADMAINTVER"). + */ + virtual void setVariableInt(const std::string& key, int value, int code) = 0; + + /** + * Called for every double variable in the DXF file (e.g. "$DIMEXO"). + */ + virtual void setVariableDouble(const std::string& key, double value, int code) = 0; + +#ifdef DL_COMPAT + virtual void setVariableVector(const char* key, double v1, double v2, double v3, int code) = 0; + virtual void setVariableString(const char* key, const char* value, int code) = 0; + virtual void setVariableInt(const char* key, int value, int code) = 0; + virtual void setVariableDouble(const char* key, double value, int code) = 0; + virtual void processCodeValuePair(unsigned int groupCode, char* groupValue) = 0; + virtual void addComment(const char* comment) = 0; + virtual void addMTextChunk(const char* text) = 0; +#endif + + /** + * Called when a SEQEND occurs (when a POLYLINE or ATTRIB is done) + */ + virtual void endSequence() = 0; + + /** Sets the current attributes for entities. */ + void setAttributes(const DL_Attributes& attrib) { + attributes = attrib; + } + + /** @return the current attributes used for new entities. */ + DL_Attributes getAttributes() { + return attributes; + } + + /** Sets the current attributes for entities. */ + void setExtrusion(double dx, double dy, double dz, double elevation) { + extrusion->setDirection(dx, dy, dz); + extrusion->setElevation(elevation); + } + + /** @return the current attributes used for new entities. */ + DL_Extrusion* getExtrusion() { + return extrusion; + } + +protected: + DL_Attributes attributes; + DL_Extrusion *extrusion; +}; + +#endif diff --git a/datafile/dxf/dxflib/dl_dxf.cpp b/datafile/dxf/dxflib/dl_dxf.cpp new file mode 100644 index 0000000..4e74bce --- /dev/null +++ b/datafile/dxf/dxflib/dl_dxf.cpp @@ -0,0 +1,5332 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "dl_dxf.h" + +#include +#include +#include +#include +#include + +#include "dl_attributes.h" +#include "dl_codes.h" +#include "dl_creationadapter.h" +#include "dl_writer_ascii.h" + +#include "iostream" + +/** + * Default constructor. + */ +DL_Dxf::DL_Dxf() { + version = DL_VERSION_2000; + + vertices = NULL; + maxVertices = 0; + vertexIndex = 0; + + knots = NULL; + maxKnots = 0; + knotIndex = 0; + + weights = NULL; + weightIndex = 0; + + controlPoints = NULL; + maxControlPoints = 0; + controlPointIndex = 0; + + fitPoints = NULL; + maxFitPoints = 0; + fitPointIndex = 0; + + leaderVertices = NULL; + maxLeaderVertices = 0; + leaderVertexIndex = 0; +} + + + +/** + * Destructor. + */ +DL_Dxf::~DL_Dxf() { + if (vertices!=NULL) { + delete[] vertices; + } + if (knots!=NULL) { + delete[] knots; + } + if (controlPoints!=NULL) { + delete[] controlPoints; + } + if (fitPoints!=NULL) { + delete[] fitPoints; + } + if (weights!=NULL) { + delete[] weights; + } + if (leaderVertices!=NULL) { + delete[] leaderVertices; + } +} + + + +/** + * @brief Reads the given file and calls the appropriate functions in + * the given creation interface for every entity found in the file. + * + * @param file Input + * Path and name of file to read + * @param creationInterface + * Pointer to the class which takes care of the entities in the file. + * + * @retval true If \p file could be opened. + * @retval false If \p file could not be opened. + */ +bool DL_Dxf::in(const std::string& file, DL_CreationInterface* creationInterface) { + FILE *fp; + firstCall = true; + currentObjectType = DL_UNKNOWN; + + fp = fopen(file.c_str(), "rt"); + if (fp) { + std::locale oldLocale = std::locale::global(std::locale("C")); // use dot in numbers + while (readDxfGroups(fp, creationInterface)) {} + std::locale::global(oldLocale); + fclose(fp); + return true; + } + + return false; +} + + + +/** + * Reads a DXF file from an existing stream. + * + * @param stream The string stream. + * @param creationInterface + * Pointer to the class which takes care of the entities in the file. + * + * @retval true If \p file could be opened. + * @retval false If \p file could not be opened. + */ +bool DL_Dxf::in(std::stringstream& stream, + DL_CreationInterface* creationInterface) { + + if (stream.good()) { + firstCall=true; + currentObjectType = DL_UNKNOWN; + while (readDxfGroups(stream, creationInterface)) {} + return true; + } + return false; +} + + + +/** + * @brief Reads a group couplet from a DXF file. Calls another function + * to process it. + * + * A group couplet consists of two lines that represent a single + * piece of data. An integer constant on the first line indicates + * the type of data. The value is on the next line.\n + * + * This function reads a couplet, determines the type of data, and + * passes the value to the the appropriate handler function of + * \p creationInterface.\n + * + * \p fp is advanced so that the next call to \p readDXFGroups() reads + * the next couplet in the file. + * + * @param fp Handle of input file + * @param creationInterface Handle of class which processes entities + * in the file + * + * @retval true If EOF not reached. + * @retval false If EOF reached. + */ +bool DL_Dxf::readDxfGroups(FILE *fp, DL_CreationInterface* creationInterface) { + + static int line = 1; + + // Read one group of the DXF file and strip the lines: + if (DL_Dxf::getStrippedLine(groupCodeTmp, DL_DXF_MAXLINE, fp) && + DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, fp, false) ) { + + groupCode = (unsigned int)toInt(groupCodeTmp); + + creationInterface->processCodeValuePair(groupCode, groupValue); + line+=2; + processDXFGroup(creationInterface, groupCode, groupValue); + } + + return !feof(fp); +} + + + +/** + * Same as above but for stringstreams. + */ +bool DL_Dxf::readDxfGroups(std::stringstream& stream, + DL_CreationInterface* creationInterface) { + + static int line = 1; + + // Read one group of the DXF file and chop the lines: + if (DL_Dxf::getStrippedLine(groupCodeTmp, DL_DXF_MAXLINE, stream) && + DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, stream, false) ) { + + groupCode = (unsigned int)toInt(groupCodeTmp); + + line+=2; + processDXFGroup(creationInterface, groupCode, groupValue); + } + return !stream.eof(); +} + + + +/** + * @brief Reads line from file & strips whitespace at start and newline + * at end. + * + * @param s Output\n + * Pointer to character array that chopped line will be returned in. + * @param size Size of \p s. (Including space for NULL.) + * @param fp Input\n + * Handle of input file. + * + * @retval true if line could be read + * @retval false if \p fp is already at end of file + * + * @todo Change function to use safer FreeBSD strl* functions + * @todo Is it a problem if line is blank (i.e., newline only)? + * Then, when function returns, (s==NULL). + */ +bool DL_Dxf::getStrippedLine(std::string& s, unsigned int size, FILE *fp, bool stripSpace) { + if (!feof(fp)) { + // The whole line in the file. Includes space for NULL. + char* wholeLine = new char[size]; + // Only the useful part of the line + char* line; + + line = fgets(wholeLine, size, fp); + + if (line!=NULL && line[0] != '\0') { // Evaluates to fgets() retval + // line == wholeLine at this point. + // Both guaranteed to be NULL terminated. + + // Strip leading whitespace and trailing CR/LF. + stripWhiteSpace(&line, stripSpace); + + s = line; + assert(size > s.length()); + } + + delete[] wholeLine; // Done with wholeLine + + return true; + } else { + s = ""; + return false; + } +} + + + +/** + * Same as above but for stringstreams. + */ +bool DL_Dxf::getStrippedLine(std::string &s, unsigned int size, + std::stringstream& stream, bool stripSpace) { + + if (!stream.eof()) { + // Only the useful part of the line + char* line = new char[size+1]; + char* oriLine = line; + stream.getline(line, size); + stripWhiteSpace(&line, stripSpace); + s = line; + assert(size > s.length()); + delete[] oriLine; + return true; + } else { + s[0] = '\0'; + return false; + } +} + + + +/** + * @brief Strips leading whitespace and trailing Carriage Return (CR) + * and Line Feed (LF) from NULL terminated string. + * + * @param s Input and output. + * NULL terminates string. + * + * @retval true if \p s is non-NULL + * @retval false if \p s is NULL + */ +bool DL_Dxf::stripWhiteSpace(char** s, bool stripSpace) { + // last non-NULL char: + int lastChar = strlen(*s) - 1; + + // Is last character CR or LF? + while ( (lastChar >= 0) && + (((*s)[lastChar] == 10) || ((*s)[lastChar] == 13) || + (stripSpace && ((*s)[lastChar] == ' ' || ((*s)[lastChar] == '\t')))) ) { + (*s)[lastChar] = '\0'; + lastChar--; + } + + // Skip whitespace, excluding \n, at beginning of line + if (stripSpace) { + while ((*s)[0]==' ' || (*s)[0]=='\t') { + ++(*s); + } + } + + return ((*s) ? true : false); +} + + + +/** + * Processes a group (pair of group code and value). + * + * @param creationInterface Handle to class that creates entities and + * other CAD data from DXF group codes + * + * @param groupCode Constant indicating the data type of the group. + * @param groupValue The data value. + * + * @retval true if done processing current entity and new entity begun + * @retval false if not done processing current entity +*/ +bool DL_Dxf::processDXFGroup(DL_CreationInterface* creationInterface, + int groupCode, const std::string& groupValue) { + + //printf("%d\n", groupCode); + //printf("%s\n", groupValue.c_str()); + + // Init values on first call + if (firstCall) { + settingValue[0] = '\0'; + firstCall=false; + } + + // Indicates comment or dxflib version: + if (groupCode==999) { + if (!groupValue.empty()) { + if (groupValue.substr(0, 6)=="dxflib") { + libVersion = getLibVersion(groupValue.substr(7)); + } + + addComment(creationInterface, groupValue); + } + } + + // Indicates start of new entity or variable: + else if (groupCode==0 || groupCode==9) { + // If new entity is encountered, the last one is complete. + // Prepare default attributes for next entity: + std::string layer = getStringValue(8, "0"); + + int width; + // Compatibility with qcad1: + if (hasValue(39) && !hasValue(370)) { + width = getIntValue(39, -1); + } + // since autocad 2002: + else if (hasValue(370)) { + width = getIntValue(370, -1); + } + // default to BYLAYER: + else { + width = -1; + } + + int color; + color = getIntValue(62, 256); + int color24; + color24 = getIntValue(420, -1); + int handle; + handle = getInt16Value(5, -1); + + std::string linetype = getStringValue(6, "BYLAYER"); + + attrib = DL_Attributes(layer, // layer + color, // color + color24, // 24 bit color + width, // width + linetype, // linetype + handle); // handle + attrib.setInPaperSpace((bool)getIntValue(67, 0)); + attrib.setLinetypeScale(getRealValue(48, 1.0)); + creationInterface->setAttributes(attrib); + + int elevationGroupCode=30; + if (currentObjectType==DL_ENTITY_LWPOLYLINE ) { + // see lwpolyline group codes reference + elevationGroupCode=38; + } + else { + // see polyline group codes reference + elevationGroupCode=30; + } + + creationInterface->setExtrusion(getRealValue(210, 0.0), + getRealValue(220, 0.0), + getRealValue(230, 1.0), + getRealValue(elevationGroupCode, 0.0)); + + // Add the previously parsed entity via creationInterface + switch (currentObjectType) { + case DL_SETTING: + addSetting(creationInterface); + break; + + case DL_LAYER: + addLayer(creationInterface); + break; + + case DL_LINETYPE: + addLinetype(creationInterface); + break; + + case DL_BLOCK: + addBlock(creationInterface); + break; + + case DL_ENDBLK: + endBlock(creationInterface); + break; + + case DL_STYLE: + addTextStyle(creationInterface); + break; + + case DL_ENTITY_POINT: + addPoint(creationInterface); + break; + + case DL_ENTITY_LINE: + addLine(creationInterface); + break; + + case DL_ENTITY_XLINE: + addXLine(creationInterface); + break; + + case DL_ENTITY_RAY: + addRay(creationInterface); + break; + + case DL_ENTITY_POLYLINE: + case DL_ENTITY_LWPOLYLINE: + addPolyline(creationInterface); + break; + + case DL_ENTITY_VERTEX: + addVertex(creationInterface); + break; + + case DL_ENTITY_SPLINE: + addSpline(creationInterface); + break; + + case DL_ENTITY_ARC: + addArc(creationInterface); + break; + + case DL_ENTITY_CIRCLE: + addCircle(creationInterface); + break; + + case DL_ENTITY_ELLIPSE: + addEllipse(creationInterface); + break; + + case DL_ENTITY_INSERT: + addInsert(creationInterface); + break; + + case DL_ENTITY_MTEXT: + addMText(creationInterface); + break; + + case DL_ENTITY_TEXT: + addText(creationInterface); + break; + + case DL_ENTITY_ARCALIGNEDTEXT: + addArcAlignedText(creationInterface); + break; + + case DL_ENTITY_ATTRIB: + addAttribute(creationInterface); + break; + + case DL_ENTITY_DIMENSION: { + int type = (getIntValue(70, 0)&0x07); + + switch (type) { + case 0: + addDimLinear(creationInterface); + break; + + case 1: + addDimAligned(creationInterface); + break; + + case 2: + addDimAngular(creationInterface); + break; + + case 3: + addDimDiametric(creationInterface); + break; + + case 4: + addDimRadial(creationInterface); + break; + + case 5: + addDimAngular3P(creationInterface); + break; + + case 6: + addDimOrdinate(creationInterface); + break; + + default: + break; + } + } + break; + + case DL_ENTITY_LEADER: + addLeader(creationInterface); + break; + + case DL_ENTITY_HATCH: + //addHatch(creationInterface); + handleHatchData(creationInterface); + break; + + case DL_ENTITY_IMAGE: + addImage(creationInterface); + break; + + case DL_ENTITY_IMAGEDEF: + addImageDef(creationInterface); + break; + + case DL_ENTITY_TRACE: + addTrace(creationInterface); + break; + + case DL_ENTITY_3DFACE: + add3dFace(creationInterface); + break; + + case DL_ENTITY_SOLID: + addSolid(creationInterface); + break; + + case DL_ENTITY_SEQEND: + endSequence(creationInterface); + break; + + default: + break; + } + + creationInterface->endSection(); + + // reset all values (they are not persistent and only this + // way we can set defaults for omitted values) +// for (int i=0; iaddComment(comment); +} + +void DL_Dxf::addDictionary(DL_CreationInterface* creationInterface) { + creationInterface->addDictionary(DL_DictionaryData(getStringValue(5, ""))); +} + +void DL_Dxf::addDictionaryEntry(DL_CreationInterface* creationInterface) { + creationInterface->addDictionaryEntry(DL_DictionaryEntryData(getStringValue(3, ""), getStringValue(350, ""))); +} + + + +/** + * Adds a variable from the DXF file. + */ +void DL_Dxf::addSetting(DL_CreationInterface* creationInterface) { + int c = -1; + std::map::iterator it = values.begin(); + if (it!=values.end()) { + c = it->first; + } +// for (int i=0; i<=380; ++i) { +// if (values[i][0]!='\0') { +// c = i; +// break; +// } +// } + + // string + if (c>=0 && c<=9) { + creationInterface->setVariableString(settingKey, values[c], c); + #ifdef DL_COMPAT + // backwards compatibility: + creationInterface->setVariableString(settingKey.c_str(), values[c].c_str(), c); + #endif + } + // vector + else if (c>=10 && c<=39) { + if (c==10) { + creationInterface->setVariableVector( + settingKey, + getRealValue(c, 0.0), + getRealValue(c+10, 0.0), + getRealValue(c+20, 0.0), + c); + } + } + // double + else if (c>=40 && c<=59) { + creationInterface->setVariableDouble(settingKey, getRealValue(c, 0.0), c); + } + // int + else if (c>=60 && c<=99) { + creationInterface->setVariableInt(settingKey, getIntValue(c, 0), c); + } + // misc + else if (c>=0) { + creationInterface->setVariableString(settingKey, getStringValue(c, ""), c); + } +} + + + +/** + * Adds a layer that was read from the file via the creation interface. + */ +void DL_Dxf::addLayer(DL_CreationInterface* creationInterface) { + // correct some invalid attributes for layers: + attrib = creationInterface->getAttributes(); + if (attrib.getColor()==256 || attrib.getColor()==0) { + attrib.setColor(7); + } + if (attrib.getWidth()<0) { + attrib.setWidth(1); + } + + std::string linetype = attrib.getLinetype(); + std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper); + if (linetype=="BYLAYER" || linetype=="BYBLOCK") { + attrib.setLinetype("CONTINUOUS"); + } + + // add layer + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } + + creationInterface->addLayer(DL_LayerData(name, getIntValue(70, 0))); +} + +/** + * Adds a linetype that was read from the file via the creation interface. + */ +void DL_Dxf::addLinetype(DL_CreationInterface* creationInterface) { + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } + int numDashes = getIntValue(73, 0); + //double dashes[numDashes]; + + DL_LinetypeData d( + // name: + name, + // description: + getStringValue(3, ""), + // flags + getIntValue(70, 0), + // number of dashes: + numDashes, + // pattern length: + getRealValue(40, 0.0) + // pattern: + //dashes + ); + + if (name != "By Layer" && name != "By Block" && name != "BYLAYER" && name != "BYBLOCK") { + creationInterface->addLinetype(d); + } +} + +/** + * Handles all dashes in linetype pattern. + */ +bool DL_Dxf::handleLinetypeData(DL_CreationInterface* creationInterface) { + if (groupCode == 49) { + creationInterface->addLinetypeDash(toReal(groupValue)); + return true; + } + + return false; +} + + +/** + * Adds a block that was read from the file via the creation interface. + */ +void DL_Dxf::addBlock(DL_CreationInterface* creationInterface) { + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } + + DL_BlockData d( + // Name: + name, + // flags: + getIntValue(70, 0), + // base point: + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0)); + + creationInterface->addBlock(d); +} + + + +/** + * Ends a block that was read from the file via the creation interface. + */ +void DL_Dxf::endBlock(DL_CreationInterface* creationInterface) { + creationInterface->endBlock(); +} + + + +void DL_Dxf::addTextStyle(DL_CreationInterface* creationInterface) { + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } + + DL_StyleData d( + // name: + name, + // flags + getIntValue(70, 0), + // fixed text heigth: + getRealValue(40, 0.0), + // width factor: + getRealValue(41, 0.0), + // oblique angle: + getRealValue(50, 0.0), + // text generation flags: + getIntValue(71, 0), + // last height used: + getRealValue(42, 0.0), + // primart font file: + getStringValue(3, ""), + // big font file: + getStringValue(4, "") + ); + creationInterface->addTextStyle(d); +} + + +/** + * Adds a point entity that was read from the file via the creation interface. + */ +void DL_Dxf::addPoint(DL_CreationInterface* creationInterface) { + DL_PointData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0)); + creationInterface->addPoint(d); +} + + + +/** + * Adds a line entity that was read from the file via the creation interface. + */ +void DL_Dxf::addLine(DL_CreationInterface* creationInterface) { + DL_LineData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0)); + + creationInterface->addLine(d); +} + +/** + * Adds an xline entity that was read from the file via the creation interface. + */ +void DL_Dxf::addXLine(DL_CreationInterface* creationInterface) { + DL_XLineData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0)); + + creationInterface->addXLine(d); +} + +/** + * Adds a ray entity that was read from the file via the creation interface. + */ +void DL_Dxf::addRay(DL_CreationInterface* creationInterface) { + DL_RayData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0)); + + creationInterface->addRay(d); +} + + + +/** + * Adds a polyline entity that was read from the file via the creation interface. + */ +void DL_Dxf::addPolyline(DL_CreationInterface* creationInterface) { + DL_PolylineData pd(maxVertices, getIntValue(71, 0), getIntValue(72, 0), getIntValue(70, 0), getRealValue(38, 0)); + creationInterface->addPolyline(pd); + + maxVertices = std::min(maxVertices, vertexIndex+1); + + if (currentObjectType==DL_ENTITY_LWPOLYLINE) { + for (int i=0; iaddVertex(d); + } + creationInterface->endEntity(); + } +} + + + +/** + * Adds a polyline vertex entity that was read from the file + * via the creation interface. + */ +void DL_Dxf::addVertex(DL_CreationInterface* creationInterface) { + + // vertex defines a face of the mesh if its vertex flags group has the + // 128 bit set but not the 64 bit. 10, 20, 30 are irrelevant and set to + // 0 in this case + if ((getIntValue(70, 0)&128) && !(getIntValue(70, 0)&64)) { + return; + } + + DL_VertexData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(42, 0.0)); + + creationInterface->addVertex(d); +} + + +/** + * Adds a spline entity that was read from the file via the creation interface. + */ +void DL_Dxf::addSpline(DL_CreationInterface* creationInterface) { + DL_SplineData sd(getIntValue(71, 3), + maxKnots, + maxControlPoints, + maxFitPoints, + getIntValue(70, 4)); + + sd.tangentStartX = getRealValue(12, 0.0); + sd.tangentStartY = getRealValue(22, 0.0); + sd.tangentStartZ = getRealValue(32, 0.0); + sd.tangentEndX = getRealValue(13, 0.0); + sd.tangentEndY = getRealValue(23, 0.0); + sd.tangentEndZ = getRealValue(33, 0.0); + + creationInterface->addSpline(sd); + + int i; + for (i=0; iaddControlPoint(d); + } + for (i=0; iaddFitPoint(d); + } + for (i=0; iaddKnot(k); + } + creationInterface->endEntity(); +} + + + +/** + * Adds an arc entity that was read from the file via the creation interface. + */ +void DL_Dxf::addArc(DL_CreationInterface* creationInterface) { + DL_ArcData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(40, 0.0), + getRealValue(50, 0.0), + getRealValue(51, 0.0)); + + creationInterface->addArc(d); +} + + + +/** + * Adds a circle entity that was read from the file via the creation interface. + */ +void DL_Dxf::addCircle(DL_CreationInterface* creationInterface) { + DL_CircleData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(40, 0.0)); + + creationInterface->addCircle(d); +} + + + +/** + * Adds an ellipse entity that was read from the file via the creation interface. + */ +void DL_Dxf::addEllipse(DL_CreationInterface* creationInterface) { + DL_EllipseData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + getRealValue(40, 1.0), + getRealValue(41, 0.0), + getRealValue(42, 2*M_PI)); + + creationInterface->addEllipse(d); +} + + + +/** + * Adds an insert entity that was read from the file via the creation interface. + */ +void DL_Dxf::addInsert(DL_CreationInterface* creationInterface) { + //printf("addInsert\n"); + //printf("code 50: %s\n", values[50]); + //printf("code 50 length: %d\n", strlen(values[50])); + //printf("code 50:\n"); + //getRealValue(50, 0.0); + + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } + + DL_InsertData d(name, + // insertion point + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // scale: + getRealValue(41, 1.0), + getRealValue(42, 1.0), + getRealValue(43, 1.0), + // angle (deg): + getRealValue(50, 0.0), + // cols / rows: + getIntValue(70, 1), + getIntValue(71, 1), + // spacing: + getRealValue(44, 0.0), + getRealValue(45, 0.0)); + + creationInterface->addInsert(d); +} + + + +/** + * Adds a trace entity (4 edge closed polyline) that was read from the file via the creation interface. + * + * @author AHM + */ +void DL_Dxf::addTrace(DL_CreationInterface* creationInterface) { + DL_TraceData td; + + for (int k = 0; k < 4; k++) { + td.x[k] = getRealValue(10 + k, 0.0); + td.y[k] = getRealValue(20 + k, 0.0); + td.z[k] = getRealValue(30 + k, 0.0); + } + creationInterface->addTrace(td); +} + + + +/** + * Adds a 3dface entity that was read from the file via the creation interface. + */ +void DL_Dxf::add3dFace(DL_CreationInterface* creationInterface) { + DL_3dFaceData td; + + for (int k = 0; k < 4; k++) { + td.x[k] = getRealValue(10 + k, 0.0); + td.y[k] = getRealValue(20 + k, 0.0); + td.z[k] = getRealValue(30 + k, 0.0); + } + creationInterface->add3dFace(td); +} + + + +/** + * Adds a solid entity (filled trace) that was read from the file via the creation interface. + * + * @author AHM + */ +void DL_Dxf::addSolid(DL_CreationInterface* creationInterface) { + DL_SolidData sd; + + for (int k = 0; k < 4; k++) { + sd.x[k] = getRealValue(10 + k, 0.0); + sd.y[k] = getRealValue(20 + k, 0.0); + sd.z[k] = getRealValue(30 + k, 0.0); + } + creationInterface->addSolid(sd); +} + + +/** + * Adds an MText entity that was read from the file via the creation interface. + */ +void DL_Dxf::addMText(DL_CreationInterface* creationInterface) { + double angle = 0.0; + + if (hasValue(50)) { + if (libVersion<=0x02000200) { + // wrong but compatible with dxflib <=2.0.2.0 (angle stored in rad): + angle = getRealValue(50, 0.0); + } else { + angle = (getRealValue(50, 0.0)*2*M_PI)/360.0; + } + } else if (hasValue(11) && hasValue(21)) { + double x = getRealValue(11, 0.0); + double y = getRealValue(21, 0.0); + + if (fabs(x)<1.0e-6) { + if (y>0.0) { + angle = M_PI/2.0; + } else { + angle = M_PI/2.0*3.0; + } + } else { + angle = atan(y/x); + } + } + + DL_MTextData d( + // insertion point + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // X direction vector + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + // height + getRealValue(40, 2.5), + // width + getRealValue(41, 0.0), + // attachment point + getIntValue(71, 1), + // drawing direction + getIntValue(72, 1), + // line spacing style + getIntValue(73, 1), + // line spacing factor + getRealValue(44, 1.0), + // text + getStringValue(1, ""), + // style + getStringValue(7, ""), + // angle + angle); + creationInterface->addMText(d); +} + +/** + * Handles all XRecord data. + */ +bool DL_Dxf::handleXRecordData(DL_CreationInterface* creationInterface) { + if (groupCode==105) { + return false; + } + + if (groupCode==5) { + creationInterface->addXRecord(groupValue); + return true; + } + + if (groupCode==280) { + xRecordValues = true; + return true; + } + + if (!xRecordValues) { + return false; + } + + // string: + if (groupCode<=9 || + groupCode==100 || groupCode==102 || groupCode==105 || + (groupCode>=300 && groupCode<=369) || + (groupCode>=1000 && groupCode<=1009)) { + + creationInterface->addXRecordString(groupCode, groupValue); + return true; + } + + // int: + else if ((groupCode>=60 && groupCode<=99) || (groupCode>=160 && groupCode<=179) || (groupCode>=270 && groupCode<=289)) { + creationInterface->addXRecordInt(groupCode, toInt(groupValue)); + return true; + } + + // bool: + else if (groupCode>=290 && groupCode<=299) { + creationInterface->addXRecordBool(groupCode, toBool(groupValue)); + return true; + } + + // double: + else if ((groupCode>=10 && groupCode<=59) || (groupCode>=110 && groupCode<=149) || (groupCode>=210 && groupCode<=239)) { + creationInterface->addXRecordReal(groupCode, toReal(groupValue)); + return true; + } + + return false; +} + +/** + * Handles all dictionary data. + */ +bool DL_Dxf::handleDictionaryData(DL_CreationInterface* creationInterface) { + if (groupCode==3) { + return true; + } + + if (groupCode==5) { + creationInterface->addDictionary(DL_DictionaryData(groupValue)); + return true; + } + + if (groupCode==350) { + creationInterface->addDictionaryEntry(DL_DictionaryEntryData(getStringValue(3, ""), groupValue)); + return true; + } + return false; +} + + + +/** + * Handles XData for all object types. + */ +bool DL_Dxf::handleXData(DL_CreationInterface* creationInterface) { + if (groupCode==1001) { + creationInterface->addXDataApp(groupValue); + return true; + } + else if (groupCode>=1000 && groupCode<=1009) { + creationInterface->addXDataString(groupCode, groupValue); + return true; + } + else if (groupCode>=1010 && groupCode<=1059) { + creationInterface->addXDataReal(groupCode, toReal(groupValue)); + return true; + } + else if (groupCode>=1060 && groupCode<=1070) { + creationInterface->addXDataInt(groupCode, toInt(groupValue)); + return true; + } + else if (groupCode==1071) { + creationInterface->addXDataInt(groupCode, toInt(groupValue)); + return true; + } + + return false; +} + +/** + * Handles additional MText data. + */ +bool DL_Dxf::handleMTextData(DL_CreationInterface* creationInterface) { + // Special handling of text chunks for MTEXT entities: + if (groupCode==3) { + creationInterface->addMTextChunk(groupValue); + return true; + } + + return false; +} + +/** + * Handles additional polyline data. + */ +bool DL_Dxf::handleLWPolylineData(DL_CreationInterface* /*creationInterface*/) { + // Allocate LWPolyline vertices (group code 90): + if (groupCode==90) { + maxVertices = toInt(groupValue); + if (maxVertices>0) { + if (vertices!=NULL) { + delete[] vertices; + } + vertices = new double[4*maxVertices]; + for (int i=0; i=0 && vertexIndex0) { + if (knots!=NULL) { + delete[] knots; + } + knots = new double[maxKnots]; + for (int i=0; i0) { + if (controlPoints!=NULL) { + delete[] controlPoints; + } + if (weights!=NULL) { + delete[] weights; + } + controlPoints = new double[3*maxControlPoints]; + weights = new double[maxControlPoints]; + for (int i=0; i0) { + if (fitPoints!=NULL) { + delete[] fitPoints; + } + fitPoints = new double[3*maxFitPoints]; + for (int i=0; i=0 && controlPointIndex=0 && fitPointIndex=0 && weightIndex0) { + if (leaderVertices!=NULL) { + delete[] leaderVertices; + } + leaderVertices = new double[3*maxLeaderVertices]; + for (int i=0; i=0 && + leaderVertexIndexaddText(d); +} + + +/** + * Adds an arc aligned text entity that was read from the file via the creation interface. + */ +void DL_Dxf::addArcAlignedText(DL_CreationInterface* creationInterface) { + DL_ArcAlignedTextData d; + d.text = getStringValue(1, ""); + d.font = getStringValue(2, ""); + d.style = getStringValue(7, ""); + d.cx = getRealValue(10, 0.0); + d.cy = getRealValue(20, 0.0); + d.cz = getRealValue(30, 0.0); + d.radius = getRealValue(40, 0.0); + d.xScaleFactor = getRealValue(41, 0.0); + d.height = getRealValue(42, 0.0); + d.spacing = getRealValue(43, 0.0); + d.offset = getRealValue(44, 0.0); + d.rightOffset = getRealValue(45, 0.0); + d.leftOffset = getRealValue(46, 0.0); + d.startAngle = getRealValue(50, 0.0); + d.endAngle = getRealValue(51, 0.0); + d.reversedCharacterOrder = getIntValue(70, 0); + d.direction = getIntValue(71, 0); + d.alignment = getIntValue(72, 0); + d.side = getIntValue(73, 0); + d.bold = getIntValue(74, 0); + d.italic = getIntValue(75, 0); + d.underline = getIntValue(76, 0); + d.characerSet = getIntValue(77, 0); + d.pitch = getIntValue(78, 0); + d.shxFont = getIntValue(79, 0); + d.wizard = getIntValue(280, 0); + d.arcHandle = getIntValue(330, 0); + + creationInterface->addArcAlignedText(d); +} + + + +/** + * Adds an attrib entity that was read from the file via the creation interface. + * @todo add attrib instead of normal text + */ +void DL_Dxf::addAttribute(DL_CreationInterface* creationInterface) { + DL_AttributeData d( + // insertion point + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // alignment point + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + // height + getRealValue(40, 2.5), + // x scale + getRealValue(41, 1.0), + // generation flags + getIntValue(71, 0), + // h just + getIntValue(72, 0), + // v just + getIntValue(74, 0), + // tag + getStringValue(2, ""), + // text + getStringValue(1, ""), + // style + getStringValue(7, ""), + // angle + (getRealValue(50, 0.0)*2*M_PI)/360.0); + + creationInterface->addAttribute(d); +} + + + +/** + * @return dimension data from current values. + */ +DL_DimensionData DL_Dxf::getDimData() { + // generic dimension data: + return DL_DimensionData( + // def point + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // text middle point + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + // type + getIntValue(70, 0), + // attachment point + getIntValue(71, 5), + // line sp. style + getIntValue(72, 1), + // line sp. factor + getRealValue(41, 1.0), + // text + getStringValue(1, ""), + // style + getStringValue(3, ""), + // angle + getRealValue(53, 0.0)); +} + + + +/** + * Adds a linear dimension entity that was read from the file via the creation interface. + */ +void DL_Dxf::addDimLinear(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); + + // horizontal / vertical / rotated dimension: + DL_DimLinearData dl( + // definition point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // definition point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0), + // angle + getRealValue(50, 0.0), + // oblique + getRealValue(52, 0.0)); + creationInterface->addDimLinear(d, dl); +} + + + +/** + * Adds an aligned dimension entity that was read from the file via the creation interface. + */ +void DL_Dxf::addDimAligned(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); + + // aligned dimension: + DL_DimAlignedData da( + // extension point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // extension point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0)); + creationInterface->addDimAlign(d, da); +} + + + +/** + * Adds a radial dimension entity that was read from the file via the creation interface. + */ +void DL_Dxf::addDimRadial(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); + + DL_DimRadialData dr( + // definition point + getRealValue(15, 0.0), + getRealValue(25, 0.0), + getRealValue(35, 0.0), + // leader length: + getRealValue(40, 0.0)); + creationInterface->addDimRadial(d, dr); +} + + + +/** + * Adds a diametric dimension entity that was read from the file via the creation interface. + */ +void DL_Dxf::addDimDiametric(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); + + // diametric dimension: + DL_DimDiametricData dr( + // definition point + getRealValue(15, 0.0), + getRealValue(25, 0.0), + getRealValue(35, 0.0), + // leader length: + getRealValue(40, 0.0)); + creationInterface->addDimDiametric(d, dr); +} + + + +/** + * Adds an angular dimension entity that was read from the file via the creation interface. + */ +void DL_Dxf::addDimAngular(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); + + // angular dimension: + DL_DimAngularData da( + // definition point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // definition point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0), + // definition point 3 + getRealValue(15, 0.0), + getRealValue(25, 0.0), + getRealValue(35, 0.0), + // definition point 4 + getRealValue(16, 0.0), + getRealValue(26, 0.0), + getRealValue(36, 0.0)); + creationInterface->addDimAngular(d, da); +} + + +/** + * Adds an angular dimension entity that was read from the file via the creation interface. + */ +void DL_Dxf::addDimAngular3P(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); + + // angular dimension (3P): + DL_DimAngular3PData da( + // definition point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // definition point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0), + // definition point 3 + getRealValue(15, 0.0), + getRealValue(25, 0.0), + getRealValue(35, 0.0)); + creationInterface->addDimAngular3P(d, da); +} + + + +/** + * Adds an ordinate dimension entity that was read from the file via the creation interface. + */ +void DL_Dxf::addDimOrdinate(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); + + // ordinate dimension: + DL_DimOrdinateData dl( + // definition point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // definition point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0), + (getIntValue(70, 0)&64)==64 // true: X-type, false: Y-type + ); + creationInterface->addDimOrdinate(d, dl); +} + + + +/** + * Adds a leader entity that was read from the file via the creation interface. + */ +void DL_Dxf::addLeader(DL_CreationInterface* creationInterface) { + // leader (arrow) + DL_LeaderData le( + // arrow head flag + getIntValue(71, 1), + // leader path type + getIntValue(72, 0), + // Leader creation flag + getIntValue(73, 3), + // Hookline direction flag + getIntValue(74, 1), + // Hookline flag + getIntValue(75, 0), + // Text annotation height + getRealValue(40, 1.0), + // Text annotation width + getRealValue(41, 1.0), + // Number of vertices in leader + getIntValue(76, 0) + ); + creationInterface->addLeader(le); + + for (int i=0; iaddLeaderVertex(d); + } + creationInterface->endEntity(); +} + +/** + * Adds a hatch entity that was read from the file via the creation interface. + */ +void DL_Dxf::addHatch(DL_CreationInterface* creationInterface) { + DL_HatchData hd(getIntValue(91, 1), + getIntValue(70, 0), + getRealValue(41, 1.0), + getRealValue(52, 0.0), + getStringValue(2, "")); + + creationInterface->addHatch(hd); + + for (unsigned int i=0; iaddHatchLoop(DL_HatchLoopData(hatchEdges[i].size())); + for (unsigned int k=0; kaddHatchEdge(DL_HatchEdgeData(hatchEdges[i][k])); + } + } + + creationInterface->endEntity(); +} + +void DL_Dxf::addHatchLoop() { + addHatchEdge(); + hatchEdges.push_back(std::vector()); +} + +void DL_Dxf::addHatchEdge() { + if (hatchEdge.defined) { + if (hatchEdges.size()>0) { + hatchEdges.back().push_back(hatchEdge); + } + hatchEdge = DL_HatchEdgeData(); + } +} + +/** + * Handles all hatch data. + */ +bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) { + // New polyline loop, group code 92 + // or new loop with individual edges, group code 93 + if (groupCode==92 || groupCode==93) { + if (firstHatchLoop) { + hatchEdges.clear(); + firstHatchLoop = false; + } + if (groupCode==92 && (toInt(groupValue)&2)==2) { + addHatchLoop(); + } + if (groupCode==93) { + addHatchLoop(); + } + return true; + } + + // New hatch edge or new section / entity: add last hatch edge: + if (groupCode==72 || groupCode==0 || groupCode==78 || groupCode==98) { + // polyline boundaries use code 72 for bulge flag: + if (groupCode!=72 || (getIntValue(92, 0)&2)==0) { + addHatchEdge(); + } + + if (groupCode==0 /*|| groupCode==78*/) { + addHatch(creationInterface); + } + else { + hatchEdge.type = toInt(groupValue); + } + return true; + } + + // polyline boundary: + if ((getIntValue(92, 0)&2)==2) { + switch (groupCode) { + case 10: + hatchEdge.type = 0; + hatchEdge.vertices.push_back(std::vector()); + hatchEdge.vertices.back().push_back(toReal(groupValue)); + return true; + case 20: + if (!hatchEdge.vertices.empty()) { + hatchEdge.vertices.back().push_back(toReal(groupValue)); + hatchEdge.defined = true; + } + return true; + case 42: + if (!hatchEdge.vertices.empty()) { + hatchEdge.vertices.back().push_back(toReal(groupValue)); + hatchEdge.defined = true; + } + return true; + } + } + else { + // Line edge: + if (hatchEdge.type==1) { + switch (groupCode) { + case 10: + hatchEdge.x1 = toReal(groupValue); + return true; + case 20: + hatchEdge.y1 = toReal(groupValue); + return true; + case 11: + hatchEdge.x2 = toReal(groupValue); + return true; + case 21: + hatchEdge.y2 = toReal(groupValue); + hatchEdge.defined = true; + return true; + } + } + + // Arc edge: + if (hatchEdge.type==2) { + switch(groupCode) { + case 10: + hatchEdge.cx = toReal(groupValue); + return true; + case 20: + hatchEdge.cy = toReal(groupValue); + return true; + case 40: + hatchEdge.radius = toReal(groupValue); + return true; + case 50: + hatchEdge.angle1 = toReal(groupValue)/360.0*2*M_PI; + return true; + case 51: + hatchEdge.angle2 = toReal(groupValue)/360.0*2*M_PI; + return true; + case 73: + hatchEdge.ccw = (bool)toInt(groupValue); + hatchEdge.defined = true; + return true; + } + } + + // Ellipse arc edge: + if (hatchEdge.type==3) { + switch (groupCode) { + case 10: + hatchEdge.cx = toReal(groupValue); + return true; + case 20: + hatchEdge.cy = toReal(groupValue); + return true; + case 11: + hatchEdge.mx = toReal(groupValue); + return true; + case 21: + hatchEdge.my = toReal(groupValue); + return true; + case 40: + hatchEdge.ratio = toReal(groupValue); + return true; + case 50: + hatchEdge.angle1 = toReal(groupValue)/360.0*2*M_PI; + return true; + case 51: + hatchEdge.angle2 = toReal(groupValue)/360.0*2*M_PI; + return true; + case 73: + hatchEdge.ccw = (bool)toInt(groupValue); + hatchEdge.defined = true; + return true; + } + } + + // Spline edge: + if (hatchEdge.type==4) { + switch (groupCode) { + case 94: + hatchEdge.degree = toInt(groupValue); + return true; + case 73: + hatchEdge.rational = toBool(groupValue); + return true; + case 74: + hatchEdge.periodic = toBool(groupValue); + return true; + case 95: + hatchEdge.nKnots = toInt(groupValue); + return true; + case 96: + hatchEdge.nControl = toInt(groupValue); + return true; + case 97: + hatchEdge.nFit = toInt(groupValue); + return true; + case 40: + if (hatchEdge.knots.size() < hatchEdge.nKnots) { + hatchEdge.knots.push_back(toReal(groupValue)); + } + return true; + case 10: + if (hatchEdge.controlPoints.size() < hatchEdge.nControl) { + std::vector v; + v.push_back(toReal(groupValue)); + hatchEdge.controlPoints.push_back(v); + } + return true; + case 20: + if (!hatchEdge.controlPoints.empty() && hatchEdge.controlPoints.back().size()==1) { + hatchEdge.controlPoints.back().push_back(toReal(groupValue)); + } + hatchEdge.defined = true; + return true; + case 42: + if (hatchEdge.weights.size() < hatchEdge.nControl) { + hatchEdge.weights.push_back(toReal(groupValue)); + } + return true; + case 11: + if (hatchEdge.fitPoints.size() < hatchEdge.nFit) { + std::vector v; + v.push_back(toReal(groupValue)); + hatchEdge.fitPoints.push_back(v); + } + return true; + case 21: + if (!hatchEdge.fitPoints.empty() && hatchEdge.fitPoints.back().size()==1) { + hatchEdge.fitPoints.back().push_back(toReal(groupValue)); + } + hatchEdge.defined = true; + return true; + case 12: + hatchEdge.startTangentX = toReal(groupValue); + return true; + case 22: + hatchEdge.startTangentY = toReal(groupValue); + return true; + case 13: + hatchEdge.endTangentX = toReal(groupValue); + return true; + case 23: + hatchEdge.endTangentY = toReal(groupValue); + return true; + } + } + } + + return false; +} + + +/** + * Adds an image entity that was read from the file via the creation interface. + */ +void DL_Dxf::addImage(DL_CreationInterface* creationInterface) { + DL_ImageData id(// pass ref insead of name we don't have yet + getStringValue(340, ""), + // ins point: + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // u vector: + getRealValue(11, 1.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + // v vector: + getRealValue(12, 0.0), + getRealValue(22, 1.0), + getRealValue(32, 0.0), + // image size (pixel): + getIntValue(13, 1), + getIntValue(23, 1), + // brightness, contrast, fade + getIntValue(281, 50), + getIntValue(282, 50), + getIntValue(283, 0)); + + creationInterface->addImage(id); + creationInterface->endEntity(); + currentObjectType = DL_UNKNOWN; +} + + + +/** + * Adds an image definition that was read from the file via the creation interface. + */ +void DL_Dxf::addImageDef(DL_CreationInterface* creationInterface) { + DL_ImageDefData id(// handle + getStringValue(5, ""), + getStringValue(1, "")); + + creationInterface->linkImage(id); + creationInterface->endEntity(); + currentObjectType = DL_UNKNOWN; +} + + + +/** + * Ends some special entities like hatches or old style polylines. + */ +void DL_Dxf::endEntity(DL_CreationInterface* creationInterface) { + creationInterface->endEntity(); +} + + +/** + * Ends a sequence and notifies the creation interface. + */ +void DL_Dxf::endSequence(DL_CreationInterface* creationInterface) { + creationInterface->endSequence(); +} + + +/** + * Converts the given string into an int. + * ok is set to false if there was an error. + */ +//int DL_Dxf::stringToInt(const char* s, bool* ok) { +// if (ok!=NULL) { +// // check string: +// *ok = true; +// int i=0; +// bool dot = false; +// do { +// if (s[i]=='\0') { +// break; +// } else if (s[i]=='.') { +// if (dot==true) { +// //std::cerr << "two dots\n"; +// *ok = false; +// } else { +// dot = true; +// } +// } else if (s[i]<'0' || s[i]>'9') { +// //std::cerr << "NaN: '" << s[i] << "'\n"; +// *ok = false; +// } +// i++; +// } while(s[i]!='\0' && *ok==true); +// } + +// return atoi(s); +//} + + +/** + * @brief Opens the given file for writing and returns a pointer + * to the dxf writer. This pointer needs to be passed on to other + * writing functions. + * + * @param file Full path of the file to open. + * + * @return Pointer to an ascii dxf writer object. + */ +DL_WriterA* DL_Dxf::out(const char* file, DL_Codes::version version) { + char* f = new char[strlen(file)+1]; + strcpy(f, file); + this->version = version; + + DL_WriterA* dw = new DL_WriterA(f, version); + if (dw->openFailed()) { + delete dw; + delete[] f; + return NULL; + } else { + delete[] f; + return dw; + } +} + + + +/** + * @brief Writes a DXF header to the file currently opened + * by the given DXF writer object. + */ +void DL_Dxf::writeHeader(DL_WriterA& dw) { + dw.comment("dxflib " DL_VERSION); + dw.sectionHeader(); + + dw.dxfString(9, "$ACADVER"); + switch (version) { + case DL_Codes::AC1009: + dw.dxfString(1, "AC1009"); + break; + case DL_Codes::AC1012: + dw.dxfString(1, "AC1012"); + break; + case DL_Codes::AC1014: + dw.dxfString(1, "AC1014"); + break; + case DL_Codes::AC1015: + dw.dxfString(1, "AC1015"); + break; + case DL_Codes::AC1009_MIN: + // minimalistic DXF version is unidentified in file: + break; + } + + // Newer version require that (otherwise a*cad crashes..) + if (version==DL_VERSION_2000) { + dw.dxfString(9, "$HANDSEED"); + dw.dxfHex(5, 0xFFFF); + } + + // commented out: more variables can be added after that by caller: + //dw.sectionEnd(); +} + + + + +/** + * Writes a point entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writePoint(DL_WriterA& dw, + const DL_PointData& data, + const DL_Attributes& attrib) { + dw.entity("POINT"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbPoint"); + } + dw.coord(DL_POINT_COORD_CODE, data.x, data.y, data.z); +} + + + +/** + * Writes a line entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeLine(DL_WriterA& dw, + const DL_LineData& data, + const DL_Attributes& attrib) { + dw.entity("LINE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbLine"); + } + dw.coord(DL_LINE_START_CODE, data.x1, data.y1, data.z1); + dw.coord(DL_LINE_END_CODE, data.x2, data.y2, data.z2); +} + + + +/** + * Writes an x line entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeXLine(DL_WriterA& dw, + const DL_XLineData& data, + const DL_Attributes& attrib) { + dw.entity("XLINE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbLine"); + } + dw.coord(DL_LINE_START_CODE, data.bx, data.by, data.bz); + dw.coord(DL_LINE_END_CODE, data.dx, data.dy, data.dz); +} + + + +/** + * Writes a ray entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeRay(DL_WriterA& dw, + const DL_RayData& data, + const DL_Attributes& attrib) { + dw.entity("RAY"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbLine"); + } + dw.coord(DL_LINE_START_CODE, data.bx, data.by, data.bz); + dw.coord(DL_LINE_END_CODE, data.dx, data.dy, data.dz); +} + + + +/** + * Writes a polyline entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + * @see writeVertex + */ +void DL_Dxf::writePolyline(DL_WriterA& dw, + const DL_PolylineData& data, + const DL_Attributes& attrib) { + if (version==DL_VERSION_2000) { + dw.entity("LWPOLYLINE"); + dw.dxfString(100, "AcDbEntity"); + dw.entityAttributes(attrib); + dw.dxfString(100, "AcDbPolyline"); + dw.dxfInt(90, (int)data.number); + dw.dxfInt(70, data.flags); + } else { + dw.entity("POLYLINE"); + dw.entityAttributes(attrib); + polylineLayer = attrib.getLayer(); + dw.dxfInt(66, 1); + dw.dxfInt(70, data.flags); + dw.coord(DL_VERTEX_COORD_CODE, 0.0, 0.0, 0.0); + } +} + + + +/** + * Writes a single vertex of a polyline to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeVertex(DL_WriterA& dw, + const DL_VertexData& data) { + + + if (version==DL_VERSION_2000) { + dw.dxfReal(10, data.x); + dw.dxfReal(20, data.y); + dw.dxfReal(30, data.z); + if (fabs(data.bulge)>1.0e-10) { + dw.dxfReal(42, data.bulge); + } + } else { + dw.entity("VERTEX"); + //dw.entityAttributes(attrib); + dw.dxfString(8, polylineLayer); + dw.coord(DL_VERTEX_COORD_CODE, data.x, data.y, data.z); + if (fabs(data.bulge)>1.0e-10) { + dw.dxfReal(42, data.bulge); + } + } +} + + + +/** + * Writes the polyline end. Only needed for DXF R12. + */ +void DL_Dxf::writePolylineEnd(DL_WriterA& dw) { + if (version==DL_VERSION_2000) { + } else { + dw.entity("SEQEND"); + } +} + + +/** + * Writes a spline entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + * @see writeControlPoint + */ +void DL_Dxf::writeSpline(DL_WriterA& dw, + const DL_SplineData& data, + const DL_Attributes& attrib) { + + dw.entity("SPLINE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSpline"); + } + dw.dxfInt(70, data.flags); + dw.dxfInt(71, data.degree); + dw.dxfInt(72, data.nKnots); // number of knots + dw.dxfInt(73, data.nControl); // number of control points + dw.dxfInt(74, data.nFit); // number of fit points +} + + + +/** + * Writes a single control point of a spline to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeControlPoint(DL_WriterA& dw, + const DL_ControlPointData& data) { + + dw.dxfReal(10, data.x); + dw.dxfReal(20, data.y); + dw.dxfReal(30, data.z); +} + + + +/** + * Writes a single fit point of a spline to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeFitPoint(DL_WriterA& dw, + const DL_FitPointData& data) { + + dw.dxfReal(11, data.x); + dw.dxfReal(21, data.y); + dw.dxfReal(31, data.z); +} + + + +/** + * Writes a single knot of a spline to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeKnot(DL_WriterA& dw, + const DL_KnotData& data) { + + dw.dxfReal(40, data.k); +} + + + +/** + * Writes a circle entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeCircle(DL_WriterA& dw, + const DL_CircleData& data, + const DL_Attributes& attrib) { + dw.entity("CIRCLE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbCircle"); + } + dw.coord(10, data.cx, data.cy, data.cz); + dw.dxfReal(40, data.radius); +} + + + +/** + * Writes an arc entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeArc(DL_WriterA& dw, + const DL_ArcData& data, + const DL_Attributes& attrib) { + dw.entity("ARC"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbCircle"); + } + dw.coord(10, data.cx, data.cy, data.cz); + dw.dxfReal(40, data.radius); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbArc"); + } + dw.dxfReal(50, data.angle1); + dw.dxfReal(51, data.angle2); +} + + + +/** + * Writes an ellipse entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeEllipse(DL_WriterA& dw, + const DL_EllipseData& data, + const DL_Attributes& attrib) { + + if (version>DL_VERSION_R12) { + dw.entity("ELLIPSE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEllipse"); + } + dw.coord(10, data.cx, data.cy, data.cz); + dw.coord(11, data.mx, data.my, data.mz); + dw.dxfReal(40, data.ratio); + dw.dxfReal(41, data.angle1); + dw.dxfReal(42, data.angle2); + } +} + + + +/** + * Writes a solid entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeSolid(DL_WriterA& dw, + const DL_SolidData& data, + const DL_Attributes& attrib) { + dw.entity("SOLID"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbTrace"); + } + dw.coord(10, data.x[0], data.y[0], data.z[0]); + dw.coord(11, data.x[1], data.y[1], data.z[1]); + dw.coord(12, data.x[2], data.y[2], data.z[2]); + dw.coord(13, data.x[3], data.y[3], data.z[3]); + dw.dxfReal(39, data.thickness); +} + +/** + * Writes a trace entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeTrace(DL_WriterA& dw, + const DL_TraceData& data, + const DL_Attributes& attrib) { + dw.entity("TRACE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbTrace"); + } + dw.coord(10, data.x[0], data.y[0], data.z[0]); + dw.coord(11, data.x[1], data.y[1], data.z[1]); + dw.coord(12, data.x[2], data.y[2], data.z[2]); + dw.coord(13, data.x[3], data.y[3], data.z[3]); + dw.dxfReal(39, data.thickness); +} + + + +/** + * Writes a 3d face entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::write3dFace(DL_WriterA& dw, + const DL_3dFaceData& data, + const DL_Attributes& attrib) { + dw.entity("3DFACE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbFace"); + } + dw.coord(10, data.x[0], data.y[0], data.z[0]); + dw.coord(11, data.x[1], data.y[1], data.z[1]); + dw.coord(12, data.x[2], data.y[2], data.z[2]); + dw.coord(13, data.x[3], data.y[3], data.z[3]); +} + + + +/** + * Writes an insert to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeInsert(DL_WriterA& dw, + const DL_InsertData& data, + const DL_Attributes& attrib) { + + if (data.name.empty()) { + std::cerr << "DL_Dxf::writeInsert: " + << "Block name must not be empty\n"; + return; + } + + dw.entity("INSERT"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + if (data.cols!=1 || data.rows!=1) { + dw.dxfString(100, "AcDbMInsertBlock"); + } + else { + dw.dxfString(100, "AcDbBlockReference"); + } + } + dw.dxfString(2, data.name); + dw.dxfReal(10, data.ipx); + dw.dxfReal(20, data.ipy); + dw.dxfReal(30, data.ipz); + if (data.sx!=1.0 || data.sy!=1.0) { + dw.dxfReal(41, data.sx); + dw.dxfReal(42, data.sy); + dw.dxfReal(43, 1.0); + } + if (data.angle!=0.0) { + dw.dxfReal(50, data.angle); + } + if (data.cols!=1 || data.rows!=1) { + dw.dxfInt(70, data.cols); + dw.dxfInt(71, data.rows); + } + if (data.colSp!=0.0 || data.rowSp!=0.0) { + dw.dxfReal(44, data.colSp); + dw.dxfReal(45, data.rowSp); + } +} + + + +/** + * Writes a multi text entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeMText(DL_WriterA& dw, + const DL_MTextData& data, + const DL_Attributes& attrib) { + + dw.entity("MTEXT"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbMText"); + } + dw.dxfReal(10, data.ipx); + dw.dxfReal(20, data.ipy); + dw.dxfReal(30, data.ipz); + dw.dxfReal(40, data.height); + dw.dxfReal(41, data.width); + + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.drawingDirection); + + // Creare text chunks of 250 characters each: + int length = data.text.length(); + char chunk[251]; + int i; + for (i=250; iDL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } + + dw.dxfReal(42, data.angle); + + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbAlignedDimension"); + } + + dw.dxfReal(13, edata.epx1); + dw.dxfReal(23, edata.epy1); + dw.dxfReal(33, 0.0); + + dw.dxfReal(14, edata.epx2); + dw.dxfReal(24, edata.epy2); + dw.dxfReal(34, 0.0); + + writeDimStyleOverrides(dw, data); +} + + + +/** + * Writes a linear dimension entity to the file. + * + * @param dw DXF writer + * @param data Generic dimension data for from the file + * @param data Specific linear dimension data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeDimLinear(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimLinearData& edata, + const DL_Attributes& attrib) { + + dw.entity("DIMENSION"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } + + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); + + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); + + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } + + dw.dxfReal(42, data.angle); + + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbAlignedDimension"); + } + + dw.dxfReal(13, edata.dpx1); + dw.dxfReal(23, edata.dpy1); + dw.dxfReal(33, 0.0); + + dw.dxfReal(14, edata.dpx2); + dw.dxfReal(24, edata.dpy2); + dw.dxfReal(34, 0.0); + + dw.dxfReal(50, edata.angle/(2.0*M_PI)*360.0); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbRotatedDimension"); + } + + writeDimStyleOverrides(dw, data); +} + + + +/** + * Writes a radial dimension entity to the file. + * + * @param dw DXF writer + * @param data Generic dimension data for from the file + * @param data Specific radial dimension data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeDimRadial(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimRadialData& edata, + const DL_Attributes& attrib) { + + dw.entity("DIMENSION"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } + + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); + + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); + + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } + + dw.dxfReal(42, data.angle); + + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbRadialDimension"); + } + + dw.dxfReal(15, edata.dpx); + dw.dxfReal(25, edata.dpy); + dw.dxfReal(35, 0.0); + + dw.dxfReal(40, edata.leader); + + writeDimStyleOverrides(dw, data); +} + + + +/** + * Writes a diametric dimension entity to the file. + * + * @param dw DXF writer + * @param data Generic dimension data for from the file + * @param data Specific diametric dimension data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeDimDiametric(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimDiametricData& edata, + const DL_Attributes& attrib) { + + dw.entity("DIMENSION"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } + + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); + + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); + + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } + + dw.dxfReal(42, data.angle); + + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDiametricDimension"); + } + + dw.dxfReal(15, edata.dpx); + dw.dxfReal(25, edata.dpy); + dw.dxfReal(35, 0.0); + + dw.dxfReal(40, edata.leader); + + writeDimStyleOverrides(dw, data); +} + + + +/** + * Writes an angular dimension entity to the file. + * + * @param dw DXF writer + * @param data Generic dimension data for from the file + * @param data Specific angular dimension data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeDimAngular(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimAngularData& edata, + const DL_Attributes& attrib) { + + dw.entity("DIMENSION"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } + + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); + + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); + + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } + + dw.dxfReal(42, data.angle); + + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDb2LineAngularDimension"); + } + + dw.dxfReal(13, edata.dpx1); + dw.dxfReal(23, edata.dpy1); + dw.dxfReal(33, 0.0); + + dw.dxfReal(14, edata.dpx2); + dw.dxfReal(24, edata.dpy2); + dw.dxfReal(34, 0.0); + + dw.dxfReal(15, edata.dpx3); + dw.dxfReal(25, edata.dpy3); + dw.dxfReal(35, 0.0); + + dw.dxfReal(16, edata.dpx4); + dw.dxfReal(26, edata.dpy4); + dw.dxfReal(36, 0.0); +} + + + +/** + * Writes an angular dimension entity (3 points version) to the file. + * + * @param dw DXF writer + * @param data Generic dimension data for from the file + * @param data Specific angular dimension data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeDimAngular3P(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimAngular3PData& edata, + const DL_Attributes& attrib) { + + dw.entity("DIMENSION"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } + + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); + + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); + + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } + + dw.dxfReal(42, data.angle); + + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDb3PointAngularDimension"); + } + + dw.dxfReal(13, edata.dpx1); + dw.dxfReal(23, edata.dpy1); + dw.dxfReal(33, 0.0); + + dw.dxfReal(14, edata.dpx2); + dw.dxfReal(24, edata.dpy2); + dw.dxfReal(34, 0.0); + + dw.dxfReal(15, edata.dpx3); + dw.dxfReal(25, edata.dpy3); + dw.dxfReal(35, 0.0); +} + + + + +/** + * Writes an ordinate dimension entity to the file. + * + * @param dw DXF writer + * @param data Generic dimension data for from the file + * @param data Specific ordinate dimension data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeDimOrdinate(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimOrdinateData& edata, + const DL_Attributes& attrib) { + + dw.entity("DIMENSION"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } + + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); + + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); + + int type = data.type; + if (edata.xtype) { + type|=0x40; + } + + dw.dxfInt(70, type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } + + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbOrdinateDimension"); + } + + dw.dxfReal(13, edata.dpx1); + dw.dxfReal(23, edata.dpy1); + dw.dxfReal(33, 0.0); + + dw.dxfReal(14, edata.dpx2); + dw.dxfReal(24, edata.dpy2); + dw.dxfReal(34, 0.0); +} + + + +/** + * Writes a leader entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + * @see writeVertex + */ +void DL_Dxf::writeLeader(DL_WriterA& dw, + const DL_LeaderData& data, + const DL_Attributes& attrib) { + if (version>DL_VERSION_R12) { + dw.entity("LEADER"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbLeader"); + } + dw.dxfString(3, "Standard"); + dw.dxfInt(71, data.arrowHeadFlag); + dw.dxfInt(72, data.leaderPathType); + dw.dxfInt(73, data.leaderCreationFlag); + dw.dxfInt(74, data.hooklineDirectionFlag); + dw.dxfInt(75, data.hooklineFlag); + dw.dxfReal(40, data.textAnnotationHeight); + dw.dxfReal(41, data.textAnnotationWidth); + dw.dxfInt(76, data.number); + } +} + + + +/** + * Writes a single vertex of a leader to the file. + * + * @param dw DXF writer + * @param data Entity data + */ +void DL_Dxf::writeLeaderVertex(DL_WriterA& dw, + const DL_LeaderVertexData& data) { + if (version>DL_VERSION_R12) { + dw.dxfReal(10, data.x); + dw.dxfReal(20, data.y); + } +} + + + +/** + * Writes the beginning of a hatch entity to the file. + * This must be followed by one or more writeHatchLoop() + * calls and a writeHatch2() call. + * + * @param dw DXF writer + * @param data Entity data. + * @param attrib Attributes + */ +void DL_Dxf::writeHatch1(DL_WriterA& dw, + const DL_HatchData& data, + const DL_Attributes& attrib) { + + dw.entity("HATCH"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbHatch"); + } + dw.dxfReal(10, 0.0); // elevation + dw.dxfReal(20, 0.0); + dw.dxfReal(30, 0.0); + dw.dxfReal(210, 0.0); // extrusion dir. + dw.dxfReal(220, 0.0); + dw.dxfReal(230, 1.0); + if (data.solid==false) { + dw.dxfString(2, data.pattern); + } else { + dw.dxfString(2, "SOLID"); + } + dw.dxfInt(70, (int)data.solid); + dw.dxfInt(71, 0); // non-associative + dw.dxfInt(91, data.numLoops); +} + + + +/** + * Writes the end of a hatch entity to the file. + * + * @param dw DXF writer + * @param data Entity data. + * @param attrib Attributes + */ +void DL_Dxf::writeHatch2(DL_WriterA& dw, + const DL_HatchData& data, + const DL_Attributes& /*attrib*/) { + + dw.dxfInt(75, 0); // odd parity + dw.dxfInt(76, 1); // pattern type + if (data.solid==false) { + dw.dxfReal(52, data.angle); + dw.dxfReal(41, data.scale); + dw.dxfInt(77, 0); // not double + //dw.dxfInt(78, 0); + dw.dxfInt(78, 1); + dw.dxfReal(53, 45.0); + dw.dxfReal(43, 0.0); + dw.dxfReal(44, 0.0); + dw.dxfReal(45, -0.0883883476483184); + dw.dxfReal(46, 0.0883883476483185); + dw.dxfInt(79, 0); + } + dw.dxfInt(98, 0); + + if (version==DL_VERSION_2000) { + dw.dxfString(1001, "ACAD"); + dw.dxfReal(1010, data.originX); + dw.dxfReal(1020, data.originY); + dw.dxfInt(1030, 0.0); + } +} + + + +/** + * Writes the beginning of a hatch loop to the file. This + * must happen after writing the beginning of a hatch entity. + * + * @param dw DXF writer + * @param data Entity data. + * @param attrib Attributes + */ +void DL_Dxf::writeHatchLoop1(DL_WriterA& dw, + const DL_HatchLoopData& data) { + + dw.dxfInt(92, 1); + dw.dxfInt(93, data.numEdges); + //dw.dxfInt(97, 0); +} + + + +/** + * Writes the end of a hatch loop to the file. + * + * @param dw DXF writer + * @param data Entity data. + * @param attrib Attributes + */ +void DL_Dxf::writeHatchLoop2(DL_WriterA& dw, + const DL_HatchLoopData& /*data*/) { + + dw.dxfInt(97, 0); +} + + +/** + * Writes the beginning of a hatch entity to the file. + * + * @param dw DXF writer + * @param data Entity data. + * @param attrib Attributes + */ +void DL_Dxf::writeHatchEdge(DL_WriterA& dw, + const DL_HatchEdgeData& data) { + + if (data.type<1 || data.type>4) { + printf("WARNING: unsupported hatch edge type: %d", data.type); + } + + dw.dxfInt(72, data.type); + + switch (data.type) { + // line: + case 1: + dw.dxfReal(10, data.x1); + dw.dxfReal(20, data.y1); + dw.dxfReal(11, data.x2); + dw.dxfReal(21, data.y2); + break; + + // arc: + case 2: + dw.dxfReal(10, data.cx); + dw.dxfReal(20, data.cy); + dw.dxfReal(40, data.radius); + dw.dxfReal(50, data.angle1/(2*M_PI)*360.0); + dw.dxfReal(51, data.angle2/(2*M_PI)*360.0); + dw.dxfInt(73, (int)(data.ccw)); + break; + + // ellipse arc: + case 3: + dw.dxfReal(10, data.cx); + dw.dxfReal(20, data.cy); + dw.dxfReal(11, data.mx); + dw.dxfReal(21, data.my); + dw.dxfReal(40, data.ratio); + dw.dxfReal(50, data.angle1/(2*M_PI)*360.0); + dw.dxfReal(51, data.angle2/(2*M_PI)*360.0); + dw.dxfInt(73, (int)(data.ccw)); + break; + + // spline: + case 4: + dw.dxfInt(94, data.degree); + dw.dxfBool(73, data.rational); + dw.dxfBool(74, data.periodic); + dw.dxfInt(95, data.nKnots); + dw.dxfInt(96, data.nControl); + for (unsigned int i=0; i0) { + dw.dxfInt(97, data.nFit); + for (unsigned int i=0; i1.0e-4 || fabs(data.startTangentY)>1.0e-4) { + dw.dxfReal(12, data.startTangentX); + dw.dxfReal(22, data.startTangentY); + } + if (fabs(data.endTangentX)>1.0e-4 || fabs(data.endTangentY)>1.0e-4) { + dw.dxfReal(13, data.endTangentX); + dw.dxfReal(23, data.endTangentY); + } + break; + + default: + break; + } +} + + + +/** + * Writes an image entity. + * + * @return IMAGEDEF handle. Needed for the IMAGEDEF counterpart. + */ +int DL_Dxf::writeImage(DL_WriterA& dw, + const DL_ImageData& data, + const DL_Attributes& attrib) { + + /*if (data.file.empty()) { + std::cerr << "DL_Dxf::writeImage: " + << "Image file must not be empty\n"; + return; +}*/ + + dw.entity("IMAGE"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbRasterImage"); + dw.dxfInt(90, 0); + } + // insertion point + dw.dxfReal(10, data.ipx); + dw.dxfReal(20, data.ipy); + dw.dxfReal(30, data.ipz); + + // vector along bottom side (1 pixel long) + dw.dxfReal(11, data.ux); + dw.dxfReal(21, data.uy); + dw.dxfReal(31, data.uz); + + // vector along left side (1 pixel long) + dw.dxfReal(12, data.vx); + dw.dxfReal(22, data.vy); + dw.dxfReal(32, data.vz); + + // image size in pixel + dw.dxfReal(13, data.width); + dw.dxfReal(23, data.height); + + // handle of IMAGEDEF object + int handle = dw.incHandle(); + dw.dxfHex(340, handle); + + // flags + dw.dxfInt(70, 15); + + // clipping: + dw.dxfInt(280, 0); + + // brightness, contrast, fade + dw.dxfInt(281, data.brightness); + dw.dxfInt(282, data.contrast); + dw.dxfInt(283, data.fade); + + return handle; +} + + + +/** + * Writes an image definiition entity. + */ +void DL_Dxf::writeImageDef(DL_WriterA& dw, + int handle, + const DL_ImageData& data) { + + /*if (data.file.empty()) { + std::cerr << "DL_Dxf::writeImage: " + << "Image file must not be empty\n"; + return; +}*/ + + dw.dxfString(0, "IMAGEDEF"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, handle); + } + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbRasterImageDef"); + dw.dxfInt(90, 0); + } + // file name: + dw.dxfString(1, data.ref); + + // image size in pixel + dw.dxfReal(10, data.width); + dw.dxfReal(20, data.height); + + dw.dxfReal(11, 1.0); + dw.dxfReal(21, 1.0); + + // loaded: + dw.dxfInt(280, 1); + // units: + dw.dxfInt(281, 0); +} + + +/** + * Writes a layer to the file. Layers are stored in the + * tables section of a DXF file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeLayer(DL_WriterA& dw, + const DL_LayerData& data, + const DL_Attributes& attrib) { + + if (data.name.empty()) { + std::cerr << "DL_Dxf::writeLayer: " + << "Layer name must not be empty\n"; + return; + } + + int color = attrib.getColor(); + if (color>=256) { + std::cerr << "Layer color cannot be " << color << ". Changed to 7.\n"; + color = 7; + } + if (data.off) { + // negative color value means layer is off: + color = -color; + } + + if (data.name == "0") { + dw.tableLayerEntry(0x10); + } else { + dw.tableLayerEntry(); + } + + dw.dxfString(2, data.name); + dw.dxfInt(70, data.flags); + dw.dxfInt(62, color); + if (version>=DL_VERSION_2000 && attrib.getColor24()!=-1) { + dw.dxfInt(420, attrib.getColor24()); + } + + dw.dxfString(6, (attrib.getLinetype().length()==0 ? + std::string("CONTINUOUS") : attrib.getLinetype())); + + if (version>=DL_VERSION_2000) { + // layer defpoints cannot be plotted + std::string lstr = data.name; + std::transform(lstr.begin(), lstr.end(), lstr.begin(), tolower); + if (lstr=="defpoints") { + dw.dxfInt(290, 0); + } + } + if (version>=DL_VERSION_2000 && attrib.getWidth()!=-1) { + dw.dxfInt(370, attrib.getWidth()); + } + if (version>=DL_VERSION_2000) { + dw.dxfHex(390, 0xF); + } +} + + + +/** + * Writes a line type to the file. Line types are stored in the + * tables section of a DXF file. + */ +void DL_Dxf::writeLinetype(DL_WriterA& dw, + const DL_LinetypeData& data) { + + std::string nameUpper = data.name; + std::transform(nameUpper.begin(), nameUpper.end(), nameUpper.begin(), ::toupper); + + if (data.name.empty()) { + std::cerr << "DL_Dxf::writeLinetype: " + << "Line type name must not be empty\n"; + return; + } + + // ignore BYLAYER, BYBLOCK for R12 + if (version=DL_VERSION_R13) { + dw.dxfInt(74, 0); + } + } + } +} + + + +/** + * Writes the APPID section to the DXF file. + * + * @param name Application name + */ +void DL_Dxf::writeAppid(DL_WriterA& dw, const std::string& name) { + if (name.empty()) { + std::cerr << "DL_Dxf::writeAppid: " + << "Application name must not be empty\n"; + return; + } + + std::string n = name; + std::transform(n.begin(), n.end(), n.begin(), ::toupper); + + if (n=="ACAD") { + dw.tableAppidEntry(0x12); + } else { + dw.tableAppidEntry(); + } + dw.dxfString(2, name); + dw.dxfInt(70, 0); +} + + + +/** + * Writes a block's definition (no entities) to the DXF file. + */ +void DL_Dxf::writeBlock(DL_WriterA& dw, const DL_BlockData& data) { + if (data.name.empty()) { + std::cerr << "DL_Dxf::writeBlock: " + << "Block name must not be empty\n"; + return; + } + + std::string n = data.name; + std::transform(n.begin(), n.end(), n.begin(), ::toupper); + + if (n=="*PAPER_SPACE") { + dw.sectionBlockEntry(0x1C); + } else if (n=="*MODEL_SPACE") { + dw.sectionBlockEntry(0x20); + } else if (n=="*PAPER_SPACE0") { + dw.sectionBlockEntry(0x24); + } else { + dw.sectionBlockEntry(); + } + dw.dxfString(2, data.name); + dw.dxfInt(70, 0); + dw.coord(10, data.bpx, data.bpy, data.bpz); + dw.dxfString(3, data.name); + dw.dxfString(1, ""); +} + + + +/** + * Writes a block end. + * + * @param name Block name + */ +void DL_Dxf::writeEndBlock(DL_WriterA& dw, const std::string& name) { + std::string n = name; + std::transform(n.begin(), n.end(), n.begin(), ::toupper); + + if (n=="*PAPER_SPACE") { + dw.sectionBlockEntryEnd(0x1D); + } else if (n=="*MODEL_SPACE") { + dw.sectionBlockEntryEnd(0x21); + } else if (n=="*PAPER_SPACE0") { + dw.sectionBlockEntryEnd(0x25); + } else { + dw.sectionBlockEntryEnd(); + } +} + + + +/** + * Writes a viewport section. This section is needed in DL_VERSION_R13. + * Note that this method currently only writes a faked VPORT section + * to make the file readable by Aut*cad. + */ +void DL_Dxf::writeVPort(DL_WriterA& dw) { + dw.dxfString(0, "TABLE"); + dw.dxfString(2, "VPORT"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0x8); + } + //dw.dxfHex(330, 0); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt(70, 1); + dw.dxfString(0, "VPORT"); + //dw.dxfHex(5, 0x2F); + if (version==DL_VERSION_2000) { + dw.handle(); + } + //dw.dxfHex(330, 8); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbViewportTableRecord"); + } + dw.dxfString( 2, "*Active"); + dw.dxfInt( 70, 0); + dw.dxfReal( 10, 0.0); + dw.dxfReal( 20, 0.0); + dw.dxfReal( 11, 1.0); + dw.dxfReal( 21, 1.0); + dw.dxfReal( 12, 286.3055555555555); + dw.dxfReal( 22, 148.5); + dw.dxfReal( 13, 0.0); + dw.dxfReal( 23, 0.0); + dw.dxfReal( 14, 10.0); + dw.dxfReal( 24, 10.0); + dw.dxfReal( 15, 10.0); + dw.dxfReal( 25, 10.0); + dw.dxfReal( 16, 0.0); + dw.dxfReal( 26, 0.0); + dw.dxfReal( 36, 1.0); + dw.dxfReal( 17, 0.0); + dw.dxfReal( 27, 0.0); + dw.dxfReal( 37, 0.0); + dw.dxfReal( 40, 297.0); + dw.dxfReal( 41, 1.92798353909465); + dw.dxfReal( 42, 50.0); + dw.dxfReal( 43, 0.0); + dw.dxfReal( 44, 0.0); + dw.dxfReal( 50, 0.0); + dw.dxfReal( 51, 0.0); + dw.dxfInt( 71, 0); + dw.dxfInt( 72, 100); + dw.dxfInt( 73, 1); + dw.dxfInt( 74, 3); + dw.dxfInt( 75, 1); + dw.dxfInt( 76, 1); + dw.dxfInt( 77, 0); + dw.dxfInt( 78, 0); + + if (version==DL_VERSION_2000) { + dw.dxfInt(281, 0); + dw.dxfInt( 65, 1); + dw.dxfReal(110, 0.0); + dw.dxfReal(120, 0.0); + dw.dxfReal(130, 0.0); + dw.dxfReal(111, 1.0); + dw.dxfReal(121, 0.0); + dw.dxfReal(131, 0.0); + dw.dxfReal(112, 0.0); + dw.dxfReal(122, 1.0); + dw.dxfReal(132, 0.0); + dw.dxfInt( 79, 0); + dw.dxfReal(146, 0.0); + } + dw.dxfString( 0, "ENDTAB"); +} + + + +/** + * Writes a style section. This section is needed in DL_VERSION_R13. + */ +void DL_Dxf::writeStyle(DL_WriterA& dw, const DL_StyleData& style) { +// dw.dxfString( 0, "TABLE"); +// dw.dxfString( 2, "STYLE"); +// if (version==DL_VERSION_2000) { +// dw.dxfHex(5, 3); +// } + //dw.dxfHex(330, 0); +// if (version==DL_VERSION_2000) { +// dw.dxfString(100, "AcDbSymbolTable"); +// } +// dw.dxfInt( 70, 1); + dw.dxfString( 0, "STYLE"); + if (version==DL_VERSION_2000) { + if (style.name=="Standard") { + //dw.dxfHex(5, 0x11); + styleHandleStd = dw.handle(); + } + else { + dw.handle(); + } + } + //dw.dxfHex(330, 3); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbTextStyleTableRecord"); + } + dw.dxfString( 2, style.name); + dw.dxfInt( 70, style.flags); + dw.dxfReal( 40, style.fixedTextHeight); + dw.dxfReal( 41, style.widthFactor); + dw.dxfReal( 50, style.obliqueAngle); + dw.dxfInt( 71, style.textGenerationFlags); + dw.dxfReal( 42, style.lastHeightUsed); + if (version==DL_VERSION_2000) { + dw.dxfString( 3, ""); + dw.dxfString( 4, ""); + dw.dxfString(1001, "ACAD"); + //dw.dxfString(1000, style.name); + dw.dxfString(1000, style.primaryFontFile); + int xFlags = 0; + if (style.bold) { + xFlags = xFlags|0x2000000; + } + if (style.italic) { + xFlags = xFlags|0x1000000; + } + dw.dxfInt(1071, xFlags); + } + else { + dw.dxfString( 3, style.primaryFontFile); + dw.dxfString( 4, style.bigFontFile); + } + //dw.dxfString( 0, "ENDTAB"); +} + + + +/** + * Writes a view section. This section is needed in DL_VERSION_R13. + * Note that this method currently only writes a faked VIEW section + * to make the file readable by Aut*cad. + */ +void DL_Dxf::writeView(DL_WriterA& dw) { + dw.dxfString( 0, "TABLE"); + dw.dxfString( 2, "VIEW"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 6); + } + //dw.dxfHex(330, 0); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt( 70, 0); + dw.dxfString( 0, "ENDTAB"); +} + + + +/** + * Writes a ucs section. This section is needed in DL_VERSION_R13. + * Note that this method currently only writes a faked UCS section + * to make the file readable by Aut*cad. + */ +void DL_Dxf::writeUcs(DL_WriterA& dw) { + dw.dxfString( 0, "TABLE"); + dw.dxfString( 2, "UCS"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 7); + } + //dw.dxfHex(330, 0); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt( 70, 0); + dw.dxfString( 0, "ENDTAB"); +} + + + +/** + * Writes a dimstyle section. This section is needed in DL_VERSION_R13. + * Note that this method currently only writes a faked DIMSTYLE section + * to make the file readable by Aut*cad. + */ +void DL_Dxf::writeDimStyle(DL_WriterA& dw, + double dimasz, double dimexe, double dimexo, + double dimgap, double dimtxt) { + + dw.dxfString( 0, "TABLE"); + dw.dxfString( 2, "DIMSTYLE"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0xA); + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt( 70, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimStyleTable"); + dw.dxfInt( 71, 0); + } + + + dw.dxfString( 0, "DIMSTYLE"); + if (version==DL_VERSION_2000) { + dw.dxfHex(105, 0x27); + } + //dw.handle(105); + //dw.dxfHex(330, 0xA); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbDimStyleTableRecord"); + } + dw.dxfString( 2, "Standard"); + if (version==DL_VERSION_R12) { + dw.dxfString( 3, ""); + dw.dxfString( 4, ""); + dw.dxfString( 5, ""); + dw.dxfString( 6, ""); + dw.dxfString( 7, ""); + dw.dxfReal( 40, 1.0); + } + + dw.dxfReal( 41, dimasz); + dw.dxfReal( 42, dimexo); + dw.dxfReal( 43, 3.75); + dw.dxfReal( 44, dimexe); + if (version==DL_VERSION_R12) { + dw.dxfReal( 45, 0.0); + dw.dxfReal( 46, 0.0); + dw.dxfReal( 47, 0.0); + dw.dxfReal( 48, 0.0); + } + dw.dxfInt( 70, 0); + if (version==DL_VERSION_R12) { + dw.dxfInt( 71, 0); + dw.dxfInt( 72, 0); + } + dw.dxfInt( 73, 0); + dw.dxfInt( 74, 0); + if (version==DL_VERSION_R12) { + dw.dxfInt( 75, 0); + dw.dxfInt( 76, 0); + } + dw.dxfInt( 77, 1); + dw.dxfInt( 78, 8); + dw.dxfReal(140, dimtxt); + dw.dxfReal(141, 2.5); + if (version==DL_VERSION_R12) { + dw.dxfReal(142, 0.0); + } + dw.dxfReal(143, 0.03937007874016); + if (version==DL_VERSION_R12) { + dw.dxfReal(144, 1.0); + dw.dxfReal(145, 0.0); + dw.dxfReal(146, 1.0); + } + dw.dxfReal(147, dimgap); + if (version==DL_VERSION_R12) { + dw.dxfInt(170, 0); + } + dw.dxfInt(171, 3); + dw.dxfInt(172, 1); + if (version==DL_VERSION_R12) { + dw.dxfInt(173, 0); + dw.dxfInt(174, 0); + dw.dxfInt(175, 0); + dw.dxfInt(176, 0); + dw.dxfInt(177, 0); + dw.dxfInt(178, 0); + } + if (version==DL_VERSION_2000) { + dw.dxfInt(271, 2); + dw.dxfInt(272, 2); + dw.dxfInt(274, 3); + dw.dxfInt(278, 44); + dw.dxfInt(283, 0); + dw.dxfInt(284, 8); + dw.dxfHex(340, styleHandleStd); + //dw.dxfHex(340, 0x11); + } + // * / + dw.dxfString( 0, "ENDTAB"); +} + + + +/** + * Writes a blockrecord section. This section is needed in DL_VERSION_R13. + * Note that this method currently only writes a faked BLOCKRECORD section + * to make the file readable by Aut*cad. + */ +void DL_Dxf::writeBlockRecord(DL_WriterA& dw) { + dw.dxfString( 0, "TABLE"); + dw.dxfString( 2, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 1); + } + //dw.dxfHex(330, 0); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt( 70, 1); + + dw.dxfString( 0, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0x1F); + } + //int msh = dw.handle(); + //dw.setModelSpaceHandle(msh); + //dw.dxfHex(330, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbBlockTableRecord"); + } + dw.dxfString( 2, "*Model_Space"); + dw.dxfHex(340, 0x22); + + dw.dxfString( 0, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0x1B); + } + //int psh = dw.handle(); + //dw.setPaperSpaceHandle(psh); + //dw.dxfHex(330, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbBlockTableRecord"); + } + dw.dxfString( 2, "*Paper_Space"); + dw.dxfHex(340, 0x1E); + + dw.dxfString( 0, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0x23); + } + //int ps0h = dw.handle(); + //dw.setPaperSpace0Handle(ps0h); + //dw.dxfHex(330, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbBlockTableRecord"); + } + dw.dxfString( 2, "*Paper_Space0"); + dw.dxfHex(340, 0x26); + + //dw.dxfString( 0, "ENDTAB"); +} + + + +/** + * Writes a single block record with the given name. + */ +void DL_Dxf::writeBlockRecord(DL_WriterA& dw, const std::string& name) { + dw.dxfString( 0, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.handle(); + } + //dw->dxfHex(330, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbBlockTableRecord"); + } + dw.dxfString( 2, name); + dw.dxfHex(340, 0); +} + + + +/** + * Writes a objects section. This section is needed in DL_VERSION_R13. + * Note that this method currently only writes a faked OBJECTS section + * to make the file readable by Aut*cad. + */ +void DL_Dxf::writeObjects(DL_WriterA& dw, const std::string& appDictionaryName) { + dw.dxfString( 0, "SECTION"); + dw.dxfString( 2, "OBJECTS"); + + + dw.dxfString( 0, "DICTIONARY"); + dw.dxfHex(5, 0xC); + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(280, 0); + dw.dxfInt(281, 1); + dw.dxfString( 3, "ACAD_GROUP"); + dw.dxfHex(350, 0xD); + dw.dxfString( 3, "ACAD_LAYOUT"); + dw.dxfHex(350, 0x1A); + dw.dxfString( 3, "ACAD_MLINESTYLE"); + dw.dxfHex(350, 0x17); + dw.dxfString( 3, "ACAD_PLOTSETTINGS"); + dw.dxfHex(350, 0x19); + dw.dxfString( 3, "ACAD_PLOTSTYLENAME"); + dw.dxfHex(350, 0xE); + dw.dxfString( 3, "AcDbVariableDictionary"); + int acDbVariableDictionaryHandle = dw.handle(350); + //int acDbVariableDictionaryHandle = dw.getNextHandle(); + //dw.dxfHex(350, acDbVariableDictionaryHandle); + //dw.incHandle(); + + if (appDictionaryName.length()!=0) { + dw.dxfString( 3, appDictionaryName); + appDictionaryHandle = dw.handle(350); + //appDictionaryHandle = dw.getNextHandle(); + //dw.dxfHex(350, appDictionaryHandle); + //dw.incHandle(); + } + + dw.dxfString( 0, "DICTIONARY"); + dw.dxfHex(5, 0xD); + //dw.handle(); // D + //dw.dxfHex(330, 0xC); + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(280, 0); + dw.dxfInt(281, 1); + + + dw.dxfString( 0, "ACDBDICTIONARYWDFLT"); + dw.dxfHex(5, 0xE); + //dicId4 = dw.handle(); // E + //dw.dxfHex(330, 0xC); // C + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(281, 1); + dw.dxfString( 3, "Normal"); + dw.dxfHex(350, 0xF); + //dw.dxfHex(350, dw.getNextHandle()+5); // F + dw.dxfString(100, "AcDbDictionaryWithDefault"); + dw.dxfHex(340, 0xF); + //dw.dxfHex(340, dw.getNextHandle()+5); // F + + + dw.dxfString( 0, "ACDBPLACEHOLDER"); + dw.dxfHex(5, 0xF); + //dw.handle(); // F + //dw.dxfHex(330, dicId4); // E + + + dw.dxfString( 0, "DICTIONARY"); + //dicId3 = dw.handle(); // 17 + dw.dxfHex(5, 0x17); + //dw.dxfHex(330, 0xC); // C + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(280, 0); + dw.dxfInt(281, 1); + dw.dxfString( 3, "Standard"); + dw.dxfHex(350, 0x18); + //dw.dxfHex(350, dw.getNextHandle()+5); // 18 + + + dw.dxfString( 0, "MLINESTYLE"); + dw.dxfHex(5, 0x18); + //dw.handle(); // 18 + //dw.dxfHex(330, dicId3); // 17 + dw.dxfString(100, "AcDbMlineStyle"); + dw.dxfString( 2, "STANDARD"); + dw.dxfInt( 70, 0); + dw.dxfString( 3, ""); + dw.dxfInt( 62, 256); + dw.dxfReal( 51, 90.0); + dw.dxfReal( 52, 90.0); + dw.dxfInt( 71, 2); + dw.dxfReal( 49, 0.5); + dw.dxfInt( 62, 256); + dw.dxfString( 6, "BYLAYER"); + dw.dxfReal( 49, -0.5); + dw.dxfInt( 62, 256); + dw.dxfString( 6, "BYLAYER"); + + + dw.dxfString( 0, "DICTIONARY"); + dw.dxfHex(5, 0x19); + //dw.handle(); // 17 + //dw.dxfHex(330, 0xC); // C + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(280, 0); + dw.dxfInt(281, 1); + + + dw.dxfString( 0, "DICTIONARY"); + //dicId2 = dw.handle(); // 1A + dw.dxfHex(5, 0x1A); + //dw.dxfHex(330, 0xC); + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(281, 1); + dw.dxfString( 3, "Layout1"); + dw.dxfHex(350, 0x1E); + //dw.dxfHex(350, dw.getNextHandle()+2); // 1E + dw.dxfString( 3, "Layout2"); + dw.dxfHex(350, 0x26); + //dw.dxfHex(350, dw.getNextHandle()+4); // 26 + dw.dxfString( 3, "Model"); + dw.dxfHex(350, 0x22); + //dw.dxfHex(350, dw.getNextHandle()+5); // 22 + + + dw.dxfString( 0, "LAYOUT"); + dw.dxfHex(5, 0x1E); + //dw.handle(); // 1E + //dw.dxfHex(330, dicId2); // 1A + dw.dxfString(100, "AcDbPlotSettings"); + dw.dxfString( 1, ""); + dw.dxfString( 2, "none_device"); + dw.dxfString( 4, ""); + dw.dxfString( 6, ""); + dw.dxfReal( 40, 0.0); + dw.dxfReal( 41, 0.0); + dw.dxfReal( 42, 0.0); + dw.dxfReal( 43, 0.0); + dw.dxfReal( 44, 0.0); + dw.dxfReal( 45, 0.0); + dw.dxfReal( 46, 0.0); + dw.dxfReal( 47, 0.0); + dw.dxfReal( 48, 0.0); + dw.dxfReal( 49, 0.0); + dw.dxfReal(140, 0.0); + dw.dxfReal(141, 0.0); + dw.dxfReal(142, 1.0); + dw.dxfReal(143, 1.0); + dw.dxfInt( 70, 688); + dw.dxfInt( 72, 0); + dw.dxfInt( 73, 0); + dw.dxfInt( 74, 5); + dw.dxfString( 7, ""); + dw.dxfInt( 75, 16); + dw.dxfReal(147, 1.0); + dw.dxfReal(148, 0.0); + dw.dxfReal(149, 0.0); + dw.dxfString(100, "AcDbLayout"); + dw.dxfString( 1, "Layout1"); + dw.dxfInt( 70, 1); + dw.dxfInt( 71, 1); + dw.dxfReal( 10, 0.0); + dw.dxfReal( 20, 0.0); + dw.dxfReal( 11, 420.0); + dw.dxfReal( 21, 297.0); + dw.dxfReal( 12, 0.0); + dw.dxfReal( 22, 0.0); + dw.dxfReal( 32, 0.0); + dw.dxfReal( 14, 1.000000000000000E+20); + dw.dxfReal( 24, 1.000000000000000E+20); + dw.dxfReal( 34, 1.000000000000000E+20); + dw.dxfReal( 15, -1.000000000000000E+20); + dw.dxfReal( 25, -1.000000000000000E+20); + dw.dxfReal( 35, -1.000000000000000E+20); + dw.dxfReal(146, 0.0); + dw.dxfReal( 13, 0.0); + dw.dxfReal( 23, 0.0); + dw.dxfReal( 33, 0.0); + dw.dxfReal( 16, 1.0); + dw.dxfReal( 26, 0.0); + dw.dxfReal( 36, 0.0); + dw.dxfReal( 17, 0.0); + dw.dxfReal( 27, 1.0); + dw.dxfReal( 37, 0.0); + dw.dxfInt( 76, 0); + //dw.dxfHex(330, dw.getPaperSpaceHandle()); // 1B + dw.dxfHex(330, 0x1B); + + + dw.dxfString( 0, "LAYOUT"); + dw.dxfHex(5, 0x22); + //dw.handle(); // 22 + //dw.dxfHex(330, dicId2); // 1A + dw.dxfString(100, "AcDbPlotSettings"); + dw.dxfString( 1, ""); + dw.dxfString( 2, "none_device"); + dw.dxfString( 4, ""); + dw.dxfString( 6, ""); + dw.dxfReal( 40, 0.0); + dw.dxfReal( 41, 0.0); + dw.dxfReal( 42, 0.0); + dw.dxfReal( 43, 0.0); + dw.dxfReal( 44, 0.0); + dw.dxfReal( 45, 0.0); + dw.dxfReal( 46, 0.0); + dw.dxfReal( 47, 0.0); + dw.dxfReal( 48, 0.0); + dw.dxfReal( 49, 0.0); + dw.dxfReal(140, 0.0); + dw.dxfReal(141, 0.0); + dw.dxfReal(142, 1.0); + dw.dxfReal(143, 1.0); + dw.dxfInt( 70, 1712); + dw.dxfInt( 72, 0); + dw.dxfInt( 73, 0); + dw.dxfInt( 74, 0); + dw.dxfString( 7, ""); + dw.dxfInt( 75, 0); + dw.dxfReal(147, 1.0); + dw.dxfReal(148, 0.0); + dw.dxfReal(149, 0.0); + dw.dxfString(100, "AcDbLayout"); + dw.dxfString( 1, "Model"); + dw.dxfInt( 70, 1); + dw.dxfInt( 71, 0); + dw.dxfReal( 10, 0.0); + dw.dxfReal( 20, 0.0); + dw.dxfReal( 11, 12.0); + dw.dxfReal( 21, 9.0); + dw.dxfReal( 12, 0.0); + dw.dxfReal( 22, 0.0); + dw.dxfReal( 32, 0.0); + dw.dxfReal( 14, 0.0); + dw.dxfReal( 24, 0.0); + dw.dxfReal( 34, 0.0); + dw.dxfReal( 15, 0.0); + dw.dxfReal( 25, 0.0); + dw.dxfReal( 35, 0.0); + dw.dxfReal(146, 0.0); + dw.dxfReal( 13, 0.0); + dw.dxfReal( 23, 0.0); + dw.dxfReal( 33, 0.0); + dw.dxfReal( 16, 1.0); + dw.dxfReal( 26, 0.0); + dw.dxfReal( 36, 0.0); + dw.dxfReal( 17, 0.0); + dw.dxfReal( 27, 1.0); + dw.dxfReal( 37, 0.0); + dw.dxfInt( 76, 0); + //dw.dxfHex(330, dw.getModelSpaceHandle()); // 1F + dw.dxfHex(330, 0x1F); + + + dw.dxfString( 0, "LAYOUT"); + //dw.handle(); // 26 + dw.dxfHex(5, 0x26); + //dw.dxfHex(330, dicId2); // 1A + dw.dxfString(100, "AcDbPlotSettings"); + dw.dxfString( 1, ""); + dw.dxfString( 2, "none_device"); + dw.dxfString( 4, ""); + dw.dxfString( 6, ""); + dw.dxfReal( 40, 0.0); + dw.dxfReal( 41, 0.0); + dw.dxfReal( 42, 0.0); + dw.dxfReal( 43, 0.0); + dw.dxfReal( 44, 0.0); + dw.dxfReal( 45, 0.0); + dw.dxfReal( 46, 0.0); + dw.dxfReal( 47, 0.0); + dw.dxfReal( 48, 0.0); + dw.dxfReal( 49, 0.0); + dw.dxfReal(140, 0.0); + dw.dxfReal(141, 0.0); + dw.dxfReal(142, 1.0); + dw.dxfReal(143, 1.0); + dw.dxfInt( 70, 688); + dw.dxfInt( 72, 0); + dw.dxfInt( 73, 0); + dw.dxfInt( 74, 5); + dw.dxfString( 7, ""); + dw.dxfInt( 75, 16); + dw.dxfReal(147, 1.0); + dw.dxfReal(148, 0.0); + dw.dxfReal(149, 0.0); + dw.dxfString(100, "AcDbLayout"); + dw.dxfString( 1, "Layout2"); + dw.dxfInt( 70, 1); + dw.dxfInt( 71, 2); + dw.dxfReal( 10, 0.0); + dw.dxfReal( 20, 0.0); + dw.dxfReal( 11, 12.0); + dw.dxfReal( 21, 9.0); + dw.dxfReal( 12, 0.0); + dw.dxfReal( 22, 0.0); + dw.dxfReal( 32, 0.0); + dw.dxfReal( 14, 0.0); + dw.dxfReal( 24, 0.0); + dw.dxfReal( 34, 0.0); + dw.dxfReal( 15, 0.0); + dw.dxfReal( 25, 0.0); + dw.dxfReal( 35, 0.0); + dw.dxfReal(146, 0.0); + dw.dxfReal( 13, 0.0); + dw.dxfReal( 23, 0.0); + dw.dxfReal( 33, 0.0); + dw.dxfReal( 16, 1.0); + dw.dxfReal( 26, 0.0); + dw.dxfReal( 36, 0.0); + dw.dxfReal( 17, 0.0); + dw.dxfReal( 27, 1.0); + dw.dxfReal( 37, 0.0); + dw.dxfInt( 76, 0); + //dw.dxfHex(330, dw.getPaperSpace0Handle()); // 23 + dw.dxfHex(330, 0x23); + + dw.dxfString( 0, "DICTIONARY"); + //dw.dxfHex(5, 0x2C); + //dicId5 = + dw.dxfHex(5, acDbVariableDictionaryHandle); + //dw.handle(); // 2C + //dw.dxfHex(330, 0xC); // C + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(281, 1); + dw.dxfString( 3, "DIMASSOC"); + //dw.dxfHex(350, 0x2F); + dw.dxfHex(350, dw.getNextHandle()+1); // 2E + dw.dxfString( 3, "HIDETEXT"); + //dw.dxfHex(350, 0x2E); + dw.dxfHex(350, dw.getNextHandle()); // 2D + + + dw.dxfString( 0, "DICTIONARYVAR"); + //dw.dxfHex(5, 0x2E); + dw.handle(); // 2E + //dw.dxfHex(330, dicId5); // 2C + dw.dxfString(100, "DictionaryVariables"); + dw.dxfInt(280, 0); + dw.dxfInt( 1, 2); + + + dw.dxfString( 0, "DICTIONARYVAR"); + //dw.dxfHex(5, 0x2D); + dw.handle(); // 2D + //dw.dxfHex(330, dicId5); // 2C + dw.dxfString(100, "DictionaryVariables"); + dw.dxfInt(280, 0); + dw.dxfInt( 1, 1); +} + +void DL_Dxf::writeAppDictionary(DL_WriterA& dw) { + dw.dxfString( 0, "DICTIONARY"); + //dw.handle(); + dw.dxfHex(5, appDictionaryHandle); + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(281, 1); +} + +int DL_Dxf::writeDictionaryEntry(DL_WriterA& dw, const std::string& name) { + dw.dxfString( 3, name); + int handle = dw.getNextHandle(); + dw.dxfHex(350, handle); + dw.incHandle(); + return handle; +} + +void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, int value) { + dw.dxfString( 0, "XRECORD"); + dw.dxfHex(5, handle); + dw.dxfHex(330, appDictionaryHandle); + dw.dxfString(100, "AcDbXrecord"); + dw.dxfInt(280, 1); + dw.dxfInt(90, value); +} + +void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, double value) { + dw.dxfString( 0, "XRECORD"); + dw.dxfHex(5, handle); + dw.dxfHex(330, appDictionaryHandle); + dw.dxfString(100, "AcDbXrecord"); + dw.dxfInt(280, 1); + dw.dxfReal(40, value); +} + +void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, bool value) { + dw.dxfString( 0, "XRECORD"); + dw.dxfHex(5, handle); + dw.dxfHex(330, appDictionaryHandle); + dw.dxfString(100, "AcDbXrecord"); + dw.dxfInt(280, 1); + dw.dxfBool(290, value); +} + +void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, const std::string& value) { + dw.dxfString( 0, "XRECORD"); + dw.dxfHex(5, handle); + dw.dxfHex(330, appDictionaryHandle); + dw.dxfString(100, "AcDbXrecord"); + dw.dxfInt(280, 1); + dw.dxfString(1000, value); +} + +/** + * Writes the end of the objects section. This section is needed in DL_VERSION_R13. + * Note that this method currently only writes a faked OBJECTS section + * to make the file readable by Aut*cad. + */ +void DL_Dxf::writeObjectsEnd(DL_WriterA& dw) { + dw.dxfString( 0, "ENDSEC"); +} + + + +/** + * Writes a comment to the DXF file. + */ +void DL_Dxf::writeComment(DL_WriterA& dw, const std::string& comment) { + dw.dxfString(999, comment); +} + + +/** + * Checks if the given variable is known by the given DXF version. + */ +bool DL_Dxf::checkVariable(const char* var, DL_Codes::version version) { + if (version>=DL_VERSION_2000) { + return true; + } else if (version==DL_VERSION_R12) { + // these are all the variables recognized by dxf r12: + if (!strcmp(var, "$ACADVER")) { + return true; + } + if (!strcmp(var, "$ACADVER")) { + return true; + } + if (!strcmp(var, "$ANGBASE")) { + return true; + } + if (!strcmp(var, "$ANGDIR")) { + return true; + } + if (!strcmp(var, "$ATTDIA")) { + return true; + } + if (!strcmp(var, "$ATTMODE")) { + return true; + } + if (!strcmp(var, "$ATTREQ")) { + return true; + } + if (!strcmp(var, "$AUNITS")) { + return true; + } + if (!strcmp(var, "$AUPREC")) { + return true; + } + if (!strcmp(var, "$AXISMODE")) { + return true; + } + if (!strcmp(var, "$AXISUNIT")) { + return true; + } + if (!strcmp(var, "$BLIPMODE")) { + return true; + } + if (!strcmp(var, "$CECOLOR")) { + return true; + } + if (!strcmp(var, "$CELTYPE")) { + return true; + } + if (!strcmp(var, "$CHAMFERA")) { + return true; + } + if (!strcmp(var, "$CHAMFERB")) { + return true; + } + if (!strcmp(var, "$CLAYER")) { + return true; + } + if (!strcmp(var, "$COORDS")) { + return true; + } + if (!strcmp(var, "$DIMALT")) { + return true; + } + if (!strcmp(var, "$DIMALTD")) { + return true; + } + if (!strcmp(var, "$DIMALTF")) { + return true; + } + if (!strcmp(var, "$DIMAPOST")) { + return true; + } + if (!strcmp(var, "$DIMASO")) { + return true; + } + if (!strcmp(var, "$DIMASZ")) { + return true; + } + if (!strcmp(var, "$DIMBLK")) { + return true; + } + if (!strcmp(var, "$DIMBLK1")) { + return true; + } + if (!strcmp(var, "$DIMBLK2")) { + return true; + } + if (!strcmp(var, "$DIMCEN")) { + return true; + } + if (!strcmp(var, "$DIMCLRD")) { + return true; + } + if (!strcmp(var, "$DIMCLRE")) { + return true; + } + if (!strcmp(var, "$DIMCLRT")) { + return true; + } + if (!strcmp(var, "$DIMDLE")) { + return true; + } + if (!strcmp(var, "$DIMDLI")) { + return true; + } + if (!strcmp(var, "$DIMEXE")) { + return true; + } + if (!strcmp(var, "$DIMEXO")) { + return true; + } + if (!strcmp(var, "$DIMGAP")) { + return true; + } + if (!strcmp(var, "$DIMLFAC")) { + return true; + } + if (!strcmp(var, "$DIMLIM")) { + return true; + } + if (!strcmp(var, "$DIMPOST")) { + return true; + } + if (!strcmp(var, "$DIMRND")) { + return true; + } + if (!strcmp(var, "$DIMSAH")) { + return true; + } + if (!strcmp(var, "$DIMSCALE")) { + return true; + } + if (!strcmp(var, "$DIMSE1")) { + return true; + } + if (!strcmp(var, "$DIMSE2")) { + return true; + } + if (!strcmp(var, "$DIMSHO")) { + return true; + } + if (!strcmp(var, "$DIMSOXD")) { + return true; + } + if (!strcmp(var, "$DIMSTYLE")) { + return true; + } + if (!strcmp(var, "$DIMTAD")) { + return true; + } + if (!strcmp(var, "$DIMTFAC")) { + return true; + } + if (!strcmp(var, "$DIMTIH")) { + return true; + } + if (!strcmp(var, "$DIMTIX")) { + return true; + } + if (!strcmp(var, "$DIMTM")) { + return true; + } + if (!strcmp(var, "$DIMTOFL")) { + return true; + } + if (!strcmp(var, "$DIMTOH")) { + return true; + } + if (!strcmp(var, "$DIMTOL")) { + return true; + } + if (!strcmp(var, "$DIMTP")) { + return true; + } + if (!strcmp(var, "$DIMTSZ")) { + return true; + } + if (!strcmp(var, "$DIMTVP")) { + return true; + } + if (!strcmp(var, "$DIMTXT")) { + return true; + } + if (!strcmp(var, "$DIMZIN")) { + return true; + } + if (!strcmp(var, "$DWGCODEPAGE")) { + return true; + } + if (!strcmp(var, "$DRAGMODE")) { + return true; + } + if (!strcmp(var, "$ELEVATION")) { + return true; + } + if (!strcmp(var, "$EXTMAX")) { + return true; + } + if (!strcmp(var, "$EXTMIN")) { + return true; + } + if (!strcmp(var, "$FILLETRAD")) { + return true; + } + if (!strcmp(var, "$FILLMODE")) { + return true; + } + if (!strcmp(var, "$HANDLING")) { + return true; + } + if (!strcmp(var, "$HANDSEED")) { + return true; + } + if (!strcmp(var, "$INSBASE")) { + return true; + } + if (!strcmp(var, "$LIMCHECK")) { + return true; + } + if (!strcmp(var, "$LIMMAX")) { + return true; + } + if (!strcmp(var, "$LIMMIN")) { + return true; + } + if (!strcmp(var, "$LTSCALE")) { + return true; + } + if (!strcmp(var, "$LUNITS")) { + return true; + } + if (!strcmp(var, "$LUPREC")) { + return true; + } + if (!strcmp(var, "$MAXACTVP")) { + return true; + } + if (!strcmp(var, "$MENU")) { + return true; + } + if (!strcmp(var, "$MIRRTEXT")) { + return true; + } + if (!strcmp(var, "$ORTHOMODE")) { + return true; + } + if (!strcmp(var, "$OSMODE")) { + return true; + } + if (!strcmp(var, "$PDMODE")) { + return true; + } + if (!strcmp(var, "$PDSIZE")) { + return true; + } + if (!strcmp(var, "$PELEVATION")) { + return true; + } + if (!strcmp(var, "$PEXTMAX")) { + return true; + } + if (!strcmp(var, "$PEXTMIN")) { + return true; + } + if (!strcmp(var, "$PLIMCHECK")) { + return true; + } + if (!strcmp(var, "$PLIMMAX")) { + return true; + } + if (!strcmp(var, "$PLIMMIN")) { + return true; + } + if (!strcmp(var, "$PLINEGEN")) { + return true; + } + if (!strcmp(var, "$PLINEWID")) { + return true; + } + if (!strcmp(var, "$PSLTSCALE")) { + return true; + } + if (!strcmp(var, "$PUCSNAME")) { + return true; + } + if (!strcmp(var, "$PUCSORG")) { + return true; + } + if (!strcmp(var, "$PUCSXDIR")) { + return true; + } + if (!strcmp(var, "$PUCSYDIR")) { + return true; + } + if (!strcmp(var, "$QTEXTMODE")) { + return true; + } + if (!strcmp(var, "$REGENMODE")) { + return true; + } + if (!strcmp(var, "$SHADEDGE")) { + return true; + } + if (!strcmp(var, "$SHADEDIF")) { + return true; + } + if (!strcmp(var, "$SKETCHINC")) { + return true; + } + if (!strcmp(var, "$SKPOLY")) { + return true; + } + if (!strcmp(var, "$SPLFRAME")) { + return true; + } + if (!strcmp(var, "$SPLINESEGS")) { + return true; + } + if (!strcmp(var, "$SPLINETYPE")) { + return true; + } + if (!strcmp(var, "$SURFTAB1")) { + return true; + } + if (!strcmp(var, "$SURFTAB2")) { + return true; + } + if (!strcmp(var, "$SURFTYPE")) { + return true; + } + if (!strcmp(var, "$SURFU")) { + return true; + } + if (!strcmp(var, "$SURFV")) { + return true; + } + if (!strcmp(var, "$TDCREATE")) { + return true; + } + if (!strcmp(var, "$TDINDWG")) { + return true; + } + if (!strcmp(var, "$TDUPDATE")) { + return true; + } + if (!strcmp(var, "$TDUSRTIMER")) { + return true; + } + if (!strcmp(var, "$TEXTSIZE")) { + return true; + } + if (!strcmp(var, "$TEXTSTYLE")) { + return true; + } + if (!strcmp(var, "$THICKNESS")) { + return true; + } + if (!strcmp(var, "$TILEMODE")) { + return true; + } + if (!strcmp(var, "$TRACEWID")) { + return true; + } + if (!strcmp(var, "$UCSNAME")) { + return true; + } + if (!strcmp(var, "$UCSORG")) { + return true; + } + if (!strcmp(var, "$UCSXDIR")) { + return true; + } + if (!strcmp(var, "$UCSYDIR")) { + return true; + } + if (!strcmp(var, "$UNITMODE")) { + return true; + } + if (!strcmp(var, "$USERI1")) { + return true; + } + if (!strcmp(var, "$USERR1")) { + return true; + } + if (!strcmp(var, "$USRTIMER")) { + return true; + } + if (!strcmp(var, "$VISRETAIN")) { + return true; + } + if (!strcmp(var, "$WORLDVIEW")) { + return true; + } + if (!strcmp(var, "$FASTZOOM")) { + return true; + } + if (!strcmp(var, "$GRIDMODE")) { + return true; + } + if (!strcmp(var, "$GRIDUNIT")) { + return true; + } + if (!strcmp(var, "$SNAPANG")) { + return true; + } + if (!strcmp(var, "$SNAPBASE")) { + return true; + } + if (!strcmp(var, "$SNAPISOPAIR")) { + return true; + } + if (!strcmp(var, "$SNAPMODE")) { + return true; + } + if (!strcmp(var, "$SNAPSTYLE")) { + return true; + } + if (!strcmp(var, "$SNAPUNIT")) { + return true; + } + if (!strcmp(var, "$VIEWCTR")) { + return true; + } + if (!strcmp(var, "$VIEWDIR")) { + return true; + } + if (!strcmp(var, "$VIEWSIZE")) { + return true; + } + return false; + } + + return false; +} + + + +/** + * @returns the library version as int (4 bytes, each byte one version number). + * e.g. if str = "2.0.2.0" getLibVersion returns 0x02000200 + */ +int DL_Dxf::getLibVersion(const std::string& str) { + int d[4]; + int idx = 0; + //char v[4][5]; + std::string v[4]; + int ret = 0; + + for (unsigned int i=0; i=2) { + d[3] = str.length(); + + v[0] = str.substr(0, d[0]); + v[1] = str.substr(d[0]+1, d[1]-d[0]-1); + v[2] = str.substr(d[1]+1, d[2]-d[1]-1); + if (idx>=3) { + v[3] = str.substr(d[2]+1, d[3]-d[2]-1); + } + else { + v[3] = "0"; + } + + ret = (atoi(v[0].c_str())<<(3*8)) + + (atoi(v[1].c_str())<<(2*8)) + + (atoi(v[2].c_str())<<(1*8)) + + (atoi(v[3].c_str())<<(0*8)); + + return ret; + } else { + std::cerr << "DL_Dxf::getLibVersion: invalid version number: " << str << "\n"; + return 0; + } +} + +/** + * Converts the given string into a double or returns the given + * default valud (def) if value is NULL or empty. + */ +//double DL_Dxf::toReal(const char* value, double def) { +// if (value!=NULL && value[0] != '\0') { +// printf("toReal: not empty: %s\n", value); +// printf("toReal: val: %f\n", atof(value)); +// printf("toReal: 0: %d\n", value[0]); +// printf("toReal: 1: %d\n", value[1]); +// printf("toReal: 2: %d\n", value[2]); +// double ret; +// if (strchr(value, ',') != NULL) { +// char* tmp = new char[strlen(value)+1]; +// strcpy(tmp, value); +// DL_WriterA::strReplace(tmp, ',', '.'); +// ret = atof(tmp); +// delete[] tmp; +// } +// else { +// ret = atof(value); +// } +// return ret; +// } else { +// return def; +// } +//} + + +/** + * Some test routines. + */ +void DL_Dxf::test() { + char* buf1; + char* buf2; + char* buf3; + char* buf4; + char* buf5; + char* buf6; + + buf1 = new char[10]; + buf2 = new char[10]; + buf3 = new char[10]; + buf4 = new char[10]; + buf5 = new char[10]; + buf6 = new char[10]; + + strcpy(buf1, " 10\n"); + strcpy(buf2, "10"); + strcpy(buf3, "10\n"); + strcpy(buf4, " 10 \n"); + strcpy(buf5, " 10 \r"); + strcpy(buf6, "\t10 \n"); + + std::cout << "1 buf1: '" << buf1 << "'\n"; + stripWhiteSpace(&buf1); + std::cout << "2 buf1: '" << buf1 << "'\n"; + //assert(!strcmp(buf1, "10")); + + std::cout << "1 buf2: '" << buf2 << "'\n"; + stripWhiteSpace(&buf2); + std::cout << "2 buf2: '" << buf2 << "'\n"; + + std::cout << "1 buf3: '" << buf3 << "'\n"; + stripWhiteSpace(&buf3); + std::cout << "2 buf3: '" << buf3 << "'\n"; + + std::cout << "1 buf4: '" << buf4 << "'\n"; + stripWhiteSpace(&buf4); + std::cout << "2 buf4: '" << buf4 << "'\n"; + + std::cout << "1 buf5: '" << buf5 << "'\n"; + stripWhiteSpace(&buf5); + std::cout << "2 buf5: '" << buf5 << "'\n"; + + std::cout << "1 buf6: '" << buf6 << "'\n"; + stripWhiteSpace(&buf6); + std::cout << "2 buf6: '" << buf6 << "'\n"; + +} + + diff --git a/datafile/dxf/dxflib/dl_dxf.h b/datafile/dxf/dxflib/dl_dxf.h new file mode 100644 index 0000000..54443c5 --- /dev/null +++ b/datafile/dxf/dxflib/dl_dxf.h @@ -0,0 +1,529 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef DL_DXF_H +#define DL_DXF_H + +#include "dl_global.h" + +#include +#include +#include +#include +#include +#include + +#include "dl_attributes.h" +#include "dl_codes.h" +#include "dl_entities.h" +#include "dl_writer_ascii.h" + +#ifdef _WIN32 +#undef M_PI +#define M_PI 3.14159265358979323846 +//#pragma warning(disable : 4800) +#endif + +#ifndef M_PI +#define M_PI 3.1415926535897932384626433832795 +#endif + +#ifndef DL_NANDOUBLE +#define DL_NANDOUBLE std::numeric_limits::quiet_NaN() +#endif + +class DL_CreationInterface; +class DL_WriterA; + + +#define DL_VERSION "3.17.0.0" + +#define DL_VERSION_MAJOR 3 +#define DL_VERSION_MINOR 17 +#define DL_VERSION_REV 0 +#define DL_VERSION_BUILD 0 + +#define DL_UNKNOWN 0 +#define DL_LAYER 10 +#define DL_BLOCK 11 +#define DL_ENDBLK 12 +#define DL_LINETYPE 13 +#define DL_STYLE 20 +#define DL_SETTING 50 +#define DL_ENTITY_POINT 100 +#define DL_ENTITY_LINE 101 +#define DL_ENTITY_POLYLINE 102 +#define DL_ENTITY_LWPOLYLINE 103 +#define DL_ENTITY_VERTEX 104 +#define DL_ENTITY_SPLINE 105 +#define DL_ENTITY_KNOT 106 +#define DL_ENTITY_CONTROLPOINT 107 +#define DL_ENTITY_ARC 108 +#define DL_ENTITY_CIRCLE 109 +#define DL_ENTITY_ELLIPSE 110 +#define DL_ENTITY_INSERT 111 +#define DL_ENTITY_TEXT 112 +#define DL_ENTITY_MTEXT 113 +#define DL_ENTITY_DIMENSION 114 +#define DL_ENTITY_LEADER 115 +#define DL_ENTITY_HATCH 116 +#define DL_ENTITY_ATTRIB 117 +#define DL_ENTITY_IMAGE 118 +#define DL_ENTITY_IMAGEDEF 119 +#define DL_ENTITY_TRACE 120 +#define DL_ENTITY_SOLID 121 +#define DL_ENTITY_3DFACE 122 +#define DL_ENTITY_XLINE 123 +#define DL_ENTITY_RAY 124 +#define DL_ENTITY_ARCALIGNEDTEXT 125 +#define DL_ENTITY_SEQEND 126 +#define DL_XRECORD 200 +#define DL_DICTIONARY 210 + + +/** + * Reading and writing of DXF files. + * + * This class can read in a DXF file and calls methods from the + * interface DL_EntityContainer to add the entities to the + * contianer provided by the user of the library. + * + * It can also be used to write DXF files to a certain extent. + * + * When saving entities, special values for colors and linetypes + * can be used: + * + * Special colors are 0 (=BYBLOCK) and 256 (=BYLAYER). + * Special linetypes are "BYLAYER" and "BYBLOCK". + * + * @author Andrew Mustun + */ +class DXFLIB_EXPORT DL_Dxf { +public: + DL_Dxf(); + ~DL_Dxf(); + + bool in(const std::string& file, + DL_CreationInterface* creationInterface); + bool readDxfGroups(FILE* fp, + DL_CreationInterface* creationInterface); + static bool getStrippedLine(std::string& s, unsigned int size, + FILE* stream, bool stripSpace = true); + + bool readDxfGroups(std::stringstream& stream, + DL_CreationInterface* creationInterface); + bool in(std::stringstream &stream, + DL_CreationInterface* creationInterface); + static bool getStrippedLine(std::string& s, unsigned int size, + std::stringstream& stream, bool stripSpace = true); + + static bool stripWhiteSpace(char** s, bool stripSpaces = true); + + bool processDXFGroup(DL_CreationInterface* creationInterface, + int groupCode, const std::string& groupValue); + void addSetting(DL_CreationInterface* creationInterface); + void addLayer(DL_CreationInterface* creationInterface); + void addLinetype(DL_CreationInterface *creationInterface); + void addBlock(DL_CreationInterface* creationInterface); + void endBlock(DL_CreationInterface* creationInterface); + void addTextStyle(DL_CreationInterface* creationInterface); + + void addPoint(DL_CreationInterface* creationInterface); + void addLine(DL_CreationInterface* creationInterface); + void addXLine(DL_CreationInterface* creationInterface); + void addRay(DL_CreationInterface* creationInterface); + + void addPolyline(DL_CreationInterface* creationInterface); + void addVertex(DL_CreationInterface* creationInterface); + + void addSpline(DL_CreationInterface* creationInterface); + + void addArc(DL_CreationInterface* creationInterface); + void addCircle(DL_CreationInterface* creationInterface); + void addEllipse(DL_CreationInterface* creationInterface); + void addInsert(DL_CreationInterface* creationInterface); + + void addTrace(DL_CreationInterface* creationInterface); + void add3dFace(DL_CreationInterface* creationInterface); + void addSolid(DL_CreationInterface* creationInterface); + + void addMText(DL_CreationInterface* creationInterface); + void addText(DL_CreationInterface* creationInterface); + void addArcAlignedText(DL_CreationInterface* creationInterface); + + void addAttribute(DL_CreationInterface* creationInterface); + + DL_DimensionData getDimData(); + void addDimLinear(DL_CreationInterface* creationInterface); + void addDimAligned(DL_CreationInterface* creationInterface); + void addDimRadial(DL_CreationInterface* creationInterface); + void addDimDiametric(DL_CreationInterface* creationInterface); + void addDimAngular(DL_CreationInterface* creationInterface); + void addDimAngular3P(DL_CreationInterface* creationInterface); + void addDimOrdinate(DL_CreationInterface* creationInterface); + + void addLeader(DL_CreationInterface* creationInterface); + + void addHatch(DL_CreationInterface* creationInterface); + void addHatchLoop(); + void addHatchEdge(); + bool handleHatchData(DL_CreationInterface* creationInterface); + + void addImage(DL_CreationInterface* creationInterface); + void addImageDef(DL_CreationInterface* creationInterface); + + void addComment(DL_CreationInterface* creationInterface, const std::string& comment); + + void addDictionary(DL_CreationInterface* creationInterface); + void addDictionaryEntry(DL_CreationInterface* creationInterface); + + bool handleXRecordData(DL_CreationInterface* creationInterface); + bool handleDictionaryData(DL_CreationInterface* creationInterface); + + bool handleXData(DL_CreationInterface *creationInterface); + bool handleMTextData(DL_CreationInterface* creationInterface); + bool handleLWPolylineData(DL_CreationInterface* creationInterface); + bool handleSplineData(DL_CreationInterface* creationInterface); + bool handleLeaderData(DL_CreationInterface* creationInterface); + bool handleLinetypeData(DL_CreationInterface* creationInterface); + + void endEntity(DL_CreationInterface* creationInterface); + + void endSequence(DL_CreationInterface* creationInterface); + + //int stringToInt(const char* s, bool* ok=NULL); + + DL_WriterA* out(const char* file, + DL_Codes::version version=DL_VERSION_2000); + + void writeHeader(DL_WriterA& dw); + + void writePoint(DL_WriterA& dw, + const DL_PointData& data, + const DL_Attributes& attrib); + void writeLine(DL_WriterA& dw, + const DL_LineData& data, + const DL_Attributes& attrib); + void writeXLine(DL_WriterA& dw, + const DL_XLineData& data, + const DL_Attributes& attrib); + void writeRay(DL_WriterA& dw, + const DL_RayData& data, + const DL_Attributes& attrib); + void writePolyline(DL_WriterA& dw, + const DL_PolylineData& data, + const DL_Attributes& attrib); + void writeVertex(DL_WriterA& dw, + const DL_VertexData& data); + void writePolylineEnd(DL_WriterA& dw); + void writeSpline(DL_WriterA& dw, + const DL_SplineData& data, + const DL_Attributes& attrib); + void writeControlPoint(DL_WriterA& dw, + const DL_ControlPointData& data); + void writeFitPoint(DL_WriterA& dw, + const DL_FitPointData& data); + void writeKnot(DL_WriterA& dw, + const DL_KnotData& data); + void writeCircle(DL_WriterA& dw, + const DL_CircleData& data, + const DL_Attributes& attrib); + void writeArc(DL_WriterA& dw, + const DL_ArcData& data, + const DL_Attributes& attrib); + void writeEllipse(DL_WriterA& dw, + const DL_EllipseData& data, + const DL_Attributes& attrib); + void writeSolid(DL_WriterA& dw, + const DL_SolidData& data, + const DL_Attributes& attrib); + void writeTrace(DL_WriterA& dw, + const DL_TraceData& data, + const DL_Attributes& attrib); + void write3dFace(DL_WriterA& dw, + const DL_3dFaceData& data, + const DL_Attributes& attrib); + void writeInsert(DL_WriterA& dw, + const DL_InsertData& data, + const DL_Attributes& attrib); + void writeMText(DL_WriterA& dw, + const DL_MTextData& data, + const DL_Attributes& attrib); + void writeText(DL_WriterA& dw, + const DL_TextData& data, + const DL_Attributes& attrib); + void writeAttribute(DL_WriterA& dw, + const DL_AttributeData& data, + const DL_Attributes& attrib); + void writeDimStyleOverrides(DL_WriterA& dw, + const DL_DimensionData& data); + void writeDimAligned(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimAlignedData& edata, + const DL_Attributes& attrib); + void writeDimLinear(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimLinearData& edata, + const DL_Attributes& attrib); + void writeDimRadial(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimRadialData& edata, + const DL_Attributes& attrib); + void writeDimDiametric(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimDiametricData& edata, + const DL_Attributes& attrib); + void writeDimAngular(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimAngularData& edata, + const DL_Attributes& attrib); + void writeDimAngular3P(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimAngular3PData& edata, + const DL_Attributes& attrib); + void writeDimOrdinate(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimOrdinateData& edata, + const DL_Attributes& attrib); + void writeLeader(DL_WriterA& dw, + const DL_LeaderData& data, + const DL_Attributes& attrib); + void writeLeaderVertex(DL_WriterA& dw, + const DL_LeaderVertexData& data); + void writeHatch1(DL_WriterA& dw, + const DL_HatchData& data, + const DL_Attributes& attrib); + void writeHatch2(DL_WriterA& dw, + const DL_HatchData& data, + const DL_Attributes& attrib); + void writeHatchLoop1(DL_WriterA& dw, + const DL_HatchLoopData& data); + void writeHatchLoop2(DL_WriterA& dw, + const DL_HatchLoopData& data); + void writeHatchEdge(DL_WriterA& dw, + const DL_HatchEdgeData& data); + + int writeImage(DL_WriterA& dw, + const DL_ImageData& data, + const DL_Attributes& attrib); + + void writeImageDef(DL_WriterA& dw, int handle, + const DL_ImageData& data); + + void writeLayer(DL_WriterA& dw, + const DL_LayerData& data, + const DL_Attributes& attrib); + + void writeLinetype(DL_WriterA& dw, + const DL_LinetypeData& data); + + void writeAppid(DL_WriterA& dw, const std::string& name); + + void writeBlock(DL_WriterA& dw, + const DL_BlockData& data); + void writeEndBlock(DL_WriterA& dw, const std::string& name); + + void writeVPort(DL_WriterA& dw); + void writeStyle(DL_WriterA& dw, const DL_StyleData& style); + void writeView(DL_WriterA& dw); + void writeUcs(DL_WriterA& dw); + void writeDimStyle(DL_WriterA& dw, + double dimasz, double dimexe, double dimexo, + double dimgap, double dimtxt); + void writeBlockRecord(DL_WriterA& dw); + void writeBlockRecord(DL_WriterA& dw, const std::string& name); + void writeObjects(DL_WriterA& dw, const std::string& appDictionaryName = ""); + void writeAppDictionary(DL_WriterA& dw); + int writeDictionaryEntry(DL_WriterA& dw, const std::string& name); + void writeXRecord(DL_WriterA& dw, int handle, int value); + void writeXRecord(DL_WriterA& dw, int handle, double value); + void writeXRecord(DL_WriterA& dw, int handle, bool value); + void writeXRecord(DL_WriterA& dw, int handle, const std::string& value); + void writeObjectsEnd(DL_WriterA& dw); + + void writeComment(DL_WriterA& dw, const std::string& comment); + + /** + * Converts the given string into a double or returns the given + * default valud (def) if value is NULL or empty. + */ + //static double toReal(const char* value, double def=0.0); + + /** + * Converts the given string into an int or returns the given + * default valud (def) if value is NULL or empty. + */ +// static int toInt(const char* value, int def=0) { +// if (value!=NULL && value[0] != '\0') { +// return atoi(value); +// } + +// return def; +// } + + /** + * Converts the given string into a string or returns the given + * default valud (def) if value is NULL or empty. + */ +// static const char* toString(const char* value, const char* def="") { +// if (value!=NULL && value[0] != '\0') { +// return value; +// } else { +// return def; +// } +// } + + static bool checkVariable(const char* var, DL_Codes::version version); + + DL_Codes::version getVersion() { + return version; + } + + int getLibVersion(const std::string &str); + + static void test(); + + bool hasValue(int code) { + return values.count(code)==1; + } + + int getIntValue(int code, int def) { + if (!hasValue(code)) { + return def; + } + return toInt(values[code]); + } + + int toInt(const std::string& str) { + char* p; + return strtol(str.c_str(), &p, 10); + } + + int getInt16Value(int code, int def) { + if (!hasValue(code)) { + return def; + } + return toInt16(values[code]); + } + + int toInt16(const std::string& str) { + char* p; + return strtol(str.c_str(), &p, 16); + } + + bool toBool(const std::string& str) { + char* p; + return (bool)strtol(str.c_str(), &p, 10); + } + + std::string getStringValue(int code, const std::string& def) { + if (!hasValue(code)) { + return def; + } + return values[code]; + } + + double getRealValue(int code, double def) { + if (!hasValue(code)) { + return def; + } + return toReal(values[code]); + } + + double toReal(const std::string& str) { + double ret; + // make sure the real value uses '.' not ',': + std::string str2 = str; + std::replace(str2.begin(), str2.end(), ',', '.'); + // make sure c++ expects '.' not ',': + std::istringstream istr(str2); + //istr.imbue(std::locale("C")); + istr >> ret; + return ret; + } + +private: + DL_Codes::version version; + + std::string polylineLayer; + double* vertices; + int maxVertices; + int vertexIndex; + + double* knots; + int maxKnots; + int knotIndex; + + double* weights; + int weightIndex; + + double* controlPoints; + int maxControlPoints; + int controlPointIndex; + + double* fitPoints; + int maxFitPoints; + int fitPointIndex; + + double* leaderVertices; + int maxLeaderVertices; + int leaderVertexIndex; + + bool firstHatchLoop; + DL_HatchEdgeData hatchEdge; + std::vector > hatchEdges; + + std::string xRecordHandle; + bool xRecordValues; + + // Only the useful part of the group code + std::string groupCodeTmp; + // ...same as integer + unsigned int groupCode; + // Only the useful part of the group value + std::string groupValue; + // Current entity type + int currentObjectType; + // Value of the current setting + char settingValue[DL_DXF_MAXLINE+1]; + // Key of the current setting (e.g. "$ACADVER") + std::string settingKey; + // Stores the group codes + std::map values; + // First call of this method. We initialize all group values in + // the first call. + bool firstCall; + // Attributes of the current entity (layer, color, width, line type) + DL_Attributes attrib; + // library version. hex: 0x20003001 = 2.0.3.1 + int libVersion; + // app specific dictionary handle: + unsigned long appDictionaryHandle; + // handle of standard text style, referenced by dimstyle: + unsigned long styleHandleStd; +}; + +#endif + +// EOF diff --git a/datafile/dxf/dxflib/dl_entities.h b/datafile/dxf/dxflib/dl_entities.h new file mode 100644 index 0000000..7a4c7ad --- /dev/null +++ b/datafile/dxf/dxflib/dl_entities.h @@ -0,0 +1,1813 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef DL_ENTITIES_H +#define DL_ENTITIES_H + +#include "dl_global.h" + +#include +#include + +/** + * Layer Data. + */ +struct DXFLIB_EXPORT DL_LayerData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LayerData(const std::string& name, + int flags, bool off = false) : + name(name), flags(flags), off(off) { + } + + /** Layer name. */ + std::string name; + /** Layer flags. (1 = frozen, 2 = frozen by default, 4 = locked) */ + int flags; + /** Layer is off */ + bool off; +}; + + + +/** + * Block Data. + */ +struct DXFLIB_EXPORT DL_BlockData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_BlockData(const std::string& bName, + int bFlags, + double bbpx, double bbpy, double bbpz) { + name = bName; + flags = bFlags; + bpx = bbpx; + bpy = bbpy; + bpz = bbpz; + } + + /** Block name. */ + std::string name; + /** Block flags. (not used currently) */ + int flags; + /** X Coordinate of base point. */ + double bpx; + /** Y Coordinate of base point. */ + double bpy; + /** Z Coordinate of base point. */ + double bpz; +}; + + +/** + * Line Type Data. + */ +struct DXFLIB_EXPORT DL_LinetypeData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LinetypeData( + const std::string& name, + const std::string& description, + int flags, + int numberOfDashes, + double patternLength, + double* pattern = NULL + ) + : name(name), + description(description), + flags(flags), + numberOfDashes(numberOfDashes), + patternLength(patternLength), + pattern(pattern) + {} + + /** Linetype name */ + std::string name; + /** Linetype description */ + std::string description; + /** Linetype flags */ + int flags; + /** Number of dashes */ + int numberOfDashes; + /** Pattern length */ + double patternLength; + /** Pattern */ + double* pattern; +}; + + + +/** + * Text style data. + */ +struct DXFLIB_EXPORT DL_StyleData { + /** + * Constructor + * Parameters: see member variables. + */ + DL_StyleData( + const std::string& name, + int flags, + double fixedTextHeight, + double widthFactor, + double obliqueAngle, + int textGenerationFlags, + double lastHeightUsed, + const std::string& primaryFontFile, + const std::string& bigFontFile + ) + : name(name), + flags(flags), + fixedTextHeight(fixedTextHeight), + widthFactor(widthFactor), + obliqueAngle(obliqueAngle), + textGenerationFlags(textGenerationFlags), + lastHeightUsed(lastHeightUsed), + primaryFontFile(primaryFontFile), + bigFontFile(bigFontFile), + bold(false), + italic(false) { + } + + bool operator==(const DL_StyleData& other) { + // ignore lastHeightUsed: + return (name==other.name && + flags==other.flags && + fixedTextHeight==other.fixedTextHeight && + widthFactor==other.widthFactor && + obliqueAngle==other.obliqueAngle && + textGenerationFlags==other.textGenerationFlags && + primaryFontFile==other.primaryFontFile && + bigFontFile==other.bigFontFile); + } + + /** Style name */ + std::string name; + /** Style flags */ + int flags; + /** Fixed text height or 0 for not fixed. */ + double fixedTextHeight; + /** Width factor */ + double widthFactor; + /** Oblique angle */ + double obliqueAngle; + /** Text generation flags */ + int textGenerationFlags; + /** Last height used */ + double lastHeightUsed; + /** Primary font file name */ + std::string primaryFontFile; + /** Big font file name */ + std::string bigFontFile; + + bool bold; + bool italic; +}; + +/** + * Point Data. + */ +struct DXFLIB_EXPORT DL_PointData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_PointData(double px=0.0, double py=0.0, double pz=0.0) { + x = px; + y = py; + z = pz; + } + + /*! X Coordinate of the point. */ + double x; + /*! Y Coordinate of the point. */ + double y; + /*! Z Coordinate of the point. */ + double z; +}; + + + +/** + * Line Data. + */ +struct DXFLIB_EXPORT DL_LineData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LineData(double lx1, double ly1, double lz1, + double lx2, double ly2, double lz2) { + x1 = lx1; + y1 = ly1; + z1 = lz1; + + x2 = lx2; + y2 = ly2; + z2 = lz2; + } + + /*! X Start coordinate of the point. */ + double x1; + /*! Y Start coordinate of the point. */ + double y1; + /*! Z Start coordinate of the point. */ + double z1; + + /*! X End coordinate of the point. */ + double x2; + /*! Y End coordinate of the point. */ + double y2; + /*! Z End coordinate of the point. */ + double z2; +}; + +/** + * XLine Data. + */ +struct DXFLIB_EXPORT DL_XLineData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_XLineData(double bx, double by, double bz, + double dx, double dy, double dz) : + bx(bx), by(by), bz(bz), + dx(dx), dy(dy), dz(dz) { + } + + /*! X base point. */ + double bx; + /*! Y base point. */ + double by; + /*! Z base point. */ + double bz; + + /*! X direction vector. */ + double dx; + /*! Y direction vector. */ + double dy; + /*! Z direction vector. */ + double dz; +}; + +/** + * Ray Data. + */ +struct DXFLIB_EXPORT DL_RayData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_RayData(double bx, double by, double bz, + double dx, double dy, double dz) : + bx(bx), by(by), bz(bz), + dx(dx), dy(dy), dz(dz) { + } + + /*! X base point. */ + double bx; + /*! Y base point. */ + double by; + /*! Z base point. */ + double bz; + + /*! X direction vector. */ + double dx; + /*! Y direction vector. */ + double dy; + /*! Z direction vector. */ + double dz; +}; + + + +/** + * Arc Data. + */ +struct DXFLIB_EXPORT DL_ArcData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_ArcData(double acx, double acy, double acz, + double aRadius, + double aAngle1, double aAngle2) { + + cx = acx; + cy = acy; + cz = acz; + radius = aRadius; + angle1 = aAngle1; + angle2 = aAngle2; + } + + /*! X Coordinate of center point. */ + double cx; + /*! Y Coordinate of center point. */ + double cy; + /*! Z Coordinate of center point. */ + double cz; + + /*! Radius of arc. */ + double radius; + /*! Startangle of arc in degrees. */ + double angle1; + /*! Endangle of arc in degrees. */ + double angle2; +}; + + + +/** + * Circle Data. + */ +struct DXFLIB_EXPORT DL_CircleData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_CircleData(double acx, double acy, double acz, + double aRadius) { + + cx = acx; + cy = acy; + cz = acz; + radius = aRadius; + } + + /*! X Coordinate of center point. */ + double cx; + /*! Y Coordinate of center point. */ + double cy; + /*! Z Coordinate of center point. */ + double cz; + + /*! Radius of arc. */ + double radius; +}; + + + +/** + * Polyline Data. + */ +struct DXFLIB_EXPORT DL_PolylineData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_PolylineData(int pNumber, int pMVerteces, int pNVerteces, int pFlags, double pElevation = 0.0) { + number = pNumber; + m = pMVerteces; + n = pNVerteces; + elevation = pElevation; + flags = pFlags; + } + + /*! Number of vertices in this polyline. */ + unsigned int number; + + /*! Number of vertices in m direction if polyline is a polygon mesh. */ + unsigned int m; + + /*! Number of vertices in n direction if polyline is a polygon mesh. */ + unsigned int n; + + /*! elevation of the polyline. */ + double elevation; + + /*! Flags */ + int flags; +}; + + + +/** + * Vertex Data. + */ +struct DXFLIB_EXPORT DL_VertexData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_VertexData(double px=0.0, double py=0.0, double pz=0.0, + double pBulge=0.0) { + x = px; + y = py; + z = pz; + bulge = pBulge; + } + + /*! X Coordinate of the vertex. */ + double x; + /*! Y Coordinate of the vertex. */ + double y; + /*! Z Coordinate of the vertex. */ + double z; + /*! Bulge of vertex. + * (The tangent of 1/4 of the arc angle or 0 for lines) */ + double bulge; +}; + + +/** + * Trace Data / solid data / 3d face data. + */ +struct DXFLIB_EXPORT DL_TraceData { + DL_TraceData() { + thickness = 0.0; + for (int i=0; i<4; i++) { + x[i] = 0.0; + y[i] = 0.0; + z[i] = 0.0; + } + } + + /** + * Constructor. + * Parameters: see member variables. + */ + DL_TraceData(double sx1, double sy1, double sz1, + double sx2, double sy2, double sz2, + double sx3, double sy3, double sz3, + double sx4, double sy4, double sz4, + double sthickness=0.0) { + + thickness = sthickness; + + x[0] = sx1; + y[0] = sy1; + z[0] = sz1; + + x[1] = sx2; + y[1] = sy2; + z[1] = sz2; + + x[2] = sx3; + y[2] = sy3; + z[2] = sz3; + + x[3] = sx4; + y[3] = sy4; + z[3] = sz4; + } + + /*! Thickness */ + double thickness; + + /*! Points */ + double x[4]; + double y[4]; + double z[4]; +}; + + + + + +/** + * Solid Data. + */ +typedef DL_TraceData DL_SolidData; + + +/** + * 3dface Data. + */ +typedef DL_TraceData DL_3dFaceData; + + +/** + * Spline Data. + */ +struct DXFLIB_EXPORT DL_SplineData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_SplineData(int degree, + int nKnots, + int nControl, + int nFit, + int flags) : + degree(degree), + nKnots(nKnots), + nControl(nControl), + nFit(nFit), + flags(flags) { + } + + /*! Degree of the spline curve. */ + unsigned int degree; + + /*! Number of knots. */ + unsigned int nKnots; + + /*! Number of control points. */ + unsigned int nControl; + + /*! Number of fit points. */ + unsigned int nFit; + + /*! Flags */ + int flags; + + double tangentStartX; + double tangentStartY; + double tangentStartZ; + double tangentEndX; + double tangentEndY; + double tangentEndZ; +}; + + + +/** + * Spline knot data. + */ +struct DXFLIB_EXPORT DL_KnotData { + DL_KnotData() {} + /** + * Constructor. + * Parameters: see member variables. + */ + DL_KnotData(double pk) { + k = pk; + } + + /*! Knot value. */ + double k; +}; + + + +/** + * Spline control point data. + */ +struct DXFLIB_EXPORT DL_ControlPointData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_ControlPointData(double px, double py, double pz, double weight) { + x = px; + y = py; + z = pz; + w = weight; + } + + /*! X coordinate of the control point. */ + double x; + /*! Y coordinate of the control point. */ + double y; + /*! Z coordinate of the control point. */ + double z; + /*! Weight of control point. */ + double w; +}; + + + +/** + * Spline fit point data. + */ +struct DXFLIB_EXPORT DL_FitPointData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_FitPointData(double x, double y, double z) : x(x), y(y), z(z) {} + + /*! X coordinate of the fit point. */ + double x; + /*! Y coordinate of the fit point. */ + double y; + /*! Z coordinate of the fit point. */ + double z; +}; + + + +/** + * Ellipse Data. + */ +struct DXFLIB_EXPORT DL_EllipseData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_EllipseData(double cx, double cy, double cz, + double mx, double my, double mz, + double ratio, + double angle1, double angle2) + : cx(cx), + cy(cy), + cz(cz), + mx(mx), + my(my), + mz(mz), + ratio(ratio), + angle1(angle1), + angle2(angle2) { + } + + /*! X Coordinate of center point. */ + double cx; + /*! Y Coordinate of center point. */ + double cy; + /*! Z Coordinate of center point. */ + double cz; + + /*! X coordinate of the endpoint of the major axis. */ + double mx; + /*! Y coordinate of the endpoint of the major axis. */ + double my; + /*! Z coordinate of the endpoint of the major axis. */ + double mz; + + /*! Ratio of minor axis to major axis.. */ + double ratio; + /*! Startangle of ellipse in rad. */ + double angle1; + /*! Endangle of ellipse in rad. */ + double angle2; +}; + + + +/** + * Insert Data. + */ +struct DXFLIB_EXPORT DL_InsertData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_InsertData(const std::string& name, + double ipx, double ipy, double ipz, + double sx, double sy, double sz, + double angle, + int cols, int rows, + double colSp, double rowSp) : + name(name), + ipx(ipx), ipy(ipy), ipz(ipz), + sx(sx), sy(sy), sz(sz), + angle(angle), + cols(cols), rows(rows), + colSp(colSp), rowSp(rowSp) { + } + + /*! Name of the referred block. */ + std::string name; + /*! X Coordinate of insertion point. */ + double ipx; + /*! Y Coordinate of insertion point. */ + double ipy; + /*! Z Coordinate of insertion point. */ + double ipz; + /*! X Scale factor. */ + double sx; + /*! Y Scale factor. */ + double sy; + /*! Z Scale factor. */ + double sz; + /*! Rotation angle in degrees. */ + double angle; + /*! Number of colums if we insert an array of the block or 1. */ + int cols; + /*! Number of rows if we insert an array of the block or 1. */ + int rows; + /*! Values for the spacing between cols. */ + double colSp; + /*! Values for the spacing between rows. */ + double rowSp; +}; + + + +/** + * MText Data. + */ +struct DXFLIB_EXPORT DL_MTextData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_MTextData(double ipx, double ipy, double ipz, + double dirx, double diry, double dirz, + double height, double width, + int attachmentPoint, + int drawingDirection, + int lineSpacingStyle, + double lineSpacingFactor, + const std::string& text, + const std::string& style, + double angle) : + ipx(ipx), ipy(ipy), ipz(ipz), + dirx(dirx), diry(diry), dirz(dirz), + height(height), width(width), + attachmentPoint(attachmentPoint), + drawingDirection(drawingDirection), + lineSpacingStyle(lineSpacingStyle), + lineSpacingFactor(lineSpacingFactor), + text(text), + style(style), + angle(angle) { + + } + + /*! X Coordinate of insertion point. */ + double ipx; + /*! Y Coordinate of insertion point. */ + double ipy; + /*! Z Coordinate of insertion point. */ + double ipz; + /*! X Coordinate of X direction vector. */ + double dirx; + /*! Y Coordinate of X direction vector. */ + double diry; + /*! Z Coordinate of X direction vector. */ + double dirz; + /*! Text height */ + double height; + /*! Width of the text box. */ + double width; + /** + * Attachment point. + * + * 1 = Top left, 2 = Top center, 3 = Top right, + * 4 = Middle left, 5 = Middle center, 6 = Middle right, + * 7 = Bottom left, 8 = Bottom center, 9 = Bottom right + */ + int attachmentPoint; + /** + * Drawing direction. + * + * 1 = left to right, 3 = top to bottom, 5 = by style + */ + int drawingDirection; + /** + * Line spacing style. + * + * 1 = at least, 2 = exact + */ + int lineSpacingStyle; + /** + * Line spacing factor. 0.25 .. 4.0 + */ + double lineSpacingFactor; + /*! Text string. */ + std::string text; + /*! Style string. */ + std::string style; + /*! Rotation angle. */ + double angle; +}; + + + +/** + * Text Data. + */ +struct DXFLIB_EXPORT DL_TextData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_TextData(double ipx, double ipy, double ipz, + double apx, double apy, double apz, + double height, double xScaleFactor, + int textGenerationFlags, + int hJustification, + int vJustification, + const std::string& text, + const std::string& style, + double angle) + : ipx(ipx), ipy(ipy), ipz(ipz), + apx(apx), apy(apy), apz(apz), + height(height), xScaleFactor(xScaleFactor), + textGenerationFlags(textGenerationFlags), + hJustification(hJustification), + vJustification(vJustification), + text(text), + style(style), + angle(angle) { + } + + /*! X Coordinate of insertion point. */ + double ipx; + /*! Y Coordinate of insertion point. */ + double ipy; + /*! Z Coordinate of insertion point. */ + double ipz; + + /*! X Coordinate of alignment point. */ + double apx; + /*! Y Coordinate of alignment point. */ + double apy; + /*! Z Coordinate of alignment point. */ + double apz; + + /*! Text height */ + double height; + /*! Relative X scale factor. */ + double xScaleFactor; + /*! 0 = default, 2 = Backwards, 4 = Upside down */ + int textGenerationFlags; + /** + * Horizontal justification. + * + * 0 = Left (default), 1 = Center, 2 = Right, + * 3 = Aligned, 4 = Middle, 5 = Fit + * For 3, 4, 5 the vertical alignment has to be 0. + */ + int hJustification; + /** + * Vertical justification. + * + * 0 = Baseline (default), 1 = Bottom, 2 = Middle, 3= Top + */ + int vJustification; + /*! Text string. */ + std::string text; + /*! Style (font). */ + std::string style; + /*! Rotation angle of dimension text away from default orientation. */ + double angle; +}; + +/** + * Arc Aligned Text Data. + */ +struct DXFLIB_EXPORT DL_ArcAlignedTextData { + + /*! Text string */ + std::string text; + /*! Font name */ + std::string font; + /*! Style */ + std::string style; + + /*! X coordinate of arc center point. */ + double cx; + /*! Y coordinate of arc center point. */ + double cy; + /*! Z coordinate of arc center point. */ + double cz; + /*! Arc radius. */ + double radius; + + /*! Relative X scale factor. */ + double xScaleFactor; + /*! Text height */ + double height; + /*! Character spacing */ + double spacing; + /*! Offset from arc */ + double offset; + /*! Right offset */ + double rightOffset; + /*! Left offset */ + double leftOffset; + /*! Start angle (radians) */ + double startAngle; + /*! End angle (radians) */ + double endAngle; + /*! Reversed character order: + * false: normal + * true: reversed + */ + bool reversedCharacterOrder; + /*! Direction + * 1: outward from center + * 2: inward from center + */ + int direction; + /*! Alignment: + * 1: fit + * 2: left + * 3: right + * 4: center + */ + int alignment; + /*! Side + * 1: convex + * 2: concave + */ + int side; + /*! Bold flag */ + bool bold; + /*! Italic flag */ + bool italic; + /*! Underline flag */ + bool underline; + /*! Character set value. Windows character set identifier. */ + int characerSet; + /*! Pitch and family value. Windows pitch and character family identifier. */ + int pitch; + /*! Font type: + * false: TTF + * true: SHX + */ + bool shxFont; + /*! Wizard flag */ + bool wizard; + /*! Arc handle/ID */ + int arcHandle; +}; + +/** + * Block attribute data. + */ +struct DXFLIB_EXPORT DL_AttributeData : public DL_TextData { + DL_AttributeData(const DL_TextData& tData, const std::string& tag) + : DL_TextData(tData), tag(tag) { + + } + + /** + * Constructor. + * Parameters: see member variables. + */ + DL_AttributeData(double ipx, double ipy, double ipz, + double apx, double apy, double apz, + double height, double xScaleFactor, + int textGenerationFlags, + int hJustification, + int vJustification, + const std::string& tag, + const std::string& text, + const std::string& style, + double angle) + : DL_TextData(ipx, ipy, ipz, + apx, apy, apz, + height, xScaleFactor, + textGenerationFlags, + hJustification, + vJustification, + text, + style, + angle), + tag(tag) { + } + + /*! Tag. */ + std::string tag; +}; + + +/** + * Generic Dimension Data. + */ +struct DXFLIB_EXPORT DL_DimensionData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimensionData(double dpx, double dpy, double dpz, + double mpx, double mpy, double mpz, + int type, + int attachmentPoint, + int lineSpacingStyle, + double lineSpacingFactor, + const std::string& text, + const std::string& style, + double angle, + double linearFactor = 1.0, + double dimScale = 1.0) : + dpx(dpx), dpy(dpy), dpz(dpz), + mpx(mpx), mpy(mpy), mpz(mpz), + type(type), + attachmentPoint(attachmentPoint), + lineSpacingStyle(lineSpacingStyle), + lineSpacingFactor(lineSpacingFactor), + text(text), + style(style), + angle(angle), + linearFactor(linearFactor), + dimScale(dimScale) { + + } + + /*! X Coordinate of definition point. */ + double dpx; + /*! Y Coordinate of definition point. */ + double dpy; + /*! Z Coordinate of definition point. */ + double dpz; + /*! X Coordinate of middle point of the text. */ + double mpx; + /*! Y Coordinate of middle point of the text. */ + double mpy; + /*! Z Coordinate of middle point of the text. */ + double mpz; + /** + * Dimension type. + * + * 0 Rotated, horizontal, or vertical + * 1 Aligned + * 2 Angular + * 3 Diametric + * 4 Radius + * 5 Angular 3-point + * 6 Ordinate + * 64 Ordinate type. This is a bit value (bit 7) + * used only with integer value 6. If set, + * ordinate is X-type; if not set, ordinate is + * Y-type + * 128 This is a bit value (bit 8) added to the + * other group 70 values if the dimension text + * has been positioned at a user-defined + * location rather than at the default location + */ + int type; + /** + * Attachment point. + * + * 1 = Top left, 2 = Top center, 3 = Top right, + * 4 = Middle left, 5 = Middle center, 6 = Middle right, + * 7 = Bottom left, 8 = Bottom center, 9 = Bottom right, + */ + int attachmentPoint; + /** + * Line spacing style. + * + * 1 = at least, 2 = exact + */ + int lineSpacingStyle; + /** + * Line spacing factor. 0.25 .. 4.0 + */ + double lineSpacingFactor; + /** + * Text string. + * + * Text string entered explicitly by user or null + * or "<>" for the actual measurement or " " (one blank space). + * for supressing the text. + */ + std::string text; + /*! Dimension style (font name). */ + std::string style; + /** + * Rotation angle of dimension text away from + * default orientation. + */ + double angle; + /** + * Linear factor style override. + */ + double linearFactor; + /** + * Dimension scale (dimscale) style override. + */ + double dimScale; +}; + + + +/** + * Aligned Dimension Data. + */ +struct DXFLIB_EXPORT DL_DimAlignedData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimAlignedData(double depx1, double depy1, double depz1, + double depx2, double depy2, double depz2) { + + epx1 = depx1; + epy1 = depy1; + epz1 = depz1; + + epx2 = depx2; + epy2 = depy2; + epz2 = depz2; + } + + /*! X Coordinate of Extension point 1. */ + double epx1; + /*! Y Coordinate of Extension point 1. */ + double epy1; + /*! Z Coordinate of Extension point 1. */ + double epz1; + + /*! X Coordinate of Extension point 2. */ + double epx2; + /*! Y Coordinate of Extension point 2. */ + double epy2; + /*! Z Coordinate of Extension point 2. */ + double epz2; +}; + + + +/** + * Linear (rotated) Dimension Data. + */ +struct DXFLIB_EXPORT DL_DimLinearData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimLinearData(double ddpx1, double ddpy1, double ddpz1, + double ddpx2, double ddpy2, double ddpz2, + double dAngle, double dOblique) { + + dpx1 = ddpx1; + dpy1 = ddpy1; + dpz1 = ddpz1; + + dpx2 = ddpx2; + dpy2 = ddpy2; + dpz2 = ddpz2; + + angle = dAngle; + oblique = dOblique; + } + + /*! X Coordinate of Extension point 1. */ + double dpx1; + /*! Y Coordinate of Extension point 1. */ + double dpy1; + /*! Z Coordinate of Extension point 1. */ + double dpz1; + + /*! X Coordinate of Extension point 2. */ + double dpx2; + /*! Y Coordinate of Extension point 2. */ + double dpy2; + /*! Z Coordinate of Extension point 2. */ + double dpz2; + + /*! Rotation angle (angle of dimension line) in degrees. */ + double angle; + /*! Oblique angle in degrees. */ + double oblique; +}; + + + +/** + * Radial Dimension Data. + */ +struct DXFLIB_EXPORT DL_DimRadialData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimRadialData(double ddpx, double ddpy, double ddpz, double dleader) { + dpx = ddpx; + dpy = ddpy; + dpz = ddpz; + + leader = dleader; + } + + /*! X Coordinate of definition point. */ + double dpx; + /*! Y Coordinate of definition point. */ + double dpy; + /*! Z Coordinate of definition point. */ + double dpz; + + /*! Leader length */ + double leader; +}; + + + +/** + * Diametric Dimension Data. + */ +struct DXFLIB_EXPORT DL_DimDiametricData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimDiametricData(double ddpx, double ddpy, double ddpz, double dleader) { + dpx = ddpx; + dpy = ddpy; + dpz = ddpz; + + leader = dleader; + } + + /*! X Coordinate of definition point (DXF 15). */ + double dpx; + /*! Y Coordinate of definition point (DXF 25). */ + double dpy; + /*! Z Coordinate of definition point (DXF 35). */ + double dpz; + + /*! Leader length */ + double leader; +}; + + + +/** + * Angular Dimension Data. + */ +struct DXFLIB_EXPORT DL_DimAngularData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimAngularData(double ddpx1, double ddpy1, double ddpz1, + double ddpx2, double ddpy2, double ddpz2, + double ddpx3, double ddpy3, double ddpz3, + double ddpx4, double ddpy4, double ddpz4) { + + dpx1 = ddpx1; + dpy1 = ddpy1; + dpz1 = ddpz1; + + dpx2 = ddpx2; + dpy2 = ddpy2; + dpz2 = ddpz2; + + dpx3 = ddpx3; + dpy3 = ddpy3; + dpz3 = ddpz3; + + dpx4 = ddpx4; + dpy4 = ddpy4; + dpz4 = ddpz4; + } + + /*! X Coordinate of definition point 1. */ + double dpx1; + /*! Y Coordinate of definition point 1. */ + double dpy1; + /*! Z Coordinate of definition point 1. */ + double dpz1; + + /*! X Coordinate of definition point 2. */ + double dpx2; + /*! Y Coordinate of definition point 2. */ + double dpy2; + /*! Z Coordinate of definition point 2. */ + double dpz2; + + /*! X Coordinate of definition point 3. */ + double dpx3; + /*! Y Coordinate of definition point 3. */ + double dpy3; + /*! Z Coordinate of definition point 3. */ + double dpz3; + + /*! X Coordinate of definition point 4. */ + double dpx4; + /*! Y Coordinate of definition point 4. */ + double dpy4; + /*! Z Coordinate of definition point 4. */ + double dpz4; +}; + + +/** + * Angular Dimension Data (3 points version). + */ +struct DXFLIB_EXPORT DL_DimAngular3PData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimAngular3PData(double ddpx1, double ddpy1, double ddpz1, + double ddpx2, double ddpy2, double ddpz2, + double ddpx3, double ddpy3, double ddpz3) { + + dpx1 = ddpx1; + dpy1 = ddpy1; + dpz1 = ddpz1; + + dpx2 = ddpx2; + dpy2 = ddpy2; + dpz2 = ddpz2; + + dpx3 = ddpx3; + dpy3 = ddpy3; + dpz3 = ddpz3; + } + + /*! X Coordinate of definition point 1. */ + double dpx1; + /*! Y Coordinate of definition point 1. */ + double dpy1; + /*! Z Coordinate of definition point 1. */ + double dpz1; + + /*! X Coordinate of definition point 2. */ + double dpx2; + /*! Y Coordinate of definition point 2. */ + double dpy2; + /*! Z Coordinate of definition point 2. */ + double dpz2; + + /*! X Coordinate of definition point 3. */ + double dpx3; + /*! Y Coordinate of definition point 3. */ + double dpy3; + /*! Z Coordinate of definition point 3. */ + double dpz3; +}; + + + +/** + * Ordinate Dimension Data. + */ +struct DXFLIB_EXPORT DL_DimOrdinateData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimOrdinateData(double ddpx1, double ddpy1, double ddpz1, + double ddpx2, double ddpy2, double ddpz2, + bool dxtype) { + + dpx1 = ddpx1; + dpy1 = ddpy1; + dpz1 = ddpz1; + + dpx2 = ddpx2; + dpy2 = ddpy2; + dpz2 = ddpz2; + + xtype = dxtype; + } + + /*! X Coordinate of definition point 1. */ + double dpx1; + /*! Y Coordinate of definition point 1. */ + double dpy1; + /*! Z Coordinate of definition point 1. */ + double dpz1; + + /*! X Coordinate of definition point 2. */ + double dpx2; + /*! Y Coordinate of definition point 2. */ + double dpy2; + /*! Z Coordinate of definition point 2. */ + double dpz2; + + /*! True if the dimension indicates the X-value, false for Y-value */ + bool xtype; +}; + + + +/** + * Leader (arrow). + */ +struct DXFLIB_EXPORT DL_LeaderData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LeaderData(int lArrowHeadFlag, + int lLeaderPathType, + int lLeaderCreationFlag, + int lHooklineDirectionFlag, + int lHooklineFlag, + double lTextAnnotationHeight, + double lTextAnnotationWidth, + int lNumber) { + + arrowHeadFlag = lArrowHeadFlag; + leaderPathType = lLeaderPathType; + leaderCreationFlag = lLeaderCreationFlag; + hooklineDirectionFlag = lHooklineDirectionFlag; + hooklineFlag = lHooklineFlag; + textAnnotationHeight = lTextAnnotationHeight; + textAnnotationWidth = lTextAnnotationWidth; + number = lNumber; + } + + /*! Arrow head flag (71). */ + int arrowHeadFlag; + /*! Leader path type (72). */ + int leaderPathType; + /*! Leader creation flag (73). */ + int leaderCreationFlag; + /*! Hookline direction flag (74). */ + int hooklineDirectionFlag; + /*! Hookline flag (75) */ + int hooklineFlag; + /*! Text annotation height (40). */ + double textAnnotationHeight; + /*! Text annotation width (41) */ + double textAnnotationWidth; + /*! Number of vertices in leader (76). */ + int number; +}; + + + +/** + * Leader Vertex Data. + */ +struct DXFLIB_EXPORT DL_LeaderVertexData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LeaderVertexData(double px=0.0, double py=0.0, double pz=0.0) { + x = px; + y = py; + z = pz; + } + + /*! X Coordinate of the vertex. */ + double x; + /*! Y Coordinate of the vertex. */ + double y; + /*! Z Coordinate of the vertex. */ + double z; +}; + + + +/** + * Hatch data. + */ +struct DXFLIB_EXPORT DL_HatchData { + /** + * Default constructor. + */ + DL_HatchData() {} + + /** + * Constructor. + * Parameters: see member variables. + */ + DL_HatchData(int numLoops, + bool solid, + double scale, + double angle, + const std::string& pattern, + double originX = 0.0, + double originY = 0.0) : + numLoops(numLoops), + solid(solid), + scale(scale), + angle(angle), + pattern(pattern), + originX(originX), + originY(originY) { + + } + + /*! Number of boundary paths (loops). */ + int numLoops; + /*! Solid fill flag (true=solid, false=pattern). */ + bool solid; + /*! Pattern scale or spacing */ + double scale; + /*! Pattern angle in degrees */ + double angle; + /*! Pattern name. */ + std::string pattern; + /*! Pattern origin */ + double originX; + double originY; +}; + + + +/** + * Hatch boundary path (loop) data. + */ +struct DXFLIB_EXPORT DL_HatchLoopData { + /** + * Default constructor. + */ + DL_HatchLoopData() {} + /** + * Constructor. + * Parameters: see member variables. + */ + DL_HatchLoopData(int hNumEdges) { + numEdges = hNumEdges; + } + + /*! Number of edges in this loop. */ + int numEdges; +}; + + + +/** + * Hatch edge data. + */ +struct DXFLIB_EXPORT DL_HatchEdgeData { + /** + * Default constructor. + */ + DL_HatchEdgeData() : defined(false), x1(0.0), y1(0.0), x2(0.0), y2(0.0) { + } + + /** + * Constructor for a line edge. + * Parameters: see member variables. + */ + DL_HatchEdgeData(double x1, double y1, + double x2, double y2) : + defined(true), + type(1), + x1(x1), + y1(y1), + x2(x2), + y2(y2) { + } + + /** + * Constructor for an arc edge. + * Parameters: see member variables. + */ + DL_HatchEdgeData(double cx, double cy, + double radius, + double angle1, double angle2, + bool ccw) : + defined(true), + type(2), + cx(cx), + cy(cy), + radius(radius), + angle1(angle1), + angle2(angle2), + ccw(ccw) { + } + + /** + * Constructor for an ellipse arc edge. + * Parameters: see member variables. + */ + DL_HatchEdgeData(double cx, double cy, + double mx, double my, + double ratio, + double angle1, double angle2, + bool ccw) : + defined(true), + type(3), + cx(cx), + cy(cy), + angle1(angle1), + angle2(angle2), + ccw(ccw), + mx(mx), + my(my), + ratio(ratio) { + } + + /** + * Constructor for a spline edge. + * Parameters: see member variables. + */ + DL_HatchEdgeData(unsigned int degree, + bool rational, + bool periodic, + unsigned int nKnots, + unsigned int nControl, + unsigned int nFit, + const std::vector& knots, + const std::vector >& controlPoints, + const std::vector >& fitPoints, + const std::vector& weights, + double startTangentX, + double startTangentY, + double endTangentX, + double endTangentY) : + defined(true), + type(4), + degree(degree), + rational(rational), + periodic(periodic), + nKnots(nKnots), + nControl(nControl), + nFit(nFit), + controlPoints(controlPoints), + knots(knots), + weights(weights), + fitPoints(fitPoints), + startTangentX(startTangentX), + startTangentY(startTangentY), + endTangentX(endTangentX), + endTangentY(endTangentY) { + } + + /** + * Set to true if this edge is fully defined. + */ + bool defined; + + /** + * Edge type. 1=line, 2=arc, 3=elliptic arc, 4=spline. + */ + int type; + + // line edges: + + /*! Start point (X). */ + double x1; + /*! Start point (Y). */ + double y1; + /*! End point (X). */ + double x2; + /*! End point (Y). */ + double y2; + + /*! Center point of arc or ellipse arc (X). */ + double cx; + /*! Center point of arc or ellipse arc (Y). */ + double cy; + /*! Arc radius. */ + double radius; + /*! Start angle of arc or ellipse arc. */ + double angle1; + /*! End angle of arc or ellipse arc. */ + double angle2; + /*! Counterclockwise flag for arc or ellipse arc. */ + bool ccw; + + /*! Major axis end point (X). */ + double mx; + /*! Major axis end point (Y). */ + double my; + /*! Axis ratio */ + double ratio; + + + /*! Spline degree */ + unsigned int degree; + bool rational; + bool periodic; + /*! Number of knots. */ + unsigned int nKnots; + /*! Number of control points. */ + unsigned int nControl; + /*! Number of fit points. */ + unsigned int nFit; + + std::vector > controlPoints; + std::vector knots; + std::vector weights; + std::vector > fitPoints; + + double startTangentX; + double startTangentY; + + double endTangentX; + double endTangentY; + + /** Polyline boundary vertices (x y [bulge])*/ + std::vector > vertices; + //bool closed; +}; + + + +/** + * Image Data. + */ +struct DXFLIB_EXPORT DL_ImageData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_ImageData(const std::string& iref, + double iipx, double iipy, double iipz, + double iux, double iuy, double iuz, + double ivx, double ivy, double ivz, + int iwidth, int iheight, + int ibrightness, int icontrast, int ifade) { + ref = iref; + ipx = iipx; + ipy = iipy; + ipz = iipz; + ux = iux; + uy = iuy; + uz = iuz; + vx = ivx; + vy = ivy; + vz = ivz; + width = iwidth; + height = iheight; + brightness = ibrightness; + contrast = icontrast; + fade = ifade; + } + + /*! Reference to the image file + (unique, used to refer to the image def object). */ + std::string ref; + /*! X Coordinate of insertion point. */ + double ipx; + /*! Y Coordinate of insertion point. */ + double ipy; + /*! Z Coordinate of insertion point. */ + double ipz; + /*! X Coordinate of u vector along bottom of image. */ + double ux; + /*! Y Coordinate of u vector along bottom of image. */ + double uy; + /*! Z Coordinate of u vector along bottom of image. */ + double uz; + /*! X Coordinate of v vector along left side of image. */ + double vx; + /*! Y Coordinate of v vector along left side of image. */ + double vy; + /*! Z Coordinate of v vector along left side of image. */ + double vz; + /*! Width of image in pixel. */ + int width; + /*! Height of image in pixel. */ + int height; + /*! Brightness (0..100, default = 50). */ + int brightness; + /*! Contrast (0..100, default = 50). */ + int contrast; + /*! Fade (0..100, default = 0). */ + int fade; +}; + + + +/** + * Image Definition Data. + */ +struct DXFLIB_EXPORT DL_ImageDefData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_ImageDefData(const std::string& iref, + const std::string& ifile) { + ref = iref; + file = ifile; + } + + /*! Reference to the image file + (unique, used to refer to the image def object). */ + std::string ref; + + /*! Image file */ + std::string file; +}; + + + +/** + * Dictionary data. + */ +struct DXFLIB_EXPORT DL_DictionaryData { + DL_DictionaryData(const std::string& handle) : handle(handle) {} + std::string handle; +}; + + + +/** + * Dictionary entry data. + */ +struct DXFLIB_EXPORT DL_DictionaryEntryData { + DL_DictionaryEntryData(const std::string& name, const std::string& handle) : + name(name), handle(handle) {} + + std::string name; + std::string handle; +}; + +#endif + +// EOF diff --git a/datafile/dxf/dxflib/dl_exception.h b/datafile/dxf/dxflib/dl_exception.h new file mode 100644 index 0000000..7fd944b --- /dev/null +++ b/datafile/dxf/dxflib/dl_exception.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** Copyright (C) 2001 Robert J. Campbell Jr. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef DL_EXCEPTION_H +#define DL_EXCEPTION_H + +#include "dl_global.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +/** + * Used for exception handling. + */ +class DXFLIB_EXPORT DL_Exception {} +; + +/** + * Used for exception handling. + */ +class DXFLIB_EXPORT DL_NullStrExc : public DL_Exception {} +; + +/** + * Used for exception handling. + */ +class DXFLIB_EXPORT DL_GroupCodeExc : public DL_Exception { + DL_GroupCodeExc(int gc=0) : groupCode(gc) {} + int groupCode; +}; +#endif + diff --git a/datafile/dxf/dxflib/dl_extrusion.h b/datafile/dxf/dxflib/dl_extrusion.h new file mode 100644 index 0000000..d836c04 --- /dev/null +++ b/datafile/dxf/dxflib/dl_extrusion.h @@ -0,0 +1,143 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef DL_EXTRUSION_H +#define DL_EXTRUSION_H + +#include "dl_global.h" + +#include + + +/** + * Extrusion direction. + * + * @author Andrew Mustun + */ +class DXFLIB_EXPORT DL_Extrusion { + +public: + + /** + * Default constructor. + */ + DL_Extrusion() { + direction = new double[3]; + setDirection(0.0, 0.0, 1.0); + setElevation(0.0); + } + + + /** + * Destructor. + */ + ~DL_Extrusion() { + delete[] direction ; + } + + + /** + * Constructor for DXF extrusion. + * + * @param direction Vector of axis along which the entity shall be extruded + * this is also the Z axis of the Entity coordinate system + * @param elevation Distance of the entities XY plane from the origin of the + * world coordinate system + */ + DL_Extrusion(double dx, double dy, double dz, double elevation) { + direction = new double[3]; + setDirection(dx, dy, dz); + setElevation(elevation); + } + + + + /** + * Sets the direction vector. + */ + void setDirection(double dx, double dy, double dz) { + direction[0]=dx; + direction[1]=dy; + direction[2]=dz; + } + + + + /** + * @return direction vector. + */ + double* getDirection() const { + return direction; + } + + + + /** + * @return direction vector. + */ + void getDirection(double dir[]) const { + dir[0]=direction[0]; + dir[1]=direction[1]; + dir[2]=direction[2]; + } + + + + /** + * Sets the elevation. + */ + void setElevation(double elevation) { + this->elevation = elevation; + } + + + + /** + * @return Elevation. + */ + double getElevation() const { + return elevation; + } + + + + /** + * Copies extrusion (deep copies) from another extrusion object. + */ + DL_Extrusion operator = (const DL_Extrusion& extru) { + setDirection(extru.direction[0], extru.direction[1], extru.direction[2]); + setElevation(extru.elevation); + + return *this; + } + + + +private: + double *direction; + double elevation; +}; + +#endif + diff --git a/datafile/dxf/dxflib/dl_global.h b/datafile/dxf/dxflib/dl_global.h new file mode 100644 index 0000000..0d52bea --- /dev/null +++ b/datafile/dxf/dxflib/dl_global.h @@ -0,0 +1,13 @@ +#if defined(DXFLIB_DLL) +# ifdef _WIN32 +# if defined(DXFLIB_LIBRARY) +# define DXFLIB_EXPORT __declspec(dllexport) +# else +# define DXFLIB_EXPORT __declspec(dllimport) +# endif +# else +# define DXFLIB_EXPORT +# endif +#else +# define DXFLIB_EXPORT +#endif diff --git a/datafile/dxf/dxflib/dl_writer.h b/datafile/dxf/dxflib/dl_writer.h new file mode 100644 index 0000000..2aa09d5 --- /dev/null +++ b/datafile/dxf/dxflib/dl_writer.h @@ -0,0 +1,654 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** Copyright (C) 2001 Robert J. Campbell Jr. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#ifndef DL_WRITER_H +#define DL_WRITER_H + +#include "dl_global.h" + +#ifndef _WIN32 +#include +#endif + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include +#include + +#include "dl_attributes.h" +#include "dl_codes.h" + + + +/** + * Defines interface for writing low level DXF constructs to + * a file. Implementation is defined in derived classes that write + * to binary or ASCII files. + * + * Implements functions that write higher level constructs in terms of + * the low level ones. + * + * @todo Add error checking for string/entry length. + */ +class DXFLIB_EXPORT DL_Writer { +public: + /** + * @param version DXF version. Defaults to DL_VERSION_2002. + */ + DL_Writer(DL_Codes::version version) : m_handle(0x30) { + this->version = version; + modelSpaceHandle = 0; + paperSpaceHandle = 0; + paperSpace0Handle = 0; + } + + virtual ~DL_Writer() {} + ; + + /** Generic section for section 'name'. + * + *

+     *   0
+     *  SECTION
+     *   2
+     *  name
+     * 
+ */ + void section(const char* name) const { + dxfString(0, "SECTION"); + dxfString(2, name); + } + + /** + * Section HEADER + * + *
+     *   0
+     *  SECTION
+     *   2
+     *  HEADER
+     * 
+ */ + void sectionHeader() const { + section("HEADER"); + } + + /** + * Section TABLES + * + *
+     *   0
+     *  SECTION
+     *   2
+     *  TABLES
+     * 
+ */ + void sectionTables() const { + section("TABLES"); + } + + /** + * Section BLOCKS + * + *
+     *   0
+     *  SECTION
+     *   2
+     *  BLOCKS
+     * 
+ */ + void sectionBlocks() const { + section("BLOCKS"); + } + + /** + * Section ENTITIES + * + *
+     *   0
+     *  SECTION
+     *   2
+     *  ENTITIES
+     * 
+ */ + void sectionEntities() const { + section("ENTITIES"); + } + + /** + * Section CLASSES + * + *
+     *   0
+     *  SECTION
+     *   2
+     *  CLASSES
+     * 
+ */ + void sectionClasses() const { + section("CLASSES"); + } + + /** + * Section OBJECTS + * + *
+     *   0
+     *  SECTION
+     *   2
+     *  OBJECTS
+     * 
+ */ + void sectionObjects() const { + section("OBJECTS"); + } + + /** + * End of a section. + * + *
+     *   0
+     *  ENDSEC
+     * 
+ */ + void sectionEnd() const { + dxfString(0, "ENDSEC"); + } + + /** + * Generic table for table 'name' with 'num' entries: + * + *
+     *   0
+     *  TABLE
+     *   2
+     *  name
+     *  70
+     *   num
+     * 
+ */ + void table(const char* name, int num, int h=0) const { + dxfString(0, "TABLE"); + dxfString(2, name); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } + else { + dxfHex(5, h); + } + dxfString(100, "AcDbSymbolTable"); + } + dxfInt(70, num); + } + + /** Table for layers. + * + * @param num Number of layers in total. + * + *
+     *   0
+     *  TABLE
+     *   2
+     *  LAYER
+     *   70
+     *      num
+     * 
+ */ + void tableLayers(int num) const { + table("LAYER", num, 2); + } + + /** Table for line types. + * + * @param num Number of line types in total. + * + *
+     *   0
+     *  TABLE
+     *   2
+     *  LTYPE
+     *   70
+     *      num
+     * 
+ */ + void tableLinetypes(int num) const { + //linetypeHandle = 5; + table("LTYPE", num, 5); + } + + /** Table for application id. + * + * @param num Number of registered applications in total. + * + *
+     *   0
+     *  TABLE
+     *   2
+     *  APPID
+     *   70
+     *      num
+     * 
+ */ + void tableAppid(int num) const { + table("APPID", num, 9); + } + + /** Table for text style. + * + * @param num Number of text styles. + * + *
+     *   0
+     *  TABLE
+     *   2
+     *  STYLE
+     *   70
+     *      num
+     * 
+ */ + void tableStyle(int num) const { + table("STYLE", num, 3); + } + + /** + * End of a table. + * + *
+     *   0
+     *  ENDTAB
+     * 
+ */ + void tableEnd() const { + dxfString(0, "ENDTAB"); + } + + /** + * End of the DXF file. + * + *
+     *   0
+     *  EOF
+     * 
+ */ + void dxfEOF() const { + dxfString(0, "EOF"); + } + + /** + * Comment. + * + *
+     *  999
+     *  text
+     * 
+ */ + void comment(const char* text) const { + dxfString(999, text); + } + + /** + * Entity. + * + *
+     *   0
+     *  entTypeName
+     * 
+ * + * @return Unique handle or 0. + */ + void entity(const char* entTypeName) const { + dxfString(0, entTypeName); + if (version>=DL_VERSION_2000) { + handle(); + } + } + + /** + * Attributes of an entity. + * + *
+     *   8
+     *  layer
+     *  62
+     *  color
+     *  39
+     *  width
+     *   6
+     *  linetype
+     * 
+ */ + void entityAttributes(const DL_Attributes& attrib) const { + + // layer name: + dxfString(8, attrib.getLayer()); + + // R12 doesn't accept BYLAYER values. The value has to be missing + // in that case. + if (version>=DL_VERSION_2000 || attrib.getColor()!=256) { + dxfInt(62, attrib.getColor()); + } + if (version>=DL_VERSION_2000 && attrib.getColor24()!=-1) { + dxfInt(420, attrib.getColor24()); + } + if (version>=DL_VERSION_2000) { + dxfInt(370, attrib.getWidth()); + } + if (version>=DL_VERSION_2000) { + dxfReal(48, attrib.getLinetypeScale()); + } + std::string linetype = attrib.getLinetype(); + std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper); + if (version>=DL_VERSION_2000 || linetype=="BYLAYER") { + dxfString(6, attrib.getLinetype()); + } + } + + /** + * Subclass. + */ + void subClass(const char* sub) const { + dxfString(100, sub); + } + + /** + * Layer (must be in the TABLES section LAYER). + * + *
+     *   0
+     *  LAYER
+     * 
+ */ + void tableLayerEntry(unsigned long int h=0) const { + dxfString(0, "LAYER"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + dxfString(100, "AcDbSymbolTableRecord"); + dxfString(100, "AcDbLayerTableRecord"); + } + } + + /** + * Line type (must be in the TABLES section LTYPE). + * + *
+     *   0
+     *  LTYPE
+     * 
+ */ + void tableLinetypeEntry(unsigned long int h=0) const { + dxfString(0, "LTYPE"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + //dxfHex(330, 0x5); + dxfString(100, "AcDbSymbolTableRecord"); + dxfString(100, "AcDbLinetypeTableRecord"); + } + } + + /** + * Appid (must be in the TABLES section APPID). + * + *
+     *   0
+     *  APPID
+     * 
+ */ + void tableAppidEntry(unsigned long int h=0) const { + dxfString(0, "APPID"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + //dxfHex(330, 0x9); + dxfString(100, "AcDbSymbolTableRecord"); + dxfString(100, "AcDbRegAppTableRecord"); + } + } + + /** + * Block (must be in the section BLOCKS). + * + *
+     *   0
+     *  BLOCK
+     * 
+ */ + void sectionBlockEntry(unsigned long int h=0) const { + dxfString(0, "BLOCK"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + //dxfHex(330, blockHandle); + dxfString(100, "AcDbEntity"); + if (h==0x1C) { + dxfInt(67, 1); + } + dxfString(8, "0"); // TODO: Layer for block + dxfString(100, "AcDbBlockBegin"); + } + } + + /** + * End of Block (must be in the section BLOCKS). + * + *
+     *   0
+     *  ENDBLK
+     * 
+ */ + void sectionBlockEntryEnd(unsigned long int h=0) const { + dxfString(0, "ENDBLK"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + //dxfHex(330, blockHandle); + dxfString(100, "AcDbEntity"); + if (h==0x1D) { + dxfInt(67, 1); + } + dxfString(8, "0"); // TODO: Layer for block + dxfString(100, "AcDbBlockEnd"); + } + } + + void color(int col=256) const { + dxfInt(62, col); + } + void linetype(const char *lt) const { + dxfString(6, lt); + } + void linetypeScale(double scale) const { + dxfReal(48, scale); + } + void lineWeight(int lw) const { + dxfInt(370, lw); + } + + void coord(int gc, double x, double y, double z=0) const { + dxfReal(gc, x); + dxfReal(gc+10, y); + dxfReal(gc+20, z); + } + + void coordTriplet(int gc, const double* value) const { + if (value) { + dxfReal(gc, *value++); + dxfReal(gc+10, *value++); + dxfReal(gc+20, *value++); + } + } + + void resetHandle() const { + m_handle = 1; + } + + /** + * Writes a unique handle and returns it. + */ + unsigned long handle(int gc=5) const { + // handle has to be hex + dxfHex(gc, m_handle); + return m_handle++; + } + + /** + * @return Next handle that will be written. + */ + unsigned long getNextHandle() const { + return m_handle; + } + + /** + * Increases handle, so that the handle returned remains available. + */ + unsigned long incHandle() const { + return m_handle++; + } + + /** + * Sets the handle of the model space. Entities refer to + * this handle. + */ + void setModelSpaceHandle(unsigned long h) { + modelSpaceHandle = h; + } + + unsigned long getModelSpaceHandle() { + return modelSpaceHandle; + } + + /** + * Sets the handle of the paper space. Some special blocks refer to + * this handle. + */ + void setPaperSpaceHandle(unsigned long h) { + paperSpaceHandle = h; + } + + unsigned long getPaperSpaceHandle() { + return paperSpaceHandle; + } + + /** + * Sets the handle of the paper space 0. Some special blocks refer to + * this handle. + */ + void setPaperSpace0Handle(unsigned long h) { + paperSpace0Handle = h; + } + + unsigned long getPaperSpace0Handle() { + return paperSpace0Handle; + } + + /** + * Must be overwritten by the implementing class to write a + * real value to the file. + * + * @param gc Group code. + * @param value The real value. + */ + virtual void dxfReal(int gc, double value) const = 0; + + /** + * Must be overwritten by the implementing class to write an + * int value to the file. + * + * @param gc Group code. + * @param value The int value. + */ + virtual void dxfInt(int gc, int value) const = 0; + + /** + * Can be overwritten by the implementing class to write a + * bool value to the file. + * + * @param gc Group code. + * @param value The bool value. + */ + virtual void dxfBool(int gc, bool value) const { + dxfInt(gc, (int)value); + } + + /** + * Must be overwritten by the implementing class to write an + * int value (hex) to the file. + * + * @param gc Group code. + * @param value The int value. + */ + virtual void dxfHex(int gc, int value) const = 0; + + /** + * Must be overwritten by the implementing class to write a + * string to the file. + * + * @param gc Group code. + * @param value The string. + */ + virtual void dxfString(int gc, const char* value) const = 0; + + /** + * Must be overwritten by the implementing class to write a + * string to the file. + * + * @param gc Group code. + * @param value The string. + */ + virtual void dxfString(int gc, const std::string& value) const = 0; + +protected: + mutable unsigned long m_handle; + mutable unsigned long modelSpaceHandle; + mutable unsigned long paperSpaceHandle; + mutable unsigned long paperSpace0Handle; + + /** + * DXF version to be created. + */ + DL_Codes::version version; +private: +}; + +#endif diff --git a/datafile/dxf/dxflib/dl_writer_ascii.cpp b/datafile/dxf/dxflib/dl_writer_ascii.cpp new file mode 100644 index 0000000..199707a --- /dev/null +++ b/datafile/dxf/dxflib/dl_writer_ascii.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** Copyright (C) 2001 Robert J. Campbell Jr. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include +#include + +#include "dl_writer_ascii.h" +#include "dl_exception.h" + + +/** + * Closes the output file. + */ +void DL_WriterA::close() const { + m_ofile.close(); +} + + +/** + * @retval true Opening file has failed. + * @retval false Otherwise. + */ +bool DL_WriterA::openFailed() const { + return m_ofile.fail(); +} + + + +/** + * Writes a real (double) variable to the DXF file. + * + * @param gc Group code. + * @param value Double value + */ +void DL_WriterA::dxfReal(int gc, double value) const { + char str[256]; + if (version==DL_Codes::AC1009_MIN) { + sprintf(str, "%.6lf", value); + } + else { + sprintf(str, "%.16lf", value); + } + + // fix for german locale: + strReplace(str, ',', '.'); + + // Cut away those zeros at the end: + bool dot = false; + int end = -1; + for (unsigned int i=0; i0 && end<(int)strlen(str)) { + str[end] = '\0'; + } + + dxfString(gc, str); + m_ofile.flush(); +} + + + +/** + * Writes an int variable to the DXF file. + * + * @param gc Group code. + * @param value Int value + */ +void DL_WriterA::dxfInt(int gc, int value) const { + m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n" << value << "\n"; +} + + + +/** + * Writes a hex int variable to the DXF file. + * + * @param gc Group code. + * @param value Int value + */ +void DL_WriterA::dxfHex(int gc, int value) const { + char str[12]; + sprintf(str, "%0X", value); + dxfString(gc, str); +} + + + +/** + * Writes a string variable to the DXF file. + * + * @param gc Group code. + * @param value String + */ +void DL_WriterA::dxfString(int gc, const char* value) const { + if (value==NULL) { +#ifndef __GCC2x__ + //throw DL_NullStrExc(); +#endif + } + m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n" + << value << "\n"; +} + + + +void DL_WriterA::dxfString(int gc, const std::string& value) const { + m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n" + << value << "\n"; +} + + +/** + * Replaces every occurence of src with dest in the null terminated str. + */ +void DL_WriterA::strReplace(char* str, char src, char dest) { + size_t i; + for (i=0; i 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "dl_writer.h" +#include +#include + +/** + * Implements functions defined in DL_Writer for writing low + * level DXF constructs to an ASCII format DXF file. + * + * @para fname File name of the file to be created. + * @para version DXF version. Defaults to DL_VERSION_2002. + * + * @todo What if \c fname is NULL? Or \c fname can't be opened for + * another reason? + */ +class DXFLIB_EXPORT DL_WriterA : public DL_Writer { +public: + DL_WriterA(const char* fname, DL_Codes::version version=DL_VERSION_2000) + : DL_Writer(version), m_ofile(fname) {} + virtual ~DL_WriterA() {} + + bool openFailed() const; + void close() const; + void dxfReal(int gc, double value) const; + void dxfInt(int gc, int value) const; + void dxfHex(int gc, int value) const; + void dxfString(int gc, const char* value) const; + void dxfString(int gc, const std::string& value) const; + + static void strReplace(char* str, char src, char dest); + +private: + /** + * DXF file to be created. + */ + mutable std::ofstream m_ofile; + +}; + +#endif + diff --git a/datafile/dxf/dxfreader.cpp b/datafile/dxf/dxfreader.cpp new file mode 100644 index 0000000..24db047 --- /dev/null +++ b/datafile/dxf/dxfreader.cpp @@ -0,0 +1,379 @@ +#include "dxfreader.h" +#include + +DxfReader::DxfReader(const QString &fileName, QObject *parent) + : QObject(parent) + , fileName(fileName) +{ + //QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); + + // 读取 dxf 文件 + DL_Dxf *dxf = new DL_Dxf; + if (!dxf->in(std::string(fileName.toLocal8Bit()), this)) { // if file open failed + std::cerr << std::string(fileName.toLocal8Bit()) << " could not be opened.\n"; + return; + } + delete dxf; + dxf = nullptr; +} + +void DxfReader::addText(const DL_TextData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfText << data; +} + +void DxfReader::addLine(const DL_LineData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfLines << data; +} + +void DxfReader::addArc(const DL_ArcData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfArcs << data; +} + +void DxfReader::addCircle(const DL_CircleData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfCircles << data; +} + +void DxfReader::addEllipse(const DL_EllipseData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfEllipses << data; +} + +void DxfReader::addPolyline(const DL_PolylineData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfPolylines << data; +} + +void DxfReader::addPoint(const DL_PointData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfPoints << data; +} + +void DxfReader::addSpline(const DL_SplineData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfSplines << data; +} + +void DxfReader::addBlock(const DL_BlockData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfBlocks << data; +} + +void DxfReader::endBlock() +{ + +} + +void DxfReader::addLayer(const DL_LayerData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfLayers << data; +} + +void DxfReader::addLinetype(const DL_LinetypeData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfLinetypes << data; +} + +void DxfReader::addLinetypeDash(double length) +{ + if(length < 0){} +} + +void DxfReader::addXLine(const DL_XLineData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfXLines << data; +} + +void DxfReader::addRay(const DL_RayData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfRays << data; +} + +void DxfReader::addVertex(const DL_VertexData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfVertexs << data; +} + +void DxfReader::addControlPoint(const DL_ControlPointData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfControlPoints << data; +} + +void DxfReader::addFitPoint(const DL_FitPointData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfFitPoints << data; +} + +void DxfReader::addKnot(const DL_KnotData &data) +{ + if(data.k == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addInsert(const DL_InsertData &data) +{ + if(data.angle == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addSolid(const DL_SolidData &data) +{ + if(data.x == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addTrace(const DL_TraceData &data) +{ + if(data.x == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addTextStyle(const DL_StyleData &data) +{ + if(data.flags == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addMTextChunk(const std::string &text) +{ + if(text.data() == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addMText(const DL_MTextData &data) +{ + if(data.angle == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addArcAlignedText(const DL_ArcAlignedTextData &data) +{ + if(data.alignment == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addAttribute(const DL_AttributeData &data) +{ + if(data.angle == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addDimAlign(const DL_DimensionData &data, const DL_DimAlignedData &edata) +{ + if(data.angle == 0){} + if(edata.epx1 == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addDimLinear(const DL_DimensionData &data, const DL_DimLinearData &edata) +{ + if(data.angle == 0){} + if(edata.angle == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addDimRadial(const DL_DimensionData &data, const DL_DimRadialData &edata) +{ + if(data.angle == 0){} + if(edata.dpx == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addDimDiametric(const DL_DimensionData &data, const DL_DimDiametricData &edata) +{ + if(data.angle == 0){} + if(edata.dpx == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addDimAngular(const DL_DimensionData &data, const DL_DimAngularData &edata) +{ + if(data.angle == 0){} + if(edata.dpx1 == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addDimAngular3P(const DL_DimensionData &data, const DL_DimAngular3PData &edata) +{ + if(data.angle == 0){} + if(edata.dpx1 == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addDimOrdinate(const DL_DimensionData &data, const DL_DimOrdinateData &edata) +{ + if(data.angle == 0){} + if(edata.dpx1 == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addLeader(const DL_LeaderData &data) +{ + if(data.arrowHeadFlag == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addLeaderVertex(const DL_LeaderVertexData &data) +{ + if(data.x == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addHatch(const DL_HatchData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfHatchs << data; +} + +void DxfReader::addHatchLoop(const DL_HatchLoopData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfHatchLoops << data; +} + +void DxfReader::addHatchEdge(const DL_HatchEdgeData &data) +{ + //qDebug() << Q_FUNC_INFO; + dxfHatchEdges << data; +} + +void DxfReader::addImage(const DL_ImageData &data) +{ + if(data.brightness == 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::linkImage(const DL_ImageDefData &data) +{ + if(data.file == ""){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addXRecord(const std::string &handle) +{ + if(handle.length() <= 0){} +} + +void DxfReader::addXRecordString(int code, const std::string &value) +{ + if(code <= 0){} + if(value.length() <= 0){} +} + +void DxfReader::addXRecordReal(int code, double value) +{ + if(code <= 0){} + if(value <= 0){} +} + +void DxfReader::addXRecordInt(int code, int value) +{ + if(code <= 0){} + if(value <= 0){} +} + +void DxfReader::addXRecordBool(int code, bool value) +{ + if(code <= 0){} + if(value <= 0){} +} + +void DxfReader::addXDataApp(const std::string &appId) +{ + if(appId.length() <= 0){} +} + +void DxfReader::addXDataString(int code, const std::string &value) +{ + if(code <= 0){} + if(value.length() <= 0){} +} + +void DxfReader::addXDataReal(int code, double value) +{ + if(code <= 0){} + if(value <= 0){} +} + +void DxfReader::addXDataInt(int code, int value) +{ + if(code <= 0){} + if(value <= 0){} +} + +void DxfReader::addDictionary(const DL_DictionaryData &data) +{ + if(data.handle.length() <= 0){} +// qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addDictionaryEntry(const DL_DictionaryEntryData &data) +{ + if(data.handle.length() <= 0){} +// qDebug() << Q_FUNC_INFO; +} + +void DxfReader::setVariableVector(const std::string &key, double v1, double v2, double v3, int code) +{ + if(key.length() <= 0){} + if(v1 <= 0){} + if(v2 <= 0){} + if(v3 <= 0){} + if(code <= 0){} +} + +void DxfReader::setVariableString(const std::string &key, const std::string &value, int code) +{ + if(key.length() <= 0){} + if(value.length() <= 0){} + if(code <= 0){} +} + +void DxfReader::setVariableInt(const std::string &key, int value, int code) +{ + if(key.length() <= 0){} + if(value <= 0){} + if(code <= 0){} +} + +void DxfReader::setVariableDouble(const std::string &key, double value, int code) +{ + if(key.length() <= 0){} + if(value <= 0){} + if(code <= 0){} +} + +void DxfReader::add3dFace(const DL_3dFaceData &data) +{ + if(data.thickness <= 0){} + //qDebug() << Q_FUNC_INFO; +} + +void DxfReader::addComment(const std::string &comment) +{ + if(comment.length() <= 0){} +} + +void DxfReader::endSequence() +{ + //qDebug() << Q_FUNC_INFO; +} diff --git a/datafile/dxf/dxfreader.h b/datafile/dxf/dxfreader.h new file mode 100644 index 0000000..cef9f40 --- /dev/null +++ b/datafile/dxf/dxfreader.h @@ -0,0 +1,109 @@ +#ifndef DXFREADER_H +#define DXFREADER_H + +#include +#include +#include "dxflib/dl_dxf.h" +#include "dxflib/dl_creationadapter.h" + +class DxfReader : public QObject, public DL_CreationAdapter +{ + Q_OBJECT +public: + struct DxfText { + QString Text; + }; + explicit DxfReader(const QString &fileName, QObject *parent = nullptr); + + virtual void addText(const DL_TextData& data) override; + virtual void addLine(const DL_LineData& data) override; + virtual void addArc(const DL_ArcData& data) override; + virtual void addCircle(const DL_CircleData& data) override; + virtual void addEllipse(const DL_EllipseData& data) override; + virtual void addPolyline(const DL_PolylineData& data) override; + virtual void addPoint(const DL_PointData& data) override; + virtual void addSpline(const DL_SplineData& data) override; + virtual void addBlock(const DL_BlockData& data) override; + virtual void endBlock() override; + + virtual void addLayer(const DL_LayerData& data) override; + virtual void addLinetype(const DL_LinetypeData& data) override; + virtual void addLinetypeDash(double length) override; + virtual void addXLine(const DL_XLineData& data) override; + virtual void addRay(const DL_RayData& data) override; + virtual void addVertex(const DL_VertexData& data) override; + virtual void addControlPoint(const DL_ControlPointData& data) override; + virtual void addFitPoint(const DL_FitPointData& data) override; + virtual void addKnot(const DL_KnotData& data) override; + virtual void addInsert(const DL_InsertData& data) override; + virtual void addSolid(const DL_SolidData& data) override; + virtual void addTrace(const DL_TraceData& data) override; + virtual void addTextStyle(const DL_StyleData& data) override; + virtual void addMTextChunk(const std::string& text) override; + virtual void addMText(const DL_MTextData& data) override; + virtual void addArcAlignedText(const DL_ArcAlignedTextData& data) override; + virtual void addAttribute(const DL_AttributeData& data) override; + virtual void addDimAlign(const DL_DimensionData& data, const DL_DimAlignedData& edata) override; + virtual void addDimLinear(const DL_DimensionData& data, const DL_DimLinearData& edata) override; + virtual void addDimRadial(const DL_DimensionData& data, const DL_DimRadialData& edata) override; + virtual void addDimDiametric(const DL_DimensionData& data, const DL_DimDiametricData& edata) override; + virtual void addDimAngular(const DL_DimensionData& data, const DL_DimAngularData& edata) override; + virtual void addDimAngular3P(const DL_DimensionData& data, const DL_DimAngular3PData& edata) override; + virtual void addDimOrdinate(const DL_DimensionData& data, const DL_DimOrdinateData& edata) override; + virtual void addLeader(const DL_LeaderData &data) override; + virtual void addLeaderVertex(const DL_LeaderVertexData &data) override; + virtual void addHatch(const DL_HatchData& data) override; + virtual void addHatchLoop(const DL_HatchLoopData& data) override; + virtual void addHatchEdge(const DL_HatchEdgeData& data) override; + virtual void addImage(const DL_ImageData &data) override; + virtual void linkImage(const DL_ImageDefData &data) override; + + virtual void addXRecord(const std::string& handle) override; + virtual void addXRecordString(int code, const std::string& value) override; + virtual void addXRecordReal(int code, double value) override; + virtual void addXRecordInt(int code, int value) override; + virtual void addXRecordBool(int code, bool value) override; + + virtual void addXDataApp(const std::string& appId) override; + virtual void addXDataString(int code, const std::string& value) override; + virtual void addXDataReal(int code, double value) override; + virtual void addXDataInt(int code, int value) override; + + virtual void addDictionary(const DL_DictionaryData& data) override; + virtual void addDictionaryEntry(const DL_DictionaryEntryData& data) override; + + virtual void setVariableVector(const std::string& key, double v1, double v2, double v3, int code) override; + virtual void setVariableString(const std::string& key, const std::string& value, int code) override; + virtual void setVariableInt(const std::string& key, int value, int code) override; + virtual void setVariableDouble(const std::string& key, double value, int code) override; + + virtual void add3dFace(const DL_3dFaceData &data) override; + virtual void addComment(const std::string &comment) override; + virtual void endSequence() override; + + QList dxfLines; + QList dxfText; + QList dxfArcs; + QList dxfCircles; + QList dxfEllipses; + QList dxfPolylines; + QList dxfPoints; + QList dxfSplines; + QList dxfBlocks; + QList dxfVertexs; + QList dxfLayers; + QList dxfLinetypes; + QList dxfXLines; + QList dxfRays; + QList dxfControlPoints; + QList dxfFitPoints; + QList dxfHatchs; + QList dxfHatchLoops; + QList dxfHatchEdges; + +private: + QString fileName; + +}; + +#endif // DXFREADER_H diff --git a/datafile/embdata.cpp b/datafile/embdata.cpp new file mode 100644 index 0000000..8b79359 --- /dev/null +++ b/datafile/embdata.cpp @@ -0,0 +1,3800 @@ +#include "embdata.h" +#include "main.h" +const QColor sewcolorGreen = QColor(0x35,0xC0,0x5C);//绿色 +u32 rgbColorGreen = qRgb(sewcolorGreen.red(),sewcolorGreen.green(),sewcolorGreen.blue()); +const QColor sewcolorYel = QColor(Qt::darkYellow);//黄色 +u32 rgbColorYel = qRgb(sewcolorYel.red(),sewcolorYel.green(),sewcolorYel.blue()); +const QColor sewcolorblue = QColor(Qt::blue);//蓝色 +u32 rgbColorBlue = qRgb(sewcolorblue.red(),sewcolorblue.green(),sewcolorblue.blue()); + +const int headNum = 5; // 机头数 + +EmbData::EmbData() +{ + m_pEmbDs16Head = new DataDs16FileHead(); + m_penHeadPix.resize(5); + m_penPoint.resize(5); + clear(); +} + +EmbData::~EmbData() +{ + clear(); + if(m_pEmbDs16Head != NULL) + { + delete m_pEmbDs16Head; + } +} + +void EmbData::clear() +{ + m_maxX = 0; + m_minX = 0; + m_maxY = 0; + m_minY = 0; + m_fileid = 0; + + m_spaceX = 0; + m_spaceY = 0; + + m_penX = 0; + m_penY = 0; + + m_embDs16Data.clear(); + + m_editedflag = 0; + m_filePath.clear(); + m_factor = 0; + + memset(m_pEmbDs16Head,0,sizeof(DataDs16FileHead)); +} + +QByteArray & EmbData::getDsDat() +{ + //qDebug()<<"m_editedflag"<fileid = fileid; + if((u32)m_embDs16Data.size() > sizeof(DataDs16FileHead)) + { + memcpy(m_embDs16Data.data(),(char*)m_pEmbDs16Head, sizeof(DataDs16FileHead)); + } + } +} + +//得到绝对坐标的maxXY和minXY +void EmbData::getAbsDatRangeXY() +{ + m_minX = S32_MAX; + m_maxX = S32_MIN; + m_minY = S32_MAX; + m_maxY = S32_MIN; + + double ax, ay; + int minx, miny, maxx, maxy; + + const QByteArray & ary = m_embAbsData; + int size = ary.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("ary data less then head size"); + } + DataDs16FileHead * pDsHead = (DataDs16FileHead *)(ary.data()); + + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("absdat dataBegin err"); + return; + } + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("absdat data size err"); + return; + } + DsAbsItem * pData = (DsAbsItem *)(ary.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; + //----- + + int begx = pDsHead->beginX; + int begy = pDsHead->beginY; + + minx = S32_MAX; + maxx = S32_MIN; + miny = S32_MAX; + maxy = S32_MIN; + + // 数据区 + for (int j = 0; j < stepsize; j++) + { + ax = absDataPtr->ax + begx; + ay = absDataPtr->ay + begy; + +// ax = absDataPtr->ax; +// ay = absDataPtr->ay; + + if (minx > ax) { minx = ax; } + if (maxx < ax) { maxx = ax; } + if (miny > ay) { miny = ay; } + if (maxy < ay) { maxy = ay; } + + absDataPtr++; + } + + if (m_minX > minx) { m_minX = minx; } + if (m_minX > maxx) { m_minX = maxx; } + if (m_maxX < minx) { m_maxX = minx; } + if (m_maxX < maxx) { m_maxX = maxx; } + if (m_minY > miny) { m_minY = miny; } + if (m_minY > maxy) { m_minY = maxy; } + if (m_maxY < miny) { m_maxY = miny; } + if (m_maxY < maxy) { m_maxY = maxy; } +} + +// 添加锁针针步 +int EmbData::addLockStitchs(u8 mode, u8 needles, u8 num) +{ + if (needles <= 0) + { + return -1; + } + + int size = m_embAbsData.size(); + if (size <= 0) + { + return -1; + } + + int lockNum = num;//锁针次数 + int lockNeedles = needles;//锁针针数 + + QByteArray tgtdsdat; // 添加后的绝对坐标数据 + tgtdsdat.clear(); + + // 文件头 + int datasize = size - sizeof(DataDs16FileHead); + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("dat size err"); + return -1; + } + + DataDs16FileHead * pHead = (DataDs16FileHead *)(m_embAbsData.data()); + DsAbsItem * pData = (DsAbsItem *)(m_embAbsData.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; + + tgtdsdat.append((char*)pHead, sizeof(DataDs16FileHead)); + //pHead = (DataDs16FileHead *)(tgtdsdat.data()); + + int runflag = 0; + + for (int j = 0; j < stepsize; j++) + { + if (absDataPtr->ctrl == DATA_SEWING)//包括起针和剪线后加锁针 + { + if ((runflag == 0 || runflag > 3)) + { + // 添加锁针 + int nst = 0; + + if(mode == MODE_LOCK)//锁针方式 + { + if(lockNum%2 == 0)//偶数 + { + nst = 1; + } + else//奇数 + { + nst = needles; + } + + do + { + if(j+nst < stepsize) + { + DsAbsItem * nextPtr = absDataPtr+nst; // 要加锁针的点 + if (nextPtr->ctrl == DATA_SEWING) + { + DsAbsItem nitem; + memset(&nitem,0,sizeof(DsAbsItem)); + + u8 ctrl = absDataPtr->ctrl; + u8 attr = 0; // absDataPtr->attr; + double arbase = absDataPtr->ar; + + if(lockNum%2 == 0)//偶数锁针 + { + nextPtr--; + for (int k = 0; k < lockNum; k++) + { + if(k%2 == 0) + { + for (int s = 0; s < lockNeedles; s++) + { + nextPtr++; + double axbase = nextPtr->ax; + double aybase = nextPtr->ay; + + nitem.ctrl = ctrl; + nitem.attr = attr; + nitem.ax = axbase; + nitem.ay = aybase; + nitem.ar = arbase; + tgtdsdat.append((char*)(&nitem), sizeof(DsAbsItem)); + } + } + + if(k > 0 && k%2 != 0) + { + for (int s = lockNeedles; s > 0; s--) + { + nextPtr--; + double axbase = nextPtr->ax; + double aybase = nextPtr->ay; + + if(k == lockNum-1 && s == 1) + { + continue;//最后一次锁针的最后一步不添加 + } + + nitem.ctrl = ctrl; + nitem.attr = attr; + nitem.ax = axbase; + nitem.ay = aybase; + nitem.ar = arbase; + tgtdsdat.append((char*)(&nitem), sizeof(DsAbsItem)); + } + } + } + } + else//奇数锁针 + { + nextPtr++; + for (int k = 0; k < lockNum; k++) + { + if(k%2 == 0) + { + for (int s = lockNeedles; s > 0; s--) + { + nextPtr--; + double axbase = nextPtr->ax; + double aybase = nextPtr->ay; + + if(k == 0 && s == lockNeedles) + { + nitem.ctrl = DATA_OFFSET;//第一针步转换为跨步 + } + else + { + nitem.ctrl = ctrl; + } + + nitem.attr = attr; + nitem.ax = axbase; + nitem.ay = aybase; + nitem.ar = arbase; + tgtdsdat.append((char*)(&nitem), sizeof(DsAbsItem)); + } + nextPtr--; + } + + if(k > 0 && k%2 != 0) + { + for (int s = 0; s < lockNeedles; s++) + { + double axbase = nextPtr->ax; + double aybase = nextPtr->ay; + + nitem.ctrl = ctrl; + nitem.attr = attr; + nitem.ax = axbase; + nitem.ay = aybase; + nitem.ar = arbase; + tgtdsdat.append((char*)(&nitem), sizeof(DsAbsItem)); + nextPtr++; + } + nextPtr++; + } + } + } + break; + } + else + { + break; + } + } + }while(1); + } + else if(mode == MODE_THICKEN)//密针方式 + { + tgtdsdat.append((char*)absDataPtr, sizeof(DsAbsItem)); + + nst = 1; + + s16 nNum = 0; + if(lockNum == 0)//如果锁针次数为0时,第一针锁针次数就是锁针针数 + { + nNum = lockNeedles+1; + } + else + { + nNum = lockNum+1; + } + + do + { + if(j+nst < stepsize) + { + DsAbsItem * nextPtr = absDataPtr+nst; // 下一个点 + if (nextPtr->ctrl == DATA_SEWING) + { + DsAbsItem nitem; + memset(&nitem,0,sizeof(DsAbsItem)); + DsAbsItem * prePtr = absDataPtr; + + u8 ctrl = absDataPtr->ctrl; + u8 attr = 0; // absDataPtr->attr; + double arbase = absDataPtr->ar; + + for (int s = 0; s < lockNeedles; s++) + { + double dx = nextPtr->ax - prePtr->ax; + double dy = nextPtr->ay - prePtr->ay; + double len = sqrt(dx*dx + dy*dy); + if (len <= 0) + { + prePtr = nextPtr; + nextPtr++; + lockNeedles++; + continue; + } + double dLen = len / nNum; + + double axbase = prePtr->ax; + double aybase = prePtr->ay; + + for (int k = 0; k < nNum; k++) + { + double nax = dx * dLen / len + axbase; + double nay = dy * dLen / len + aybase; + + nitem.ctrl = ctrl; + nitem.attr = attr; + nitem.ax = nax; + nitem.ay = nay; + nitem.ar = arbase; + tgtdsdat.append((char*)(&nitem), sizeof(DsAbsItem)); + + axbase = nax; + aybase = nay; + } + if(lockNum == 0) + { + nNum--; + } + prePtr = nextPtr; + nextPtr++; + } + break; + } + else + { + break; + } + } + }while(1); + + for (int s = 0; s <= lockNeedles; s++)//跳到不加锁针的那一针 + { + absDataPtr++; + j++; + } + } + runflag = 1; + } + } + else if (absDataPtr->ctrl == DATA_CUTTRD) + { + runflag = 10; + } + else + { + runflag = 0; + } + + //结束前或剪线前加锁针 + if (absDataPtr->ctrl == DATA_END || + absDataPtr->ctrl == DATA_NULL || + j == stepsize-1 || + absDataPtr->ctrl == DATA_CUTTRD) + { + int m = 1; + //结束前或剪线前加锁针 + DsAbsItem * prePtr = absDataPtr-1; // 上一个点 + u8 ctl = prePtr->ctrl; + while(ctl != DATA_SEWING) + { + prePtr--; + m++; + ctl = prePtr->ctrl; + if(prePtr == pData)//起始地址 + { + return -1; + } + } + + // 添加锁针 + int nst = 1; + + if(mode == MODE_LOCK)//锁针方式 + { + do + { + if(j-m-nst > 0) + { + DsAbsItem * lockPtr = prePtr; // 要加锁针的点 + if (lockPtr->ctrl == DATA_SEWING) + { + DsAbsItem nitem; + memset(&nitem,0,sizeof(DsAbsItem)); + + u8 ctrl = prePtr->ctrl; + u8 attr = 0; // absDataPtr->attr; + double arbase = prePtr->ar; + + for (int k = 0; k < lockNum; k++) + { + if(k%2 == 0) + { + for (int s = lockNeedles; s > 0; s--) + { + lockPtr--; + double axbase = lockPtr->ax; + double aybase = lockPtr->ay; + + nitem.ctrl = ctrl; + nitem.attr = attr; + nitem.ax = axbase; + nitem.ay = aybase; + nitem.ar = arbase; + tgtdsdat.append((char*)(&nitem), sizeof(DsAbsItem)); + } + } + + if(k > 0 && k%2 != 0) + { + for (int s = 0; s < lockNeedles; s++) + { + lockPtr++; + double axbase = lockPtr->ax; + double aybase = lockPtr->ay; + + nitem.ctrl = ctrl; + nitem.attr = attr; + nitem.ax = axbase; + nitem.ay = aybase; + nitem.ar = arbase; + tgtdsdat.append((char*)(&nitem), sizeof(DsAbsItem)); + } + } + } + break; + } + else + { + break; + } + } + }while(1); + } + else if(mode == MODE_THICKEN)//密针方式 + { + nst = needles; + //去除要加密针的已添加的针步 + tgtdsdat.remove(tgtdsdat.size()-needles*sizeof(DsAbsItem),needles*sizeof(DsAbsItem)); + + s16 nNum = 0; + if(lockNum == 0)//如果锁针次数为0时,第一针锁针次数就是锁针针数 + { + nNum = lockNeedles+1; + } + else + { + nNum = lockNum+1; + } + + do + { + if(j-m-nst > 0) + { + DsAbsItem * lockPtr = prePtr-lockNeedles; // 加锁针点 + if (lockPtr->ctrl == DATA_SEWING) + { + DsAbsItem nitem; + memset(&nitem,0,sizeof(DsAbsItem)); + + u8 ctrl = prePtr->ctrl; + u8 attr = 0; // absDataPtr->attr; + double arbase = prePtr->ar; + + for (int s = 0; s < lockNeedles; s++) + { + DsAbsItem * nextPtr = lockPtr+1; + double dx = nextPtr->ax - lockPtr->ax; + double dy = nextPtr->ay - lockPtr->ay; + double len = sqrt(dx*dx + dy*dy); + if (len <= 0) + { + if(lockNum == 0) + { + nNum--; + } + + lockPtr++; + continue; + } + double dLen = len / nNum; + + double axbase = lockPtr->ax; + double aybase = lockPtr->ay; + + for (int k = 0; k < nNum; k++) + { + double nax = dx * dLen / len + axbase; + double nay = dy * dLen / len + aybase; + + nitem.ctrl = ctrl; + nitem.attr = attr; + nitem.ax = nax; + nitem.ay = nay; + nitem.ar = arbase; + tgtdsdat.append((char*)(&nitem), sizeof(DsAbsItem)); + + axbase = nax; + aybase = nay; + } + if(lockNum == 0) + { + nNum--; + } + lockPtr++; + } + break; + } + else + { + break; + } + } + }while(1); + } + } + + tgtdsdat.append((char*)absDataPtr, sizeof(DsAbsItem)); + + absDataPtr++; + } + + m_embAbsData.clear(); + m_embAbsData = tgtdsdat; + + m_editedflag = 1; + return 0; +} + +//角度修正 +int EmbData::angleCorrection(s16 oft) +{ + if (oft != 0) + { + s32 dx, dy, dr; + double ax, ay, ar; + int bdx, bdy; + bdx = bdy = 0; + + int size = m_embAbsData.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("ary data less then head size"); + return -1; + } + + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("absdat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("absdat data size err"); + return -1; + } + DsAbsItem * pData = (DsAbsItem *)(m_embAbsData.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; //中间数据针步 + + double addx,addy; + addx = addy = 0; + double s = 0; + + // 数据区 + for (int j = 0; j < stepsize; j++) + { + if (j == 0)//第一针 + { + dx = absDataPtr->ax; + dy = absDataPtr->ay; + dr = absDataPtr->ar; + } + else + { + dx = absDataPtr->ax - ax; + dy = absDataPtr->ay - ay; + dr = absDataPtr->ar - ar; + } + + //判断夹角是否大于60度 + if(dr >= ANGLECORR || dr <= -ANGLECORR) + { + s = sqrt(bdx*bdx + bdy*bdy); + if(s == 0) + { + addx = 0; + addy = 0; + } + else + { + addx = bdx*oft/s; + addy = bdy*oft/s; + } + + absDataPtr--; + if(absDataPtr->ctrl == DATA_SEWING) + { + absDataPtr->ax += addx; + absDataPtr->ay += addy; + } + absDataPtr++; + } + + ax = absDataPtr->ax; + ay = absDataPtr->ay; + ar = absDataPtr->ar; + + bdx = dx; + bdy = dy; + + absDataPtr++; + } + } + return 0; +} + +int EmbData::angleCorrectionXY(s32 px, s32 nx, s32 py, s32 ny) +{ + if(px == 0 && nx == 0 && py == 0 && ny == 0) + { + return -1; + } + s32 dx, dy, dr; + double ax, ay, ar; + + int size = m_embAbsData.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("ary data less then head size"); + return -1; + } + + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("absdat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("absdat data size err"); + return -1; + } + DsAbsItem * pData = (DsAbsItem *)(m_embAbsData.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; //中间数据针步 + + double addx,addy; + addx = addy = 0; + + // 数据区 + for (int j = 0; j < stepsize; j++) + { + if (j == 0)//第一针 + { + dx = absDataPtr->ax; + dy = absDataPtr->ay; + dr = absDataPtr->ar; + } + else + { + dx = absDataPtr->ax - ax; + dy = absDataPtr->ay - ay; + dr = absDataPtr->ar - ar; + } + + //判断夹角是否大于60度 + if(dr >= ANGLECORR || dr <= -ANGLECORR) + { + if(dx > 0) + { + addx = px; + } + else if(dx == 0) + { + DsAbsItem * prePtr = absDataPtr-1; + double prex = prePtr ->ax; + while(prex == absDataPtr->ax) + { + prePtr--; + prex = prePtr->ax; + if(prePtr == pData) + { + break; + } + } + s32 cx = prex - absDataPtr->ax; + if(cx < 0) + { + addx = px; + } + else + { + addx = 0 - nx; + } + } + else + { + addx = 0 - nx; + } + + if(dy > 0) + { + addy = py; + } + else if(dy == 0) + { + DsAbsItem * prePtr = absDataPtr-1; + double prey = prePtr ->ay; + while(prey == absDataPtr->ay) + { + prePtr--; + prey = prePtr->ay; + if(prePtr == pData) + { + break; + } + } + s32 cy = prey - absDataPtr->ay; + if(cy < 0) + { + addy = py; + } + else + { + addy = 0 - ny; + } + } + else + { + addy = 0 - ny; + } + + absDataPtr--; + if(absDataPtr->ctrl == DATA_SEWING) + { + absDataPtr->ax += addx; + absDataPtr->ay += addy; + } + absDataPtr++; + } + + ax = absDataPtr->ax; + ay = absDataPtr->ay; + ar = absDataPtr->ar; + + absDataPtr++; + } + + return 0; +} + +//按固定针步重新拟合(用户可设置的参数,暂未用到) +void EmbData::reFitByStep(s32 stepLen) +{ + QList lineList; + lineList.clear(); + + int stepLength = stepLen;//参数(300-800 单位0.01mm) + + LineItem item; + item.absItemList.clear(); + + int dr = 0; + unsigned char ctrl; + double prer = 0; + + double ax, ay, ar; + ax = ay = ar = 0; + + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + + //添加线段集合(夹角大于某个值时为新的一段线段) + int datasize = m_embAbsData.size() - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + return; + } + int stepsize = datasize/sizeof(DsAbsItem); + DsAbsItem * dataBeg = (DsAbsItem *)(m_embAbsData.data()+sizeof(DataDs16FileHead)); + prer = dataBeg->ar; + for (int i = 0; i < stepsize; i++) + { + ctrl = dataBeg->ctrl; + dr = dataBeg->ar - prer; + + unsigned char nctrl,bctrl; + if(i == stepsize-1) + { + nctrl = ctrl; + } + else + { + dataBeg++; + nctrl = dataBeg->ctrl;//下一针步属性 + dataBeg--; + } + + if(i == 0) + { + bctrl = ctrl; + } + else + { + dataBeg--; + bctrl = dataBeg->ctrl;//上一针步属性 + dataBeg++; + } + + if(ctrl != DATA_SEWING) + { + item.absItemList.append(*dataBeg); + } + + //上一针非缝纫属性且当前针为缝纫属性 + if(bctrl != DATA_SEWING && ctrl == DATA_SEWING) + { + lineList.append(item); + item.absItemList.clear(); + item.absItemList.append(*dataBeg); + } + //下一针非缝纫针步与当前针为缝纫针步 + else if(nctrl != DATA_SEWING && ctrl == DATA_SEWING) + { + lineList.append(item); + item.absItemList.clear(); + item.absItemList.append(*dataBeg); + } + //上一针为缝纫针步与当前针非缝纫针步 + else if(bctrl == DATA_SEWING && ctrl != DATA_SEWING) + { + lineList.append(item); + item.absItemList.clear(); + item.absItemList.append(*dataBeg); + } + //下一针为缝纫针步与当前针非缝纫针步 + else if(nctrl == DATA_SEWING && ctrl != DATA_SEWING) + { + lineList.append(item); + item.absItemList.clear(); + item.absItemList.append(*dataBeg); + } + else if(ctrl == DATA_SEWING) + { + double angle = dr / 10000.0 * (180.0 / PI); + if(angle > 30 || angle < -30)//新的一条线段(30度为分界) + { + lineList.append(item); + item.absItemList.clear(); + item.absItemList.append(*dataBeg); + } + else + { + item.absItemList.append(*dataBeg); + } + } + prer = dataBeg->ar; + dataBeg++; + } + + //开始重置针步(绝对坐标的线段集合) + QByteArray nabsData; + nabsData.clear(); + double cx,cy,cr; + cx = cy = cr = 0; + int lSize = lineList.size(); + for(int j = 0; j < lSize; j++) + { + int pSize = lineList[j].absItemList.size(); + for(int m = 0; m < pSize; m++) + { + memset(&absItem,0,sizeof(DsAbsItem)); + absItem = lineList[j].absItemList[m]; + + ctrl = absItem.ctrl; + //absItem.ax = absItem.ax - minX; + //absItem.ay = absItem.ay - minY; + ax = absItem.ax; + ay = absItem.ay; + ar = absItem.ar; + + if(ctrl != DATA_SEWING) + { + nabsData.append((char*)&absItem,sizeof(DsAbsItem)); + continue; + } + if(m == 0) + { + cx = ax; + cy = ay; + nabsData.append((char*)&absItem,sizeof(DsAbsItem)); + } + if(m == pSize - 1 && pSize > 1) + { + //最后一步如果超出长度就均分 + int pos = nabsData.size()-sizeof(DsAbsItem); + DsAbsItem * litem = (DsAbsItem *)((nabsData.data()+pos)); + + double curX = absItem.ax; + double curY = absItem.ay; + + double preX = litem->ax; + double preY = litem->ay; + + double ldis = sqrt(((curX-preX)/100.0*(curX-preX)/100.0)*10000.0+((curY-preY)/100.0*(curY-preY)/100.0)*10000.0); + if(ldis > stepLength) + { + DsAbsItem addItem; + memset(&addItem,0,sizeof(DsAbsItem)); + addItem = absItem; + + if(litem->ay == absItem.ay)//y相同 + { + addItem.ay = absItem.ay; + addItem.ax = (absItem.ax+litem->ax)/2; + + nabsData.append((char*)&addItem,sizeof(DsAbsItem)); + nabsData.append((char*)&absItem,sizeof(DsAbsItem)); + break; + } + else if(litem->ax == absItem.ax)//x相同 + { + addItem.ax = absItem.ax; + addItem.ay = (absItem.ay+litem->ay)/2; + + nabsData.append((char*)&addItem,sizeof(DsAbsItem)); + nabsData.append((char*)&absItem,sizeof(DsAbsItem)); + break; + } + else + { + double k = ((double)(absItem.ay-litem->ay))/((double)(absItem.ax-litem->ay)); + double cdis = ldis / 2; + double r = atan(k); + double x = cdis * cos(r); + double y = cdis * sin(r); + + addItem.ax = litem->ax + x; + addItem.ay = litem->ay + y; + nabsData.append((char*)&addItem,sizeof(DsAbsItem)); + + nabsData.append((char*)&absItem,sizeof(DsAbsItem)); + break; + } + } + else + { + nabsData.append((char*)&absItem,sizeof(DsAbsItem)); + break; + } + } + double dis = sqrt(((ax-cx)/100.0*(ax-cx)/100.0)*10000.0+((ay-cy)/100.0*(ay-cy)/100.0)*10000.0); + while(dis > stepLength) + { + QPoint firstPoint(0,0);//直线第一个点 + if((m-1) >= 0) + { + // firstPoint.setX(lineList[j].absItemList[m-1].ax-minX); + // firstPoint.setY(lineList[j].absItemList[m-1].ay-minY); + firstPoint.setX(lineList[j].absItemList[m-1].ax); + firstPoint.setY(lineList[j].absItemList[m-1].ay); + } + + QPoint secondPoint;//直线第二个点 + secondPoint.setX(ax); + secondPoint.setY(ay); + + QPoint circlePoint;//圆心 + circlePoint.setX(cx); + circlePoint.setY(cy); + + QPoint p; + if(secondPoint.x()-firstPoint.x() == 0) + { + p.setX(secondPoint.x()); + //int y = (secondPoint.y()/stepLength)*stepLength; + //int y = (secondPoint.y()+firstPoint.y())/2; + //取出上一点的坐标 + int pos = nabsData.size()-sizeof(DsAbsItem); + DsAbsItem * litem = (DsAbsItem *)((nabsData.data()+pos)); + int y = 0; + if(litem->ay >= secondPoint.y()) + { + y = litem->ay - stepLength; + } + else + { + y = litem->ay + stepLength; + } + + p.setY(y); + + cx = p.x(); + cy = p.y(); + + if(cx < 0 || cy < 0) + { + //qDebug()<= (stepLength-10)) + { + bl3 = true; + } + + if(bl3) + { + if(bl1 == true && bl2 == true) + { + double dis1 = sqrt(((ax-x1)/100.0*(ax-x1)/100.0)*10000.0+((ay-y1)/100.0*(ay-y1)/100.0)*10000.0); + double dis2 = sqrt(((ax-x2)/100.0*(ax-x2)/100.0)*10000.0+((ay-y2)/100.0*(ay-y2)/100.0)*10000.0); + if(dis1 > dis2) + { + cx = x2; + cy = y2; + } + else + { + cx = x1; + cy = y1; + } + + absItem.ax = cx; + absItem.ay = cy; + nabsData.append((char*)&absItem,sizeof(DsAbsItem)); + + dis = sqrt(((ax-cx)/100.0*(ax-cx)/100.0)*10000.0+((ay-cy)/100.0*(ay-cy)/100.0)*10000.0); + } + else + { + if(bl1) + { + p.setX(x1); + p.setY(y1); + } + else if(bl2) + { + p.setX(x2); + p.setY(y2); + } + else + { + qDebug()<<"bl1&bl2=false"; + break; + } + + cx = p.x(); + cy = p.y(); + + if(cx < 0 || cy < 0) + { + //qDebug()<dataSize = stepsize*sizeof(DsAbsItem); // 数据字节数 + m_pEmbDs16Head->itemNums = stepsize; // 数据项个数 + m_pEmbDs16Head->dataChecksum = calcCheckSum32((u8 *)(nabsData.data()) , nabsData.length()); // 数据累加校验和 + m_pEmbDs16Head->checkCrc = calcCrc16((u8 *)(m_pEmbDs16Head), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + u32 fileID = 0; + fileID = calcCheckSum32((u8 *)(nabsData.data()) , nabsData.length()); // 原始数据累加校验和 + m_pEmbDs16Head->fileid = fileID; //中间数据的 fileid = + + m_embAbsData.clear(); + m_embAbsData.append((char *)(m_pEmbDs16Head), sizeof(DataDs16FileHead)); + m_embAbsData.append(nabsData); +} + +#define MERGEANGLE PI/180*70*10000 //70度 +void EmbData::reFitLine(s32 stepLen) +{ + QList lineList; + lineList.clear(); + + double stepLength = stepLen;//参数(200-800 单位0.01mm) + if(stepLength <= 0) + { + return; + } + + LineItem item; + item.absItemList.clear(); + + int dr = 0; + double prer = 0; + DsAbsItem preItem; + memset(&preItem,0,sizeof(DsAbsItem)); + s16 addOftFlag = 0; + s16 addSewFlag = 0; + + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + + //添加线段集合(夹角大于某个值时为新的一段线段) + int datasize = m_embAbsData.size() - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + return; + } + int stepsize = datasize/sizeof(DsAbsItem); + memcpy((char*)m_pEmbDs16Head,m_embAbsData.data(),sizeof(DataDs16FileHead)); + DsAbsItem * dataBeg = (DsAbsItem *)(m_embAbsData.data()+sizeof(DataDs16FileHead)); + prer = dataBeg->ar; + for (int i = 0; i < stepsize; i++) + { + dr = dataBeg->ar - prer; + + while (dr < -PI10000) + { + dr += PI20000; + } + while (dr > PI10000) + { + dr -= PI20000; + } + + if(dataBeg->ctrl != DATA_SEWING) + { + if(addSewFlag == 1) + { + lineList.append(item); + item.absItemList.clear(); + item.absItemList.append(*(dataBeg-1)); + addSewFlag = 0; + } + item.absItemList.append(*dataBeg); + addOftFlag = 1; + } + else + { + addSewFlag = 1; + if(addOftFlag == 1) + { + lineList.append(item); + item.absItemList.clear(); + item.absItemList.append(*(dataBeg-1)); + item.absItemList.append(*dataBeg); + addOftFlag = 0; + } + if((abs(dr) > MERGEANGLE))//新的一条线段 + { + lineList.append(item); + item.absItemList.clear(); + item.absItemList.append(*(dataBeg-1)); + item.absItemList.append(*dataBeg); + } + else + { + item.absItemList.append(*dataBeg); + } + } + + prer = dataBeg->ar; + dataBeg++; + } + + //开始重置针步(绝对坐标的线段集合) + QByteArray nabsData; + nabsData.clear(); + QList outList; + + int lSize = lineList.size(); + for(int i = 0; i < lSize; i++) + { + outList.clear(); + + int pSize = lineList[i].absItemList.size(); + if(pSize == 1)//只有一个点 + { + nabsData.append((char*)&lineList[i].absItemList[0],sizeof(DsAbsItem)); + } + else + { + getCurvePointFillLine(lineList[i].absItemList,stepLength,outList); + //从第二段开始起始点不向绝对坐标中添加,如果添加会出现空针步 + int idx = 0; + if(i > 0) + { + idx = 1; + } + for(int m = idx; m < outList.size(); m++) + { + nabsData.append((char*)(&outList[m]), sizeof(DsAbsItem)); + } + } + } + + //重新计算ar + stepsize = nabsData.size() / sizeof(DsAbsItem); + if(stepsize <= 0) + { + return; + } + + //最后添加结束码,ax和ay是最后一针的 + DsAbsItem dsAbsItem; + memcpy(&dsAbsItem,nabsData.data()+(nabsData.size() - sizeof(DsAbsItem)),sizeof(DsAbsItem)); + dsAbsItem.ctrl = DATA_END; + nabsData.append((char*)(&dsAbsItem), sizeof(DsAbsItem)); + stepsize++; + + DsAbsItem * absDataPtr = (DsAbsItem *)(nabsData.data()); + + double minX, maxX, minY, maxY; + minX = S32_MAX; + maxX = S32_MIN; + minY = S32_MAX; + maxY = S32_MIN; + + double prex,prey,curx,cury,dx,dy,ar; + prex = prey = curx = cury = dx = dy = ar = 0; + + prex = absDataPtr->ax; + prey = absDataPtr->ay; + + for (int i = 0; i < stepsize; i++) + { + curx = absDataPtr->ax; + cury = absDataPtr->ay; + + dx = curx - prex; + dy = cury - prey; + + double tar = atan2(dy,dx); + ar = (tar*10000+0.5*(tar>0?1:-1)); + absDataPtr->ar = ar; + + if(curx > maxX) + { + maxX = curx; + } + if(curx < minX) + { + minX = curx; + } + + if(cury > maxY) + { + maxY = cury; + } + if(cury < minY) + { + minY = cury; + } + + prex = curx; + prey = cury; + + absDataPtr++; + } + + //修改绝对坐标数据 + m_pEmbDs16Head->dataSize = stepsize*sizeof(DsAbsItem); // 数据字节数 + m_pEmbDs16Head->itemNums = stepsize; // 数据项个数 + m_pEmbDs16Head->maxX = maxX; + m_pEmbDs16Head->minX = minX; + m_pEmbDs16Head->maxY = maxY; + m_pEmbDs16Head->minY = minY; + m_pEmbDs16Head->dataChecksum = calcCheckSum32((u8 *)(nabsData.data()) , nabsData.length()); // 数据累加校验和 + m_pEmbDs16Head->checkCrc = calcCrc16((u8 *)(m_pEmbDs16Head), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + u32 fileID = 0; + fileID = calcCheckSum32((u8 *)(nabsData.data()) , nabsData.length()); // 原始数据累加校验和 + m_pEmbDs16Head->fileid = fileID; //中间数据的 fileid = + + m_embAbsData.clear(); + m_embAbsData.append((char *)(m_pEmbDs16Head), sizeof(DataDs16FileHead)); + m_embAbsData.append(nabsData); +} + +//移动起始点,左边,前边 +int EmbData::moveStartPoint(short left, short front) +{ + if(m_pEmbDs16Head == NULL){return -1;} + if(m_embDs16Data.size() <= 0){return -1;} + + m_pEmbDs16Head->anchorX += left; + m_pEmbDs16Head->anchorY += front; + m_pEmbDs16Head->beginX += left; + m_pEmbDs16Head->beginY += front; + + //将最大最小值写入文件头 + m_pEmbDs16Head->maxX += left; + m_pEmbDs16Head->minX += left; + m_pEmbDs16Head->maxY += front; + m_pEmbDs16Head->minY += front; + + m_maxX += left; + m_minX += left; + m_maxY += front; + m_minY += front; + memcpy(m_embDs16Data.data(),(char*)m_pEmbDs16Head,sizeof(DataDs16FileHead)); + + return 0; +} + +void EmbData::moveDataBeginPonit(s32 left, s32 front) +{ + if((u32)m_embAbsData.size() > sizeof(DataDs16FileHead)){ + DataDs16FileHead *dhead = (DataDs16FileHead *)(m_embAbsData.data()); + dhead->beginX += left; + dhead->beginY += front; + dhead->maxX += left; + dhead->minX += left; + dhead->maxY += front; + dhead->minY += front; + } +} + +void EmbData::appendAEmbAbsFile(QString filePath, QByteArray array, int mirror) +{ + m_filePath = filePath; + convertAbsDat(array,mirror);//是否镜像、旋转、缩放的转换 + m_embAbsData.clear(); + m_embAbsData.append(array); + m_editedflag = 1; +} + +void EmbData::setAbsDat(QByteArray & dat) +{ + m_embAbsData = dat; +} + +QByteArray & EmbData::getAbsDat(void) +{ + return m_embAbsData; +} + +int EmbData::getPosInfoFromNeedleIdx(int stitchIdx, int &posx, int &posy, int &colorIdx) +{ + if (m_editedflag != 0) + { + createEmbDs16FromAbs(); + } + + posx = 0; + posy = 0; + colorIdx = 0; + + // 文件头 + int size = m_embDs16Data.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("m_embDs16Data data less then head size"); + return -1; + } + + DataDs16FileHead * pDsHead = (DataDs16FileHead *)(m_embDs16Data.data()); + + int datasize = size - sizeof(DataDs16FileHead); + int stepsize = datasize/sizeof(Ds16Item); + if (stepsize <= 0) + { + qDebug("ds16 data size err"); + return -1; + } + + Ds16Item * ds16DataPtr; + Ds16Item * pData = (Ds16Item *)(m_embDs16Data.data() + sizeof(DataDs16FileHead)); + ds16DataPtr = pData; + + posx = pDsHead->beginX; + posy = pDsHead->beginY; + + colorIdx = 1; + + if (stitchIdx <= 0) + { + return 0; + } + + if (stitchIdx > datasize) + { + stitchIdx = datasize; + } + + int dx, dy; + u8 ctrl, attr; + + for (int i = 0; i < stitchIdx; i++) + { + ctrl = ds16DataPtr->ctrl; + attr = ds16DataPtr->attr; + dx = ds16DataPtr->dx; + dy = ds16DataPtr->dy; + + if (ctrl == DATA_CHGND) + { + colorIdx++; + } + + if ((attr&0x80) != 0) + { + dx *= -1; + } + + if ((attr&0x40) != 0) + { + dy *= -1; + } + + posx += dx; + posy += dy; + + ds16DataPtr++; + } + + return 0; +} + +//设置起始点 +void EmbData::setStartPosition(int x, int y) +{ + if(m_pEmbDs16Head == NULL){return;} + if(m_embDs16Data.size() <= 0){return;} + + //旧的起始点坐标 + int oldBeginX = m_pEmbDs16Head->beginX; + int oldBeginY = m_pEmbDs16Head->beginY; + + m_pEmbDs16Head->beginX = x; + m_pEmbDs16Head->beginY = y; + + //新的起始点坐标与旧的起始点坐标的差值 + int cx = x - oldBeginX; + int cy = y - oldBeginY; + + //重新计算最大最小XY + double maxX = m_pEmbDs16Head->maxX + cx; + double minX = m_pEmbDs16Head->minX + cx; + double maxY = m_pEmbDs16Head->maxY + cy; + double minY = m_pEmbDs16Head->minY + cy; + + //将最大最小值写入文件头 + m_pEmbDs16Head->maxX = maxX; + m_pEmbDs16Head->minX = minX; + m_pEmbDs16Head->maxY = maxY; + m_pEmbDs16Head->minY = minY; + + //修复偶尔点击中间按钮花样消失的bug + m_maxX = maxX; + m_minX = minX; + m_maxY = maxY; + m_minY = minY; + memcpy(m_embDs16Data.data(),(char*)m_pEmbDs16Head,sizeof(DataDs16FileHead)); + + qDebug()<<"m_maxX"<beginX *= factorx; + pDsHead->beginY *= factory; + + // 数据缩放 + for (int j = 0; j < stepsize; j++) + { + double ax = absDataPtr->ax; + double ay = absDataPtr->ay; + + ax *= factorx; + ay *= factory; + + absDataPtr->ax = ax; + absDataPtr->ay = ay; + + absDataPtr++; + } + + m_editedflag = 1; + + return 1; +} + +int EmbData::setMirror(int mirror) +{ + if (mirror == 0) // 0, 无镜像; 1, 水平镜像; 2, 垂直镜像; 3, 水平和垂直镜像 + { + return 0; + } + + int mirrorx = 1; //x轴 + int mirrory = 1; //y轴 + int mirrorr = 0; + int mirrorrdir = 0; + + if(mirror == 1 || mirror == 3) + { + mirrorx = -1; + } + if(mirror == 2 || mirror == 3) + { + mirrory = -1; + } + + if(mirror == 1) + { + mirrorr = 1*PI*10000; + mirrorrdir = -1; + } + else if (mirror == 2) + { + mirrorr = 2*PI*10000; + mirrorrdir = -1; + } + else if (mirror == 3) + { + mirrorr = 1*PI*10000; + mirrorrdir = 1; + } + + // 文件头 + const QByteArray & ary = m_embAbsData; + int size = ary.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("ary data less then head size"); + return -1; + } + + int datasize = size - sizeof(DataDs16FileHead); + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("dat data size err"); + return -1; + } + + DataDs16FileHead * pDsHead = (DataDs16FileHead *)(ary.data()); + + //在最大最小xy中 对起始点进行镜像处理 + + int bx = pDsHead->beginX; + int by = pDsHead->beginY; + + if(mirrorx == -1) + pDsHead->beginX = pDsHead->maxX - (bx - pDsHead->minX); + if(mirrory == -1) + pDsHead->beginY = pDsHead->maxY - (by - pDsHead->minY); + + //beginR的旋转 + double br = pDsHead->beginR; + if (mirrorrdir > 0) + { + br = br + mirrorr; + } + else if (mirrorrdir < 0) + { + br = mirrorr - br; + } + + while (br > 2*PI * 10000) + { + br -= 2*PI * 10000; + } + while (br < -2*PI * 10000) + { + br += 2*PI * 10000; + } + pDsHead->beginR = br; + + DsAbsItem * pData = (DsAbsItem *)(ary.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; + + // 数据镜像 + for (int j = 0; j < stepsize; j++) + { + double ax = absDataPtr->ax; + double ay = absDataPtr->ay; + double ar = absDataPtr->ar; + + int rx = ax * mirrorx; //相对坐标 乘负数则数据镜像 + int ry = ay * mirrory; + + if (mirrorrdir > 0) + { + ar = ar + mirrorr; + } + else if (mirrorrdir < 0) + { + ar = mirrorr - ar; + } + + while (ar > 2*PI * 10000) + { + ar -= 2*PI * 10000; + } + while (ar < -2*PI * 10000) + { + ar += 2*PI * 10000; + } + + absDataPtr->ax = rx; + absDataPtr->ay = ry; + absDataPtr->ar = ar; + + absDataPtr++; + } + + m_editedflag = 1; + return 1; +} + +//flag :true代表顺时针方向 +int EmbData::setRotate90(bool flag) +{ + + // 文件头 + const QByteArray & ary = m_embAbsData; + int size = ary.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("ary data less then head size"); + return -1; + } + int datasize = size - sizeof(DataDs16FileHead); + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("dat data size err"); + return -1; + } + DataDs16FileHead * pDsHead = (DataDs16FileHead *)(ary.data()); + + int maxX = pDsHead->maxX; + int maxY = pDsHead->maxY; + + int bx = pDsHead->beginX; + int by = pDsHead->beginY; + + if(flag){ //正向旋转90 + pDsHead->beginX = maxY - by; + pDsHead->beginY = bx; + } + else{ + pDsHead->beginX = by; + pDsHead->beginY = maxX - bx; + } + + DsAbsItem * pData = (DsAbsItem *)(ary.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; + + for (int j = 0; j < stepsize; j++) + { + double ax = absDataPtr->ax; + double ay = absDataPtr->ay; + + int rx, ry; + if(flag){ //正向旋转90 + rx = -ay; + ry = ax; + }else{ + rx = ay; + ry = -ax; + } + + absDataPtr->ax = rx; + absDataPtr->ay = ry; + + absDataPtr++; + } + + m_editedflag = 1; + return 1; + +} + +/// +/// \brief //获得下一个图元的第一缝纫针步 +/// \param curIndex +/// \return +/// +int EmbData::getNextElementIndex(int curIndex) +{ + // ds16数据 + int size = m_embDs16Data.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("16 data less then head size"); + return -1; + } + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("dat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(Ds16Item); + if (stepsize <= 0) + { + qDebug("ds16 data size err"); + return -1; + } + + Ds16Item * ds16DataPtr = (Ds16Item *)(m_embDs16Data.data() + sizeof(DataDs16FileHead)); + ds16DataPtr = ds16DataPtr + curIndex; + + u8 curByte =ds16DataPtr->ctrl; //当前状态 + ds16DataPtr ++; + curIndex ++; + + int i = curIndex; + for (; i < stepsize; i++) + { + + if(curByte != DATA_SEWING) + { + if(ds16DataPtr->ctrl == DATA_SEWING) + break; + }else{ + if(ds16DataPtr->ctrl != DATA_SEWING) + curByte = ds16DataPtr->ctrl; + } + ds16DataPtr++; + } + return i; +} + +/// +/// \brief //上一个图元(当前为跨步时)或当前图元(当前为缝纫时)的第一缝纫针步 +/// \param curIndex +/// \return +/// +int EmbData::getPreOrThisElementIndex(int curIndex) +{ + // ds16数据 + int size = m_embDs16Data.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("16 data less then head size"); + return -1; + } + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("dat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(Ds16Item); + if (stepsize <= 0) + { + qDebug("ds16 data size err"); + return -1; + } + + Ds16Item * ds16DataPtr = (Ds16Item *)(m_embDs16Data.data() + sizeof(DataDs16FileHead)); + ds16DataPtr = ds16DataPtr + curIndex; + + u8 curByte =ds16DataPtr->ctrl; //当前状态 + ds16DataPtr--; + curIndex --; + + int i = curIndex; + + for (; i > 0; i--) + { + //如果当前是缝纫数据,找到其他的就返回下一针 + if(curByte == DATA_SEWING) + { + if(ds16DataPtr->ctrl != DATA_SEWING) + break; + }else{ + //找到其他的就返回下一针 + if(ds16DataPtr->ctrl == DATA_SEWING) + curByte = DATA_SEWING; + } + ds16DataPtr--; + } + return ++i; +} + +int EmbData::setRotate(int dr) +{ + double rr = (dr * PI / 180) * 10000; //转换为弧度 + + if (dr == 0 || dr == 360) + { + return 0; + } + + double angle, sina, cosa; + +#if (1) + // 因为计算三角函数有问题,现在只支持 1度,10度,90度 + switch(dr) + { + case 1: + sina = 0.01745240643728351281941897851632; + cosa = 0.99984769515639123915701155881391; + break; + case 10: + sina = 0.17364817766693034885171662676931; + cosa = 0.98480775301220805936674302458952; + break; + case 90: + sina = 1; + cosa = 0; + break; + case -1: + sina = -0.01745240643728351281941897851632; + cosa = 0.99984769515639123915701155881391; + break; + case -10: + sina = -0.17364817766693034885171662676931; + cosa = 0.98480775301220805936674302458952; + break; + case -90: + sina = -1; + cosa = 0; + break; + default: + angle = (dr * PI) / 180.0; + sina = (double)qSin(angle); + cosa = (double)qCos(angle); + break; + } + +#else + + angle = (dr * PI) / 180.0; + sina = (double)qSin(angle); + cosa = (double)qCos(angle); +#endif + + + // 文件头 + const QByteArray & ary = m_embAbsData; + int size = ary.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("ary data less then head size"); + return -1; + } + + int datasize = size - sizeof(DataDs16FileHead); + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("dat data size err"); + return -1; + } + DataDs16FileHead * pDsHead = (DataDs16FileHead *)(ary.data()); + + //beginR的旋转 + double br = pDsHead->beginR + rr; + while (br > 2*PI * 10000) + { + br -= 2*PI * 10000; + } + while (br < -2*PI * 10000) + { + br += 2*PI * 10000; + } + pDsHead->beginR = br; + + DsAbsItem * pData = (DsAbsItem *)(ary.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; + + // 数据旋转 + for (int j = 0; j < stepsize; j++) + { + // 变换前点坐标 + double ax = absDataPtr->ax; + double ay = absDataPtr->ay; + double ar = absDataPtr->ar + rr; + + while (ar > 2*PI * 10000) + { + ar -= 2*PI * 10000; + } + while (ar < -2*PI * 10000) + { + ar += 2*PI * 10000; + } + // 变换后点的坐标 + double rax = (ax*cosa - ay*sina); + double ray = (ax*sina + ay*cosa); + + absDataPtr->ax = rax; + absDataPtr->ay = ray; + absDataPtr->ar = ar; + absDataPtr++; + } + + m_editedflag = 1; + + return 1; +} + +//此函数转换传入的绝对坐标值,是否取镜像及反复时数据之间的间距 +void EmbData::convertAbsDat(QByteArray &dat, int mirror) +{ + //无镜像、xy间距、角度旋转、缩放比例都为0时数据无需转换 + if(mirror == 0 && + m_spaceX == 0 && + m_spaceY == 0 ) + { + return; + } + + int size = dat.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("data less then head size"); + return; + } + DataDs16FileHead * pDsHead = (DataDs16FileHead *)(dat.data()); + + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("dat dataBegin err"); + return; + } + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("dat data size err"); + return; + } + DsAbsItem * pData = (DsAbsItem *)(dat.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; + //-------- + + //镜像数值不为0---开始 + // mirror 0, 无镜像; 1, 水平镜像; 2, 垂直镜像; 3, 水平和垂直镜像 + int mirrorx = 1; + int mirrory = 1; + int mirrorr = 1; + + if(mirror == 1 || mirror == 3) + { + mirrorx = -1; + mirrorr = -1; + } + if(mirror == 2 || mirror == 3) + { + mirrory = -1; + mirrorr = -1; + } + + // 镜像文件头转换 + if(mirror != 0) + { + pDsHead->beginX = pDsHead->beginX * mirrorx; + pDsHead->beginY = pDsHead->beginY * mirrory; + } + + // 镜像或列表间距不为0 + if(mirror != 0 || m_spaceX != 0 || m_spaceY != 0) + { + //图形先居中,起始点在加上偏移 + int centerx = (m_maxX + m_minX)/2; + int centery = (m_maxY + m_minY)/2; + + int rx = (pDsHead->beginX - centerx) * mirrorx; + int ry = (pDsHead->beginY - centery) * mirrory; + + int beginx = rx + centerx; + int beginy = ry + centery; + + //用下面两行代码,否则反复方式为Y轴对称或XY对称时不对 + pDsHead->beginX = beginx + m_spaceX; + pDsHead->beginY = beginy + m_spaceY; + } + //镜像数值不为0---结束 + + absDataPtr = pData; + + //镜像有变换时运动步才转换 + double dx, dy, dr; + + if(mirror != 0) + { + for (int i = 0; i < stepsize; i++) + { + // 读入一个针步数据 + dx = absDataPtr->ax; + dy = absDataPtr->ay; + dr = absDataPtr->ar; + + //镜像不为0 + if(mirror != 0) + { + dx = dx * mirrorx; + dy = dy * mirrory; + dr = dr * mirrorr; + } + + absDataPtr->ax = dx; + absDataPtr->ay = dy; + absDataPtr->ar = dr; + + absDataPtr++; + } + } + + return; +} + +int EmbData::calcLine(double x0, double y0, double x1, double y1, s16 step, QByteArray &absAry, DsAbsItem item) +{ + DsAbsItem absItem; + memcpy(&absItem,&item,sizeof(DsAbsItem)); + + s32 dx, dy; + double length; + double tmp; + int count; + int i; + double stepx, stepy; + double sx, sy; + int actx, acty; + double k; + + if(x0 == x1 && y0 == y1) + { + return 0; + } + + if(x0 > x1) + { + sx = -1.0; // x反向 + } + else + { + sx = 1.0; + } + + if(y0 > y1) + { + sy = -1.0; // y反向 + } + else + { + sy = 1.0; + } + + // 开始分割针步 + length = sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)); + + tmp = length/step; /* 实际针步数 */ + count = floor(tmp); /* 最少整针步数 */ + + if (tmp - count > 0.01) + { + count += 1; + } + + if (count == 0 && length > 0) // 短直线 + { + count = 1; + } + + tmp = 0; + actx = x0; + acty = y0; + + if (x1 != x0 && y1 == y0) // 横直线 + { + for (i = 0; i < count; i++) + { + tmp = ((i+1)*(length)/count)*sx+x0; // 实际针步 + + stepx = tmp - actx; + dx = (s32)(stepx+0.5*sx); + dy = 0; + actx += dx; + + absItem.ax = actx; + absItem.ay = y0; + absAry.append((char*)&absItem,sizeof(DsAbsItem)); + } + } + else if (x1 == x0 && y1 != y0) // 竖直线 + { + for (i = 0; i < count; i++) + { + tmp = ((i+1)*(length)/count)*sy + y0; // 实际针步 + + stepy = tmp - acty; + + dx = 0; + dy = (s32)(stepy+0.5*sy); + acty += dy; + + absItem.ax = x0; + absItem.ay = acty; + absAry.append((char*)&absItem,sizeof(DsAbsItem)); + } + } + else if(x1 != x0 && y1 != y0) // 任意斜线 + { + k = (y1-y0)/(x1-x0); + for (i = 0; i < count; i++) + { + tmp = ((i+1)*(length)/count); + + stepx = fabs(tmp*cos(atan(k)))*sx + x0; // 实际针步x + stepy = fabs(tmp*sin(atan(k)))*sy + y0; // 实际针步y + + dx = (s32)(stepx-actx+0.5*sx); + dy = (s32)(stepy-acty+0.5*sy); + + actx += dx; + acty += dy; + + absItem.ax = actx; + absItem.ay = acty; + absAry.append((char*)&absItem,sizeof(DsAbsItem)); + } + } + else + { + printf("what's this?\n"); + } + + return count; +} + +//花版的定位点为绝对坐标数据点,起始点为相对于定位点的相对坐标点,第一针为相对于起始点的坐标点 +//有的花版起始点有偏移量,第一针偏移量为0,有的花版起始点偏移量为0,第一针有偏移量 +//所以ds16文件头定位点坐标就是花版中的定位点,起始点坐标为花版中的定位点坐标+起始点坐标+第一针的坐标,同时ds16数据的第一针坐标偏移应置为0 +//生成DS16数据 +int EmbData::createEmbDs16FromAbs() +{ +#if(0) + QString ds16FilePath = m_filePath + ".ds16"; + QFile file(ds16FilePath); + + if(file.exists())//存在ds16文件 + { + if(!file.open(QIODevice::ReadOnly)) + { + qDebug() << "open file fail when read, path =" << m_filePath; + return -1; + } + + m_embDs16Data = file.readAll(); + file.close(); + + if(m_embDs16Data.size() <= 0) + { + return -1; + } + + memcpy(m_pEmbDs16Head, m_embDs16Data.data(), sizeof(DataDs16FileHead)); // 文件名称 + + m_minX = m_pEmbDs16Head->minX; + m_maxX = m_pEmbDs16Head->maxX; + m_minY = m_pEmbDs16Head->minY; + m_maxY = m_pEmbDs16Head->maxY; + m_beginX = m_pEmbDs16Head->beginX; + m_beginY = m_pEmbDs16Head->beginY; + + m_editedflag = 0; + + return 0; + } +#endif + + if (m_editedflag != 0) + { + m_minX = S32_MAX; + m_maxX = S32_MIN; + m_minY = S32_MAX; + m_maxY = S32_MIN; + + m_embDs16Data.clear(); + + QString name; + + QByteArray tgtdsdat; + tgtdsdat.clear(); + + u8 ctrlByte; + u8 attrByte; + WORD actionWord; //附加动作 + s32 dx, dy, dr; + u16 len; + double ax, ay, ar; + int actx, acty, actr; + int ddx, ddy,ddr; + + int beginx, beginy, beginr, anchorx, anchory; + int minx, miny, maxx, maxy; + int colornum = 1; + int jumpNeedleNum = 0;//跳针数 + actx = 0; + acty = 0; + actr =0; + beginx = 0; + beginy = 0; + beginr = 0; + anchorx = anchory = 0; + + int totalstepsize = 0; + memset(m_pEmbDs16Head,0,sizeof(DataDs16FileHead)); + + const QByteArray & ary = m_embAbsData; + int size = ary.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("ary data less then head size"); + return -1; + } + DataDs16FileHead * pDsHead = (DataDs16FileHead *)(ary.data()); + //fileId = pDsHead->fileid; + + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("absdat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(DsAbsItem); + if (stepsize <= 0) + { + qDebug("absdat data size err"); + return -1; + } + DsAbsItem * pData = (DsAbsItem *)(ary.data() + sizeof(DataDs16FileHead)); + DsAbsItem * absDataPtr = pData; //中间数据针步 + //----- + + // 文件名称 + QString str = QString::fromLocal8Bit(pDsHead->fileName); + name = str; + //str.sprintf("%s", pDsHead->fileName); + //name += " "; + //name += str; + + minx = absDataPtr->ax; + maxx = absDataPtr->ax; + miny = absDataPtr->ay; + maxy = absDataPtr->ay; + + // 数据区 + qDebug()<<"stepsize:"<ctrl; + attrByte = absDataPtr->attr;//绝对数据的属性字节 + actionWord = absDataPtr->action; + + ax = absDataPtr->ax;//绝对数据的X位置 + ay = absDataPtr->ay; + ar = absDataPtr->ar; + + // 轮廓 + if (minx > ax) { minx = ax; } + if (maxx < ax) { maxx = ax; } + if (miny > ay) { miny = ay; } + if (maxy < ay) { maxy = ay; } + + if (j == 0)//第一针 + { + beginx = ax; + beginy = ay; + beginr = ar; + actx = ax; + acty = ay; + actr = ar; + anchorx = pDsHead->anchorX; + anchory = pDsHead->anchorY; + + ddx = 0; + ddy = 0; + //让ddr等于0,因为在datafiledsr中将beginR置为0而非第一针的角度,所以不应该用 absDataPtr->ar - pDsHead->beginR + //如果beginR等于第一针的角度,那么第一针的ddr就应该是0 + ddr = 0; + + //过滤掉空针 + if(ddx== 0 && ddy == 0) + { + actx += ddx; + acty += ddy; + actr += ddr; + absDataPtr++; + + continue; + } + } + else + { + ddx = ax - actx; + ddy = ay - acty; + ddr = ar -actr; + } + + if( ctrlByte == DATA_END || + ctrlByte == DATA_PAUSE || + ctrlByte == DATA_CHGND || + ctrlByte == DATA_CUTTRD || + ctrlByte == DATA_ANGLE || + 0 ) + { + ddx = 0; + ddy = 0; + ddr = 0; + } + + dx = ddx; + dy = ddy; + dr = ddr; + + actx += ddx; + acty += ddy; + actr += ddr; + + while (dr < -PI10000) + { + dr += PI20000; + } + while (dr > PI10000) + { + dr -= PI20000; + } + + if ( 0 && (ctrlByte == DATA_END || ctrlByte == DATA_NULL)) + { + qDebug()<< "增加剪线" < maxStep && ctrlByte == DATA_SEWING) + if(xyLen > maxStep) + { + s16 addx,addy; + addx = addy = 0; + //分割针步 + double splitVal = 400.0;//分割针步为400 + s32 stepNum = xyLen / splitVal;//拆分几步 + double lastStep = (double)((int)xyLen % (int)splitVal); + double addStep = lastStep / stepNum; + + double stepX = 0; + double stepY = 0; + double stepDr = 0; + for(int m = 0; m < stepNum; m++) + { + stepX = 0; + stepY = 0; + stepDr = 0; + memset(&ds16Item,0,sizeof(Ds16Item));//初始化结构体 + + stepX = dx * splitVal / xyLen + dx * addStep / xyLen; + stepY = dy * splitVal / xyLen + dy * addStep / xyLen; + + if(m == 0) + { + stepDr = dr; + } + + ds16Item.dx = qRound(stepX);//四舍五入 + ds16Item.dy = qRound(stepY); + + if (m == stepNum-1) + {// 最后一针,消除累计误差 + ds16Item.dx = dx - addx; + ds16Item.dy = dy - addy; + } + else + { + addx += ds16Item.dx; + addy += ds16Item.dy; + } + + ds16Item.ctrl = ctrlByte; + len = sqrt(ds16Item.dx*ds16Item.dx + ds16Item.dy*ds16Item.dy); + ds16Item.attr = attrByte; + ds16Item.action[0] = 0; + ds16Item.action[1] = 0; + ds16Item.dr = stepDr; + ds16Item.len = len; + memset(ds16Item.rev,0,sizeof(ds16Item.rev)); + tgtdsdat.append((char*)(&ds16Item), sizeof(Ds16Item)); + totalstepsize++; + } + } + else + { + len = sqrt(dx*dx + dy*dy); + ds16Item.ctrl = ctrlByte; + ds16Item.attr = attrByte; + + memcpy(ds16Item.action,&actionWord,sizeof(actionWord)); + + ds16Item.dx = dx; + ds16Item.dy = dy; + ds16Item.dr = dr; + ds16Item.len = len; + memset(ds16Item.rev,0,sizeof(ds16Item.rev)); + tgtdsdat.append((char*)(&ds16Item), sizeof(Ds16Item));//ds16针步 + totalstepsize++; + } + + if (ctrlByte == DATA_CHGND) + { + colornum++; + } + + if (ctrlByte == DATA_OFFSET) + { + jumpNeedleNum++;//跨步总数加1 + } + + absDataPtr++; + } + + if (m_minX > minx) { m_minX = minx; } + if (m_minX > maxx) { m_minX = maxx; } + if (m_maxX < minx) { m_maxX = minx; } + if (m_maxX < maxx) { m_maxX = maxx; } + if (m_minY > miny) { m_minY = miny; } + if (m_minY > maxy) { m_minY = maxy; } + if (m_maxY < miny) { m_maxY = miny; } + if (m_maxY < maxy) { m_maxY = maxy; } + + // 针数 + int newstepnum = tgtdsdat.size() / sizeof(Ds16Item); + qDebug()<< "newstepnum" < 0) + { + // 修改文件头 + int namelen = name.size(); + if (namelen > HEAD_NAME_STR_LEN) + { + namelen = HEAD_NAME_STR_LEN; + } + + QByteArray array = name.toLocal8Bit().data(); + int asize = array.length(); + memcpy(m_pEmbDs16Head->fileName, array, asize); // 文件名称 + m_pEmbDs16Head->dataSize = newstepnum*sizeof(Ds16Item); // 数据字节数 + m_pEmbDs16Head->itemNums = newstepnum; // 数据项个数 + m_pEmbDs16Head->bytesPerItem = sizeof(Ds16Item); // 每项占的字节数 + m_pEmbDs16Head->bytesPerBlk = MAX_EXDP_LEN; // 数据内容划分块大小 + m_pEmbDs16Head->dataChecksum = calcCheckSum32((u8 *)(tgtdsdat.data()) , m_pEmbDs16Head->dataSize); // 数据累加校验和 + m_pEmbDs16Head->checkCrc = calcCrc16((u8 *)(m_pEmbDs16Head), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + m_pEmbDs16Head->fileid = m_pEmbDs16Head->checkCrc; + + m_pEmbDs16Head->anchorX = anchorx; // 定位点坐标X + m_pEmbDs16Head->anchorY = anchory; // 定位点坐标Y, 设置为0,作为基准 + m_pEmbDs16Head->beginX = beginx; // 数据起点坐标X + m_pEmbDs16Head->beginY = beginy; // 数据起点坐标Y + m_pEmbDs16Head->beginR = beginr; // 数据起点坐标R //-rq + m_pEmbDs16Head->minX = m_minX; + m_pEmbDs16Head->maxX = m_maxX; + m_pEmbDs16Head->minY = m_minY; + m_pEmbDs16Head->maxY = m_maxY; // 轮廓范围,使用重新计算之后的值 + //中间数据的文件头 + + // 添加文件头 + m_embDs16Data.append((char*)m_pEmbDs16Head, sizeof(DataDs16FileHead));//ds16头文件存在ds16中 + // 添加文件数据 + m_embDs16Data.append(tgtdsdat); + } + +#if(1) + //保存成ds16文件 + QString ds16FilePath = m_filePath + ".ds16"; + QFile file(ds16FilePath); + + if(file.exists())//存在ds16文件 + { + QFile::remove(ds16FilePath); + } + + if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + qDebug() << "open file fail when wirte, path =" << m_filePath; + return -1; + } + else + { + file.write(m_embDs16Data); + file.close(); + } +#endif + } + + m_editedflag = 0; + + return 0; +} + +int EmbData::reCalcDataChecksum() +{ + return 0; +} + +//绘制针数索引的跟踪笔 +void EmbData::drawNeedleIdxPen(int x, int y, QPainter &painter) +{ + //贴图的xy和画笔的xy值相同 + m_penX = x; + m_penY = y; + + m_penPix = m_canvas.copy(x-20,y-30,40,40);//复制画笔区域未绘制笔之前的图像 + + QPen pen; + QColor color; + + //绘制深灰色画笔 + pen.setWidth(2); + color.setRgb(60,60,60);//深灰色 + pen.setColor(color); + painter.setPen(pen); + + painter.drawLine(x-4, y-28, x-4, y-8);//画左"|" + painter.drawLine(x+4, y-28, x+4, y-8); //画右"|" + painter.drawEllipse(x-1, y-10, 2, 2);//画中心"°" + painter.drawLine(x-4, y-8, x, y);//画左"\"(笔尖) + painter.drawLine(x+4, y-8, x, y); //画右"/"(笔尖) + + //绘制深红色画笔 + pen.setWidth(1); + color.setRgb(174,60,64);//深红色 + pen.setColor(color); + painter.setPen(pen); + + painter.drawLine(x-3, y-28, x-3, y-8);//画左"|" + painter.drawLine(x+5, y-28, x+5, y-8); //画右"|" + painter.drawEllipse(x-2, y-12, 3, 3);//画中心"°" + painter.drawLine(x-3, y-8, x, y);//画左"\"(笔尖) + painter.drawLine(x+5, y-8, x, y); //画右"/"(笔尖) +} + +void EmbData::drawFork(int x, int y, QPainter &painter) +{ + //贴图的xy和画笔的xy值相同 + m_penX = x; + m_penY = y; + + m_penPix = m_canvas.copy(x-20,y-30,40,40);//复制画笔区域未绘制笔之前的图像 + + QPen pen; + QColor color; + + //绘制深灰色画笔 + pen.setWidth(2); + color.setRgb(228,42,48); + pen.setColor(color); + painter.setPen(pen); + + painter.drawLine(x-8, y-8, x-3, y-3);// \上一半 + painter.drawLine(x+8, y-8, x+3, y-3);// /上一半 + + painter.drawLine(x+3, y+3, x+8, y+8); + painter.drawLine(x-3, y+3, x-8, y+8); +} + +void EmbData::drawFork(int x, int y, QPainter &painter, int index, bool isDraw) +{ + m_penPoint[index].setX(x); + m_penPoint[index].setY(y); + + m_penHeadPix[index] = m_canvas.copy(x-20,y-30,40,40);//复制画笔区域未绘制笔之前的图像 + + QPen pen; + QColor color; + + if(isDraw){ + //绘制深灰色画笔 + pen.setWidth(2); + color.setRgb(228,42,48); + pen.setColor(color); + painter.setPen(pen); + + painter.drawLine(x-8, y-8, x-3, y-3);// \上一半 + painter.drawLine(x+8, y-8, x+3, y-3);// /上一半 + + painter.drawLine(x+3, y+3, x+8, y+8); + painter.drawLine(x-3, y+3, x-8, y+8); + } + +} + +//擦除针数索引的跟踪笔 +void EmbData::eraseNeedleIdxPen(QPainter &painter) +{ + //贴图的xy和画笔的xy值相同 + painter.drawPixmap(m_penX-20,m_penY-30,m_penPix); +} + +void EmbData::eraseNeedleIdxPen(QPainter &painter, int index) +{ + painter.drawPixmap(m_penPoint[index].x()-20,m_penPoint[index].y()-30,m_penHeadPix[index]); +} + +void EmbData::getCurvePointFillLine(QList &inList, double indRunLen, QList &outList) +{ + DsAbsItem dPoint1, dPoint2, dPoint3; + double dTatol, dLen1, dLen2, dSpace; + long lSum, lCount; + + //计算总的线段长 + int iCountPoint = inList.size(); + if(iCountPoint <= 0) + { + return; + } + + getTotalDistanceFillLine(&inList, dTatol); + if(dTatol == 0) + return; + + lSum = (long)round(dTatol / indRunLen + 0.1667); + dSpace = dTatol / (double)lSum; + if(lSum == 0) + lSum = 1; + + dPoint1 = inList[0]; + outList.append(dPoint1);//添加第一个点 + dPoint2 = dPoint1; + + dLen1 = dSpace; + dLen2 = 0; + int i = 0; + for(lCount = 0; lCount < lSum; lCount++) + { + while(i < inList.size()-1 && dLen2 < dLen1) + { + dLen1 -= dLen2; + dPoint1 = dPoint2; + i++; + dPoint2 = inList[i]; + dLen2 = sqrt((dPoint1.ax - dPoint2.ax) * (dPoint1.ax - dPoint2.ax) + (dPoint1.ay - dPoint2.ay) * (dPoint1.ay - dPoint2.ay)); + } + if(dLen1 < dLen2) + { + getPointInSectFillLine(dPoint1, dPoint2, dLen1, dPoint3); + } + else + { + dPoint3 = dPoint2; + } + outList.append(dPoint3); + dLen2 -= dLen1; + dLen1 = dSpace; + dPoint1 = dPoint3; + } +} + +int EmbData::getTotalDistanceFillLine(QList *pPointList, double &dTotal) +{ + DsAbsItem dPoint, dNext; + double d; + dTotal = 0; + int i = 0; + long lSum = (long)pPointList->count(); + if(lSum > 1) + { + while(i < pPointList->size()) + { + dPoint = pPointList->at(i); + i++; + if(i < pPointList->size()) + { + dNext = pPointList->at(i); + d = sqrt((dPoint.ax - dNext.ax) * (dPoint.ax - dNext.ax) + (dPoint.ay- dNext.ay) * (dPoint.ay- dNext.ay)); + dTotal += d; + } + else + { + break; + } + } + } + return 0; +} + +bool EmbData::getPointInSectFillLine(const DsAbsItem &p1, const DsAbsItem &p2, const double &d, DsAbsItem &outp) +{ + bool bRes; + DsAbsItem dpoint[3]; + + dpoint[0] = p1; + dpoint[1] = p2; + dpoint[2] = outp; + outp = dpoint[1]; + + bRes = getPointAtSect(dpoint[0], dpoint[1], d, dpoint[2]); + outp.ax = dpoint[2].ax; + outp.ay = dpoint[2].ay; + + return bRes; +} + +bool EmbData::getPointAtSect(const DsAbsItem &p1, const DsAbsItem &p2, const double &d, DsAbsItem &outp) +{ + double s = sqrt((p1.ax - p2.ax) * (p1.ax - p2.ax) + (p1.ay - p2.ay) * (p1.ay - p2.ay)); + if(fabs(s) < ZERO) + { + if(d < ZERO) + { + outp.ax = p1.ax; + outp.ay = p1.ay; + } + return false; + } + outp.ax = (p2.ax - p1.ax) * d / s + p1.ax; + outp.ay = (p2.ay - p1.ay) * d / s + p1.ay; + + return true; +} + +//设置视图尺寸(透明背景) +int EmbData::setViewInfo(int width, int height) +{ + // if (m_viewWidth != width || + // m_viewHight != height) + { + if (width <= EMB_PREVIEW_SIDE*2 || height <= EMB_PREVIEW_SIDE*2) + { + return -1; + } + m_viewWidth = width; + m_viewHight = height; + m_canvas = QPixmap(m_viewWidth, m_viewHight); + m_canvas.fill(Qt::transparent);//用透明色填充 + //memset(m_canvas.bits(), 0x00, m_canvas.byteCount()); + } + return 0; +} + +//设置视图(带背景图片背景) +void EmbData::setViewInfo(QPixmap pix) +{ + m_canvas = pix; +} + +//重置数据 +void EmbData::setEmbData(int type, int redraw) +{ + m_type = type; + createDispFromEmbDs16Dat(m_embDs16Data); + if (redraw != 0) + { + drawImageByDispFile(); + } +} + +void EmbData::setDispMode(EmbData::DISP_MODE dispmode, int redraw) +{ + m_dispMode = dispmode; + if(redraw != 0) + { + drawImageByDispFile(); + } +} + +void EmbData::setDrawMode(EmbData::DRAW_MODE drawmode) +{ + m_drawMode = drawmode; +} + +//设置进度显示数据 +void EmbData::setExecIndex(int index) +{ + m_stitchIndex = index; + + if (m_dispMode == DISP_EXECING) + { + drawImageByDispFile(); + } +} + +void EmbData::reDraw() +{ + drawImageByDispFile(); +} + +//创建显示用的数据(为了快速显示) +int EmbData::createDispFromEmbDs16Dat(QByteArray &ds16dat) +{ + if(m_type == MACHINE_FIVEHEADPRECISIONSEWING) + return createDispFromEmbDs16DatForHeadInfo(ds16dat); + + DispItem dispItem; + m_dispDat.clear();//显示绘图用的数据(需要转换) + + // DsAbsItem absItem;//用于轮廓提取的绝对坐标值 + // m_ds16ToAbsDat.clear();//用于轮廓提取的绝对坐标值 + + m_stitchIndex = 0; + m_dispIndex = 0; + + // ds16数据 + int size = ds16dat.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("16 data less then head size"); + return -1; + } + DataDs16FileHead * pDsHead = (DataDs16FileHead *)(ds16dat.data()); + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("dat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(Ds16Item); + if (stepsize <= 0) + { + qDebug("ds16 data size err"); + return -1; + } + + Ds16Item * ds16DataPtr; + Ds16Item * pData = (Ds16Item *)(ds16dat.data() + sizeof(DataDs16FileHead)); + ds16DataPtr = pData; + + // 图形显示区域 + int width = m_canvas.width();//留4个像素的边 + int height = m_canvas.height();//留4个像素的边 + if (width <= EMB_PREVIEW_SIDE*2 || height <= EMB_PREVIEW_SIDE*2) + { + qDebug("preview img too small"); + return -1; + } + + //留边(否则实时跟踪笔会画出界) + int viewSide = EMB_PREVIEW_SIDE; + if(m_drawMode == DRAW_PREVIEW) + { + viewSide = 20;//预览模式时整区域留20像素绘制(原色显示) + } + int dpminx = viewSide; + int dpmaxx = width - viewSide; + int dpminy = viewSide; + int dpmaxy = height - viewSide; + + //1:1显示无需留边 + // int dpminx = 0; + // int dpmaxx = width; + // int dpminy = 0; + // int dpmaxy = height; + + // 计算缩放系数 + double factor, temp; + if ((dpmaxx - dpminx) <= 0 || (dpmaxy - dpminy) <= 0) + { + return -1; + } + + factor = (double)(fabs(m_maxX-m_minX)) / (dpmaxx - dpminx); // 按框尺寸x计算的缩放系数 + temp = (double)(fabs(m_maxY-m_minY)) / (dpmaxy - dpminy); // 按框尺寸y计算的缩放系数 + + if (temp >= factor) // 使用较大的缩放系数 + { + factor = temp; + } + + m_factor = factor; + + // 计算显示参数,按照图形的实际位置显示(数据坐标零点对应图形中心) + int dpx = (int)((dpminx+dpmaxx)/2 - ((m_maxX+m_minX)/factor)/2); + int dpy = (int)((dpminy+dpmaxy)/2 - ((m_maxY+m_minY)/factor)/2); + + // 显示花样图形 + u8 ctrlByte; + u8 attrByte; + int dx; + int dy; + int dr; + + double datposx, datposy, datposr; + int curx, cury, curr, prex, prey; + curx = cury = curr = prex = prey = 0; + + datposx = pDsHead->beginX; + datposy = pDsHead->beginY; + datposr = pDsHead->beginR; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (EMB_SHOWDIRX == -1) + { + curx = width - curx; + } + if (EMB_SHOWDIRY == -1) + { + cury = height - cury; + } + + for (int i = 0; i < stepsize; i++) + { + prex = curx; + prey = cury; + + // 读入一个针步数据 + ctrlByte = ds16DataPtr->ctrl; + attrByte = ds16DataPtr->attr; + dx = ds16DataPtr->dx; + dy = ds16DataPtr->dy; + dr = ds16DataPtr->dr; + + datposx += dx; + datposy += dy; + datposr += dr; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (EMB_SHOWDIRX == -1) + { + curx = width - curx; + } + if (EMB_SHOWDIRY == -1) + { + cury = height - cury; + } + + while(datposr >= PI10000) + { + datposr -= (PI20000-1); + } + while(datposr <= -PI10000) + { + datposr += (PI20000-1); + } + + dispItem.ctrl = ctrlByte; + dispItem.attr = attrByte; + dispItem.bx = prex; + dispItem.by = prey; + dispItem.ex = curx; + dispItem.ey = cury; + dispItem.ar = curr; + if(ctrlByte ==DATA_OFFSET) //跨步(偏移)针步另一钟颜色显示 + dispItem.rgb = rgbColorYel; + else + dispItem.rgb = rgbColorBlue; + + memcpy(&dispItem.action,ds16DataPtr->action,sizeof(dispItem.action)); + + m_dispDat.append((char*)(&dispItem), sizeof(DispItem)); + + ds16DataPtr++; + } + + qDebug("CreateDispFromEmbDs16, stepsize=%d", m_dispDat.size() / sizeof(DispItem)); + + return 0; +} + +int EmbData::createDispFromEmbDs16DatForHeadInfo(QByteArray &ds16dat) +{ + m_headDispDate.clear(); + + DataFileDsr dsr;//可能引起栈内存溢出的问题 + dsr.initFile(m_filePath); + dsr.convertDataToEmbAbs(); + DsrHeadEx62 head = dsr.get62ExHead(); + int StepNum = dsr.getStepNums(); + int maxHSP = findMaxSpHead(head,StepNum); + + Disp_HeadItem dispItem; + m_dispDat.clear();//显示绘图用的数据(需要转换) + + m_stitchIndex = 0; + m_dispIndex = 0; + + // ds16数据 + int size = ds16dat.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("16 data less then head size"); + return -1; + } + DataDs16FileHead * pDsHead = (DataDs16FileHead *)(ds16dat.data()); + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("dat dataBegin err"); + return -1; + } + int stepsize = datasize/sizeof(Ds16Item); + if (stepsize <= 0) + { + qDebug("ds16 data size err"); + return -1; + } + + Ds16Item * ds16DataPtr; + Ds16Item * pData = (Ds16Item *)(ds16dat.data() + sizeof(DataDs16FileHead)); + ds16DataPtr = pData; + + // 图形显示区域 + int width = m_canvas.width();//留4个像素的边 + int height = m_canvas.height();//留4个像素的边 + if (width <= EMB_PREVIEW_SIDE*2 || height <= EMB_PREVIEW_SIDE*2) + { + qDebug("preview img too small"); + return -1; + } + + //留边(否则实时跟踪笔会画出界) + int viewSide = EMB_PREVIEW_SIDE; + if(m_drawMode == DRAW_PREVIEW) + { + viewSide = 20;//预览模式时整区域留20像素绘制(原色显示) + } + int dpminx = viewSide; + int dpmaxx = width - viewSide; + int dpminy = viewSide; + int dpmaxy = height - viewSide; + + // 计算缩放系数 + double factor, temp; + if ((dpmaxx - dpminx) <= 0 || (dpmaxy - dpminy) <= 0) + { + return -1; + } + + factor = (double)(fabs(m_maxX+(maxHSP*10)-m_minX)) / (dpmaxx - dpminx); // 按框尺寸x计算的缩放系数 五头机加上一个最大值保证绘图不越界 + temp = (double)(fabs(m_maxY-m_minY)) / (dpmaxy - dpminy); // 按框尺寸y计算的缩放系数 + // 使用较大的缩放系数 + factor = temp >= factor?temp:factor; + m_factor = factor; + + // 计算显示参数,按照图形的实际位置显示(数据坐标零点对应图形中心) + int dpx = (int)((dpminx+dpmaxx)/2 - ((m_maxX+m_minX+(maxHSP*10))/factor)/2);//最大x需要 五头机加上一个最大值保证绘图不越界 + int dpy = (int)((dpminy+dpmaxy)/2 - ((m_maxY+m_minY)/factor)/2); + + // 显示花样图形 + + double datposx = pDsHead->beginX; + double datposy = pDsHead->beginY; + + int curx = (datposx) / factor + dpx; + int cury = (datposy) / factor + dpy; + + if (EMB_SHOWDIRX == -1) + { + curx = width - curx; + } + if (EMB_SHOWDIRY == -1) + { + cury = height - cury; + } + + for (int i = 0; i < stepsize; i++) + { + int prex = curx; + int prey = cury; + + // 读入一个针步数据 + int dx = ds16DataPtr->dx; + int dy = ds16DataPtr->dy; + unsigned short int headSpHndex = ds16DataPtr->action[1] & 0xFF; + + datposx += dx; + datposy += dy; + + curx = (datposx) / factor + dpx; + cury = (datposy) / factor + dpy; + + if (EMB_SHOWDIRX == -1) + { + curx = width - curx; + } + if (EMB_SHOWDIRY == -1) + { + cury = height - cury; + } + + dispItem.ctrl = ds16DataPtr->ctrl; + dispItem.attr = ds16DataPtr->attr; + dispItem.bx = prex; + dispItem.by = prey; + dispItem.ex = curx; + dispItem.ey = cury; + dispItem.ar = ds16DataPtr->dr; + memcpy(&dispItem.action,ds16DataPtr->action,2); + dispItem.headtable.iswork = head.headEnableSpacing[headSpHndex].iswork; + dispItem.headtable.distance1_2 = head.headEnableSpacing[headSpHndex].distance1_2; + dispItem.headtable.distance1_3 = head.headEnableSpacing[headSpHndex].distance1_3; + dispItem.headtable.distance1_4 = head.headEnableSpacing[headSpHndex].distance1_4; + dispItem.headtable.distance1_5 = head.headEnableSpacing[headSpHndex].distance1_5; + dispItem.headtable.distance1_6 = head.headEnableSpacing[headSpHndex].distance1_6; + dispItem.headtable.distance1_7 = head.headEnableSpacing[headSpHndex].distance1_7; + dispItem.headtable.distance1_8 = head.headEnableSpacing[headSpHndex].distance1_8; + if(ds16DataPtr->ctrl ==DATA_OFFSET) //跨步(偏移)针步另一钟颜色显示 + dispItem.rgb = rgbColorYel; + else + dispItem.rgb = rgbColorGreen; + + m_headDispDate.append(dispItem); + + ds16DataPtr++; + } + + qDebug("CreateDispFromEmbDs16, stepsize=%d", m_headDispDate.size()); + + return 0; +} + +#define DRAWDR 0 + +int EmbData::drawImageByDispFile() +{ + if(m_type == MACHINE_FIVEHEADPRECISIONSEWING) + return drawImageByOneStepLotLine(); + + int bx, by, ex, ey, ar; + bx = by = ex = ey = ar = 0; + int i; + u8 ctrlByte; + DispItem * pDispBuff = (DispItem *)m_dispDat.data(); + + int size = m_dispDat.size(); + int stitchCount = size/sizeof(DispItem); + + if (stitchCount <= 0) + { + stitchCount = 0; + } + if (m_stitchIndex >= stitchCount) + { + m_stitchIndex = stitchCount - 1; + } + if (m_stitchIndex < 0) + { + m_stitchIndex = 0; + } + + DISP_MODE dispmode = m_dispMode; + + QPainter painter(&m_canvas); + + QRgb rgb; + QPen pen; + + //笔宽 + pen.setWidth(1); + rgb = 0; + + if (dispmode == DISP_ALL_NORMAL || // 显示所有线迹(原色显示) + dispmode == DISP_ALL_EXEC || // 显示所有线迹(执行过的显示原色,其余显示灰色) + 0) + { + int tenThousand = 0; + for (i = 0; i < stitchCount; i++) + { + tenThousand++; + if(tenThousand == TENTHOUSANDNEEDLE) + { + tenThousand = 0; + int idx = i / TENTHOUSANDNEEDLE; + //每十万针主界面加载图片的进度条走一格 + emit siDrawNeedleIdx(idx); + } + + bx = pDispBuff[i].bx; + by = pDispBuff[i].by; + ex = pDispBuff[i].ex; + ey = pDispBuff[i].ey; + rgb = pDispBuff[i].rgb; + ctrlByte = pDispBuff[i].ctrl; + + // 从开始到 m_stitchIndex 显示正常颜色的线迹(执行过),从 m_stitchIndex 结束显示未缝纫颜色线迹(未执行) + if ((dispmode == DISP_ALL_EXEC) && (i >= m_stitchIndex)) + { + if(ctrlByte ==DATA_OFFSET) //跨步(偏移)针步另一钟颜色显示 + rgb = rgbColorYel; + else + rgb = rgbColorGreen; + } + + pen.setColor(rgb); + painter.setPen(pen); + painter.drawLine(bx, by, ex, ey); + +#if(DRAWDR) + double len = sqrt((double)(ex-bx)*(double)(ex-bx)+ (double)(ey-by)*(double)(ey-by)); + + int mx = len * cos((PI10000-ar)/10000.0); + int my = len * sin((PI10000-ar)/10000.0); + QColor color = QColor(Qt::green); + QPen pen; + pen.setColor(color); + painter.setPen(pen); + painter.drawLine(bx, by, bx+mx, by+my); + pen.setColor(QColor(Qt::red)); + painter.setPen(pen); + painter.drawEllipse(bx+mx, by+my,2,2); +#endif + } + + if (dispmode == DISP_ALL_EXEC && m_stitchIndex < stitchCount) + { + i = m_stitchIndex; + + bx = pDispBuff[i].bx; + by = pDispBuff[i].by; + drawFork(bx, by, painter);//绘制准星 + m_dispIndex = m_stitchIndex; // 移动显示指针 + } + } + else if (dispmode == DISP_EXECING) // 刷新部分线迹(缝纫中进度显示) + { + //qDebug()<<"m_stitchIndex"< m_dispIndex && m_stitchIndex < stitchCount) + { + i = m_dispIndex; + + while(i < m_stitchIndex) // 显示为原线迹 + { + bx = pDispBuff[i].bx; + by = pDispBuff[i].by; + ex = pDispBuff[i].ex; + ey = pDispBuff[i].ey; + rgb = pDispBuff[i].rgb; + + pen.setColor(rgb); + painter.setPen(pen); + painter.drawLine(bx, by, ex, ey); + i++; + } + } + else if (m_stitchIndex < m_dispIndex && m_dispIndex < stitchCount) + { + i = m_stitchIndex; + + while(i <= m_dispIndex) // 显示为未缝纫颜色线迹 + { + bx = pDispBuff[i].bx; + by = pDispBuff[i].by; + ex = pDispBuff[i].ex; + ey = pDispBuff[i].ey; + rgb = pDispBuff[i].rgb; + ctrlByte = pDispBuff[i].ctrl; + + if(ctrlByte ==DATA_OFFSET) //跨步(偏移)针步另一钟颜色显示 + rgb = rgbColorYel; + else + rgb = rgbColorGreen; + + pen.setColor(rgb); + painter.setPen(pen); + painter.drawLine(bx, by, ex, ey); + i++; + } + } + + i = m_stitchIndex; + + bx = pDispBuff[i].bx; + by = pDispBuff[i].by; + drawFork(bx, by, painter);//绘制跟踪笔 + m_dispIndex = m_stitchIndex; // 移动显示指针 + } + } + return 0; +} + +#include +using namespace std; +/** + * @brief EmbData::drawImageByOneStepLotLine + * @return + * 五头机绘图函数 根据机头间距表信息单步画多条线 + */ +int EmbData::drawImageByOneStepLotLine() +{ + int stitchCount = m_headDispDate.size(); + //限制针步数 否则访问溢出 + if (stitchCount <= 0) + { + stitchCount = 0; + } + if (m_stitchIndex >= stitchCount) + { + m_stitchIndex = stitchCount - 1; + } + if (m_stitchIndex < 0) + { + m_stitchIndex = 0; + } + + QPainter painter(&m_canvas); + QRgb rgb; + QPen pen; + + //笔宽 + pen.setWidth(1); + + if (m_dispMode == DISP_ALL_NORMAL || // 显示所有线迹(原色显示) + m_dispMode == DISP_ALL_EXEC || // 显示所有线迹(执行过的显示原色,其余显示灰色) + 0) + { + int tenThousand = 0; + for (int i = 0; i < stitchCount; i++) + { + tenThousand++; + if(tenThousand == TENTHOUSANDNEEDLE) + { + tenThousand = 0; + int idx = i / TENTHOUSANDNEEDLE; + //每十万针主界面加载图片的进度条走一格 + emit siDrawNeedleIdx(idx); + } + + // 从开始到 m_stitchIndex 显示正常颜色的线迹(执行过),从 m_stitchIndex 结束显示未缝纫颜色线迹(未执行) + rgb = m_headDispDate[i].rgb; + + if ((m_dispMode == DISP_ALL_EXEC) && (i >= m_stitchIndex)) + { + if(m_headDispDate[i].ctrl ==DATA_OFFSET) //跨步(偏移)针步另一钟颜色显示 + rgb = rgbColorYel; + else + rgb = rgbColorGreen; + } + + drawMultiLine(painter,pen,rgb,i);///多机头绘线 + } + + if (m_dispMode == DISP_ALL_EXEC && m_stitchIndex < stitchCount) + { + drawMultiTrack(painter);///绘制多机头的跟踪图案 + m_dispIndex = m_stitchIndex; // 移动显示指针 + } + } + else if (m_dispMode == DISP_EXECING) // 刷新部分线迹(缝纫中进度显示)前进回退的时候 + { + //qDebug()<<"m_stitchIndex"< m_dispIndex && m_stitchIndex < stitchCount) + { + /// 从小针步增加到大针步 + int i = m_dispIndex; + + while(i < m_stitchIndex) // 显示为原线迹 + { + if(m_headDispDate[i].ctrl ==DATA_OFFSET) //跨步(偏移)针步另一钟颜色显示 + rgb = rgbColorYel; + else + rgb = rgbColorBlue; + drawMultiLine(painter,pen,rgb,i);///多机头绘线 + i++; + } + } + else if (m_stitchIndex < m_dispIndex && m_dispIndex < stitchCount) + { + /// 从大针步减少到小针步 + int i = m_stitchIndex; + + while(i <= m_dispIndex) // 显示为未缝纫颜色线迹 + { + rgb = m_headDispDate[i].rgb; + drawMultiLine(painter,pen,rgb,i);///多机头绘线 + i++; + } + } + + drawMultiTrack(painter);///绘制多机头的跟踪图案 + m_dispIndex = m_stitchIndex; // 移动显示指针 + } + } + return 0; +} + +/** + * @brief EmbData::findMaxSpHead + * @param head 机头间距表 + * @param StepNum 跨步数 + * @return 返回机头间距表中用到的最大偏移值 + */ +int EmbData::findMaxSpHead(DsrHeadEx62 &head,int StepNum) +{ + int max = 0; + for(int i = 0 ; i < StepNum;i++){ + bitset<8> iswork(head.headEnableSpacing[i].iswork); + for(int j = 1; j < headNum; j++) + { + if(!iswork.test(j)) // test(i)为0返回false + continue; + unsigned short int* row = (unsigned short int*)&head.headEnableSpacing[i]; + unsigned short int space = *(row + j); //向后偏移得到具体大小 + max = max > space ? max : space; + } + } + return max; +} + +/// +/// \brief 根据机头间距表的iswork字段 选择性的绘制跟踪画笔 +/// +void EmbData::drawMultiTrack(QPainter &painter) +{ + int bx = m_headDispDate[m_stitchIndex].bx; + int by = m_headDispDate[m_stitchIndex].by; + bitset<8> iswork(m_headDispDate[m_stitchIndex].headtable.iswork); + + for(int j = 0; j < headNum; j++){ + if(j==0)//第一个机头不需要偏移 + drawFork(bx, by, painter, j, true);//绘制准星 + else + { + unsigned short int* row = (unsigned short int*)&m_headDispDate[m_stitchIndex].headtable; // 取到结构体的初始地址 + unsigned short int space = *(row + j); //向后偏移得到具体大小 + space = (space*10)/m_factor; //从实际距离转换为像素,得到最终的偏移像素 + drawFork(bx + space, by, painter, j, iswork.test(j));//绘制准星 + } + } +} + +/// +/// \brief 五头机函数,根据机头间距表信息多机头同时画线 +/// \param painter +/// \param pen +/// \param rgb +/// \param index +/// +void EmbData::drawMultiLine(QPainter &painter, QPen &pen, QRgb rgb, int index) +{ + int bx = m_headDispDate[index].bx;//begin + int by = m_headDispDate[index].by; + int ex = m_headDispDate[index].ex;//end + int ey = m_headDispDate[index].ey; + + pen.setColor(rgb); + painter.setPen(pen); + bitset<8> iswork(m_headDispDate[index].headtable.iswork); + + + for(int j = 0; j < headNum; j++){ + if(!iswork.test(j)) // test(i)为0,表示机头不工作,跳过循环 + { + if(j == 0){//如果是一机头不工作,那么使用黄色线段画出 + painter.save(); + painter.setPen(rgbColorYel); + painter.drawLine(bx, by, ex, ey); //机头1 缝纫数据 和原数据一致 + painter.restore(); + } + continue; + } + + //缝纫数据 + if(m_headDispDate[index].ctrl ==DATA_SEWING) + { + if(j == 0){//机头1 + painter.drawLine(bx, by, ex, ey); //机头1 缝纫数据 和原数据一致 + } + else + { + unsigned short int* row = (unsigned short int*)&m_headDispDate[index].headtable; // 取到结构体的初始地址 + unsigned short int space = *(row + j); //向后偏移得到具体大小 + space = (space*10)/m_factor; //从实际距离转换为像素 + painter.drawLine(bx+space, by, ex+space, ey); //不是机头1的画线时需要偏移 + } + } + else{ + painter.drawLine(bx, by, ex, ey); + } + + } +} + + + diff --git a/datafile/embdata.h b/datafile/embdata.h new file mode 100644 index 0000000..c2c1a65 --- /dev/null +++ b/datafile/embdata.h @@ -0,0 +1,202 @@ +#ifndef EMBDATA_H +#define EMBDATA_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "machine/comm/datadef.h" +#include "machine/comm/crc16.h" +#include +#include "datafile/datafiledsr.h" + +#define ZERO 1e-6 + +#define MAX_EMB_STEP 121//四字节针步最大针步限制 +#define DEFAULT_JUMP 70//默认针步大小 +#define SEW_NEEDLE_NUM 2 //缝纫2个针杆 +#define COLORTABLE_NUM 512//色序表 + +#define EMB_PREVIEW_SIDE (32) // 留边大小 +#define TENTHOUSANDNEEDLE 100000 + +#define EMB_SHOWDIRX (1) // X向显示坐标和数据坐标的差异 +#define EMB_SHOWDIRY (1) // Y向显示坐标和数据坐标的差异 +#define OUTLINESTEPFACTOR 100 // 生成轮廓花样针步乘以的系数,单位是0.01,所以乘以100 + +#define PI10000 31416 +#define PI20000 62832 +#define ANGLECORR 10466 //60度对应的弧度值 + +#define MODE_THICKEN 0 //密针方式 +#define MODE_LOCK 1 //锁针方式 + +class EmbData: public QObject +{ + Q_OBJECT + +public: + EmbData(); + ~EmbData(); + +public: + void clear(); + QByteArray & getDsDat();//得到转换后的ds16数据 + inline DataDs16FileHead * getDsDatHead(){return m_pEmbDs16Head;}//得到转换后的ds16数据的文件头 + void setDsDatHeadFileID(u32 fileid);//设置数据区文件头的fileid + void getAbsDatRangeXY();//得到绝对坐标的maxXY和minXY + void appendAEmbAbsFile(QString filePath,QByteArray array,int mirror = 0);//附加一个绝对坐标的花样文件 + int addLockStitchs(u8 mode, u8 needles, u8 num); + int angleCorrection(s16 oft);//角度修正 + int angleCorrectionXY(s32 px, s32 nx, s32 py, s32 ny);//角度修正 + void reFitByStep(s32 stepLen);//按固定针步重新拟合(用户可设置的参数,暂未用到) + void reFitLine(s32 stepLen);//按固定针步重新拟合直线(用户可设置的参数) + int moveStartPoint(short left, short front);//移动起始点,左边,前边 + +public: + inline QString getFileName(){return m_pEmbDs16Head->fileName;}//得到花版名称 + inline int getStitchNums(){return m_pEmbDs16Head->itemNums;}//得到数据的针数 + inline int getDatWidth(){return m_pEmbDs16Head->maxX - m_pEmbDs16Head->minX;}//得到数据的图形宽度 + inline int getDatHeight(){return m_pEmbDs16Head->maxY - m_pEmbDs16Head->minY;}//得到数据的图形高度 + inline int getMaxX(){return m_pEmbDs16Head->maxX;}//得到数据最大X+ + inline int getMinX(){return m_pEmbDs16Head->minX;}//得到数据最小X- + inline int getMaxY(){return m_pEmbDs16Head->maxY;}//得到数据最大Y+ + inline int getMinY(){return m_pEmbDs16Head->minY;}//得到数据最小Y- + inline int getBeginX(){return m_pEmbDs16Head->beginX;} + inline int getBeginY(){return m_pEmbDs16Head->beginY;} + inline int getAnchorX(){return m_pEmbDs16Head->anchorX;}//得到数据定位点 + inline int getAnchorY(){return m_pEmbDs16Head->anchorY;}//得到数据定位点 + +public: + void moveDataBeginPonit(s32 left, s32 front); + void setAbsDat(QByteArray & dat); + QByteArray & getAbsDat(void); + int getPosInfoFromNeedleIdx(int stitchIdx, int & posx, int & posy, int & colorIdx); + void setStartPosition(int x, int y);//设置起始点 + void setAnchorPosition(int x, int y);//设置定位点 + +public: + double getAngle(double x1, double y1, double x2, double y2); + int setDatSizeChange(int dsx, int dsy);//设置尺寸变化 + int setMirror(int mirror);//设置镜像 + int setFLip(int mirror);//设置镜像 + int setRotate(int dr);//设置旋转 + int setRotate90(bool flag);//旋转+-90度 flag :true代表顺时针方向 + int getNextElementIndex(int curIndex);//获得下一个图元的第一缝纫针步 + int getPreOrThisElementIndex(int curIndex);//上一个图元(当前为跨步时)或当前图元(当前为缝纫时)的第一缝纫针步 + +private: + void splitBorderStitchAndAdd(QByteArray & dat,int bx,int by,int ex,int ey);//分割边框针步并添加 + //此函数转换传入的绝对坐标值,是否取镜像及反复时数据之间的间距 + void convertAbsDat(QByteArray & dat,int mirror = 0); + int calcLine(double x0, double y0, double x1, double y1, s16 step, QByteArray &absAry, DsAbsItem item); + + int createEmbDs16FromAbs();//生成DS16数据 + int reCalcDataChecksum();//重新计算文件CRC + void drawNeedleIdxPen(int x, int y, QPainter &painter);//绘制针数索引的跟踪笔 + void drawFork(int x, int y, QPainter &painter);//绘制针数索引的十字 + void drawFork(int x, int y, QPainter &painter,int index, bool isDraw = 1);//绘制针数索引的十字 + void eraseNeedleIdxPen(QPainter &painter);//擦除针数索引的跟踪笔 + void eraseNeedleIdxPen(QPainter &painter,int index);//擦除针数索引的跟踪笔 + +private: + void getCurvePointFillLine(QList &inList, double indRunLen,QList &outList); + int getTotalDistanceFillLine(QList *pPointList, double &dTotal); + bool getPointInSectFillLine(const DsAbsItem &p1, const DsAbsItem &p2, const double &d, DsAbsItem &outp); + //距p1点距离为d的点 + // d > s : out_p在p2延长线上 + // s >= d >= 0 : out_p在p1、p2线段上 + // d < 0 : out_p在p1延长线上 + bool getPointAtSect(const DsAbsItem &p1, const DsAbsItem &p2, const double &d, DsAbsItem &outp); + +public: + int m_editedflag;//数据被编辑的标志 + int m_spaceX;//横向间隙 + int m_spaceY;//纵向移动距离 + +//用于调节颜色 +#if(1) + QString m_selfilename; +#endif + + double m_minX; + double m_maxX; + double m_minY; + double m_maxY; + +private: + QByteArray m_embAbsData; // 转换后的绝对坐标数据 + QByteArray m_embDs16Data;//发给下位机的ds16数据(需要转换) + int m_totalJumpNeedle;//总跳针数 + DataDs16FileHead * m_pEmbDs16Head;//ds16 文件头 //数据转换用的都是DataDs16FileHead + double m_factor;//绘制数据与实际数据的缩放率 + u32 m_fileid; + +//图形预览、刷新 +public: + //显示所有线迹(原色显示) + //显示所有线迹(有效区域内的显示原色,其余显示灰色) + //显示所有线迹(执行过的显示原色,其余显示灰色) + //刷新部分线迹(缝纫中进度显示) + enum DISP_MODE {DISP_ALL_NORMAL = 0, DISP_ALL_AREA, DISP_ALL_EXEC, DISP_EXECING}; + enum DRAW_MODE {DRAW_VIEW = 0, DRAW_PREVIEW};//绘制模式(非预览模式、预览模式) + +public: + int setViewInfo(int width, int height);//设置视图尺寸(透明背景) + void setViewInfo(QPixmap pix);//设置视图(带背景图片背景) + void setEmbData(int type,int redraw = 0);//重置数据 + //是否重绘 //是否为渐变 + void setDispMode(DISP_MODE dispmode = DISP_ALL_NORMAL, int redraw = 0);//设置预览模式 + void setDrawMode(DRAW_MODE drawmode = DRAW_VIEW);//设置绘制模式 + + void setExecIndex(int index);//设置进度显示数据 + void reDraw();//重新绘图 + +public: + inline QPixmap getPreviewImage(){return m_canvas;}//返回预览图片 + +private: + int createDispFromEmbDs16Dat(QByteArray & ds16dat);//创建显示用的数据(为了快速显示) + int createDispFromEmbDs16DatForHeadInfo(QByteArray & ds16dat); + int drawImageByDispFile();//用显示数据画图(是否渐变显示) + int drawImageByOneStepLotLine(); + int findMaxSpHead(DsrHeadEx62 & head,int headCount); + void drawMultiTrack(QPainter &painter); //绘制多机头的跟踪图案 + void drawMultiLine(QPainter &painter, QPen &pen, QRgb rgb, int index); //绘制多机头的线迹 + +private: + int m_type; //机型 + int m_penX, m_penY;//执行过程中绘制跟踪笔的坐标索引 + + QPixmap m_canvas;//预览图片 + QPixmap m_penPix;//跟踪笔绘制的临时区域 + QVector m_penHeadPix; + QVector m_penPoint; + + int m_viewWidth; + int m_viewHight; + + QString m_filePath;//文件路径 + +private: + QByteArray m_dispDat;//绘制图形的绝对数据(进行缩放的) + QVector m_headDispDate; //五头机绘图针步 + int m_stitchIndex; //进度步数 + int m_dispIndex; //当前index + DISP_MODE m_dispMode; + DRAW_MODE m_drawMode; + +signals: + void siDrawNeedleIdx(int idx); + +}; + +#endif // EMBDATA_H diff --git a/datafile/hpgl/importhpgl.cpp b/datafile/hpgl/importhpgl.cpp new file mode 100644 index 0000000..3d64745 --- /dev/null +++ b/datafile/hpgl/importhpgl.cpp @@ -0,0 +1,2401 @@ +#include "importhpgl.h" +#include +#include +#include +#include "vectorfont.h" + +ImportHPGL::ImportHPGL(QObject *parent) : + QObject(parent) +{ + m_iDPMM = 40; + m_iPenNo = 1; + m_ptCurrentPos = QPoint(0,0); + m_lineType.bDefault = true; + m_bPenUp = true; + + m_pMarker = new Marker(); + m_dScale = (double)1.0; + + m_chTerminator = 3; + m_nTerminatorMode = 1; + + m_listXY.clear(); + + m_penPen.setColor(QColor(0,0,0)); + m_cutPen.setColor(QColor(0,255,0)); + m_halfCutPen.setColor(QColor(0,0,255)); + + m_dTextHeight = 0.375 * 10 * m_iDPMM;//字的高度 + m_dTextWidth = 0.285 * 10 * m_iDPMM;//字的宽度 + m_nLableOrigin = 1;//字符串相对于原点位置 + m_dTextAngle = 0;//指定每行文本输出时相对于设备x轴的角度,其单位为1/10度 + + m_dScaleX = 1; + m_dScaleY = 1; + m_ptOrigin = QPoint(0,0); + m_nLength = 0; + m_bPage = false; + m_bFontItalic = false; + m_iFontSize = 0; + m_strFontName = ""; + + m_pFileBuf = NULL; + + m_embAbsData.clear(); + m_maxX = S32_MIN; + m_maxY = S32_MIN; + m_minY = S32_MAX; + m_minX = S32_MAX; + m_stepCtrl = DATA_SEWING; +} + +ImportHPGL::~ImportHPGL() +{ + if(m_pMarker != NULL) + { + delete m_pMarker; + m_pMarker = NULL; + } + + if (m_pFileBuf != NULL) + { + delete []m_pFileBuf; + m_pFileBuf = NULL; + } +} + +int ImportHPGL::GetQRVesion(int nCount) +{ + int nVesion = 1; + + if (nCount < 17) + { + nVesion = 1; + } + else if ((nCount >= 17) && (nCount < 32)) + { + nVesion = 2; + } + else if ((nCount >= 32) && (nCount < 53)) + { + nVesion = 3; + } + else if ((nCount >= 53) && (nCount < 78)) + { + nVesion = 4; + } + else if ((nCount >= 78) && (nCount < 106)) + { + nVesion = 5; + } + else if ((nCount >= 106) && (nCount < 134)) + { + nVesion = 6; + } + else if ((nCount >= 134) && (nCount < 154)) + { + nVesion = 7; + } + else if ((nCount >= 154) && (nCount < 192)) + { + nVesion = 8; + } + else if ((nCount >= 192) && (nCount < 230)) + { + nVesion = 9; + } + else if ((nCount >= 230) && (nCount < 271)) + { + nVesion = 10; + } + else + { + nVesion = 40; + } + return nVesion; +} + +void ImportHPGL::PointRotate(QPoint &ptPoint, QPoint ptPointO, double dSinBeta, double dCosBeta) +{ + int tx = ptPoint.x() - ptPointO.x(); + int ty = ptPoint.y() - ptPointO.y(); + + int nx = tx*dCosBeta - ty*dSinBeta; + int ny = tx*dSinBeta + ty*dCosBeta; + + ptPoint.setX(nx); + ptPoint.setY(ny); +} + +void ImportHPGL::IniPara() +{ + m_fileFullPathName.clear(); + m_iPenNo = 1; + m_ptCurrentPos = QPoint(0,0); + m_lineType.bDefault = true; + m_bPenUp = true; + + m_pMarker->Initialize(); + m_dScale=(double)1.0; + + m_chTerminator = 3; + m_nTerminatorMode = 1; + + m_listXY.clear(); + + m_dTextHeight = 0.375 * 10 * m_iDPMM;//字的高度 + m_dTextWidth = 0.285 * 10 * m_iDPMM;//字的宽度 + m_nLableOrigin = 1;//字符串相对于原点位置 + m_dTextAngle = 0;//指定每行文本输出时相对于设备x轴的角度,其单位为1/10度 + + m_dScaleX = 1; + m_dScaleY = 1; + m_ptOrigin = QPoint(0,0); + m_nLength = 0; + m_bPage = false; + m_lineType.bDefault = true; +} + +bool ImportHPGL::Read(QString strPathName) +{ + m_fileFullPathName = strPathName; + QFile file(strPathName); + char c; + bool bOk; + + if(!file.open(QIODevice::ReadOnly)) + { + qDebug() <<"file open failed"; + return false; + } + + m_dScale=(double)m_pMarker->m_iDPMM / m_iDPMM; + m_listXY.clear(); + m_nFileLength = file.size(); + m_pFileBuf = new char[m_nFileLength]; + file.read(m_pFileBuf,m_nFileLength); + file.close(); + m_nCharCount = 0; + bOk=GetChar(&c); + while (bOk && m_nCharCount < m_nFileLength) + { + switch (c) + { + case 'S': //S命令 + case 's': + bOk=S_Code(); + break; + case 'I': //I命令 + case 'i': + bOk=I_Code(); + break; + case 'P': //P命令 + case 'p': + bOk=P_Code(); + break; + case 'L': //L命令 + case 'l': + bOk=L_Code(); + break; + case 'D': + case 'd': + bOk=D_Code(); + break; + case 'C': + case 'c': + bOk=C_Code(); + break; + case ';': + case ' ': + case 0x0A: + case 0x0D: + break; + default: + bOk = MoveToNextEnglishChar(); + break; + } + + if (bOk) + { + bOk=GetChar(&c); + if (m_nCharCount == m_nFileLength) bOk=true; + } + } + + AddPolylineToMarker(); + + if (m_pFileBuf != NULL) + { + delete []m_pFileBuf; + m_pFileBuf = NULL; + } + + return bOk; +} + +#if(0) +void ImportHPGL::creatPolylinePainterPath() +{ + if(m_pMarker == NULL){return;} + + QPainterPath painterPath; + QRect rect = m_pMarker->GetRect(); + int minX = rect.left(); + int minY = rect.top(); + int maxY = rect.bottom(); + + int nLineCount = m_pMarker->m_listPolyline.size(); + // m_polyTextPath = QPainterPath(); + for(int i = 0; i < nLineCount; i++) + { + CRPPolyline polyLine = m_pMarker->m_listPolyline.at(i); + int type = polyLine.m_nDrawingType; + // if(polyLine.m_nDrawingType == 3)//文字 + // { + // CRPText text = polyLine.m_text; + // } + + int nPointCount = polyLine.m_listPoint.size(); + for(int j = 0; j < nPointCount; j++) + { + double x = (polyLine.m_listPoint.at(j).x() - minX)/(double)M_IDPMM*MMPIXELY; + double y = ((0 - (polyLine.m_listPoint.at(j).y() - minY))+(maxY-minY))/(double)M_IDPMM*MMPIXELY; + QPointF point(x,y); + + if(j == 0) + { + painterPath.moveTo(point); + } + else + { + painterPath.lineTo(point); + } + } + } + + m_polylinePainterPath = painterPath; +} +#endif + +//读取一个非空格、非回车、非换行的字符 +//输入参数: +// pFile 切割数据文件 +//输出参数: +// *pChar 读取的字符 +// bEndOfFile =true 已到文件尾 +//返回值: +// true 成功取得一个字符 +// false 失败 +bool ImportHPGL::GetChar(char *pChar) +{ + char c; + uint nCount; + bool bOk; + bOk=true; + + nCount = ReadChar(&c); + while ((nCount == 1) && ((c == ' ') || (c == 0x0A) || (c == 0x0D))) + { + nCount = ReadChar(&c); + } + + if (bOk && (nCount == 0)) + { + bOk=false; + } + + if (nCount == 1) + { + *pChar=c; + bOk=true; + } + + return bOk; +} + +uint ImportHPGL::ReadChar(char* lpBuf) +{ + uint nCount = 1; + + if (m_nCharCount < m_nFileLength) + { + *lpBuf = m_pFileBuf[m_nCharCount]; + m_nCharCount = m_nCharCount + 1; + nCount = 1; + } + else + { + nCount = 0; + } + + return nCount; +} + +//判断下一个非空格、非回车、非换行的字符是不是',' +//输入参数: +// pFile 切割数据文件 +//输出参数: +// bEndOfFile =true 已到文件尾 +//返回值: +// true 下一个非空格、非回车、非换行的字符是',', 并且已将','从文件中读出 +// false 下一个非空格、非回车、非换行的字符不是',', 并且该字符没有从文件中读出 +bool ImportHPGL::NextCharIsComma() +{ + char cCh1; + bool bNextCharIsStart; + + bNextCharIsStart=false; + + if (GetChar(&cCh1)) + { + if (cCh1 == ',') + { + bNextCharIsStart=true; + } + else + { + m_nCharCount = m_nCharCount - 1; + } + } + + return bNextCharIsStart; +} + +//取一个整数 +//输入参数: +// pFile 切割数据文件 +//输出参数: +// iValue 取得的整数 +// bEndOfFile =true 已到文件尾 +//返回值: +// true 成功取得一个整数iValue +// false 失败 +bool ImportHPGL::GetIntegerData(int &iValue) +{ + QString string1; + char c; + bool bOk,bNum; + + bNum=false; + + bOk=GetChar(&c); + if (bOk && (c == '-')) + { + string1=string1 + c; + bOk=GetChar(&c); + } + while (bOk) + { + if (('0' <= c) && (c <= '9')) + { + string1=string1 + c; + bNum=true; + } + else + { + m_nCharCount = m_nCharCount - 1; + break; + } + + bOk=GetChar(&c); + } + + if (!bOk) + { + if (m_nCharCount == m_nFileLength) + bOk=true; + } + if (!bNum) + bOk=false; + + if (bOk) + iValue=string1.toInt(); + + return bOk; +} + +//取一个双精度浮点数 +//输入参数: +// pFile 切割数据文件 +//输出参数: +// dValue 取得的双精度浮点数 +// bEndOfFile =true 已到文件尾 +//返回值: +// true 成功取得一个双精度浮点数dValue +// false 失败 +bool ImportHPGL::GetDoubleData(double &dValue) +{ + QString string1; + char c; + bool bOk,bNum; + + bNum=false; + + bOk=GetChar(&c); + if (bOk && (c == '-')) + { + string1=string1 + c; + bOk=GetChar(&c); + } + while (bOk) + { + if ((('0' <= c) && (c <= '9')) || c == '.') + { + string1=string1 + c; + bNum=true; + } + else + { + m_nCharCount = m_nCharCount - 1; + break; + } + + bOk=GetChar(&c); + } + + if (!bOk) + { + if (m_nCharCount == m_nFileLength) + bOk=true; + } + + if (!bNum) + bOk=false; + + if (bOk) + dValue=string1.toDouble(); + + return bOk; +} + +//取坐标值 +//输入参数: +// pFile 切割数据文件 +//输出参数: +// ptPoint 坐标 +// bEndOfFile =true 已到文件尾 +//返回值: +// true 成功 +// false 失败 +bool ImportHPGL::GetCoordinate(QPoint &ptPoint) +{ + bool bOk; + int iX,iY; + double x,y; + QString strInfo; + + ptPoint=m_ptCurrentPos; + //bOk=GetIntegerData(x); + bOk=GetDoubleData(x);//为了兼容Gemini文件,Gemini坐标不是整数,是小数 + if (bOk) + { + iX=(double)(x+m_nLength) * m_dScale * m_dScaleX; + ptPoint.setX(iX); + } + + if (bOk) + { + bOk=SearchChar(',' ,strInfo); + if (bOk) + { + //bOk=GetIntegerData(y); + bOk=GetDoubleData(y);//为了兼容Gemini文件,Gemini坐标不是整数,是小数 + if (bOk) + { + iY=(double)y * m_dScale * m_dScaleY; + ptPoint.setY(iY); + } + + } + } + + return bOk; +} + +//获得线的类型 +//输入参数: +// pFile 切割数据文件 +//输出参数: +// lineType 线型 +// bEndOfFile =true 已到文件尾 +//返回值: +// true 成功 +// false 失败 +bool ImportHPGL::GetLineType(LineType &lineType) +{ + bool bOk; + int nLineType, nPatternLength, nMode; + QString strInfo; + lineType = m_lineType; + bOk=GetIntegerData(nLineType); + if (bOk) + { + lineType.bDefault = false; + lineType.nLinetype = nLineType; + bOk=SearchChar( ',' ,strInfo); + if (bOk) + { + bOk=GetIntegerData(nPatternLength); + if (bOk) + { + lineType.nPatternLength = nPatternLength; + } + + bOk=SearchChar( ';' ,strInfo); + if (bOk) + { + bOk=GetIntegerData(nMode); + if (bOk) + { + lineType.nMode = nMode; + } + } + else + { + lineType.nMode = 0; + } + } + else + { + lineType.nPatternLength = 4; + } + } + else + { + lineType.bDefault = true; + } + + return bOk; +} + +//查找一个指定的字符 +//输入参数: +// pFile 切割数据文件 +// cFind 指定的字符 +//输出参数: +// bEndOfFile =true 已到文件尾 +// strInfo 从开始位置到指定字符之前的内容(不包括最后的指定字符) +//返回值: +// true 成功取得一个字符 +// false 失败 +bool ImportHPGL::SearchChar(char cFind,QString &strInfo) +{ + char c; + uint nCount; + bool bOk; + + bOk=true; + strInfo.clear(); + + + nCount = ReadChar(&c); + while ((nCount == 1) && (c != cFind)) + { + strInfo = strInfo + c; + nCount = ReadChar(&c); + } + + + if (bOk && (nCount == 0)) + { + bOk=false; + } + + if (nCount == 1) + { + bOk=true; + } + + return bOk; +} + +//将文件的读取位置移到下一个英文字母(26个英文字母) +//输入参数: +// pFile 切割数据文件 +//输出参数: +// bEndOfFile =true 已到文件尾 +//返回值: +// true 成功将文件的读取位置移到下一个英文字母 +// false 失败 +bool ImportHPGL::MoveToNextEnglishChar() +{ + char c; + uint nCount; + bool bOk, bFind; + + bOk=true; + + bFind = false; + nCount = ReadChar(&c); + while ((nCount == 1) && (!bFind)) + { + if ((('A' <= c) && (c <= 'Z')) || (('a' <= c) && (c <= 'z'))) + { + m_nCharCount = m_nCharCount - 1; + bFind = true; + } + else + { + nCount = ReadChar(&c); + } + } + + return bOk; +} + +//将m_listXY加入到m_pMarker中,并将m_listXY清空 +void ImportHPGL::AddPolylineToMarker() +{ + //长度<0.2mm为钻孔 + CRPPolyline RPPolyline1; + QPoint pt1,pt2; + CDrill drill; + bool bIsdirll = false; + + if (m_listXY.size() >= 2) + { + if (m_listXY.size() == 2 && m_iPenNo == 3) + { + pt1 = m_listXY.at(0); + pt2 = m_listXY.at(1); + if (((pt1.x() - pt2.x())*(pt1.x() - pt2.x())+(pt1.y() - pt2.y())*(pt1.y() - pt2.y()))<=64) + { + bIsdirll = true; + } + } + if (bIsdirll) + { + drill.m_pt = pt1; + drill.m_nDrillType = 0; + drill.m_nAngle = 0; + RPPolyline1.m_nDrawingType = 5; + RPPolyline1.m_drill = drill; + RPPolyline1.m_nPenNo = drill.m_nDrillType; + } + else + { + RPPolyline1.m_nPenNo = m_iPenNo; + RPPolyline1.m_bPgEnd = m_bPage; + RPPolyline1.m_lineType = m_lineType; + RPPolyline1.m_listPoint.clear(); + RPPolyline1.m_listPoint.append(m_listXY); + } + m_pMarker->m_listPolyline.append(RPPolyline1); + } + else + { + if (m_iPenNo == 20 && m_listXY.size() > 0) + { + drill.m_pt = m_listXY.at(0); + drill.m_nDrillType = 0; + drill.m_nAngle = 0; + RPPolyline1.m_nDrawingType = 5; + RPPolyline1.m_drill = drill; + RPPolyline1.m_nPenNo = drill.m_nDrillType; + m_pMarker->m_listPolyline.append(RPPolyline1); + } + } + m_listXY.clear(); +} + +void ImportHPGL::AddPoint2listXY(QPoint ptPoint) +{ + if ((m_listXY.size() == 0) && (m_ptCurrentPos != ptPoint)) + { + m_listXY.append(m_ptCurrentPos); + } + + m_listXY.append(ptPoint); +} + +void ImportHPGL::AddTextPointToLine(bool bUp,QPoint ptPoint) +{ + if (bUp) + { + AddPolylineToMarker(); + m_ptCurrentPos = ptPoint; + m_bPenUp = true; + } + else + { + AddPoint2listXY(ptPoint); + m_ptCurrentPos = ptPoint; + m_bPenUp = false; + } +} + +QPoint ImportHPGL::GetTextOrigin(QPoint pt,QString strText) +{ + int nLen; + double dTextAngle; + double dLength; + int iX; + int iY; + nLen = strText.size(); + dTextAngle = m_dTextAngle/180.0*PI ; + switch(m_nLableOrigin) + { + case 1: + iX=pt.x()-(m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()+(m_dTextHeight)*qCos(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 2: + iX=pt.x()-(0.5*m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()+(0.5*m_dTextHeight)*qCos(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 4: + iX=pt.x()-(m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()+(m_dTextHeight)*qCos(dTextAngle); + iX=iX-(0.5*nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(0.5*nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 5: + iX=pt.x()-(0.5*m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()+(0.5*m_dTextHeight)*qCos(dTextAngle); + iX=iX-(0.5*nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(0.5*nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 6: + iX=pt.x()-(0.5*nLen*m_dTextWidth)*qCos(dTextAngle); + iY=pt.y()-(0.5*nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 7: + iX=pt.x()-(m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()+(m_dTextHeight)*qCos(dTextAngle); + iX=iX-(nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 8: + iX=pt.x()-(0.5*m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()+(0.5*m_dTextHeight)*qCos(dTextAngle); + iX=iX-(nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 9: + iX=pt.x()-(nLen*m_dTextWidth)*qCos(dTextAngle); + iY=pt.y()-(nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 11: + dTextAngle=qAtan2(0.25*m_dTextHeight,0.25*m_dTextWidth)+m_dTextAngle; + dTextAngle=dTextAngle/180.0*PI ; + dLength=qSqrt((0.25*m_dTextHeight)*(0.25*m_dTextHeight)+(0.25*m_dTextWidth)*(0.25*m_dTextWidth)); + iX=pt.x()+dLength*qCos(dTextAngle); + iY=pt.y()+dLength*qSin(dTextAngle); + dTextAngle=m_dTextAngle/180.0*PI; + iX=iX-(m_dTextHeight)*qSin(dTextAngle); + iY=iY+(m_dTextHeight)*qCos(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 12: + iX=pt.x()+(0.25*m_dTextWidth)*qCos(dTextAngle); + iY=pt.y()+(0.25*m_dTextWidth)*qSin(dTextAngle); + iX=iX-(0.5*m_dTextHeight)*qSin(dTextAngle); + iY=iY+(0.5*m_dTextHeight)*qCos(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 13: + dTextAngle=qAtan2(0.25*m_dTextHeight,0.25*m_dTextWidth)-m_dTextAngle; + dTextAngle=dTextAngle/180.0*PI; + dLength=qSqrt((0.25*m_dTextHeight)*(0.25*m_dTextHeight)+(0.25*m_dTextWidth)*(0.25*m_dTextWidth)); + iX=pt.x()+dLength*qCos(dTextAngle); + iY=pt.y()-dLength*qSin(dTextAngle); + dTextAngle=m_dTextAngle/180.0*PI; + pt.setX(iX); + pt.setY(iY); + break; + case 14: + iX=pt.x()-(1.25*m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()+(1.25*m_dTextHeight)*qCos(dTextAngle); + iX=iX-(0.5*nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(0.5*nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 15: + iX=pt.x()-(0.5*m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()+(0.5*m_dTextHeight)*qCos(dTextAngle); + iX=iX-(0.5*nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(0.5*nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 16: + iX=pt.x()+(0.25*m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()-(0.25*m_dTextHeight)*qCos(dTextAngle); + iX=iX-(0.5*nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(0.5*nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 17: + dTextAngle=qAtan2(0.25*m_dTextHeight,0.25*m_dTextWidth)-m_dTextAngle; + dTextAngle=dTextAngle/180.0*PI; + dLength=qSqrt((0.25*m_dTextHeight)*(0.25*m_dTextHeight)+(0.25*m_dTextWidth)*(0.25*m_dTextWidth)); + iX=pt.x()-dLength*qCos(dTextAngle); + iY=pt.y()+dLength*qSin(dTextAngle); + dTextAngle=m_dTextAngle/180.0*PI; + iX=iX-(m_dTextHeight)*qSin(dTextAngle); + iY=iY+(m_dTextHeight)*qCos(dTextAngle); + iX=iX-(nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 18: + iX=pt.x()-(0.25*m_dTextWidth)*qCos(dTextAngle); + iY=pt.y()-(0.25*m_dTextWidth)*qSin(dTextAngle); + iX=iX-(0.5*m_dTextHeight)*qSin(dTextAngle); + iY=pt.y()+(0.5*m_dTextHeight)*qCos(dTextAngle); + iX=iX-(nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + case 19: + dTextAngle=qAtan2(0.25*m_dTextHeight,0.25*m_dTextWidth)+m_dTextAngle; + dTextAngle=dTextAngle/180.0*PI; + dLength=sqrt((0.25*m_dTextHeight)*(0.25*m_dTextHeight)+(0.25*m_dTextWidth)*(0.25*m_dTextWidth)); + iX=pt.x()-dLength*qCos(dTextAngle); + iY=pt.y()-dLength*qSin(dTextAngle); + dTextAngle=m_dTextAngle/180.0*PI; + iX=iX-(nLen*m_dTextWidth)*qCos(dTextAngle); + iY=iY-(nLen*m_dTextWidth)*qSin(dTextAngle); + pt.setX(iX); + pt.setY(iY); + break; + } + return pt; +} + +double ImportHPGL::GetTextAngle(double dX,double dY) +{ + double dAngle = 0; + + if ((dX == 0) && (dY > 0)) + { + dAngle = 90; + } + else if ((dX == 0) && (dY < 0)) + { + dAngle = -90; + } + else if ((dX > 0) && (dY == 0)) + { + dAngle = 0; + } + else if ((dX < 0) && (dY == 0)) + { + dAngle = 180; + } + else if ((dX!=0) && (dY!=0)) + { + dAngle=qAtan2(dY,dX)*180/PI; + } + + double tmp = (dAngle - (int)dAngle); + if(qAbs((int)(tmp*10)) >= 5) + { + double angle = dAngle < 0 ? dAngle += -1 : dAngle+=1; + dAngle = angle; + } + dAngle = (int)dAngle; + + return dAngle; +} + +void ImportHPGL::SetScale() +{ + double dScaleX,dScaleY; + switch(m_sc.nType) + { + case 0://异步 + m_dScaleX=(double)(m_ptP2.x()-m_ptP1.x())/(m_sc.dXMax-m_sc.dXMin); + m_dScaleY=(double)(m_ptP2.y()-m_ptP1.y())/(m_sc.dYMax-m_sc.dYMin); + m_ptOrigin.setX(m_ptP1.x()-m_sc.dXMin*m_dScaleX); + m_ptOrigin.setY(m_ptP1.y()-m_sc.dYMin*m_dScaleY); + break; + case 1://同步 + dScaleX=(double)(m_ptP2.x()-m_ptP1.x())/(m_sc.dXMax-m_sc.dXMin); + dScaleY=(double)(m_ptP2.y()-m_ptP1.y())/(m_sc.dYMax-m_sc.dYMin); + if(dScaleX>dScaleY) //x>y + { + m_dScaleX=dScaleY; + m_dScaleY=dScaleY; + m_ptOrigin.setY(m_ptP1.y()); + m_ptOrigin.setX(((m_ptP2.x()-m_ptP1.x())-(m_sc.dXMax-m_sc.dXMin)*dScaleY)*m_sc.dLeft/100.0); + } + else //x= 22) + { + char cFileBuf[23]; + file.read(&cFileBuf[0],22); + if((cFileBuf[0] == 0x66) && (cFileBuf[1] == 0x53) &&(strncmp(&cFileBuf[3],"Richpeace plot file",19) == 0)) + { + file.close(); + return true; + } + else + { + file.close(); + return false; + } + } + return false; +} + +int ImportHPGL::BitMapDtat(QString strFileName, QString strSecretFile) +{ + int i,j,k,m,n,nRemainChar; + char cFileBuf[1025]; + char cSecretBuf[256]; + char errRe; + QFile file(strFileName); + int nLength; + BOOL bError = FALSE; + + m=j=0; + nRemainChar = 0; + errRe=0; + QFile hFile(strSecretFile); + + if (!hFile.open(QIODevice::WriteOnly|QIODevice::Truncate)) + { + return 0; + } + + if(!file.open(QIODevice::ReadOnly)) + { + return 0; + } + + nLength = file.size(); + file.read(&cFileBuf[0],22); + i = 22; + + for(;i 0) + { + n = 252 - nRemainChar + 2; + if (j > nRemainChar) + { + m = 254; + j -= nRemainChar; + i += nRemainChar; + } + else + { + m = n + j; + i += j; + j = 0; + } + if ((n < m) && ((nRemainChar & 0x01) != 0)) + { + nRemainChar -= (m - n); + cFileBuf[k++] = cSecretBuf[n++] ^ cSecretBuf[1]; + } + else + nRemainChar -= (m - n); + for (;n 0) + { + if (nLength == i) + { + break; + } + if ((nLength - i) < 256) + { + bError = TRUE; + errRe = 1; + break; + } + file.read(cSecretBuf,256); + i += 256; + cSecretBuf[0] ^= cSecretBuf[254]; + cSecretBuf[1] ^= cSecretBuf[255]; + cSecretBuf[0] ^= 0xac; + cSecretBuf[1] ^= 0xe3; + if (j < 252) + { + m = j + 2; + nRemainChar = 252 - j; + j = 0; + i -= nRemainChar; + } + else + { + m = 254; + j -= 252; + nRemainChar = 0; + } + if ((m & 0x01) != 0) + { + m--; + for (n=2;nm_iDPMM / 40; + m_listXY.clear(); + nSecretFileLength = file.size(); + pSecretFileBuf = new unsigned char[nSecretFileLength]; + if(pSecretFileBuf != NULL) + { + file.read((char*)pSecretFileBuf,nSecretFileLength); + } + file.close(); + + while (i < nSecretFileLength) + { + c = pSecretFileBuf[i++]; + switch (c) + { + case DEFCMD_IN://0x8a://IN + break; + case DEFCMD_PG://0x97://PG + m_nLength = m_pMarker->GetRect().right(); + break; + case DEFCMD_SP://0x7c: + { + AddPolylineToMarker(); + unsigned char cTemp; + cTemp = pSecretFileBuf[i++]; + m_iPenNo = cTemp; + } + break; + case DEFCMD_LT://0xe6: + { + c = pSecretFileBuf[i++]; + c ^= 0xce; + if (c != 0) + { + if (c == 1) + c = 3; + else if (c == 2) + c = 1; + else + c = 8; + } + } + break; + case DEFCMD_SI://0x5d: 字体宽×高 + { + cPin = (unsigned char *)&m_dTextWidth; + for(int nCount=7; nCount>=0; nCount--) + { + *(cPin+nCount) = pSecretFileBuf[i++]; + } + m_dTextWidth = m_dTextWidth * 10 * M_IDPMM; + + cPin = (unsigned char *)&m_dTextHeight; + for(int nCount=7; nCount>=0; nCount--) + { + *(cPin+nCount) = pSecretFileBuf[i++]; + } + m_dTextHeight = m_dTextHeight * 10 * M_IDPMM; + } + break; + case DEFCMD_LB://0x4d: + { + AddPolylineToMarker(); + cPin = (unsigned char *)&nParameter; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + + cPin = (unsigned char *)&pointx; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + m_ptCurrentPos.setX(pointx); + + cPin = (unsigned char *)&pointy; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + m_ptCurrentPos.setY(pointy); + + strTemp.clear(); + QByteArray tempArr; + tempArr.clear(); + for(int nCount=0; nCounttoUnicode(tempArr); + + m_ptCurrentPos = GetTextOrigin(m_ptCurrentPos,strTemp); + vectorFont.m_dFontHeight = m_dTextHeight; + vectorFont.m_dFontAngle = m_dTextAngle; + vectorFont.TextOutString(m_ptCurrentPos.x(),m_ptCurrentPos.y(),(const char*)strTemp.data(),strTemp.length()); + } + break; + case DEFCMD_DI://0x5B: + { + cPin = (unsigned char *)&m_dTextAngle; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + + m_bFontItalic = pSecretFileBuf[i++]; + + cPin = (unsigned char *)&m_iFontSize; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + } + break; + case DEFCMD_FN://0x4B: + { + m_strFontName = ""; + cPin = (unsigned char *)&iFontNameLenth; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + + for (int a = 0; a < iFontNameLenth; a++) + { + char chTemp = pSecretFileBuf[i++]; + m_strFontName = m_strFontName + chTemp; + } + } + break; + case DEFCMD_DRILL://0xD2:冲孔 + { + AddPolylineToMarker(); + cPin = (unsigned char *)&pointx; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + drill.m_pt.setX(pointx); + + cPin = (unsigned char *)&pointy; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + drill.m_pt.setY(pointy); + + cPin = (unsigned char *)&drill.m_nDrillType; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + + cPin = (unsigned char *)&drill.m_nAngle; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + + RPPolyline.m_nDrawingType = 5; + RPPolyline.m_drill = drill; + RPPolyline.m_nPenNo = drill.m_nDrillType; + m_pMarker->m_listPolyline.append(RPPolyline); + } + break; + case DEFCMD_NOTCH://0xD3:剪口 + { + AddPolylineToMarker(); + cPin = (unsigned char *)&pointx; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + notch.m_ptStart.setX(pointx); + + cPin = (unsigned char *)&pointy; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + notch.m_ptStart.setY(pointy); + + cPin = (unsigned char *)&pointx; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + notch.m_ptEnd.setX(pointx); + + cPin = (unsigned char *)&pointy; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + notch.m_ptEnd.setY(pointy); + + cPin = (unsigned char *)¬ch.m_nWidth; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + + cPin = (unsigned char *)¬ch.m_nNotchType; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + + notch.CovertToOutputByOffset(notchOffsetX,notchOffsetY); + RPPolyline.m_nDrawingType = 6; + RPPolyline.m_notch = notch; + RPPolyline.m_nPenNo = notchPenNO; + m_pMarker->m_listPolyline.append(RPPolyline); + } + break; + case DEFCMD_PU://0xb5: + case DEFCMD_LPU://0x5e: + { + AddPolylineToMarker(); + cPin = (unsigned char *)&pointx; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + ptPoint.setX(pointx); + + cPin = (unsigned char *)&pointy; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + ptPoint.setY(pointy); + + m_ptCurrentPos = ptPoint; + m_bPenUp = true; + } + break; + case DEFCMD_PD://0x3d: + case DEFCMD_LPD://0x3b: + { + cPin = (unsigned char *)&pointx; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + ptPoint.setX(pointx); + + cPin = (unsigned char *)&pointy; + *(cPin+3) = pSecretFileBuf[i++]; + *(cPin+2) = pSecretFileBuf[i++]; + *(cPin+1) = pSecretFileBuf[i++]; + *cPin = pSecretFileBuf[i++]; + ptPoint.setY(pointy); + + AddPoint2listXY(ptPoint); + m_ptCurrentPos = ptPoint; + } + break; + case DEFCMD_NULL://0x00:空指令 + AddPolylineToMarker(); + break; + default: + qDebug()<GetRect().right(); + //qDebug()<< "length:" << m_nLength; + //qDebug()<< "line count:" << m_pMarker->m_listPolyline.size(); + m_bPage = false; + break; + default: + bOk = MoveToNextEnglishChar(); + break; + } + } + + bOk=true; + return bOk; +} + +bool ImportHPGL::L_Code() +{ + char cCh1; + bool bOk; + QString strText; + VectorFont vectorFont; + connect(&vectorFont, SIGNAL(siLineTo(bool,QPoint)), this, SLOT(AddTextPointToLine(bool,QPoint))); + connect(&vectorFont, SIGNAL(siMoveTo(bool,QPoint)), this, SLOT(AddTextPointToLine(bool,QPoint))); + + CRPPolyline crppolylineTemp; + + bOk=GetChar(&cCh1); + if (bOk) + { + switch (cCh1) + { + case 'T': + case 't': + AddPolylineToMarker(); + GetLineType(m_lineType); + bOk = MoveToNextEnglishChar(); + break; + case 'B': + case 'b': + AddPolylineToMarker(); + bOk = SearchChar(m_chTerminator,strText); + m_ptCurrentPos = GetTextOrigin(m_ptCurrentPos,strText); + + crppolylineTemp.m_nDrawingType = 3; + crppolylineTemp.m_text.m_strText = strText; + crppolylineTemp.m_text.m_ptTextPos = m_ptCurrentPos; + crppolylineTemp.m_text.m_dTextAngle = m_dTextAngle; + crppolylineTemp.m_text.m_nHeight = m_dTextHeight; + crppolylineTemp.m_text.m_nWidth = m_dTextWidth; + crppolylineTemp.m_text.m_ptPostLU = m_ptCurrentPos; + crppolylineTemp.m_text.m_ptPostLD = QPoint(m_ptCurrentPos.x(),m_ptCurrentPos.y()+m_dTextHeight); + crppolylineTemp.m_text.m_ptPostRU = QPoint(m_ptCurrentPos.x()+m_dTextWidth*strText.length(),m_ptCurrentPos.y()); + crppolylineTemp.m_text.m_ptPostRD = QPoint(m_ptCurrentPos.x()+m_dTextWidth*strText.length(),m_ptCurrentPos.y()+m_dTextHeight); + + //用线段方法绘制 +#ifdef Q_OS_WIN + vectorFont.m_dFontHeight = m_dTextHeight; + vectorFont.m_dFontAngle = m_dTextAngle; + vectorFont.TextOutString(m_ptCurrentPos.x(),m_ptCurrentPos.y(),strText.toStdString().c_str(),strText.size()); +#endif + + //qDebug()<m_listPolyline.append(crppolylineTemp);//用文本方法绘制 + + break; + case 'O': + case 'o': + bOk=GetIntegerData(m_nLableOrigin); + break; + default: + bOk = MoveToNextEnglishChar(); + break; + } + } + + return bOk; +} + + +bool ImportHPGL::D_Code() +{ + char cCh1; + bool bOk; + QString strInfo; + + bOk=GetChar(&cCh1); + if (bOk) { + switch (cCh1) { + case 'F': + case 'f': + break; + case 'I': + case 'i': + double dX,dY; + + bOk = GetDoubleData(dX); + if (bOk) + { + bOk = SearchChar(',' ,strInfo); + bOk = GetDoubleData(dY); + } + else + { + dX = 1; + dY = 0; + } + m_dTextAngle = GetTextAngle(dX,dY); + bOk = MoveToNextEnglishChar(); + break; + case 'T': + case 't': + char chTerminator; + int nTerminatorMode; + bOk = GetChar(&chTerminator); + if (bOk) + { + m_chTerminator = chTerminator; + bOk = GetIntegerData(nTerminatorMode); + if (bOk) + { + m_nTerminatorMode = nTerminatorMode; + } + } + bOk = MoveToNextEnglishChar(); + break; + default: + bOk = MoveToNextEnglishChar(); + break; + } + } + + return bOk; +} + +bool ImportHPGL::Write(QString strPathName,Marker *pMarker) +{ + QFile *writeFile = new QFile(strPathName); + writeFile->open(QIODevice::ReadWrite | QFile::Truncate); + // 如果文件没有被占用可以打开 + // 创建stream + QTextStream txtOutput(writeFile); + + QString strHPGL = "IN;DF;SP0;PU0,0;"; + //int nLength = 0; + int i,j; + int iLineCount,iPointCount; + + QString strTemp; + int nOldPenNo = 0; + + bool bSetLT = false; + + iLineCount = pMarker->m_listPolyline.size(); + for (i = 0; i < iLineCount; i++) + { + CRPPolyline polyLine = pMarker->m_listPolyline.at(i); + + if (polyLine.m_lineType.bDefault == false) + { + bSetLT = true; + strTemp = QString("LT%1,%2,%3;").arg(polyLine.m_lineType.nLinetype).arg(polyLine.m_lineType.nPatternLength).arg(1); + } + else + { + if (bSetLT) + strTemp = "LT;"; + } + strHPGL = strHPGL + strTemp; + + if (polyLine.m_nDrawingType == 0) + { + iPointCount = polyLine.m_listPoint.size(); + //选择画笔 1为笔绘 3为半透切割 其它为切割 + if (nOldPenNo != polyLine.m_nPenNo) + { + if (polyLine.m_nPenNo == 1) + { + strTemp = QString("SP%1;").arg(polyLine.m_nPenNo); + nOldPenNo = polyLine.m_nPenNo; + } + else if (polyLine.m_nPenNo == 3) + { + strTemp = QString("SP%1;").arg(polyLine.m_nPenNo); + nOldPenNo = polyLine.m_nPenNo; + } + else + { + strTemp = QString("SP%1;").arg(polyLine.m_nPenNo); + nOldPenNo = polyLine.m_nPenNo; + } + strHPGL = strHPGL + strTemp; + } + + + for (j = 0; j < iPointCount; j++) + { + + QPoint pt = polyLine.m_listPoint.at(j); + + if (j == 0) + { + strTemp = QString("PU%1,%2;").arg(pt.x()).arg(pt.y()); + + } + else if(j == 1) + { + if (j + 1 == iPointCount) + { + strTemp = QString("PD%1,%2;").arg(pt.x()).arg(pt.y()); + + } + else + { + strTemp = QString("PD%1,%2,").arg(pt.x()).arg(pt.y()); + + } + } + else + { + if (j + 1 == iPointCount) + { + + strTemp = QString("%1,%2;").arg(pt.x()).arg(pt.y()); + } + else + { + strTemp = QString("%1,%2,").arg(pt.x()).arg(pt.y()); + + } + } + strHPGL = strHPGL + strTemp; + } + } + else if (polyLine.m_nDrawingType == 5) + { + strTemp = "SP20;"; + strHPGL = strHPGL + strTemp; + strTemp = QString("PU%1,%2;").arg(polyLine.m_drill.m_pt.x()).arg(polyLine.m_drill.m_pt.y()); + strHPGL = strHPGL + strTemp; + strTemp = QString("PD%1,%2;").arg(polyLine.m_drill.m_pt.x()).arg(polyLine.m_drill.m_pt.y()); + strHPGL = strHPGL + strTemp; + nOldPenNo = 20; + } + + // 在stream追加数据,并换行 + txtOutput << strHPGL << endl; + strHPGL = ""; + + } + strHPGL = strHPGL + "SP0;"; + //nLength = strHPGL.size(); + + // 在stream追加数据,并换行 + txtOutput << strHPGL << endl; + strHPGL = ""; + writeFile->close(); + return true; +} + +// 生成预览图 +int ImportHPGL::createPreviewImage(QImage *pImg, int saveflag, int penwidth, int reDraw) +{ +#if(1) + if(reDraw == 0)//图片存在则不重画 + { + // 图片是否存在,存在则返回 + QString previewPath = getFileFullPathName() + ".preview.png"; + QFile imageFile(previewPath); + if (imageFile.exists()) + { + return 0; + } + } +#endif + + int newimgflag = 0; + QImage * pImage; + int width, height; + if (pImg == NULL) + { + width = PLT_PREVIEW_WIDTH; + height = PLT_PREVIEW_HEIGHT; + pImage = new QImage(width, height, IMAGE_TYPE); + newimgflag = 1; + } + else + { + pImage = pImg; + } + + width = pImage->width(); + height = pImage->height(); + + if (width <= PLT_PREVIEW_SIDE*2 || height <= PLT_PREVIEW_SIDE*2) + { + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + qDebug("preview img too small"); + return -1; + } + + memset(pImage->bits(), 0x00, pImage->byteCount()); + + QPainter painter(pImage); + QColor backcolor(255, 255, 255, 0); // 透明背景 + + // 背景 + QPen pen; + pen.setWidth(penwidth); + pen.setColor(backcolor); + painter.setPen(pen); + painter.setBrush(backcolor); + painter.drawRect(0, 0, width, height); + + if(m_pMarker == NULL) + { + return -1; + } + + //得到XY边界值 + QRect rect = m_pMarker->GetRect(); + int minX = rect.left(); + int maxX = rect.right(); + int minY = rect.top(); + int maxY = rect.bottom(); + + // 图形显示区域 + int dpminx = PLT_PREVIEW_SIDE; + int dpmaxx = width - PLT_PREVIEW_SIDE; + int dpminy = PLT_PREVIEW_SIDE + PLT_PREVIEW_SIDE; + int dpmaxy = height - PLT_PREVIEW_SIDE; + + // 计算缩放系数 + double factor, temp; + factor = (double)(abs(maxX - minX)) / (dpmaxx - dpminx); // 按x计算的缩放系数 + temp = (double)(abs(maxY - minY)) / (dpmaxy - dpminy); // 按轮廓计算,最小能够放下重复次数个图形 + if (temp >= factor) // 使用较大的缩放系数 + { + factor = temp; + } + + // 计算显示参数,按照图形的实际位置显示(数据坐标零点对应图形中心) + int dpx = (int)((dpminx+dpmaxx)/2 - ((maxX+minX)/factor)/2); + int dpy = (int)((dpminy+dpmaxy)/2 - ((maxY+minY)/factor)/2); + + // 显示花样图形 + QColor sewcolor = QColor(Qt::green); + pen.setColor(sewcolor); + painter.setPen(pen); + + CBitmapInfo bitmapInfo; + QPainterPath painterPath; + + int nLineCount = m_pMarker->m_listPolyline.size(); + for(int i = 0; i < nLineCount; i++) + { + CRPPolyline polyLine = m_pMarker->m_listPolyline.at(i); + int type = polyLine.m_nDrawingType; + + if(type == 0)//直线 + { + int nPointCount = polyLine.m_listPoint.size(); + for(int j = 0; j < nPointCount; j++) + { + double x = polyLine.m_listPoint.at(j).x() / factor + dpx; + double y = polyLine.m_listPoint.at(j).y() / factor + dpy; + + if (PLT_SHOWDIRX == -1) + { + x = width - x; + } + if (PLT_SHOWDIRY == -1) + { + y = height - y; + } + + QPointF point(x,y); + + if(j == 0) + { + painterPath.moveTo(point); + } + else + { + painterPath.lineTo(point); + } + } + } + else if(type == 1)//位图 + { + bitmapInfo = polyLine.m_bitmapInfo; + int x = bitmapInfo.m_ptAbPostLU.x(); + int y = bitmapInfo.m_ptAbPostLU.y(); + + int nx = x / factor + dpx; + int ny = y / factor + dpy; + + if (PLT_SHOWDIRX == -1) + { + nx = width - nx; + } + if (PLT_SHOWDIRY == -1) + { + ny = height - ny; + } + + bitmapInfo.m_ptAbPostLU.setX(nx); + bitmapInfo.m_ptAbPostLU.setY(ny); + } + } + + painter.drawPath(painterPath); + if(bitmapInfo.m_iBytes > 0)//有位图 + { + painter.drawPixmap(bitmapInfo.m_ptAbPostLU.x(),bitmapInfo.m_ptAbPostLU.y(),bitmapInfo.m_pBitmap); + } + + // 保存成文件 + QString preview = getFileFullPathName(); + if (saveflag != 0 && preview.isEmpty() == false) + { +#if (1) + preview += ".preview.png"; + pImage->save(preview, "png"); +#endif + } + + if (pImage != NULL && newimgflag == 1) + { + delete pImage; + } + + return 0; +} + +//转换为中间绝对坐标数据 +void ImportHPGL::convertDataToEmbAbs() +{ + CBitmapInfo bitmapInfo; + m_embAbsData.clear(); + + //得到数据的第一个点 + int firstx, firsty, firstFlag; + firstx = firsty = firstFlag = 0; + int nLineCount = m_pMarker->m_listPolyline.size(); + for(int i = 0; i < nLineCount; i++) + { + if(firstFlag != 0) + { + break; + } + + CRPPolyline polyLine = m_pMarker->m_listPolyline.at(i); + int type = polyLine.m_nDrawingType; + + if(type == 0)//直线 + { + int nPointCount = polyLine.m_listPoint.size(); + for(int j = 0; j < nPointCount; j++) + { + firstx = polyLine.m_listPoint.at(j).x(); + firsty = polyLine.m_listPoint.at(j).y(); + firstFlag = 1; + break; + } + } + else if(type == 1)//位图 + { + bitmapInfo = polyLine.m_bitmapInfo; + firstx = bitmapInfo.m_ptAbPostLU.x(); + firsty = bitmapInfo.m_ptAbPostLU.y(); + firstFlag = 1; + } + } + + //转换为绝对坐标的中间数据 + QByteArray absData;//绝对坐标 + absData.clear(); + DsAbsItem absItem; + memset(&absItem,0,sizeof(DsAbsItem)); + absItem.ctrl = m_stepCtrl; + // 绝对坐标数据 + DataDs16FileHead dhead; + memset(&dhead, 0, sizeof(DataDs16FileHead)); + + double xfactor = (1.0 / (double)M_IDPMM) * PLT_EMB_DATADIRX * PLT_EMB_DATASCALE; + double yfactor = (1.0 / (double)M_IDPMM) * PLT_EMB_DATADIRY * PLT_EMB_DATASCALE; + + //得到XY边界值 + QRect rect = m_pMarker->GetRect(); + m_minX = (rect.left() - firstx) * xfactor; + m_maxX = (rect.right() - firstx) * xfactor; + m_minY = (rect.top() - firsty) * yfactor; + m_maxY = (rect.bottom() - firsty) * yfactor; + + double x,y; + x = y = 0; + int stepidx = 0; + double ddx, ddy, prex, prey, ar; + ddx = ddy = ar = 0; + //前一针初始值 + prex = (0 - firstx) * xfactor; + prey = (0 - firsty) * yfactor; + + for(int i = 0; i < nLineCount; i++) + { + CRPPolyline polyLine = m_pMarker->m_listPolyline.at(i); + int type = polyLine.m_nDrawingType; + + if(type == 0)//直线 + { + int nPointCount = polyLine.m_listPoint.size(); + for(int j = 0; j < nPointCount; j++) + { + x = (polyLine.m_listPoint.at(j).x() - firstx) * xfactor; + y = (polyLine.m_listPoint.at(j).y() - firsty) * yfactor; + + ddx = x - prex; + ddy = y - prey; + double tar = atan2(ddy,ddx); + ar = (tar * 10000+0.5*(tar>0?1:-1)); + + //图元之间的连接转换为偏移针步 + if(i != 0 && j == 0) + { + absItem.ctrl = DATA_OFFSET; + } + else + { + absItem.ctrl = m_stepCtrl; + } + + absItem.ax = x; + absItem.ay = y; + absItem.ar = ar; + prex = x; + prey = y; + + absData.append((char*)(&absItem), sizeof(DsAbsItem)); + stepidx++; + } + } + else if(type == 1)//位图 + { + bitmapInfo = polyLine.m_bitmapInfo; + x = (bitmapInfo.m_ptAbPostLU.x() - firstx) * xfactor; + y = (bitmapInfo.m_ptAbPostLU.y() - firsty) * yfactor; + + ddx = x - prex; + ddy = y - prey; + double tar = atan2(ddy,ddx); + ar = (tar * 10000+0.5*(tar>0?1:-1)); + + //图元之间的连接转换为偏移针步 + absItem.ctrl = DATA_OFFSET; + absItem.ax = x; + absItem.ay = y; + absItem.ar = ar; + prex = x; + prey = y; + + absData.append((char*)(&absItem), sizeof(DsAbsItem)); + stepidx++; + } + } + + //添加结束针步数据 + absItem.ctrl = 0; + absData.append((char*)(&absItem), sizeof(DsAbsItem)); + stepidx++; + + int newstepnum = stepidx; // 转换后的数据长度 + + // 文件头转换 + QString name = getFileFullPathName(); + int namelen = name.size(); + if (namelen > HEAD_NAME_STR_LEN) + { + namelen = HEAD_NAME_STR_LEN; + } + memcpy(dhead.fileName, name.data(), namelen); // 文件名称 + dhead.dataSize = newstepnum*sizeof(DsAbsItem); // 数据字节数 + dhead.itemNums = newstepnum; // 数据项个数 + dhead.bytesPerItem = sizeof(DsAbsItem); // 每项占的字节数 + dhead.bytesPerBlk = MAX_EXDP_LEN; // 数据内容划分块大小 + dhead.dataChecksum = calcCheckSum32((u8 *)(absData.data()) , absData.length()); // 数据累加校验和 + dhead.checkCrc = calcCrc16((u8 *)(&dhead), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + u32 fileID = 0; + fileID = calcCheckSum32((u8 *)(absData.data()) , absData.length()); // 原始数据累加校验和 + dhead.fileid = fileID; //中间数据的 fileid = + + dhead.anchorX = 0; // 定位点坐标X + dhead.anchorY = 0; // 定位点坐标Y + dhead.beginX = 0; // 数据起点坐标X + dhead.beginY = 0; // 数据起点坐标Y + dhead.beginR = 0; + dhead.minX = m_minX; + dhead.maxX = m_maxX; + dhead.minY = m_minY; + dhead.maxY = m_maxY; // 轮廓范围,使用重新计算之后的值 + + // 保存文件头到数组中 + m_embAbsData.append((char *)(&dhead), sizeof(DataDs16FileHead)); + + // 保存数据到数组中 + m_embAbsData.append(absData); +} + +void ImportHPGL::setStepCtrl(u8 ctrl) +{ + m_stepCtrl = ctrl; +} + +QByteArray ImportHPGL::getEmbAbsData() +{ + return m_embAbsData; +} + +#if(0) +QPainterPath ImportHPGL::GetPolylinePainterPath() +{ + return m_polylinePainterPath; +} +#endif + +#if(0) +int ImportHPGL::CreatePreviewImage(QString saveName,QImage *pImg, int saveflag) +{ + QImage * pImage = NULL; + int width, height; + width = height = 0; + + if (pImg == NULL) + { + width = (m_maxX - m_minX) / M_IDPMM + 2*PREVIEW_SIDE; + height = (m_maxY - m_minY) / M_IDPMM+ 2*PREVIEW_SIDE; + pImage = new QImage(width, height, QImage::Format_ARGB32); // + } + else + { + pImage = pImg; + } + + width = pImage->width(); + height = pImage->height(); + if (width < PREVIEW_SIDE*2 || height < PREVIEW_SIDE*2) + { + if (pImage != NULL) + { + delete pImage; + } + return -1; + } + + QPainter painter(pImage); + QColor backcolor(255, 255, 255, 255); + QColor pencolor(0, 0, 0, 255); + + // 背景 + QPen pen; + pen.setWidth(1); + pen.setColor(backcolor); + painter.setPen(pen); + painter.setBrush(backcolor); + painter.drawRect(0, 0, width, height); + + // 图形显示区域 + int dpminx = PREVIEW_SIDE; + int dpmaxx = width - PREVIEW_SIDE; + int dpminy = PREVIEW_SIDE; + int dpmaxy = height - PREVIEW_SIDE; + + // 计算缩放系数 + double factor, temp; + factor = (double)(abs(m_maxX - m_minX)) / (dpmaxx - dpminx); // 按x计算的缩放系数 + temp = (double)(abs(m_maxY - m_minY)) / (dpmaxy - dpminy); // 按轮廓计算,最小能够放下重复次数个图形 + if (temp >= factor) // 使用较大的缩放系数 + { + factor = temp; + } + + // 计算显示参数,按照图形的实际位置显示(数据坐标零点对应图形中心) + int dpx = (int)((dpminx+dpmaxx)/2 - ((m_maxX+m_minX)/factor)/2); + int dpy = (int)((dpminy+dpmaxy)/2 - ((m_maxY+m_minY)/factor)/2); + + int curx, cury, prex, prey; + curx = cury = prex = prey = 0; + + curx = dpx; + cury = (height) - dpy; + + pen.setColor(pencolor); + painter.setPen(pen); + + int nLineCount = m_pMarker->m_listPolyline.size(); + for(int i = 0; i < nLineCount; i++) + { + CRPPolyline polyLine = m_pMarker->m_listPolyline.at(i); + int nPointCount = polyLine.m_listPoint.size(); + for(int j = 0; j < nPointCount; j++) + { + prex = curx; + prey = cury; + + curx = polyLine.m_listPoint.at(j).x() / factor+ dpx; + cury = height - (polyLine.m_listPoint.at(j).y() / factor + dpy); + + if(j == 0) + { + continue; + } + + painter.drawLine(prex, prey, curx, cury); + } + } + + // 保存成文件 + if (saveflag != 0) + { + saveName += ".preview.bmp"; + pImage->save(saveName, "bmp"); + } + + if (pImage != NULL) + { + pImage = NULL; + delete pImage; + } + + return 0; +} +#endif diff --git a/datafile/hpgl/importhpgl.h b/datafile/hpgl/importhpgl.h new file mode 100644 index 0000000..f5192ae --- /dev/null +++ b/datafile/hpgl/importhpgl.h @@ -0,0 +1,294 @@ +#ifndef IMPORTHPGL_H +#define IMPORTHPGL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "marker.h" +#include "machine/comm/config.h" +#include "machine/comm/datadef.h" +#include "machine/comm/crc16.h" + +#define DEFCMD_IN 0x8A //IN +#define DEFCMD_SP 0x7C //SP +#define DEFCMD_LT 0xE6 //LT 0:PS_SOLID; 1:PS_DASH; 2:PS_DOT; 3:PS_DASHDOT +#define DEFCMD_PG 0x97 //PG +#define DEFCMD_PU 0xB5 //PU 单个PU +#define DEFCMD_PD 0x3D //PD 单个PD +#define DEFCMD_LPU 0x5E //PU 连续PU +#define DEFCMD_LPD 0x3B //PD 连续PD +#define DEFCMD_DI 0x5B //AG 角度 +#define DEFCMD_SI 0x5D //SI 64位双精度浮点 +#define DEFCMD_FN 0x4B //FN 字体名 +#define DEFCMD_LB 0x4D //LB +#define DEFCMD_BT 0x9A //BIT 位图 +#define DEFCMD_CODE 0xE7 //CODE 条形码、二维码 +#define DEFCMD_NULL 0x00 //NUll 空指令 +#define DEFCMD_DRILL 0xD2 //DRILL 冲孔 +#define DEFCMD_NOTCH 0xD3 //NOTCH 剪口 + +#define M_IDPMM 40.0 +#define MMPIXELY 7.936508 + +#define PREVIEW_SIDE (10) +#define PREVIEW_WIDTH (240) +#define PREVIEW_HEIGHT (240) + +#define WIDTHBYTES(bits) (((bits)+31)/32*4) + +#define PixelFormatIndexed 0x00010000 // Indexes into a palette +#define PixelFormatGDI 0x00020000 // Is a GDI-supported format +#define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI) + +#define PLT_PREVIEW_SIDE (15) // 留边大小 +#define PLT_PREVIEW_WIDTH (156) // 默认预览图区域宽度 +#define PLT_PREVIEW_HEIGHT (164) // 默认预览图区域高度 + +#define PLT_EMB_DATADIRX (1) // X向数据坐标与下位机坐标系统的差异 +#define PLT_EMB_DATADIRY (-1) // Y向数据坐标与下位机坐标系统的差异 +#define PLT_EMB_DATADIRR (1) // R向数据坐标与下位机坐标系统的差异 +#define PLT_EMB_DATASCALE 100 // plt数据转为下位机数据需要扩大10倍,因为下位机单位为0.01mm + +#define PLT_SHOWDIRX (1) // X向显示坐标和数据坐标的差异 +#define PLT_SHOWDIRY (-1) // Y向显示坐标和数据坐标的差异 + +struct SC +{ + double dXMin; + double dXMax; + double dYMin; + double dYMax; + int nType; + double dLeft; + double dBottom; +}; + +class ImportHPGL : public QObject +{ + Q_OBJECT +public: + explicit ImportHPGL(QObject *parent = 0); + virtual ~ImportHPGL(); + +signals: + +public slots: + +private: + inline const QString & getFileFullPathName() const {return m_fileFullPathName;} // 文件路径名称 + + //获得QR二维码版本 + //输入参数:nCount 字符个数 + //返回参数:QR二维码版本 + int GetQRVesion(int nCount); + + //样点旋转 + //输入参数: + // ptPoint被旋转点,ptPointO旋转原点,dSinBeta,dCosBeta逆时针旋转角度的正余弦 + //输出参数: + // ptPoint旋转后的值 + void PointRotate(QPoint &ptPoint,QPoint ptPointO,double dSinBeta,double dCosBeta); + +protected: + + //分析S指令 + //输入参数: + // pFile 切割数据文件 + //输出参数: + // bEndOfFile =true 已到文件尾 + //返回值: + // true 正确的G指令 + // false 不正确的G指令 + bool S_Code(); + bool I_Code(); + bool P_Code(); + bool PU_Code(); + bool PD_Code(); + bool L_Code(); + bool D_Code(); + bool SC_Code(); + bool C_Code(); + + //读取一个字符 + //输出参数: + // *pChar 读取的字符 + //返回值: + // 1 成功取得一个字符 + // 0 失败 + uint ReadChar(char* lpBuf); + + //读取一个非空格、非回车、非换行的字符 + //输入参数: + // pFile 切割数据文件 + //输出参数: + // *pChar 读取的字符 + //返回值: + // true 成功取得一个字符 + // false 失败 + bool GetChar(char *pChar); + //判断下一个非空格、非回车、非换行的字符是不是',' + //输入参数: + // pFile 切割数据文件 + //返回值: + // true 下一个非空格、非回车、非换行的字符是',', 并且已将','从文件中读出 + // false 下一个非空格、非回车、非换行的字符不是',', 并且该字符没有从文件中读出 + bool NextCharIsComma(); + + //取一个双精度浮点数 + //输入参数: + // pFile 切割数据文件 + //输出参数: + // dValue 取得的双精度浮点数 + //返回值: + // true 成功取得一个双精度浮点数dValue + // false 失败 + bool GetDoubleData(double &dValue); + + //取一个整数 + //输入参数: + // pFile 切割数据文件 + //输出参数: + // iValue 取得的整数 + //返回值: + // true 成功取得一个整数iValue + // false 失败 + bool GetIntegerData(int &iValue); + + //取坐标值 + //输入参数: + // pFile 切割数据文件 + //输出参数: + // ptPoint 坐标 + //返回值: + // true 成功 + // false 失败 + bool GetCoordinate(QPoint &ptPoint); + + //获得线的类型 + //输入参数: + // pFile 切割数据文件 + //输出参数: + // lineType 线型 + //返回值: + // true 成功 + // false 失败 + bool GetLineType(LineType &lineType); + + //查找一个指定的字符 + //输入参数: + // pFile 切割数据文件 + // cFind 指定的字符 + //输出参数: + // strInfo 从开始位置到指定字符之前的内容(不包括最后的指定字符) + //返回值: + // true 成功取得一个字符 + // false 失败 + bool SearchChar(char cFind,QString &strInfo); + + //将文件的读取位置移到下一个英文字母(26个英文字母) + //输入参数: + // pFile 切割数据文件 + //输出参数: + // *pChar 读取的字符 + //返回值: + // true 成功将文件的读取位置移到下一个英文字母 + // false 失败 + bool MoveToNextEnglishChar(); + + //将m_listXY加入到m_pMarker中,并将m_listXY清空 + void AddPolylineToMarker(); + + void AddPoint2listXY(QPoint ptPoint); + + QString m_fileFullPathName; //文件名称 + int m_iDPMM; //长度数据单位:m_iDPMM(每毫米点) + int m_iPenNo; //当前的笔号 + QPoint m_ptCurrentPos; //笔的当前位置,单位:(1/CMarker::m_iDPMM)毫米 + LineType m_lineType;//当前线型 + bool m_bPenUp;//当前刀具的状态 true:刀具状态为抬起 false:刀具状态为落下 + bool m_bPage;//是否识别到PG指令 + + Marker *m_pMarker; //当前使用的唛架,仅能在读文件时使用 + double m_dScale; //读入文件时将切割数据文件的单位转换成内部数据单位时的比例 + QPen m_penPen;//笔绘画笔 + QPen m_cutPen;//切割画笔 + QPen m_halfCutPen;//半透切割画笔 + + QList m_listXY; //还没有确定抬落刀的坐标 + //QPainterPath m_polylinePainterPath;//绘图路径-线段 + + unsigned char m_chTerminator;//标志终结符,除了NULL LF ESC及;十进制分别为0,5,27,59;外的所有字符,默认为ETX 十进制3 + int m_nTerminatorMode;//模式0:打印1:不打印 默认值为1 + + double m_dTextHeight;//字的高度 单位cm + double m_dTextWidth;//字的宽度 单位cm + int m_nLableOrigin;//字符串相对于原点位置 + double m_dTextAngle;//指定每行文本输出时相对于设备x轴的角度,其单位为1/10度 + QPoint m_ptP1;//解析IP指令中的坐标点 + QPoint m_ptP2;//解析IP指令中的坐标点 + SC m_sc;//解析SC指令 + double m_dScaleX;//通过 IP和SC指令算出的缩放比例 + double m_dScaleY;//通过 IP和SC指令算出的缩放比例 + QPoint m_ptOrigin;//通过 IP和SC指令算出的原点 + int m_nLength;//用于PG分页,记录累计长度 + char* m_pFileBuf;//存放从文件中读取的全部字符 + int m_nCharCount;//已经读取的字符个数 + int m_nFileLength;//文件长度 + QString m_workPath; + + bool m_bFontItalic; //文字斜体 + int m_iFontSize; //字体榜数 + QString m_strFontName;//字体名称 + +private: + QByteArray m_embAbsData; // 转换后的绝对坐标数据 + int m_minX; + int m_maxX; + int m_minY; + int m_maxY; + u8 m_stepCtrl; + +public: + //输入参数: + // pFile 需要读入的RS274D文件 + // pMarker 解析到的数据保存到此唛架 + //返回值: + // true 读入文件成功 + // false 读入文件失败 + bool Read(QString strPathName); + bool Write(QString strPathName,Marker *pMarker); + int createPreviewImage(QImage * pImg = NULL, int saveflag = 0, int penwidth = 1, int reDraw = 0); // 生成预览文件 + void convertDataToEmbAbs(); // 转换为绝对数据 + void setStepCtrl(u8 ctrl);//设置针步属性 + QByteArray getEmbAbsData(); // 得到转换后的数据 + + //void creatPolylinePainterPath();//获得文件图形的范围 + //QPainterPath GetPolylinePainterPath(); + + //初始化参数,读取参数前,需将参数值重置,避免造成参数值读取错误 + void IniPara(); + + QPoint GetTextOrigin(QPoint pt,QString strText); + double GetTextAngle(double dX,double dY); + void SetScale(); + bool IsSecretFile(QString strPatnName); + int BitMapDtat(QString strFileName,QString strSecretFile); + bool ReadSecretFile(QString stePathName); // 打开位图文件 + +private slots: + //输入参数: + // bUp 刀的状态,true:抬起状态 false:落下状态 + // ptPoint 矢量字体中点阵中的一个坐标 + void AddTextPointToLine(bool bUp,QPoint ptPoint); +}; + +#endif // IMPORTHPGL_H diff --git a/datafile/hpgl/marker.cpp b/datafile/hpgl/marker.cpp new file mode 100644 index 0000000..4ab42d8 --- /dev/null +++ b/datafile/hpgl/marker.cpp @@ -0,0 +1,262 @@ +#include "marker.h" + +Marker::Marker(QObject *parent) : + QObject(parent) +{ + m_iDPMM = 40; + m_listPolyline.clear(); + m_nProducts = 0; + m_nActualMatchRegions = 0; + m_nMatchRegions = 0; + m_strProductCode = ""; +} + +Marker::~Marker() +{ +} + +Marker::Marker(const Marker &a): QObject() +{ + m_iDPMM = a.m_iDPMM; + m_listPolyline.clear(); + m_listPolyline.append(a.m_listPolyline); + m_nProducts = a.m_nProducts; + m_nActualMatchRegions = a.m_nActualMatchRegions; + m_nMatchRegions = a.m_nMatchRegions; + m_strProductCode = a.m_strProductCode; +} + +Marker Marker::operator=(const Marker &a) +{ + m_iDPMM = a.m_iDPMM; + m_listPolyline.clear(); + m_listPolyline.append(a.m_listPolyline); + m_nProducts = a.m_nProducts; + m_nActualMatchRegions = a.m_nActualMatchRegions; + m_nMatchRegions = a.m_nMatchRegions; + m_strProductCode = a.m_strProductCode; + return *this; +} + +void Marker::Initialize() +{ + m_iDPMM = 40; + m_listPolyline.clear(); + m_nProducts = 0; + m_nActualMatchRegions = 0; + m_nMatchRegions = 0; + m_strProductCode = ""; +} + +QRect Marker::GetRect() +{ + QRect rect; + + CRPPolyline RPPolyline; + rect.setRect(0,0,0,0); + + for(int i = 0; i < m_listPolyline.size(); i++) + { + RPPolyline = m_listPolyline.at(i); + if (RPPolyline.m_nDrawingType == 0) + { + rect |= RectofPolyline(RPPolyline.m_listPoint); + } + else if (RPPolyline.m_nDrawingType == 3) + { + rect |= QRect(RPPolyline.m_text.m_ptPostLU,RPPolyline.m_text.m_ptPostRD); + } + else if (RPPolyline.m_nDrawingType == 1) + { + rect |= QRect(RPPolyline.m_bitmapInfo.m_ptAbPostLU,RPPolyline.m_bitmapInfo.m_ptAbPostRD); + } + } + + return rect; +} + +QRect Marker::RectofPolyline(const QList &listPoint) +{ + if(listPoint.empty()) + { + return QRect(0,0,0,0); + } + int iXMin = INT_MAX; + int iXMax = INT_MIN; + int iYMin = INT_MAX; + int iYMax = INT_MIN; + + int iValueX; + int iValueY; + + int iPointCount = listPoint.size(); + for(int i = 0 ;i < iPointCount; i++) + { + iValueX = listPoint.at(i).x(); + iValueY = listPoint.at(i).y(); + + if( iValueX > iXMax ) + { + iXMax = iValueX; + } + + if(iValueX < iXMin ) + { + iXMin = iValueX; + } + + if( iValueY > iYMax ) + { + iYMax = iValueY; + } + + if(iValueY < iYMin ) + { + iYMin = iValueY; + } + } + + return QRect(QPoint(iXMin,iYMin),QPoint(iXMax,iYMax)); +} + + +double CNotch::angle_2(int startx, int starty, int endx, int endy) +{ + //直线与X轴之间的夹角 X轴向量OE(1,0) + double dAngle = 0; + if((endx == startx) && (endy == starty)) + { + return dAngle; + } + //求直线的向量坐标 + double dX = endx - startx; + double dY = endy - starty; + dAngle = qAcos((dX)/(qSqrt(dX*dX + dY*dY))); + return dAngle; +} + +void CNotch::CovertToOutputByOffset(int nOffSetX, int nOffsetY) +{ + double a = 0; + double b = 0; + double c = 0; + //范围在[0,2pi)之间 + double dAngle = angle_2(m_ptStart.x(),m_ptStart.y(),m_ptEnd.x(),m_ptEnd.y()); + m_nAngle = dAngle*180.0/CONST_PI*100.0 + 0.5; + //double dX = m_ptEnd.x - m_ptStart.x; + //double dY = m_ptEnd.y - m_ptStart.y; + //double dLen = sqrt(dX*dX + dY*dY); + //m_ptCorrect.x = nOffSetY/dLen * dX + m_ptStart.x; + //m_ptCorrect.y = nOffsetY/dLen * dY + m_ptStart.y; + QPoint ptY; + ptY.setX(nOffsetY*cos(dAngle) + m_ptStart.x() + 0.5); + ptY.setY(nOffsetY*sin(dAngle) + m_ptStart.y() + 0.5); + + if (nOffSetX == 0) + { + m_ptCorrect.setX(ptY.x()); + m_ptCorrect.setY(ptY.y()); + return; + } + + int nX = m_ptEnd.x() - m_ptStart.x(); + int nY = m_ptEnd.y() - m_ptStart.y(); + + if (nX == 0) + { + a = 0; + b = 1; + c = -ptY.y(); + } + if (nY == 0) + { + a = 1; + b = 0; + c = -ptY.x(); + } + + double k = double(m_ptStart.x() - m_ptEnd.x())/double(m_ptEnd.y() - m_ptStart.y()); + c = ptY.y() - k*ptY.x(); + a = k; + b = -1; + int nRadius = abs(nOffSetX); + QPoint ptInter1; + QPoint ptInter2; + if (IntOfLineCircle(a,b,c,ptY.x(),ptY.y(),nRadius,ptInter1,ptInter2) == 2) + { + //向量 + int nYv = ptInter1.y() - ptY.y(); + int nXv = ptInter1.x() - ptY.x(); + //判断该点在起点到终点连线的哪一侧?>0 右侧 + if((nXv*nY -nYv*nX)>0) + { + if (nOffSetX > 0)//右侧 + { + m_ptCorrect.setX(ptInter1.x()); + m_ptCorrect.setY(ptInter1.y()); + } + else + { + m_ptCorrect.setX(ptInter2.x()); + m_ptCorrect.setY(ptInter2.y()); + } + + } + else + { + if (nOffSetX < 0)//左侧 + { + m_ptCorrect.setX(ptInter1.x()); + m_ptCorrect.setY(ptInter1.y()); + } + else + { + m_ptCorrect.setX(ptInter2.x()); + m_ptCorrect.setY(ptInter2.y()); + } + } + } +} + +int CNotch::IntOfLineCircle(double a, double b, double c, int xc, int yc, int nR, QPoint &lpptIntersection1, QPoint &lpptIntersection2) +{ + //点:(x0,y0) + //线:Ax+By+C=0 + //①距离=ABS(A*x0+B*y0+C) / SQRT(A*A+B*B) + double dis = 0; + dis = abs(a*xc+b*yc+c)/sqrt(a*a+b*b); + + int rel = 0; + if(dis < nR) + { + rel = 0; + } + else if(dis == nR) + { + rel = 1; + } + else if(dis > nR) + { + double k = -a/b; + double b1 = 2*xc-2*k*(b-yc); + double sval = (b1/100.0)*(b1/100.0)*10000.0-4*a*c; + if(sval < 0) + { + qDebug()< +#include +#include +#include +#include +#include + +#define CONST_PI 3.14159265359 + +struct LineType +{ + //具体参照HPGL英文版手册216页 当LT没有设置值时,线型为实线 + bool bDefault;//LT是否设置值 + int nLinetype;//线型 取值为-8~8 ,99 =0 实线 =1 虚线 + int nPatternLength;//图案长度 缺省为P1、P2距离的4% + int nMode;//0相对模式 缺省值 解释为P1、P2距离的百分比 1绝对模式,以毫米解释图案长度 +}; + + +class CBitmapInfo +{ +public: + //原始读取的的坐标 + QPoint m_ptPostLU; //位图的左上角在整个图中的XY位置 + QPoint m_ptPostLD; //位图的左下角在整个图中的XY位置 + QPoint m_ptPostRU; //位图的右上角在整个图中的XY位置 + QPoint m_ptPostRD; //位图的右下角在整个图中的XY位置 + + //换算后的坐标 + QPoint m_ptAbPostLU; //位图的左上角在整个图中的XY位置 + QPoint m_ptAbPostLD; //位图的左下角在整个图中的XY位置 + QPoint m_ptAbPostRU; //位图的右上角在整个图中的XY位置 + QPoint m_ptAbPostRD; //位图的右下角在整个图中的XY位置 + + int m_iTransparent;//为1时则为透明显示; 为0则为非透明显示 + int m_iBKColor;//背景颜色(在透明显示时背景颜色的点将不被显示) + + int m_iWidth;// GDI+中BitmapData的Width,单位:像素 + int m_iHeight;//GDI+中BitmapData的Height,单位:像素 + int m_iStride;//GDI+中BitmapData的Stride(每行的字节数) + int m_iPixelFormat;//GDI+中BitmapData的PixelFormat + + int m_iBytes;//int压缩后位图数据大小(字节数) + QBitmap m_pBitmap;//位图数据(压缩后的位图数据) + + CBitmapInfo() + { + m_ptPostLU = QPoint(0,0); + m_ptPostLD = QPoint(0,0); + m_ptPostRU = QPoint(0,0); + m_ptPostRD = QPoint(0,0); + m_ptAbPostLU = QPoint(0,0); + m_ptAbPostLD = QPoint(0,0); + m_ptAbPostRU = QPoint(0,0); + m_ptAbPostRD = QPoint(0,0); + m_iTransparent = 0; + m_iBKColor = 0; + m_iWidth = 0; + m_iHeight = 0; + m_iStride = 0; + m_iPixelFormat = 1; + m_iBytes = 0; + //m_pBitmap = NULL; + + } + ~CBitmapInfo() {} + CBitmapInfo operator=(const CBitmapInfo &a) + { + m_ptPostLU = a.m_ptPostLU; + m_ptPostLD = a.m_ptPostLD; + m_ptPostRU = a.m_ptPostRU; + m_ptPostRD = a.m_ptPostRD; + m_ptAbPostLU = a.m_ptAbPostLU; + m_ptAbPostLD = a.m_ptAbPostLD; + m_ptAbPostRU = a.m_ptAbPostRU; + m_ptAbPostRD = a.m_ptAbPostRD; + m_iTransparent = a.m_iTransparent; + m_iBKColor = a.m_iBKColor; + m_iWidth = a.m_iWidth; + m_iHeight = a.m_iHeight; + m_iStride = a.m_iStride; + m_iPixelFormat = a.m_iPixelFormat; + m_iBytes = a.m_iBytes; + m_pBitmap = a.m_pBitmap; + return *this; + } +}; + +class CRPArc +{ +public: + QPoint m_ptCenter; + int m_nRadius; + bool m_bCircle;//是圆还是圆弧1:圆 0 :圆弧 + QPoint m_ptStart;//圆弧起始点 + QPoint m_ptEnd;//圆弧结束点 + + CRPArc() + { + m_bCircle = true; + } + ~CRPArc() {} + CRPArc(CRPArc &a) + { + m_ptCenter = a.m_ptCenter; + m_nRadius = a.m_nRadius; + m_bCircle = a.m_bCircle; + m_ptStart = a.m_ptStart; + m_ptEnd = a.m_ptEnd; + } + CRPArc operator=(const CRPArc &a) + { + m_ptCenter = a.m_ptCenter; + m_nRadius = a.m_nRadius; + m_bCircle = a.m_bCircle; + m_ptStart = a.m_ptStart; + m_ptEnd = a.m_ptEnd; + return *this; + } +}; + +class CRPText +{ +public: + QString m_strText;//字符串 + QString m_strFontName;//字体名称 + QPoint m_ptTextPos;//文字起点坐标 + double m_dTextAngle;//文字角度 + int m_nHeight;//文字高度 + int m_nWidth;//文字宽度 + int m_nWeight;//加粗 + bool m_bItalic;//斜体 + + //文字坐标 + QPoint m_ptPostLU; //文字的左上角在整个图中的XY位置 + QPoint m_ptPostLD; //文字的左下角在整个图中的XY位置 + QPoint m_ptPostRU; //文字的右上角在整个图中的XY位置 + QPoint m_ptPostRD; //文字的右下角在整个图中的XY位置 + + + CRPText() + { + m_strText = ""; + m_strFontName = ""; + m_ptTextPos = QPoint(0,0); + m_dTextAngle = 0; + m_nHeight = 0; + m_nWidth = 0; + m_nWeight = 0; + m_bItalic = false; + m_ptPostLU = QPoint(0,0); + m_ptPostLD = QPoint(0,0); + m_ptPostRU = QPoint(0,0); + m_ptPostRD = QPoint(0,0); + } + ~CRPText() {} + CRPText(CRPText &a) + { + m_strText = a.m_strText; + m_strFontName = a.m_strFontName; + m_ptTextPos = a.m_ptTextPos; + m_dTextAngle = a.m_dTextAngle; + m_nHeight = a.m_nHeight; + m_nWidth = a.m_nWidth; + m_nWeight = a.m_nWeight; + m_bItalic = a.m_bItalic; + m_ptPostLU = a.m_ptPostLU; + m_ptPostLD = a.m_ptPostLD; + m_ptPostRU = a.m_ptPostRU; + m_ptPostRD = a.m_ptPostRD; + } + CRPText operator=( const CRPText &a) + { + m_strText = a.m_strText; + m_strFontName = a.m_strFontName; + m_ptTextPos = a.m_ptTextPos; + m_dTextAngle = a.m_dTextAngle; + m_nHeight = a.m_nHeight; + m_nWidth = a.m_nWidth; + m_nWeight = a.m_nWeight; + m_bItalic = a.m_bItalic; + m_ptPostLU = a.m_ptPostLU; + m_ptPostLD = a.m_ptPostLD; + m_ptPostRU = a.m_ptPostRU; + m_ptPostRD = a.m_ptPostRD; + return *this; + } +}; + +class CCode +{ +public: + int m_nLX;//左上角X位置 + int m_nLY;//左上角Y位置 + int m_nSizeX;//X方向大小 + int m_nSizeY;//Y方向大小 + int m_nAngle;//角度(逆时针方向为正),单位:0.01度 + int m_nType;//类型(0:条形码,1:二维码) + int m_nCount;//字符串个数(字符串的字节数) + QString m_strCode;//字符串 + QBitmap *m_pBitmap;//生成的位图数据 + + CCode() + { + m_nLX = 0; + m_nLY = 0; + m_nSizeX = 0; + m_nSizeY = 0; + m_nAngle = 0; + m_nType = 0; + m_nCount = 0; + m_strCode = ""; + } + ~CCode() {} + CCode(CCode &a) + { + m_nLX = a.m_nLX; + m_nLY = a.m_nLY; + m_nSizeX = a.m_nSizeX; + m_nSizeY = a.m_nSizeY; + m_nAngle = a.m_nAngle; + m_nType = a.m_nType; + m_nCount = a.m_nCount; + m_strCode = a.m_strCode; + m_pBitmap = a.m_pBitmap; + } + CCode operator=(const CCode &a) + { + m_nLX = a.m_nLX; + m_nLY = a.m_nLY; + m_nSizeX = a.m_nSizeX; + m_nSizeY = a.m_nSizeY; + m_nAngle = a.m_nAngle; + m_nType = a.m_nType; + m_nCount = a.m_nCount; + m_strCode = a.m_strCode; + m_pBitmap = a.m_pBitmap; + return *this; + } +}; + +class CNotch +{ +public: + QPoint m_ptStart;//剪口起点 + QPoint m_ptEnd;//剪口终点 + int m_nWidth;//剪口宽度 + int m_nNotchType;//剪口类型 + QPoint m_ptCorrect;//通过根据刀的X、Y偏移计算得出的实际落刀位置 + int m_nAngle;//根据交口起点和终点计算得出的角度(逆时针方向为正),单位:0.01度 + double angle_2(int startx,int starty,int endx,int endy); + + CNotch() + { + m_ptStart = QPoint(0,0); + m_ptEnd = QPoint(0,0); + m_nWidth = 0;; + m_nNotchType = 0; + m_ptCorrect = QPoint(0,0); + m_nAngle = 0; + } + ~CNotch() {} + CNotch(CNotch &a) + { + m_ptStart = a.m_ptStart; + m_ptEnd = a.m_ptEnd; + m_nWidth = a.m_nWidth; + m_nNotchType = a.m_nNotchType; + m_ptCorrect = a.m_ptCorrect; + m_nAngle = a.m_nAngle; + } + CNotch operator=(const CNotch &a) + { + m_ptStart = a.m_ptStart; + m_ptEnd = a.m_ptEnd; + m_nWidth = a.m_nWidth; + m_nNotchType = a.m_nNotchType; + m_ptCorrect = a.m_ptCorrect; + m_nAngle = a.m_nAngle; + return *this; + } + void CovertToOutputByOffset(int nOffSetX,int nOffsetY); + int IntOfLineCircle(double a,double b,double c,int xc,int yc,int nR,QPoint &lpptIntersection1,QPoint &lpptIntersection2); + +}; + +class CDrill +{ +public: + QPoint m_pt;//冲孔的位置 + int m_nDrillType;//冲孔类型 + int m_nAngle;//冲孔的角度(逆时针方向为正),单位:0.01度 + + CDrill() + { + m_pt = QPoint(0,0); + m_nDrillType = 0;; + m_nAngle = 0; + } + ~CDrill() {} + CDrill(CDrill &a) + { + m_pt = a.m_pt; + m_nDrillType = a.m_nDrillType; + m_nAngle = a.m_nAngle; + } + CDrill operator=(const CDrill &a) + { + m_pt = a.m_pt; + m_nDrillType = a.m_nDrillType; + m_nAngle = a.m_nAngle; + return *this; + } +}; + +class CRPPolyline +{ +public: + int m_nDrawingType;//0:直线 1:位图 2:圆 3:文字 4:条形码、二维码 5:钻孔 6:剪口 + int m_nID;//标识切割线切割顺序 从0开始 + int m_nPenNo; + bool m_bSelect;//是否处于选中状态,true:选中状态 false:未选中状态 + bool m_bPgEnd;//标识该切割线是该页的最后一条线 + int m_nComType;//补偿类型 0 无补偿 1向右(内)补偿 2向左(外)补偿 + + CBitmapInfo m_bitmapInfo; + CRPArc m_circle; + CRPText m_text; + CCode m_code; + CDrill m_drill; + CNotch m_notch; + + LineType m_lineType; + QList m_listPoint; + + CRPPolyline() + { + m_nDrawingType = 0; + m_nID = 0; + m_nPenNo = 0; + m_bSelect = false; + m_bPgEnd = false; + m_lineType.bDefault = true; + m_listPoint.clear(); + m_nComType = 0; + } + ~CRPPolyline() {} + CRPPolyline(const CRPPolyline &a) + { + m_nDrawingType = a.m_nDrawingType; + m_nID = a.m_nID; + m_nPenNo = a.m_nPenNo; + m_bSelect = a.m_bSelect; + m_bPgEnd = a.m_bPgEnd; + m_lineType = a.m_lineType; + m_listPoint.clear(); + m_listPoint.append(a.m_listPoint); + m_text = a.m_text; + m_nComType = a.m_nComType; + m_circle = a.m_circle; + m_text = a.m_text; + m_code = a.m_code; + m_notch = a.m_notch; + m_drill = a.m_drill; + m_bitmapInfo = a.m_bitmapInfo; + } + CRPPolyline operator=( const CRPPolyline &a) + { + m_nDrawingType = a.m_nDrawingType; + m_nID = a.m_nID; + m_nPenNo = a.m_nPenNo; + m_bSelect = a.m_bSelect; + m_bPgEnd = a.m_bPgEnd; + m_lineType = a.m_lineType; + m_listPoint.clear(); + m_listPoint.append(a.m_listPoint); + m_text = a.m_text; + m_nComType = a.m_nComType; + m_circle = a.m_circle; + m_text = a.m_text; + m_code = a.m_code; + m_notch = a.m_notch; + m_drill = a.m_drill; + m_bitmapInfo = a.m_bitmapInfo; + return *this; + } +}; + +class Marker : public QObject +{ + Q_OBJECT +public: + explicit Marker(QObject *parent = 0); + virtual ~Marker(); + Marker(const Marker &a); + Marker operator=(const Marker &a); + void Initialize(); + QRect GetRect(); + QRect RectofPolyline(const QList &listPoint); + + double m_iDPMM; //长度数据单位:m_iDPMM(每毫米点) + QList m_listPolyline; //切割的点链,单位:1/m_iDPMM mm, X向右为正,Y向上为正 + int m_nProducts; + int m_nActualMatchRegions; + int m_nMatchRegions; + QString m_strProductCode;//产品型号 + + +signals: + +public slots: + +}; + +#endif // MARKER_H diff --git a/datafile/hpgl/plotbitmap.cpp b/datafile/hpgl/plotbitmap.cpp new file mode 100644 index 0000000..d5ad090 --- /dev/null +++ b/datafile/hpgl/plotbitmap.cpp @@ -0,0 +1,79 @@ +#include "plotbitmap.h" + +PlotBitmap::PlotBitmap(QObject *parent) : QObject(parent) +{ + +} + +//QBitmap PlotBitmap::Create1BPPBitmap(int bTransparent, int crBkColor, int iWidth, int iHeight, int iStride, int nPixFormat, char *pBmpData) +QBitmap PlotBitmap::Create1BPPBitmap(int iWidth,int iHeight,unsigned char *pBmpData) +{ + QPen pen; + pen.setWidth(1); + pen.setColor(QColor(Qt::black)); + + //QImage::Format_RGBA8888 代表彩色图 + QImage image = QImage(pBmpData, iWidth, iHeight, QImage::Format_RGB888); + //image.save("D:\\1.png"); + + QBitmap pixmap = QBitmap(iWidth,iHeight); + QPainter *pixPainter = new QPainter(); + pixPainter->setPen(pen); + pixPainter->begin(&pixmap); + pixmap.fill(Qt::white);//用白色填充 + pixPainter->drawImage(0,0,image); + //pixmap.save("D:\\1.bmp"); + +#if(0)//转灰度图 + QImage gimage = QImage(); + uchar* pImageData1 = NULL,*pImageData2 = NULL; + + pImageData1 = image.bits(); + + gimage = image.convertToFormat(QImage::Format_Indexed8); + + QVector table; + for( int i = 0 ; i < 256 ; ++i ) + { + table.append(qRgb(i,i,i)); + } + + gimage.setColorTable(table); + + for(int i =0; i< gimage.width();i++) + { + for(int j=0; j< gimage.height();j++) + { + QRgb pix_value = gimage.pixel(i,j); + gimage.setPixel(i,j,qGray(pix_value)); + } + + } + + pImageData2 = gimage.bits(); + gimage.save("D:\\1.bmp"); + +#endif + return pixmap; +} + +//设置unsigned char中某位的值 +//dat 需要设置的unsigned char +//index 设置位 +//val 设置值0或者1 +void PlotBitmap::SetUncharBit(unsigned char &dat, int index, int val) +{ + unsigned int bitmod = 0x01; + if(index >= 0 && index < 8) + { + bitmod <<= index; + if (val == 0) + { + dat &= ~bitmod; + } + else + { + dat |= bitmod; + } + } +} diff --git a/datafile/hpgl/plotbitmap.h b/datafile/hpgl/plotbitmap.h new file mode 100644 index 0000000..e6114e5 --- /dev/null +++ b/datafile/hpgl/plotbitmap.h @@ -0,0 +1,64 @@ +#ifndef PLOTBITMAP_H +#define PLOTBITMAP_H + +#include +#include +#include +#include +//#include + +//BMP文件头(14字节) +typedef struct /**** BMP file header structure ****/ +{ + unsigned short bfType; /* 类型 */ + unsigned int bfSize; /* 整个bmp文件大小 */ + unsigned short bfReserved1; /* Reserved */ + unsigned short bfReserved2; /* ... */ + unsigned int bfOffBits; /* 偏移数,位图文件头+位图信息头+调色板大小 */ +} BmpHeader; + +//位图信息头(40字节) +typedef struct /**** BMP file info structure ****/ +{ + unsigned int biSize; /* Size of info header */ + int biWidth; /* Width of image */ + int biHeight; /* Height of image */ + unsigned short biPlanes; /* Number of color planes */ + unsigned short biBitCount; /* Number of bits per pixel */ + unsigned int biCompression; /* Type of compression to use */ + unsigned int biSizeImage; /* Size of image data */ + int biXPelsPerMeter; /* X pixels per meter */ + int biYPelsPerMeter; /* Y pixels per meter */ + unsigned int biClrUsed; /* Number of colors used */ + unsigned int biClrImportant; /* Number of important colors */ +} BmpInfo; + +class PlotBitmap : public QObject +{ + Q_OBJECT +public: + explicit PlotBitmap(QObject *parent = NULL); + +public: + //创建单色的位图 + //输入参数: + // bTransparent 透明显示 + // crBkColor 背景颜色(在透明显示时位图中颜色为crBkColor的点将不被显示在纸样上) + // iWidth 位图的宽,单位:像素 + // iHeight 位图的高,单位:像素 + // iStride 位图每行的字节数 + // nPixFormat 位图点的格式(见GDI+中BitmapData类PixelFormat的定义) + // pBmpData 位图数据(保存数据的顺序是从左到右,从上到下) + //返回值: + // NULL 失败 + // 非NULL 新生成的位图指针 + //QBitmap Create1BPPBitmap(int bTransparent,int crBkColor,int iWidth,int iHeight,int iStride,int nPixFormat,char *pBmpData); + QBitmap Create1BPPBitmap(int iWidth,int iHeight,unsigned char *pBmpData); + + void SetUncharBit(unsigned char & dat, int index, int val); +signals: + +public slots: +}; + +#endif // PLOTBITMAP_H diff --git a/datafile/hpgl/typedef.h b/datafile/hpgl/typedef.h new file mode 100644 index 0000000..cf4918e --- /dev/null +++ b/datafile/hpgl/typedef.h @@ -0,0 +1,107 @@ +#ifndef TYPEDEF_H +#define TYPEDEF_H + +//--------------------------------------------------------------- + + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + + +//--------------------------------------------------------------- + + +#define DATA_VALID 0x55AA + +//--------------------------------------------------------------- + +typedef int BOOL; +typedef unsigned char BYTE; +typedef unsigned short int WORD; +typedef unsigned long int DWORD; + +typedef unsigned char u8; +typedef unsigned short int u16; +typedef unsigned int u32; +typedef char s8; +typedef short int s16; +typedef int s32; + +//--------------------------------------------------------------- + +#define U8_MAX ((u8)255) +#define S8_MAX ((s8)127) +#define S8_MIN ((s8)(-128)) +#define U16_MAX ((u16)65535u) +#define S16_MAX ((s16)32767) +#define S16_MIN ((s16)(-32768)) +#define U32_MAX ((u32)4294967295uL) +#define S32_MAX ((s32)2147483647uL) +#define S32_MIN ((s32)(-2147483648uL)) + +//--------------------------------------------------------------- +#ifndef LOBYTE +#define LOBYTE(w) ((BYTE)(((WORD)(w)) & 0xff)) +#endif + +#ifndef HIBYTE +#define HIBYTE(w) ((BYTE)((((WORD)(w)) >> 8) & 0xff)) +#endif + +#ifndef LOWORD +#define LOWORD(l) ((WORD)(((DWORD)(l)) & 0xffff)) +#endif + +#ifndef HIWORD +#define HIWORD(l) ((WORD)((((DWORD)(l)) >> 16) & 0xffff)) +#endif + +#ifndef MAKEWORD +#define MAKEWORD(a, b) ((WORD)((BYTE)(a)) | (((WORD)((BYTE)(b))) << 8)) +#endif + +#ifndef MAKEDWORD +#define MAKEDWORD(a, b) ((DWORD)((WORD)(a)) | (((DWORD)((WORD)(b))) << 16)) +#endif + +#ifndef LOHFBYTE +#define LOHFBYTE(b) ((BYTE)((b) & 0x0f)) +#endif + +#ifndef HIHFBYTE +#define HIHFBYTE(b) ((BYTE)(((b) >> 4) & 0x0f)) +#endif + +#ifndef MAKEBYTE +#define MAKEBYTE(a, b) ((BYTE)((BYTE)((a) & 0x0f)) | ((BYTE)(((BYTE)((b) & 0x0f)) << 4))) +#endif + +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + +//--------------------------------------------------------------- + +#ifndef PI + +#define PI 3.1415926535897932 + +#endif + + + + +#endif // TYPEDEF_H diff --git a/datafile/hpgl/vectorfont.cpp b/datafile/hpgl/vectorfont.cpp new file mode 100644 index 0000000..3e3c9ff --- /dev/null +++ b/datafile/hpgl/vectorfont.cpp @@ -0,0 +1,918 @@ +#include "vectorfont.h" +#include +#include +#include "main.h" + +VectorFont::VectorFont(QObject *parent) : + QObject(parent) +{ + m_iDPMM = 40; + m_pChinese_char = NULL; + m_pEnglish_char = NULL; + m_nChinese_char_count = 0; + m_nEnglish_char_count = 0; + IniVectorFont(); +} + +VectorFont::~VectorFont() +{ + if(m_pChinese_char != NULL) + { + delete []m_pChinese_char; + m_pChinese_char = NULL; + } + if(m_pEnglish_char != NULL) + { + delete []m_pEnglish_char; + m_pEnglish_char = NULL; + } +} + +void VectorFont::IniVectorFont() +{ + QFile fntFile; + QString strCharFileName; + + BYTE byte[10]; + int nCharCount_C; + int nCharCount_E; + CChinese_char Chinese_char1; + CEnglish_char English_char1; + int nCountChar; + + + QString appPath = QCoreApplication::applicationDirPath(); + QChar separator = QChar('/'); + if(!appPath.contains(separator)) // 判断分隔符 + { + separator = QChar('\\'); + } + m_workPath = appPath + separator; + + + strCharFileName = m_workPath + "english.fnt"; + //qDebug()<< "strCharFileName" << strCharFileName; + fntFile.setFileName(strCharFileName); + + if(!fntFile.open(QIODevice::ReadOnly)) + { + qDebug() <<"english file open failed"; + return; + } + + fntFile.seek(0); + fntFile.read((char*)byte,10); + + m_nInternalLeading_E=(int)((WORD)byte[0] | ((WORD)byte[1] << 8)); + m_nHeight_E=(int)((WORD)byte[2] | ((WORD)byte[3] << 8)); + m_nDescent_E=(int)((WORD)byte[4] | ((WORD)byte[5] << 8)); + nCharCount_E=(int)((DWORD)byte[6] | ((DWORD)byte[7] << 8) | ((DWORD)byte[9] << 16) | ((DWORD)byte[9] << 24)); + //m_aEnglish_char.clear(); + m_pEnglish_char = new CEnglish_char[nCharCount_E]; + m_nEnglish_char_count = nCharCount_E; + fntFile.seek(10); + + nCountChar=nCharCount_E; + while (nCountChar > 0) + { + fntFile.read((char*)byte,10); + + English_char1.m_wCharCode=(WORD)byte[0] | ((WORD)byte[1] << 8); + English_char1.m_wBytes=(WORD)byte[2] | ((WORD)byte[3] << 8); + English_char1.m_wWidth=(WORD)byte[4] | ((WORD)byte[5] << 8); + English_char1.m_dwPosition=(DWORD)byte[6] | ((DWORD)byte[7] << 8) | ((DWORD)byte[9] << 16) | ((DWORD)byte[9] << 24); + + m_pEnglish_char[nCharCount_E-nCountChar] = English_char1; + //m_aEnglish_char.append(English_char1); + + nCountChar--; + } + fntFile.close(); + + strCharFileName = m_workPath + "Hz.fnt"; + //qDebug()<< "strCharFileName" << strCharFileName; + fntFile.setFileName(strCharFileName); + if(!fntFile.open(QIODevice::ReadOnly)) + { + qDebug() <<"chinese file open failed"; + return; + } + fntFile.seek(0); + fntFile.read((char*)byte,8); + + m_nWidth_C=(int)((WORD)byte[0] | ((WORD)byte[1] << 8)); + m_nHeight_C=(int)((WORD)byte[2] | ((WORD)byte[3] << 8)); + nCharCount_C=(int)((DWORD)byte[4] | ((DWORD)byte[5] << 8) | ((DWORD)byte[6] << 16) | ((DWORD)byte[7] << 24)); + + //m_aChinese_char.clear(); + m_pChinese_char = new CChinese_char[nCharCount_C]; + m_nChinese_char_count = nCharCount_C; + + fntFile.seek(8); + nCountChar=nCharCount_C; + while (nCountChar > 0) + { + fntFile.read((char*)byte,8); + + Chinese_char1.m_wCharCode=(WORD)byte[0] | ((WORD)byte[1] << 8); + Chinese_char1.m_wBytes=(WORD)byte[2] | ((WORD)byte[3] << 8); + Chinese_char1.m_dwPosition=(DWORD)byte[4] | ((DWORD)byte[5] << 8) | ((DWORD)byte[6] << 16) | ((DWORD)byte[7] << 24); + + + m_pChinese_char[nCharCount_C-nCountChar] = Chinese_char1; + //m_aChinese_char.append(Chinese_char1); + nCountChar--; + } + fntFile.close(); + + m_dFontAngle = 0; + m_dFontHeight = 0.375 * 10 * m_iDPMM; +} + + +//输入参数: +// ptPointLU 显示字符串的左上角坐标(即TextOut(...)的x,y值) +// pbyData 字符的描述数据 +// wBytes 字符的描述数据个数 +// nLeft,nDown 字符的左下角坐标(即以英汉字库的公共单位及坐标水平绘制字符串时,字符的的左下角坐标) +// nFontScale 字库的长度比例 +void VectorFont::PlotChar(QPoint ptPointLU,BYTE *pbyData,WORD wBytes,int nLeft,int nDown,int nFontScale) +{ + BYTE byByteX,byByteY; + QPoint ptCurrentPos,ptCenter,ptPointS,ptPointE; + QPoint ptPoint1; + WORD wIndex1; + WORD wDirection,wLength; + BOOL bPenUp,bVerTextCommand,bClockwise; + WORD wRadius,wArcS,wSpan; + int nRadius; + double dAngleS,dAngleE,dAngleOffsetS,dAngleOffsetE; + double dx1,dy1,dx2,dy2,dxc,dyc,dr,dD,dH,dBulge; + double dCos,dSin; + double dLToDScale; + int nHeight; + + if (wBytes == 0) return; + + nHeight=(m_nInternalLeading_E + m_nHeight_E) * m_nHeight_E; + //nHeight=(m_nInternalLeading_E + m_nHeight_E) * m_nHeight_C; //之前 + dLToDScale=(double)nHeight / m_dFontHeight; + + m_dRake = m_dFontAngle/180.0*PI; + dCos=cos(m_dRake); + dSin=sin(m_dRake); + + ptCurrentPos=QPoint(nLeft,nDown); + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + MoveTo(ptPoint1); + bVerTextCommand=false; + bPenUp=false; + wIndex1=0; + while (wIndex1 < wBytes) { + switch (pbyData[wIndex1]) { + case 0x0: + wIndex1++; + break; + case 0x1: + wIndex1++; + bPenUp=false; + break; + case 0x2: + wIndex1++; + bPenUp=true; + break; + case 0x3: + wIndex1++; + wIndex1++; + bVerTextCommand=false; + break; + case 0x4: + wIndex1++; + wIndex1++; + bVerTextCommand=false; + break; + case 0x5: + wIndex1++; + bPenUp=true; + break; + case 0x6: + wIndex1++; + bPenUp=true; + break; + case 0x7: + wIndex1++; + wIndex1++; + bPenUp=true; + break; + case 0x8: + if (bVerTextCommand) { + wIndex1=wIndex1+3; + } + else { + wIndex1++; + ptCurrentPos.setX(ptCurrentPos.x() + (char)pbyData[wIndex1] * nFontScale); + wIndex1++; + ptCurrentPos.setY(ptCurrentPos.y() + (char)pbyData[wIndex1] * nFontScale); + + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + if (bPenUp) + MoveTo(ptPoint1); + else + LineTo(ptPoint1); + + wIndex1++; + } + bVerTextCommand=false; + break; + case 0x9: + if (bVerTextCommand) { + wIndex1++; + byByteX=pbyData[wIndex1]; + wIndex1++; + byByteY=pbyData[wIndex1]; + while ((byByteX != 0) || (byByteY != 0)) { + wIndex1++; + byByteX=pbyData[wIndex1]; + wIndex1++; + byByteY=pbyData[wIndex1]; + } + wIndex1++; + } + else { + wIndex1++; + byByteX=pbyData[wIndex1]; + wIndex1++; + byByteY=pbyData[wIndex1]; + while ((byByteX != 0) || (byByteY != 0)) { + ptCurrentPos.setX(ptCurrentPos.x() + (char)byByteX * nFontScale); + ptCurrentPos.setY(ptCurrentPos.y() + (char)byByteY * nFontScale); + + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + if (bPenUp) + MoveTo(ptPoint1); + else + LineTo(ptPoint1); + + wIndex1++; + byByteX=pbyData[wIndex1]; + wIndex1++; + byByteY=pbyData[wIndex1]; + } + + wIndex1++; + } + bVerTextCommand=false; + break; + case 0xA: + if (bVerTextCommand) { + wIndex1=wIndex1+3; + } + else { + wIndex1++; + wRadius=(WORD)pbyData[wIndex1]; + wIndex1++; + if (((char)pbyData[wIndex1]) < 0) bClockwise=true; + else bClockwise=false; + wArcS=(WORD)pbyData[wIndex1]; + wArcS=wArcS & 0x70; + wArcS=wArcS >> 4; + wSpan=(WORD)pbyData[wIndex1]; + wSpan=wSpan & 0x7; + + //计算圆心 + ptCenter=ptCurrentPos; + ptCenter.setX(ptCenter.x() - ((double)wRadius * (double)nFontScale * cos((double)wArcS * 45.0 / 180.0 * 3.14159265359))+0.5); + ptCenter.setY(ptCenter.y() - ((double)wRadius * (double)nFontScale * sin((double)wArcS * 45.0 / 180.0 * 3.14159265359))+0.5); + + dAngleS=(double)wArcS * 45.0 / 180.0 * 3.14159265359; + if (bClockwise) dAngleE=dAngleS - (double)wSpan * 45.0 / 180.0 * 3.14159265359; + else dAngleE=dAngleS + (double)wSpan * 45.0 / 180.0 * 3.14159265359; + + if (bClockwise) { + ptPointS.setX(ptCenter.x() + (double)wRadius * (double)nFontScale * cos(dAngleE)+0.5); + ptPointS.setY(ptCenter.y() + (double)wRadius * (double)nFontScale * sin(dAngleE)+0.5); + ptPointE.setX(ptCenter.x() + (double)wRadius * (double)nFontScale * cos(dAngleS)+0.5); + ptPointE.setY(ptCenter.y() + (double)wRadius * (double)nFontScale * sin(dAngleS)+0.5); + ptCurrentPos=ptPointS; + } + else { + ptPointS.setX(ptCenter.x() + (double)wRadius * (double)nFontScale * cos(dAngleS)+0.5); + ptPointS.setY(ptCenter.y() + (double)wRadius * (double)nFontScale * sin(dAngleS)+0.5); + ptPointE.setX(ptCenter.x() + (double)wRadius * (double)nFontScale * cos(dAngleE)+0.5); + ptPointE.setY(ptCenter.y() + (double)wRadius * (double)nFontScale * sin(dAngleE)+0.5); + ptCurrentPos=ptPointE; + } + + ptCenter=CPToLP(ptCenter,nHeight,ptPointLU,dSin,dCos,dLToDScale); + ptPointS=CPToLP(ptPointS,nHeight,ptPointLU,dSin,dCos,dLToDScale); + ptPointE=CPToLP(ptPointE,nHeight,ptPointLU,dSin,dCos,dLToDScale); + nRadius=(double)wRadius * (double)nFontScale / dLToDScale + 0.5; + Arc(ptCenter.x() - nRadius,ptCenter.y() - nRadius, + ptCenter.x() + nRadius,ptCenter.y() + nRadius, + ptPointS.x(),ptPointS.y(),ptPointE.x(),ptPointE.y()); + + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + MoveTo(ptPoint1); + + wIndex1++; + } + bVerTextCommand=false; + break; + case 0xB: + if (bVerTextCommand) { + wIndex1=wIndex1+6; + } + else { + wIndex1++; + dAngleOffsetS=(double)((WORD)pbyData[wIndex1]); + wIndex1++; + dAngleOffsetE=(double)((WORD)pbyData[wIndex1]); + wIndex1++; + wRadius=(WORD)pbyData[wIndex1]; + wRadius=wRadius << 8; + wIndex1++; + wRadius=wRadius | (WORD)pbyData[wIndex1]; + wIndex1++; + if (((char)pbyData[wIndex1]) < 0) bClockwise=true; + else bClockwise=false; + wArcS=(WORD)pbyData[wIndex1]; + wArcS=wArcS & 0x70; + wArcS=wArcS >> 4; + wSpan=(WORD)pbyData[wIndex1]; + wSpan=wSpan & 0x7; + + //计算圆心 + ptCenter=ptCurrentPos; + ptCenter.setX(ptCenter.x() - (double)wRadius * (double)nFontScale * cos((double)wArcS * 45.0 / 180.0 * 3.14159265359)+0.5); + ptCenter.setY(ptCenter.y() - (double)wRadius * (double)nFontScale * sin((double)wArcS * 45.0 / 180.0 * 3.14159265359)+0.5); + + dAngleS=(double)wArcS * 45.0; + dAngleS=dAngleOffsetS * 45.0 / 256.0 + dAngleS; + if (bClockwise) dAngleE=-(double)wSpan * 45.0; + else dAngleE=(double)wSpan * 45.0; + dAngleE=dAngleOffsetE * 45.0 / 256.0 + dAngleE; + dAngleE=dAngleOffsetE * 45.0 / 256.0 + dAngleE; + dAngleS=dAngleS / 180.0 * 3.14159265359; + dAngleE=dAngleE / 180.0 * 3.14159265359; + + if (bClockwise) { + ptPointS.setX(ptCenter.x() + (double)wRadius * (double)nFontScale * cos(dAngleE)+0.5); + ptPointS.setY(ptCenter.y() + (double)wRadius * (double)nFontScale * sin(dAngleE)+0.5); + ptPointE.setX(ptCenter.x() + (double)wRadius * (double)nFontScale * cos(dAngleS)+0.5); + ptPointE.setY(ptCenter.y() + (double)wRadius * (double)nFontScale * sin(dAngleS)+0.5); + ptCurrentPos=ptPointS; + } + else { + ptPointS.setX(ptCenter.x() + (double)wRadius * (double)nFontScale * cos(dAngleS)+0.5); + ptPointS.setY(ptCenter.y() + (double)wRadius * (double)nFontScale * sin(dAngleS)+0.5); + ptPointE.setX(ptCenter.x() + (double)wRadius * (double)nFontScale * cos(dAngleE)+0.5); + ptPointE.setY(ptCenter.y() + (double)wRadius * (double)nFontScale * sin(dAngleE)+0.5); + ptCurrentPos=ptPointE; + } + + ptCenter=CPToLP(ptCenter,nHeight,ptPointLU,dSin,dCos,dLToDScale); + ptPointS=CPToLP(ptPointS,nHeight,ptPointLU,dSin,dCos,dLToDScale); + ptPointE=CPToLP(ptPointE,nHeight,ptPointLU,dSin,dCos,dLToDScale); + nRadius=(double)wRadius * (double)nFontScale / dLToDScale + 0.5; + + Arc(ptCenter.x() - nRadius,ptCenter.y() - nRadius, + ptCenter.x() + nRadius,ptCenter.y() + nRadius, + ptPointS.x(),ptPointS.y(),ptPointE.x(),ptPointE.y()); + + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + MoveTo(ptPoint1); + + wIndex1++; + } + bVerTextCommand=false; + break; + case 0xC: + if (bVerTextCommand) { + wIndex1=wIndex1+4; + } + else { + wIndex1++; + dx1=(double)((char)pbyData[wIndex1]) * (double)nFontScale; + wIndex1++; + dy1=(double)((char)pbyData[wIndex1]) * (double)nFontScale; + wIndex1++; + dBulge=(double)((char)pbyData[wIndex1]); + if (((char)pbyData[wIndex1]) < 0) bClockwise=true; + else bClockwise=false; + + dD=sqrt(dx1*dx1 + dy1*dy1); + dH=fabs(dBulge) * dD / 127.0 / 2.0; + + if (((char)pbyData[wIndex1]) == 0) { + ptCurrentPos.setX(ptCurrentPos.x() + (int)dx1); + ptCurrentPos.setY(ptCurrentPos.y() - (int)dy1); + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + + if (bPenUp) MoveTo(ptPoint1); + else LineTo(ptPoint1); + } + else { + if (bClockwise) { + dx2=-dy1; + dy2=dx1; + } + else { + dx2=dy1; + dy2=-dx1; + } + dx2=dx2 / dD * dH + dx1 / 2.0; + dy2=dy2 / dD * dH + dy1 / 2.0; + + CircleCR(0.0,0.0,dx2,dy2,dx1,dy1,dxc,dyc,dr); + ptCenter.setX(ptCurrentPos.x() + dxc + 0.5); + ptCenter.setY(ptCurrentPos.y() + dyc + 0.5); + + if (bClockwise) + { + ptPointS.setX(ptCurrentPos.x() + dx1 + 0.5); + ptPointS.setY(ptCurrentPos.y() + dy1 + 0.5 ); + ptPointE=ptCurrentPos; + ptCurrentPos=ptPointS; + } + else + { + ptPointS=ptCurrentPos; + ptPointE.setX(ptCurrentPos.x() + dx1 + 0.5); + ptPointE.setY(ptCurrentPos.y() + dy1 + 0.5); + ptCurrentPos=ptPointE; + } + + ptCenter=CPToLP(ptCenter,nHeight,ptPointLU,dSin,dCos,dLToDScale); + ptPointS=CPToLP(ptPointS,nHeight,ptPointLU,dSin,dCos,dLToDScale); + ptPointE=CPToLP(ptPointE,nHeight,ptPointLU,dSin,dCos,dLToDScale); + nRadius=dr / dLToDScale + 0.5; + + Arc(ptCenter.x() - nRadius,ptCenter.y() - nRadius,ptCenter.x() + nRadius,ptCenter.y() + nRadius, + ptPointS.x(),ptPointS.y(),ptPointE.x(),ptPointE.y()); + + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + MoveTo(ptPoint1); + } + + wIndex1++; + } + bVerTextCommand=false; + break; + case 0xD: + if (bVerTextCommand) { + wIndex1=wIndex1+4; + } + else { + wIndex1++; + while ((pbyData[wIndex1] != 0) || (pbyData[wIndex1+1] != 0)) { + dx1=(double)((char)pbyData[wIndex1]) * (double)nFontScale; + wIndex1++; + dy1=(double)((char)pbyData[wIndex1]) * (double)nFontScale; + wIndex1++; + dBulge=(double)((char)pbyData[wIndex1]); + if (((char)pbyData[wIndex1]) < 0) bClockwise=true; + else bClockwise=false; + + dD=sqrt(dx1*dx1 + dy1*dy1); + dH=fabs(dBulge) * dD / 127.0 / 2.0; + + if (((char)pbyData[wIndex1]) == 0) { + ptCurrentPos.setX(ptCurrentPos.x() + (int)dx1); + ptCurrentPos.setY(ptCurrentPos.y() - (int)dy1); + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + + if (bPenUp) + MoveTo(ptPoint1); + else + LineTo(ptPoint1); + } + else { + if (bClockwise) { + dx2=-dy1; + dy2=dx1; + } + else { + dx2=dy1; + dy2=-dx1; + } + dx2=dx2 / dD * dH + dx1 / 2.0; + dy2=dy2 / dD * dH + dy1 / 2.0; + + CircleCR(0.0,0.0,dx2,dy2,dx1,dy1,dxc,dyc,dr); + ptCenter.setX(ptCurrentPos.x() + dxc + 0.5); + ptCenter.setY(ptCurrentPos.y() + dyc + 0.5); + + if (bClockwise) + { + ptPointS.setX(ptCurrentPos.x() + dx1 + 0.5); + ptPointS.setY(ptCurrentPos.y() + dy1 + 0.5); + ptPointE=ptCurrentPos; + ptCurrentPos=ptPointS; + } + else + { + ptPointS=ptCurrentPos; + ptPointE.setX(ptCurrentPos.x() + dx1 + 0.5); + ptPointE.setY(ptCurrentPos.y() + dy1 + 0.5); + ptCurrentPos=ptPointE; + } + + ptCenter=CPToLP(ptCenter,nHeight,ptPointLU,dSin,dCos,dLToDScale); + ptPointS=CPToLP(ptPointS,nHeight,ptPointLU,dSin,dCos,dLToDScale); + ptPointE=CPToLP(ptPointE,nHeight,ptPointLU,dSin,dCos,dLToDScale); + nRadius=dr / dLToDScale + 0.5; + + Arc(ptCenter.x() - nRadius,ptCenter.y() - nRadius,ptCenter.x() + nRadius,ptCenter.y() + nRadius, + ptPointS.x(),ptPointS.y(),ptPointE.x(),ptPointE.y()); + + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + MoveTo(ptPoint1); + } + + wIndex1++; + } + } + bVerTextCommand=false; + break; + case 0xE: + bVerTextCommand=true; + wIndex1++; + break; + default: + if (bVerTextCommand) { + wIndex1++; + } + else { + wDirection=(WORD)(pbyData[wIndex1] % 16); + wLength=(WORD)(pbyData[wIndex1] / 16) * (WORD)nFontScale; + ptCurrentPos=GetNextCoodinate(wDirection,wLength,ptCurrentPos); + + ptPoint1=CPToLP(ptCurrentPos,nHeight,ptPointLU,dSin,dCos,dLToDScale); + if (bPenUp) MoveTo(ptPoint1); + else LineTo(ptPoint1); + + wIndex1++; + } + bVerTextCommand=false; + break; + } + } +} + +QPoint VectorFont::CPToLP(QPoint ptCP,int nHeight,QPoint ptPointLU,double dSin,double dCos,double dScale) +{ + double dx,dy; + QPoint ptPoint1; + + dx=(double)ptCP.x(); + dy=(double)ptCP.y()-(double)nHeight; + ptPoint1.setX(ptPointLU.x() + ((dx*dCos - dy*dSin) / dScale + 0.5)); + ptPoint1.setY(ptPointLU.y() + ((dx*dSin + dy*dCos) / dScale + 0.5)); + + return ptPoint1; +} + +//抬笔移动到点(x,y) +void VectorFont::MoveTo(long x, long y) +{ + if(x == 0){} + if(y == 0){} +} + +//抬笔移动到点ptPoint +void VectorFont::MoveTo(QPoint ptPoint) +{ + emit siMoveTo(true,ptPoint); +} + +//从当前位置画线到点(x,y) +void VectorFont::LineTo(long x, long y) +{ + if(x == 0){} + if(y == 0){} +} + +//从当前位置画线到点ptPoint +void VectorFont::LineTo(QPoint ptPoint) +{ + emit siLineTo(false,ptPoint); +} + +//从(x,y)点开始写字,nCount为字节数 +void VectorFont::TextOutString(int x, int y, const char* lpszString, int nCount) +{ + QString strEnglish,strChinese; + QFile fileEnglish,fileChinese; + BYTE *pbyData; + int nLeft; + BYTE byByte1,byByte2; + WORD wCharCode; + int nIndex1,nIndex2,nIndex3,nIndex4; + bool bEnglishChar; + + strEnglish = m_workPath + "english.fnt"; + strChinese = m_workPath + "Hz.fnt"; + + fileEnglish.setFileName(strEnglish); + if(!fileEnglish.open(QIODevice::ReadOnly)) + { + qDebug() <<"file open failed"; + return; + } + + fileChinese.setFileName(strChinese); + if(!fileChinese.open(QIODevice::ReadOnly)) + { + qDebug() <<"file open failed"; + return; + } + + nLeft=0; + nIndex1=0; + while (nIndex1 < nCount) + { + pbyData=NULL; + byByte1=(BYTE)lpszString[nIndex1]; + if ((byByte1 >= 128) && ((nIndex1+1) < nCount)) + { + bEnglishChar=false; + + nIndex1++; + byByte2=(BYTE)lpszString[nIndex1]; + wCharCode=(((WORD)byByte1) << 8) | (WORD)byByte2; + + nIndex2=0; + nIndex3=m_nChinese_char_count - 1; + if (m_pChinese_char[nIndex2].m_wCharCode == wCharCode) nIndex4=nIndex2; + else if (m_pChinese_char[nIndex3].m_wCharCode == wCharCode) nIndex4=nIndex3; + else nIndex4=(nIndex2 + nIndex3) / 2; + while (((nIndex3 - nIndex2) > 1) && + (m_pChinese_char[nIndex4].m_wCharCode != wCharCode)) + { + if (m_pChinese_char[nIndex4].m_wCharCode > wCharCode) + { + nIndex3=nIndex4; + if (nIndex2 > nIndex3) break; + nIndex4=(nIndex2 + nIndex3) / 2; + } + else + { + nIndex2=nIndex4; + if (nIndex2 > nIndex3) break; + nIndex4=(nIndex2 + nIndex3) / 2; + } + } + + if ((m_pChinese_char[nIndex4].m_wCharCode == wCharCode) && + (m_pChinese_char[nIndex4].m_wBytes > 0)) + { + pbyData=new BYTE[m_pChinese_char[nIndex4].m_wBytes + 1]; + + fileChinese.seek(m_pChinese_char[nIndex4].m_dwPosition); + fileChinese.read((char*)pbyData,m_pChinese_char[nIndex4].m_wBytes); + } + } + else + { + bEnglishChar=true; + wCharCode=(WORD)byByte1; + nIndex2=0; + nIndex3=m_nEnglish_char_count - 1; + if (m_pEnglish_char[nIndex2].m_wCharCode == wCharCode) nIndex4=nIndex2; + else if (m_pEnglish_char[nIndex3].m_wCharCode == wCharCode) nIndex4=nIndex3; + else nIndex4=(nIndex2 + nIndex3) / 2; + while (((nIndex3 - nIndex2) > 1) && + (m_pEnglish_char[nIndex4].m_wCharCode != wCharCode)) + { + if (m_pEnglish_char[nIndex4].m_wCharCode > wCharCode) + { + nIndex3=nIndex4; + if (nIndex2 > nIndex3) break; + nIndex4=(nIndex2 + nIndex3) / 2; + } + else + { + nIndex2=nIndex4; + if (nIndex2 > nIndex3) break; + nIndex4=(nIndex2 + nIndex3) / 2; + } + } + + if ((m_pEnglish_char[nIndex4].m_wCharCode == wCharCode) && + (m_pEnglish_char[nIndex4].m_wBytes > 0)) { + pbyData=new BYTE[m_pEnglish_char[nIndex4].m_wBytes + 1]; + + fileEnglish.seek(m_pEnglish_char[nIndex4].m_dwPosition); + fileEnglish.read((char*)pbyData,m_pEnglish_char[nIndex4].m_wBytes); + } + } + if (pbyData != NULL) + { + if (bEnglishChar) + { + PlotChar(QPoint(x,y),pbyData,m_pEnglish_char[nIndex4].m_wBytes,nLeft,0,m_nHeight_C); + } + else + { + PlotChar(QPoint(x,y),pbyData,m_pChinese_char[nIndex4].m_wBytes,nLeft,0,m_nInternalLeading_E + m_nHeight_E); + } + delete []pbyData; + if (bEnglishChar) nLeft=nLeft + m_pEnglish_char[nIndex4].m_wWidth * m_nHeight_C; + else nLeft=nLeft + m_nWidth_C * (m_nInternalLeading_E + m_nHeight_E); + } + else + { + if (bEnglishChar) nLeft=nLeft + m_pEnglish_char[0].m_wWidth * m_nHeight_C; + else nLeft=nLeft + m_nWidth_C * (m_nInternalLeading_E + m_nHeight_E); + } + + nIndex1++; + } + + fileEnglish.close(); + fileChinese.close(); +} +//画弧,从Start逆时针画到End +void VectorFont::Arc(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect, + int nXStartArc,int nYStartArc,int nXEndArc,int nYEndArc) +{ + double dXC,dYC,dRadius; + double dx,dy; + double dAngleS,dAngleE,dAngle,dStep; + double dCos,dSin; + int nCount; + + dXC=((double)nLeftRect + (double)nRightRect) / 2.0; + dYC=((double)nTopRect + (double)nBottomRect) / 2.0; + dRadius=((double)nRightRect - (double)nLeftRect) / 2.0; + + dAngleS=angle_2(dXC,dYC,(double)nXStartArc,(double)nYStartArc); + dAngleE=angle_2(dXC,dYC,(double)nXEndArc,(double)nYEndArc); + while (dAngleE >= dAngleS) dAngleE=dAngleE - 2.0 * PI; + + if ((nXStartArc == nXEndArc) && (nYStartArc == nYEndArc)) + { + dAngleS=0.0; + dAngleE=-2.0 * PI; + } + + dSin=qSin(dAngleS); + dCos=qCos(dAngleS); + dx=dRadius * dCos + dXC; + dy=dRadius * dSin + dYC; + MoveTo(dx+0.5,dy+0.5); + + nCount=120; + dStep=PI / 180.0 * (360.0 / (double)nCount); //3度 + dAngle=dAngleS; + while (dAngle > dAngleE) + { + dAngle=dAngle - dStep; + if (dAngle < dAngleE) dAngle=dAngleE; + dSin=qSin(dAngle); + dCos=qCos(dAngle); + dx=dRadius * dCos + dXC; + dy=dRadius * dSin + dYC; + LineTo(dx+0.5,dy+0.5); + } + +} + +QPoint VectorFont::GetNextCoodinate(WORD wDirection,WORD wLength,QPoint ptPoint) +{ + QPoint ptPoint1; + + switch (wDirection) { + case 0: + ptPoint1.setX( ptPoint.x() + (int)wLength); + ptPoint1.setY(ptPoint.y()); + break; + case 1: + ptPoint1.setX(ptPoint.x() + (int)wLength); + ptPoint1.setY(ptPoint.y() + (int)wLength/2); + break; + case 2: + ptPoint1.setX(ptPoint.x() + (int)wLength); + ptPoint1.setY(ptPoint.y() + (int)wLength); + break; + case 3: + ptPoint1.setX(ptPoint.x() + (int)wLength/2); + ptPoint1.setY(ptPoint.y() + (int)wLength); + break; + case 4: + ptPoint1.setX(ptPoint.x()); + ptPoint1.setY(ptPoint.y() + (int)wLength); + break; + case 5: + ptPoint1.setX(ptPoint.x() - (int)wLength/2); + ptPoint1.setY(ptPoint.y() + (int)wLength); + break; + case 6: + ptPoint1.setX(ptPoint.x() - (int)wLength); + ptPoint1.setY(ptPoint.y() + (int)wLength); + break; + case 7: + ptPoint1.setX(ptPoint.x() - (int)wLength); + ptPoint1.setY(ptPoint.y() + (int)wLength/2); + break; + case 8: + ptPoint1.setX(ptPoint.x() - (int)wLength); + ptPoint1.setY(ptPoint.y()); + break; + case 9: + ptPoint1.setX(ptPoint.x() - (int)wLength); + ptPoint1.setY(ptPoint.y() - (int)wLength/2); + break; + case 10: + ptPoint1.setX(ptPoint.x() - (int)wLength); + ptPoint1.setY(ptPoint.y() - (int)wLength); + break; + case 11: + ptPoint1.setX(ptPoint.x() - (int)wLength/2); + ptPoint1.setY(ptPoint.y() - (int)wLength); + break; + case 12: + ptPoint1.setX(ptPoint.x()); + ptPoint1.setY(ptPoint.y() - (int)wLength); + break; + case 13: + ptPoint1.setX(ptPoint.x() + (int)wLength/2); + ptPoint1.setY(ptPoint.y() - (int)wLength); + break; + case 14: + ptPoint1.setX(ptPoint.x() + (int)wLength); + ptPoint1.setY(ptPoint.y() - (int)wLength); + break; + case 15: + ptPoint1.setX(ptPoint.x() + (int)wLength); + ptPoint1.setY(ptPoint.y() - (int)wLength/2); + break; + } + + return ptPoint1; +} + +//求两点确定的直线与X轴的夹角,在[0,2pi)之间 +//输入参数: +// (startx,starty) 起点 +// (endx,endy) 终点 +//返回值: +// 夹角 +double VectorFont::angle_2(int startx,int starty,int endx,int endy) +{ + //直线与X轴之间的夹角 X轴向量OE(1,0) + double dAngle = 0; + if((endx == startx) && (endy == starty)) + { + return dAngle; + } + //求直线的向量坐标 + double dX = endx - startx; + double dY = endy - starty; + dAngle = qAcos((dX)/(qSqrt(dX*dX + dY*dY))); + return dAngle; +} + +///////////////////////// 计算三点定圆时的圆心和半径 /////////////////////////// +// 输入参数:三个样点(x1,y1),(x2,y2),(x3,y3) +// 算法描述: +// 过(x1,y1),(x2,y2)的中点作垂线L1, +// 过(x2,y2),(x3,y3)的中点作垂线L2, +// 求L1,L2的交点. +// 输出参数: +// 如果不能形成圆返回false, +// 否则返回true其中圆心为(cx,cy),半径=cr. +// 按逆时针方向画弧时,如cr>0 则(x1,y1)是起点,(x3,y3)是终点, +// 如cr<0 则(x3,y3)是起点,(x1,y1)是终点. +// 特别说明:此处所说的逆时针是指显示器而言,如果对于对X向右为正, +// Y向上为正的坐标系来说此处是顺时针 +//bool CircleCR(int x1,int y1,int x2,int y2,int x3,int y3,int& cx,int& cy,int& cr); +//////////////////////////////////////////////////////////////////////////////// +bool VectorFont::CircleCR(double x1,double y1,double x2,double y2,double x3,double y3,double& cx,double& cy,double& cr) +{ + double a1,b1,c1,a2,b2,c2; + if(((x1 ==x2) && (y1==y2)) || ((x1 ==x3) && (y1==y3)) || ((x2 ==x3) && (y2==y3))) + { + return false; + } + a1 = x1 - x2; + b1 = y1 - y2; + c1 = -a1 * (x1 + x2) / 2.0 - b1 * (y1 + y2)/2.0; + a2 = x3 - x2; + b2 = y3 - y2; + c2 = -a2 * (x2 + x3) / 2.0 - b2 * (y2 + y3)/2.0; + + double D = a1*b2 - a2*b1; + if(D == 0)//两直线平行 + { + return false; + } + + cx = (b1*c2 - b2*c1)/D; + cy = (c1*a2 - c2*a1)/D; + + //用圆心和其中一个点求距离得到半径: + cr = qSqrt((cx - x1)*(cx - x1) + (cy - y1)*(cy - y1)); + return true; +} + diff --git a/datafile/hpgl/vectorfont.h b/datafile/hpgl/vectorfont.h new file mode 100644 index 0000000..b21390d --- /dev/null +++ b/datafile/hpgl/vectorfont.h @@ -0,0 +1,132 @@ +#ifndef VECTORFONT_H +#define VECTORFONT_H + +#include +#include +#include "typedef.h" + +class CChinese_char +{ +public: + WORD m_wCharCode; + WORD m_wBytes; + DWORD m_dwPosition; + + CChinese_char() + { + m_wCharCode=0; + m_wBytes=0; + m_dwPosition=0; + } + CChinese_char(const CChinese_char &a) + { + m_wCharCode=a.m_wCharCode; + m_wBytes=a.m_wBytes; + m_dwPosition=a.m_dwPosition; + } + CChinese_char(WORD wCharCode,WORD wBytes,DWORD dwPosition) + { + m_wCharCode=wCharCode; + m_wBytes=wBytes; + m_dwPosition=dwPosition; + } + ~CChinese_char() {} + CChinese_char operator=(const CChinese_char &a) + { + m_wCharCode=a.m_wCharCode; + m_wBytes=a.m_wBytes; + m_dwPosition=a.m_dwPosition; + return *this; + } +}; + +class CEnglish_char +{ +public: + WORD m_wCharCode; + WORD m_wBytes; + WORD m_wWidth; + DWORD m_dwPosition; + + CEnglish_char() + { + m_wCharCode=0; + m_wBytes=0; + m_wWidth=0; + m_dwPosition=0; + } + CEnglish_char(const CEnglish_char &a) + { + m_wCharCode=a.m_wCharCode; + m_wBytes=a.m_wBytes; + m_wWidth=a.m_wWidth; + m_dwPosition=a.m_dwPosition; + } + CEnglish_char(WORD wCharCode,WORD wBytes,WORD wWidth,DWORD dwPosition) + { + m_wCharCode=wCharCode; + m_wBytes=wBytes; + m_wWidth=wWidth; + m_dwPosition=dwPosition; + } + ~CEnglish_char() {} + CEnglish_char operator=(const CEnglish_char &a) + { + m_wCharCode=a.m_wCharCode; + m_wBytes=a.m_wBytes; + m_wWidth=a.m_wWidth; + m_dwPosition=a.m_dwPosition; + return *this; + } +}; +class VectorFont : public QObject +{ + Q_OBJECT +public: + explicit VectorFont(QObject *parent = 0); + ~VectorFont(); + void IniVectorFont(); + + +signals: + void siLineTo(bool bl,QPoint point); + void siMoveTo(bool bl,QPoint point); + +public slots: +protected: + + double m_iDPMM; //长度数据单位:m_iDPMM(每毫米点) + double m_dRake; //倾斜角(第1个字符原点到最后1个字符原点的连线的角度),单位:弧度 + + QString m_workPath; + + //QList m_aChinese_char; + //QList m_aEnglish_char; + CChinese_char *m_pChinese_char; + CEnglish_char *m_pEnglish_char; + int m_nChinese_char_count; + int m_nEnglish_char_count; + int m_nInternalLeading_E,m_nHeight_E,m_nDescent_E; //m_nHeight_E是windows中字体的Ascent-InternalLeading + int m_nHeight_C,m_nWidth_C; +public: + + void PlotChar(QPoint ptPointLU,BYTE*pbyData,WORD wBytes,int nLeft,int nDown,int nFontScale); + QPoint CPToLP(QPoint ptCP,int nHeight,QPoint ptPointLU,double dSin,double dCos,double dScale); + void TextOutString(int x, int y, const char* lpszString, int nCount); + void Arc(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,int nXStartArc,int nYStartArc,int nXEndArc,int nYEndArc); + QPoint GetNextCoodinate(WORD wDirection,WORD wLength,QPoint ptPoint); + void MoveTo(QPoint ptPoint); + void MoveTo(long x,long y); + void LineTo(QPoint ptPoint); + void LineTo(long x,long y); + double angle_2(int startx,int starty,int endx,int endy); + bool CircleCR(double x1,double y1,double x2,double y2,double x3,double y3,double& cx,double& cy,double& cr); + + double m_dFontHeight; //字的高度 + double m_dFontAngle;//指定每行文本输出时相对于设备x轴的角度,其单位为1/10度 + + + +}; + +#endif // VECTORFONT_H diff --git a/denmark.qm b/denmark.qm new file mode 100644 index 0000000..be651ee --- /dev/null +++ b/denmark.qm @@ -0,0 +1 @@ + + + + + BrokenLineDialog + + + Form + + + + + + 1 + + + + + Broken Line Prompt + + + + + ClothingMac + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + Template recognition device + + + + + No device:0;Bar code:1;Coding hole:2;Multiple files:3 + + + + + X frame sensor coordinates + + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Y frame sensor coordinates + + + + + Spindle parking sensor angle + + + + + Lift sensor coordinates + + + + + Angle of spindle hook sensor + + + + + Spindle jog parking angle + + + + + X movable area negative boundary + + + + + X movable area positive boundary + + + + + Y movable area negative boundary + + + + + Y movable area positive boundary + + + + + X Sewing area negative boundary + + + + + X Sewing area positive boundary + + + + + Y Sewing area negative boundary + + + + + Y Sewing area positive boundary + + + + + XY start stop speed + + + + + + + + + + + mm/s + + + + + XY zero running speed + + + + + XY simulate running speed + + + + + XY movement acceleration + + + + + + mm/s2 + + + + + XY brake acceleration + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + XY maximum moving speed + + + + + Spindle start stop speed + + + + + + + + + + + + + + + + + r/min + + + + + Spindle zero reset speed + + + + + Spindle running speed + + + + + Spindle running acceleration + + + + + + + r/ss + + + + + Spindle brake acceleration + + + + + sewing maximum speed + + + + + Spindle zeroing compensation angle + + + + + X gap compensation + + + + + Y gap compensation + + + + + Sewing main shaft working speed + + + + + Spindle cutting speed + + + + + Spindle needle return speed + + + + + Spindle start slow speed + + + + + Reverse equivalent spindle speed + + + + + Sewing frame movement mode + + + + + XY continuous:0;XY intermittent:1 + + + + + Sewing frame start angle + + + + + Sewing frame steadiness angle + + + + + Slow stitch at beginning + + + + + + + Needle + + + + + Needle action, thread loosen allowed + + + + + + + + + + + + + + + + + + + + + + Not allow:0;allowed:1 + + + + + Needle action,tight bobbin spring allowed + + + + + Needle action, catch upper thread allowed + + + + + Cut thread allowed + + + + + Do not trim:0;Automatic:1;Last trimming:2;Data trimming:3 + + + + + Trimmer cutting angle + + + + + Trimming completion angle + + + + + Thread cut, upper thread loosen allowed + + + + + Thread cut, tensile thread allowed + + + + + Thread cut, catch upper thread allowed + + + + + Thread cut, presser foot lift allowed + + + + + Stitch detect if thread broken + + + + + Thread brake detection, main shaft angle + + + + + Bobbin change reminder function + + + + + Not enabled: 0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bobbin thread length + + + + + Bobbin thread correction per stitch + + + + + Bobbin change as per sewed pieces + + + + + + times + + + + + Oiling mode selection + + + + + No oil:0;Oiling by time:1;Oiling by stitches:2;Oiling continously:3 + + + + + Oiling interval by needle stitch + + + + + Oiling interval by working time + + + + + + + s + + + + + Needle Oiling sustained time + + + + + Stop position selection after work complete + + + + + Current:0;Start:1;Anchor:2;Feeding:3;Offset:4 + + + + + Valid flag for offset point coordinates + + + + + + invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate valid symbol + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Delay after pneumatic frame off + + + + + Sewing acceleration + + + + + Trimming frame displacement + + + + + Automatic move to threading point allowed + + + + + Large presser foot action allowed + + + + + Sewing move head up down + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Software limit XY move allowed + + + + + Number of Needle hooks + + + + + Trimming frame direction + + + + + No:0;left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Early speed reduction + + + + + Delayed speed step + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Pneumatic frame off + + + + + + Penumatic frame on + + + + + ms + + + + + Loop work allowed + + + + + Shuttle Oiling sustained time + + + + + Sewing operation speed 1 + + + + + Sewing operation speed 2 + + + + + Sewing operation speed 3 + + + + + Change the sewing needle count value + + + + + Enable + + + + + Disable + + + + + JogP + + + + + JogN + + + + + Zero + + + + + Open + + + + + Close + + + + + Up + + + + + Down + + + + + Extend + + + + + Back + + + + + Combine + + + + + Separate + + + + + X to move motor + + + + + Y to move motor + + + + + Spindle motor + + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + + + + + Frame + + + + + Big foot + + + + + Middle foot + + + + + Buckle the bottom line + + + + + Top and bottom lines + + + + + Lower scissors to cut thread + + + + + Sandwich line + + + + + Elastic thread + + + + + Elastic thread 2 + + + + + Laser control + + + + + Laser blow + + + + + Oil + + + + + Headlamp + + + + + Sewing Blow + + + + + Hookline ext + + + + + Hookline open and close + + + + + Sewing machine head lifting + + + + + Spindle clutch + + + + + Pen + + + + + All to zero + + + + + Needle shuttle reset + + + + + Back thread + + + + + Back offset + + + + + Back shuttle + + + + + Back work + + + + + Set anchor + + + + + Back anchor + + + + + + Back start + + + + + Forwrak or back + + + + + Bottom count reset + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + SoftwareSet + + + + + Authorization + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Select + + + + + Para + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ControlActionWidget + + + Form + + + + + Control action + 控制动作 + + + + + Control action < Auxiliary function + 控制动作 < 辅助功能 + + + + + PageNums: 1/1 + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PushButton + + + + + pageNum: + + + + + The machine is about to move, please pay attention to safety! + + + + + All to zero + + + + + DebugInfoDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + DebugInfo: + + + + + pageNum: 0/0 + + + + + pageNum: + + + + + FileSelectDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + pageNum: + + + + + FiveHeadPrecisionSewing + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + + + + + + + + + + + + + + + + + + + mm + + + + + Left + + + + + Front + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + Y Sewing area Negative boundary + + + + + sewing work speed + + + + + + r/min + + + + + Bobbin thread length + Bottom line length + + + + + Refueling method selection + + + + + Head 4 shuttle refueling + Refueling needles interval + + + + + Refueling duration + + + + + Production preset + + + + + Sewing machine head 2 - surface thread breakage inspection + Thread trimming moving frame direction + + + + + Pin 1 motor + + + + + Allow for needle starting and thread loosening + + + + + Allow for loose thread during thread cutting + + + + + Allow needle withdrawal during thread cutting + + + + + Automatically thread back points during sewing + + + + + Allow for loose lines when moving boxes + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + Shuttle 1 motor + + + + + Spindle 2 motor + + + + + Pin 2 motor + + + + + Shuttle 2 motor + + + + + Spindle 3 motor + + + + + Pin 3 motor + + + + + Shuttle 3 motor + + + + + Spindle 4 motor + + + + + Pin 4 motor + + + + + Spindle 5 motor + + + + + Pin 5 motor + + + + + Shuttle 5 motor + + + + + Head 1 Elastic thread + + + + + Head 2 Elastic thread + + + + + Head 3 Elastic thread + + + + + Head 4 Elastic thread + + + + + Head 5 Elastic thread + + + + + Head 1 blow + + + + + Head 2 blow + + + + + Head 3 blow + + + + + Head 4 blow + + + + + Head 5 blow + + + + + Head 1 trim + + + + + Head 2 trim + + + + + Head 3 trim + + + + + Head 4 trim + + + + + Head 5 trim + + + + + Head 1 needle refueling + + + + + Head 2 needle refueling + + + + + Head 3 needle refueling + + + + + Head 4 needle refueling + + + + + Head 5 needle refueling + + + + + Head 1 shuttle refueling + + + + + Head 2 shuttle refueling + + + + + Head 3 shuttle refueling + + + + + Head 5 shuttle refueling + + + + + Head 1 lifting + + + + + Head 2 lifting + + + + + Head 3 lifting + + + + + Head 4 lifting + + + + + Head 5 lifting + + + + + X Sewing area positive boundary + + + + + Y Sewing area positive boundary + + + + + Zero position coordinate of head 2 + + + + + Zero position coordinate of head 3 + + + + + Zero position coordinate of head 4 + + + + + Zero position coordinate of head 5 + + + + + Sewing motion frame method + + + + + Xy continuous moving box:0;Xy intermittent moving frame:1 + + + + + Thread cutting allowed + + + + + No. of stitch detect if thread broken + Number of thread breakage detection needles + + + + + Bobbin change reminder function + Change shuttle core reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + do not enable this feature:0;Count delay reminders by length:1;Count by number of pieces:2;Prompt immediately based on length:3 + + + + + Count of shuttle change pieces + + + + + Times + + + + + not refueling:0;Intermittent refueling according to worktime:1;Intermittent refueling according to the number of working stitches:2;Continuously refueling:3 + + + + + Interval between refueling stitches + + + + + + + second + + + + + Cutting and parting angle + + + + + Thread trimming completion angle + + + + + Software limit: xy movement + + + + + Automatic sewing speed regulation + Sewing speed reduction mode + + + + + Circular working function + + + + + Duration of shuttle refueling + + + + + Sewing and blowing time + + + + + Sewing hook angle + + + + + Continuous angle of sewing frame + + + + + Zero All + + + + + X to move motor + + + + + Y to move motor + + + + + Head moving motor + + + + + All spindle zero positions + + + + + Spindle 1 motor + Spindle motor + + + + + Shuttle 4 motor + Shuttle motor + + + + + Lock frame cylinder + + + + + Flap control + + + + + Barcode testing + + + + + AllSpleHook + AllSpindleJogs + + + + + Spindle thread cutting speed + + + + + Allowing for wire clamping during wire cutting + + + + + Number of stitches for surface thread clamping + + + + + Head 1 ThreadCuttingAction + + + + + Head 2 ThreadCuttingAction + + + + + Head 3 ThreadCuttingAction + + + + + Head 4 ThreadCuttingAction + + + + + Head 5 ThreadCuttingAction + + + + + Head 1 Clamp wire + + + + + Head 2 Clamp wire + + + + + Head 3 Clamp wire + + + + + Head 4 Clamp wire + + + + + Head 5 Clamp wire + + + + + MU_Canl + makeupCanl + + + + + Makeup1 + makeup1 + + + + + Makeup2 + makeup2 + + + + + Makeup3 + makeup3 + + + + + Makeup4 + makeup4 + + + + + Makeup5 + makeup5 + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + ThCutAct1 + + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Coordinate of threading point X + + + + + Coordinate of threading point Y + + + + + ThCutAct2 + + + + + ThCutAct3 + + + + + ThCutAct4 + + + + + ThCutAct5 + + + + + SetStart + + + + + ProcReset + + + + + Simulate + + + + + HeadLifting + + + + + GoFeedt + + + + + Back start + + + + + Select + + + + + X negative limit + + + + + Y negative limit + + + + + freedom from error + + + + + Not powered on + + + + + + Insufficient air pressure + + + + + + Safe Area Intervention + + + + + + The usage deadline has expired + + + + + Filling data error + + + + + + Working status not allowed + + + + + control error + + + + + Motion control chip version error + + + + + Waiting for button to lift timeout + + + + + FPGA reset error + + + + + Peripheral not ready + + + + + Transmission data error + + + + + Program version error + + + + + Production completed + + + + + forward limit + + + + + Reverse limit + + + + + Motion alarm + + + + + Motion limit + + + + + Exercise emergency stop + + + + + + Motion parameter error + + + + + + Machine parameter error + + + + + + Input parameter error + + + + + The file is correct + + + + + Waiting for files + + + + + Zero successfully + + + + + Zero error + + + + + + Coordinate system error + + + + + + Target position out of range + + + + + + X forward limit + + + + + + X reverse limit + + + + + + Y forward limit + + + + + + Y reverse limit + + + + + + No Data + + + + + data error + + + + + + Spindle not in zero position + + + + + + Rotary shuttle not in zero position + + + + + Needle shuttle out of sync + + + + + Rotation out of sync + + + + + The scissors are not returning to their original position + + + + + + Machine head not in high position + + + + + Machine head not in low position + + + + + Light curtain intervention + + + + + + Broken surface thread + + + + + Bottom line disconnection + + + + + + Head lifting timeout + + + + + + Replacing the shuttle core + + + + + Abnormal feeding pressure roller + + + + + Abnormal discharge pressure roller + + + + + Abnormal discharge and pressing + + + + + Tensioning device abnormal + + + + + Abnormal cloth clamping device + + + + + Edge cutting motor blocked + + + + + Cross cutting motor abnormality + + + + + Password set successfully + + + + + Password setting failed + + + + + Needle motor alarm + + + + + Shuttle motor alarm + + + + + X motor alarm + + + + + Y motor alarm + + + + + Needle motor reset failed + + + + + Shuttle motor reset failed + + + + + X motor reset failed + + + + + Y motor reset failed + + + + + Slave board communication timeout + + + + + X motor not in zero position + + + + + The safety door is not closed + + + + + The machine head is not in a safe area + + + + + Template not in place + + + + + Para + + + + + Starting angle of sewing frame + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + AllSpleJogs + + + + + N/S_Proof + + + + + AMShaftRun + + + + + Setting + + + + + Authorize + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Jog button 1 + + + + + Open frame button 1 + + + + + Manual operation button 1 + + + + + Be ready button 1 + + + + + Key button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + Template in position 1 + + + + + Template in position 2 + + + + + MOTOR_ALM1 + + + + + MOTOR_ALM9 + + + + + MOTOR_ALM17 + + + + + MOTOR_ALM25 + + + + + MOTOR_ALM33 + + + + + MOTOR_ALM41 + + + + + X zero position + + + + + Y zero position + + + + + X deceleration + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Sewing machine head 2 lifting upper limit + + + + + Sewing machine head 3 lifting upper limit + + + + + Sewing machine head 4 lifting upper limit + + + + + Lower lifting limit of sewing machine head 0 + + + + + Lower lifting limit of sewing machine head 1 + + + + + Lower lifting limit of sewing machine head 2 + + + + + Lower lifting limit of sewing machine head 3 + + + + + Moving up motor limit on head 1 + + + + + Moving down motor limit on head 1 + + + + + Sewing needle parking space 1 + + + + + Sewing needle parking space 2 + + + + + Sewing needle parking space 3 + + + + + Embroidery spindle zero position 9 + + + + + Embroidery spindle zero position 10 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing shuttle 2- parking space + + + + + Sewing shuttle 3- parking space + + + + + Sewing shuttle 4- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + Sewing machine head 3 - surface thread breakage inspection + + + + + Sewing machine head 4 - surface thread breakage inspection + + + + + Sewing thread trimming return 1 + + + + + Sewing thread trimming return 2 + + + + + Sewing thread trimming return 3 + + + + + Sewing thread trimming return 4 + + + + + GLOBAL + + + Language + + + + + Year + + + + + Month + + + + + Day + + + + + Hour + + + + + Minute + + + + + Second + + + + + Server IP settings + + + + + Server port settings + + + + + Local IP settings + + + + + Local port settings + + + + + Resolution + + + + + Communication method + + + + + Network:0;SerialPort:1 + + + + + Machine type + + + + + 001 McHighSingleQui:0;002 FiveHeadPrecisionSewing:1;003 ClothingMac:2;004 multineedlerotary:3 + + + + + Whether there is a Automatic shuttle change function + + + + + Is there a Richpeace logo + + + + + Product type + + + + + Chinese:0;English:1 + + + + + ProductNull: + + + + + Parameter is classified + + + + + HMI decrypt + + + + + Gateway connection method + + + + + Serial port:0; Network port:1 + Serial port1:0;Serial port2:1;Network port:2 + + + + + Input rack number + + + + + Network settings + + + + + Factory expects delivery time + + + + + Debugging progress + + + + + HeadSpacingSheetDialog + + + Dialog + + + + + PageNums: 0/0 + + + + + Sub title + + + + + Sub title < Title + + + + + pageNum: + + + + + PageNum: 0/0 + + + + + + + + Prompt + + + + + + USB flash drive is not detected! + + + + + Export successful + + + + + Import successful! + + + + + HighSingleQui + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + % + + + + + Step size + + + + + Reinforcement method + + + + + Tight locking:0;Reinforced locking:1 + + + + + Reinforcement needles + + + + + pin + + + + + Reinforcement frequency + + + + + Angle correction offset + + + + + Angle correction x positive + + + + + Angle correction x negative + + + + + Angle correction y positive + + + + + Angle correction y negative + + + + + Left + + + + + Front + + + + + Automatic shuttle changing device + + + + + + + + + + No:0;Have:1 + + + + + Infrared device + + + + + + + + + Normally closed:0;Normally open:1 + + + + + Pneumatic device + + + + + Power-on device + + + + + Safety door device + + + + + Manual and automatic button device + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + X Sewing area Positive margin + + + + + Y Sewing area Negative boundary + + + + + Y Sewing area Positive margin + + + + + Encoder coefficient molecule + + + + + Zero tangent distance + + + + + Feeding device + + + + + Crosscutting device + + + + + Cloth clamping device + + + + + Tensioning device + + + + + Edge cutting device + + + + + sewing work speed + + + + + + + + r/min + + + + + Spindle Back needle speed + + + + + Sewing moving frame + + + + + Continuous:0;Intermittent:1 + + + + + Sewing acceleration and deceleration mode + + + + + No acceleration or deceleration:0;Xy sine acceleration and deceleration:1 + + + + + Sewing machine head rotating manner + + + + + Continuous rotation:0;Xy intermittent rotation:1 + + + + + Sewing head deceleration mode + + + + + No acceleration or deceleration:0;Intermittent acceleration and deceleration:1 + + + + + + + + + + + Not allow:0;Allowed:1 + + + + + Cut lines allow + + + + + Equal ratio + + + + + Thread loosening is allowed during thread cutting + + + + + During thread cutting, the stay wire is allowed + + + + + Thread clamping is allowed during thread cutting + + + + + It is allowed to lift the presser foot during thread trimming + + + + + Lifting machine head thread cutting is allowed during thread cutting + + + + + The thread clamping of the lifting head is allowed during thread cutting + + + + + It is allowed to hook the thread at the foot of the presser during thread cutting + + + + + Needle withdrawal allowed during thread trimming + + + + + Buckle the thread allowed during thread trimming + + + + + Number of broken wires + + + + + + Needles + + + + + Change bobbin Reminder function + + + + + Not:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bottom line length + + + + + Number of shuttles + + + + + times + + + + + Refueling method selection + + + + + No:0; According to working hours:1; According to the number of working stitches:2; Persistent refueling:3 + + + + + Refueling needles interval + + + + + Refueling duration + + + + + + + s + + + + + Parking position selection after completion + + + + + Current:0;Starting:1;Anchor:2;Feeding:3;Offset:4 + + + + + Offset point coordinate valid flag + + + + + + Invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate effective mark + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Trimming frame displacement + + + + + Automatic threading back point is allowed during sewing + + + + + Lifting and lowering of frame crossing machine head in sewing room + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Frame moving and automatic frame pressing allowed + + + + + Allowed to move frame and thread + + + + + Software limit XY move allowed + + + + + Thread trimming moving frame direction + + + + + Fixed frame:0;Left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Auto Zero after power on + + + + + Automatic drawing is allowed + + + + + The opposite side is allowed when feeding + + + + + Allowing distribution during feeding + + + + + Medium cutting is allowed during feeding + + + + + During feeding, it is allowed to cut across the edge + + + + + The thread loosening is allowed when the head is lifting + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe input emergency door allowed + + + + + Manual and automatic safe input + + + + + Loop work allowed + + + + + Shuttle refueling duration + + + + + + Replace the punch count value + + + + + Starting angle of sewing frame + + + + + Trimming completion angle + + + + + Spindle parking sensor angle + + + + + Spindle thread cutting speed + + + + + Enable + + + + + Disable + + + + + JogP + + + + + JogN + + + + + Zero + + + + + Open + + + + + Close + + + + + X to move motor + + + + + Y to move motor + + + + + Spindle motor + + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + + + + + Lower scissors to cut thread + + + + + Buckle the bottom line + + + + + Elastic thread + + + + + oil + + + + + headlamp + + + + + Sewing machine head lifting + + + + + Sandwich line + + + + + Shuttle changing device grabbing + + + + + Shuttle changer swing + + + + + Shuttle changer rotation + + + + + Sewing Blow + + + + + AllToZero + + + + + BackThread + + + + + BackOffset + + + + + BackZero + + + + + CountReset + + + + + OutputReset + + + + + NeedZeroPos + + + + + ShutZeroPos + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + SoftwareSet + + + + + Authorization + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Select + + + + + Para + + + + + Width + + + + + Height + + + + + Allow for needle starting and thread loosening + + + + + Needle and thread clamping allowed + + + + + Do not trim:0;Automatic thread trim:1;Finally trim:2;Data trim:3 + Do not trim: 0;Automatic thread trim:1;Finally trim:2;Data trim:3 + + + + + Sewing speed reduction mode + + + + + Auto:0;Param:1;Not:2 + + + + + Front_Back + + + + + N/S_Proof + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ImportHPGL + + + Encrypted file parsing error! + + + + + MainWidget + + + Richpeace Embroidery Control System + 富怡绣花控制系统 + + + + + XPlatForm-RP-HMI-L1910-V210713 + + + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + PatternSet + + + + + Pattern + 花样设置 + + + + + Assist + 辅助功能 + + + + + ParaSet + 参数设定 + + + + + Shortcut + 快捷功能 + + + + + Main + 主界面 + + + + + 4999 + + + + + + + Not connected + Status:Not connected + 状态 + + + + + 2021/03/08 8:37:16 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + assist + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + shortcut + + + + + Forward or back + 快进快退 + + + + + + + + + + + + + + + + + + labelParaType + + + + + Init windows... + + + + + Init communication... + + + + + Richpeace Quilting Control System + + + + + Quilting Control System + + + + + FileName + + + + + Index + + + + + StartPoint + + + + + LocatePoint + + + + + Range + + + + + Position + + + + + Production + + + + + + Connected + Status:Connected + + + + + Connnecting... + Status:Connnecting... + + + + + Pattern selection + + + + + Pattern setting > Pattern selection + + + + + Sensor signal + + + + + Auxiliary function > Sensor signal + + + + + Control action + + + + + Auxiliary function > Control action + + + + + + Accessibility + + + + + Accessibility > Software setting + + + + + Accessibility > Network Manage + + + + + Time setting + + + + + Accessibility > Time setting + + + + + Spindle test + + + + + Accessibility > Spindle test + + + + + + + Root + + + + + + + Accessibility > Root + + + + + Pattern import + + + + + Pattern setting > Pattern import + + + + + Pattern export + + + + + Pattern setting > Pattern export + + + + + Pattern delete + + + + + Pattern setting > Pattern delete + + + + + Normal operation + + + + + Ready + Status:Ready + + + + + Working + Status: Working + + + + + Simulated sewing + + + + + Undefined error, + + + + + + Pattern para + + + + + Pattern setting > Head spacing + + + + + Pattern setting > Pattern para + + + + + Prompt + + + + + Loading patterns, please wait... + + + + + Setting workable area + + + + + + + Parameter setting + + + + + Limit parameter + + + + + Speed control parameters + + + + + Action settings + + + + + Operating parameters + + + + + Machine parameters + + + + + Parameter setting > + + + + + Parameter setting > Parameter setting + + + + + MainWidgetFunction + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Prompt + + + + + + + + USB flash drive is not detected! + + + + + The program is corrupted, please re-upgrade after replacing the program! + + + + + The file format is wrong, please select again! + + + + + File bytes are 0, please check the file! + + + + + + File size not match, invalid file! + + + + + Data check error, invalid file! + + + + + Parameters imported successfully! + + + + + File head not match, invalid file! + + + + + Parameter Import + + + + + Auxiliary Function > Parameter Import + + + + + + + + MC Upgrade + + + + + Auxiliary Function > MC Upgrade + + + + + + ssid is empty! + + + + + + Settings require screen restart to take effect! + + + + + IP input + + + + + Whether to exit the program? + + + + + HMI Upgrade + + + + + Auxiliary Function > HMI Upgrade + + + + + Parameters exported successfully! + + + + + All to zero + + + + + + + + + + + + + + + + + + + + + + + + + The machine is about to move, please pay attention to safety! + + + + + + All to reset + + + + + Whether to reset the output? + + + + + If all process to reset? + + + + + Spindle jog + + + + + Spindle rotate angle + + + + + Back work point + + + + + Back to origin + + + + + Set start point + Set embroidery point + + + + + + Whether to set the current point as the start point? + + + + + Back anchor point + + + + + Back embroidery point + + + + + Set offset point + + + + + Whether to set the current point as the offset point? + + + + + Back offset point + + + + + Border check + + + + + Password input + + + + + Whether to set to change a shuttle automatically? + + + + + The machine is about to cut the thread, please pay attention to safety! + + + + + Lower cutter + + + + + The scissors are about to move, please pay attention to safety! + + + + + Trim + + + + + Failed to initialize wlan0! + + + + + Failed to search for WiFi list. Please try again later! + + + + + dynamic + + + + + static + + + + + Failed to obtain IP. Please check the settings! + + + + + WIFI + + + + + Auxiliary Function > WIFI + + + + + Simulate frame + + + + + Process reset + + + + + The machine is about to reset, please pay attention to safety! + + + + + Manual oil + + + + + The machine is about to oil! + + + + + Goto zero pos + + + + + Set work range + + + + + If automatically set work range? + + + + + Bottom line detection + + + + + Face line detection + + + + + Exit successfully! + + + + + Shuttle count reset + Shuttle change + + + + + The machine is about to change the shuttle automatically! + + + + + System info + + + + + Production statistics + + + + + Auxiliary Function > Production statistics + + + + + Error Log + + + + + Auxiliary Function > Error Log + + + + + Breakage Log + + + + + Auxiliary Function > Breakage Log + + + + + ErrorLog + + + + + Auxiliary Function > ErrorLog + + + + + No connection + + + + + Warrant + + + + + Setting workable area + + + + + Debug Info + + + + + Auxiliary Function >Debug Info + + + + + Is the bottom line count reset? + + + + + Are you sure to ManualSwitch? + + + + + Are you sure to AutoSwitch? + + + + + Total number of patterns processed: + + + + + Total number of embroidery: + + + + + Pattern name: + + + + + Pattern break line num: + + + + + Head + + + + + break line num: + + + + + Day + + + + + Hour + + + + + Minutes + + + + + The remaining available time of the machine is + + + + + Undefined error, + + + + + Failed to upgrade the main control system! + + + + + The main control system has been successed, waiting until machine restart + + + + + System will restart %1 s later + + + + + Main control system is being upgraded... + + + + + Failed to send data file! + + + + + The data file is send successfully! + + + + + Data file sending... + + + + + Journal exported successfully! + + + + + Journal exported failed! + + + + + Password input * + + + + + Password input ** + + + + + Password input **** + + + + + + + The password is wrong,please re-enter! + + + + + reset parameters password successfully logged in! + + + + + HMI decrypt + + + + + The interface program is licensed, and then take effect after restarting, please restart manually! + + + + + Password error, interface program authorization failed! + + + + + Is the version restored? + + + + + Modify the first level password + + + + + The two passwords are inconsistent! + + + + + Password reset complete! + + + + + Do you delete the configuration file? + + + + + The settings take effect after restarting the interface! + + + + + Import csv file successful! + + + + + Do you delete the csv file? + + + + + Reset succeeded! + + + + + Whether to enter debug mode? + + + + + whether to exit debug mode? + + + + + Please log in to super user again! + + + + + Is the pattern clear? + + + + + Delete complete! + + + + + Simulated sewing + + + + + Whether to switch working status + + + + + Manual thread cutting + + + + + makeup sewing + + + + + Head lifting and lowering + + + + + Head lifting + + + + + Set anchor point + + + + + Back shuttle pos + + + + + Needle shuttle adjust + + + + + Whether to shut down the computer? + + + + + AllSpindleZeroPositions + + + + + AllSpindleHookLines + + + + + AllSpindleJogs + + + + + NeedleShuttleProofreading + + + + + AllMainShaftRun + + + + + McHeadDialog + + + Dialog + + + + + + + + + + + + PushButton + + + + + MultiNeedleRotary + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + startX + + + + + + + + mm + + + + + startrY + + + + + + + r/min + + + + + Sewing main shaft working speed + + + + + Main shaft zero reset speed + + + + + Main shaft running speed + + + + + + XY zero reset speed + + + + + + + + + mm/s + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + Work head selection 1 + + + + + + Not allow:0;allowed:1 + + + + + Work head selection 2 + + + + + Production preset + + + + + + No. of stitch detect if thread broken + + + + + Needle + + + + + + Bobbin thread length + + + + + Bobbin change reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe door allowed + + + + + X to move motor + + + + + Y to move motor + + + + + All spindle zero positions + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + Setting + + + + + Authorize + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Para + + + + + Select + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Jog button 1 + + + + + Open frame button 1 + + + + + NumerInputDialog + + + Dialog + + + + + C + + + + + (0~3000)rmp + + + + + Number input + + + + + ← + + + + + ParameterSetDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + Sub title + + + + + Sub title < Title + + + + + Repetitions + + + + + + pageNum: + + + + + HMI Configuration + + + + + Root > HMI Configuration + + + + + IOT Configuration + + + + + Root > IOT Configuration + + + + + Network Settings + + + + + IOT Configuration > Network Settings + + + + + Machine parameters + + + + + Root > Machine parameters + + + + + Work parameters + + + + + Root > Work parameters + + + + + Repetitions : 0 + + + + + Server IP settings + + + + + Server Port settings + + + + + + Local IP settings + + + + + Local Port settings + + + + + Board IP settings + + + + + + + Root + + + + + + + Accessibility > Root + + + + + Board port settings + + + + + Local port settings + + + + + + + + + + Network error + + + + + Input + + + + + + + read parameter... + + + + + + + No connection + + + + + + + + + + + Prompt + + + + + + The settings take effect after restarting the interface! + + + + + + Network settings are completed, re-establish after reboot + + + + + The time setting is completed and will take effect after restart + + + + + Unreasonable time setting, please reset + + + + + Time setting failed, please reset + + + + + Connection mode changes, take effect after the reboot! + + + + + Whether to recover the default parameters for the board? + + + + + PassWordDialog + + + Dialog + + + + + Password + + + + + 9 + + + + + 1 + + + + + 2 + + + + + ← + + + + + 3 + + + + + 6 + + + + + 8 + + + + + C + + + + + 0 + + + + + 5 + + + + + 7 + + + + + 4 + + + + + Prompt + + + + + IP settings are unreasonable! + + + + + PatternManageWidget + + + Form + + + + + PageNums: 0/0 + + + + + Sub title < Title + + + + + Sub title + + + + + + 1000.0 + + + + + W + + + + + 500.0 + + + + + 999 + + + + + H + + + + + 1000000 + + + + + Y + + + + + X + + + + + 800.0 + + + + + dst + + + + + C + + + + + N + + + + + pageNum: + + + + + + + + + + Prompt + + + + + Over 1.28 million stitches, can not be imported! + + + + + Format error, can not be imported! + + + + + This file already exists! + + + + + Rename + + + + + Importing + + + + + Exporting + + + + + Import complete + + + + + Export complete + + + + + USB flash drive is not detected! + + + + + Whether to delete the pattern? + + + + + Operation screen + + + + + USB + + + + + + + Pattern Import + + + + + + + Pattern Import < Pattern setting + + + + + Pattern Export + + + + + Pattern Export < Pattern setting + + + + + new folder + + + + + This folder already exists! + + + + + PatternSelectWidget + + + Form + + + + + Name: + 花样名: + + + + + N + + + + + H + C + + + + + W + + + + + + X + + + + + + Y + + + + + Width + + + + + NeedleNum + + + + + Name + + + + + Height + + + + + Pattern Select + 花样选择 + + + + + Pattern Select < Pattern Setting + 花样选择 < 花样设置 + + + + + PageNums: 0/0 + + + + + PageNum: 0/0 + + + + + pageNum: + + + + + Prompt + + + + + The number of stitches of the selected pattern has reached the upper limit (2 million stitches), and it cannot be embroidered! + + + + + PromptDialog + + + Dialog + + + + + Prompt + + + + + ID: + + + + + Password: + 密码: + + + + + ID + + + + + DecryptInfo + + + + + DecryptInfo: + 解密信息: + + + + + Spindle angle: + 主轴角度: + + + + + deg + + + + + + New Password: + 密码: + + + + + Confirm Password: + 解密信息: + + + + + X + + + + + + X - + + + + + Y + + + + + + Y - + + + + + Board + + + + + Build Time: + + + + + Unlimited time + + + + + Time has run out + + + + + Day + + + + + Hour + + + + + Minutes + + + + + ID: %1 + + + + + + Password: %1 + + + + + + Time: %1 + + + + + Warrant + + + + + HMI decrypt + + + + + Spindle angle rotation + + + + + New Password input + + + + + Confirm Password input + + + + + QObject + + + (0x0002)Insufficient air pressure + Insufficient air pressure + + + + + (0x0003)safe area error + safe area error + + + + + (0x0004)Expiration of use + Expiration of use + + + + + (0x0005)Driver alarm + Driver alarm + + + + + (0x0006)Fill data error + Fill data error + + + + + (0x0007)Not allowed to work + Not allowed to work + + + + + (0x0008)Control error + Control error + + + + + (0x0009)Motion control chip version error + Motion control chip version error + + + + + (0x000A)Waiting for button to lift timeout + Waiting for button to lift timeout + + + + + (0x000B)FPGA Reset + FPGA Reset + + + + + (0x000C)Peripheral Device not ready + Peripheral Device not ready + + + + + (0x000D)Transmission data error + Transmission data error + + + + + (0x000E)Program version error + Program version error + + + + + (0x000F)Complete output + Complete output + + + + + (0x0010)Positive limit + Positive limit + + + + + (0x0011)Negative limit + Negative limit + + + + + (0x0012)Motion alarm + Motion alarm + + + + + (0x0013)Motion limit + Motion limit + + + + + (0x0014)Emergency stop + Emergency stop + + + + + (0x0015)Motion parameters error + Motion parameters error + + + + + (0x0016)Machine parameters error + Machine parameters error + + + + + (0x0017)Input parameters error + Input parameters error + + + + + (0x001A)Not in work status error + Not in work status error + + + + + (0x001B)Prohibited frame moving state + Prohibited frame moving state + + + + + (0x001F)Zero success + Zero success + + + + + (0x0020)Return to zero error + Return to zero error + + + + + (0x0021)Coordinate system error + Coordinate system error + + + + + (0x0022)Target position out of bounds + Target position out of bounds + + + + + (0x0023)X Positive limit + X Positive limit + + + + + (0x0024)X Negative limit + X Negative limit + + + + + (0x0025)Y Positive limit + Y Positive limit + + + + + (0x0026)Y Negative limit + Y Negative limit + + + + + (0x002B)Safety door error + + + + + (0x002C)Entering the light curtain 1 + Entering the light curtain 1 + + + + + (0x002D)Entering the light curtain 2 + Entering the light curtain 2 + + + + + (0x0040)None data + None data + + + + + (0x0041)Data error + Data error + + + + + (0x0042)Graphics out of range + Graphics out of range + + + + + (0x0050)Spindle is not in zero position + Spindle is not in zero position + + + + + (0x0051)Rotary hook is not in zero position + + + + + (0x0054)Scissors are not in position + Scissors are not in position + + + + + (0x0056)Nose not in low position + + + + + (0x0058)Thread is broken + Thread is broken + + + + + (0x0059)Bottom thread disconnected + Bottom thread disconnected + + + + + (0x005D)Execution command timed out + Execution command timed out + + + + + (0x005F)Head lifting timeout + + + + + (0x00F0)Change the bobbin + Change the bobbin + + + + + (0x00F1)Replace bobbin A + Replace bobbin A + + + + + (0x00F2)Replace bobbin B + Replace bobbin B + + + + + (0x00F3)The machine is in the state of replacing the bobbin + The machine is in the state of replacing the bobbin + + + + + (0x002E)Insufficient air pressure + + + + + Normal stop + (0x0100)Normal stop + + + + + Find zero success + (0x0101)Find zero success + + + + + work pause + (0x0102)work pause + + + + + End of work + (0x0103)End of work + + + + + Work done + (0x0104)Work done + + + + + Complete production + (0x0105)Complete production + + + + + (0x0106)Execute success + Execute success + + + + + (0x0107)Execute false + Execute false + + + + + (0x0108)wait file + wait file + + + + + (0x0109)change the bobbin + change the bobbin + + + + + (0x010A)Execute finish + Execute finish + + + + + (0x010B)Execute runnibng + Execute runnibng + + + + + Enable + + + + + Disable + + + + + JogP + + + + + JogN + + + + + Turn + + + + + Zero + + + + + Open + + + + + Close + + + + + Ascending + + + + + descending + + + + + Trim + + + + + SensorInputWidget + + + Form + + + + + + Sensor + + + + + PageNums: 1/1 + + + + + pageNum: + + + + + SetWorkArea + + + Form + + + + + Prompt + + + + + X + + + + + + X - + + + + + Y + + + + + + Y - + + + + + SystemManageDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + + Update + + + + + 192.168.2.196 + + + + + StaticIP + + + + + DynamicIP + + + + + *Before setting the static IP, you need to first set the dynamic IP. After the dynamic IP is set, you need to return to this interface to continue setting the static IP + 设置静态IP前需要先设置动态IP,动态IP设置完成后需要返回此界面继续设置静态IP + + + + + pageNum: 0/0 + + + + + pageNum: + + + + + + + + Prompt + + + + + The upgrade needs to restart the program. Do you need to restart to upgrade? + + + + + Do you want to clear the production statistics? + + + + + Do you want to clear the journal? + + + + + Do you want to export journal? + + + + + WordsInputDialog + + + Dialog + + + + + Words input + + + + + Name: + + + + + ← + + + + + old + + + + diff --git a/english.qm b/english.qm new file mode 100644 index 0000000..be651ee --- /dev/null +++ b/english.qm @@ -0,0 +1 @@ + + + + + BrokenLineDialog + + + Form + + + + + + 1 + + + + + Broken Line Prompt + + + + + ClothingMac + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + Template recognition device + + + + + No device:0;Bar code:1;Coding hole:2;Multiple files:3 + + + + + X frame sensor coordinates + + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Y frame sensor coordinates + + + + + Spindle parking sensor angle + + + + + Lift sensor coordinates + + + + + Angle of spindle hook sensor + + + + + Spindle jog parking angle + + + + + X movable area negative boundary + + + + + X movable area positive boundary + + + + + Y movable area negative boundary + + + + + Y movable area positive boundary + + + + + X Sewing area negative boundary + + + + + X Sewing area positive boundary + + + + + Y Sewing area negative boundary + + + + + Y Sewing area positive boundary + + + + + XY start stop speed + + + + + + + + + + + mm/s + + + + + XY zero running speed + + + + + XY simulate running speed + + + + + XY movement acceleration + + + + + + mm/s2 + + + + + XY brake acceleration + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + XY maximum moving speed + + + + + Spindle start stop speed + + + + + + + + + + + + + + + + + r/min + + + + + Spindle zero reset speed + + + + + Spindle running speed + + + + + Spindle running acceleration + + + + + + + r/ss + + + + + Spindle brake acceleration + + + + + sewing maximum speed + + + + + Spindle zeroing compensation angle + + + + + X gap compensation + + + + + Y gap compensation + + + + + Sewing main shaft working speed + + + + + Spindle cutting speed + + + + + Spindle needle return speed + + + + + Spindle start slow speed + + + + + Reverse equivalent spindle speed + + + + + Sewing frame movement mode + + + + + XY continuous:0;XY intermittent:1 + + + + + Sewing frame start angle + + + + + Sewing frame steadiness angle + + + + + Slow stitch at beginning + + + + + + + Needle + + + + + Needle action, thread loosen allowed + + + + + + + + + + + + + + + + + + + + + + Not allow:0;allowed:1 + + + + + Needle action,tight bobbin spring allowed + + + + + Needle action, catch upper thread allowed + + + + + Cut thread allowed + + + + + Do not trim:0;Automatic:1;Last trimming:2;Data trimming:3 + + + + + Trimmer cutting angle + + + + + Trimming completion angle + + + + + Thread cut, upper thread loosen allowed + + + + + Thread cut, tensile thread allowed + + + + + Thread cut, catch upper thread allowed + + + + + Thread cut, presser foot lift allowed + + + + + Stitch detect if thread broken + + + + + Thread brake detection, main shaft angle + + + + + Bobbin change reminder function + + + + + Not enabled: 0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bobbin thread length + + + + + Bobbin thread correction per stitch + + + + + Bobbin change as per sewed pieces + + + + + + times + + + + + Oiling mode selection + + + + + No oil:0;Oiling by time:1;Oiling by stitches:2;Oiling continously:3 + + + + + Oiling interval by needle stitch + + + + + Oiling interval by working time + + + + + + + s + + + + + Needle Oiling sustained time + + + + + Stop position selection after work complete + + + + + Current:0;Start:1;Anchor:2;Feeding:3;Offset:4 + + + + + Valid flag for offset point coordinates + + + + + + invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate valid symbol + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Delay after pneumatic frame off + + + + + Sewing acceleration + + + + + Trimming frame displacement + + + + + Automatic move to threading point allowed + + + + + Large presser foot action allowed + + + + + Sewing move head up down + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Software limit XY move allowed + + + + + Number of Needle hooks + + + + + Trimming frame direction + + + + + No:0;left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Early speed reduction + + + + + Delayed speed step + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Pneumatic frame off + + + + + + Penumatic frame on + + + + + ms + + + + + Loop work allowed + + + + + Shuttle Oiling sustained time + + + + + Sewing operation speed 1 + + + + + Sewing operation speed 2 + + + + + Sewing operation speed 3 + + + + + Change the sewing needle count value + + + + + Enable + + + + + Disable + + + + + JogP + + + + + JogN + + + + + Zero + + + + + Open + + + + + Close + + + + + Up + + + + + Down + + + + + Extend + + + + + Back + + + + + Combine + + + + + Separate + + + + + X to move motor + + + + + Y to move motor + + + + + Spindle motor + + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + + + + + Frame + + + + + Big foot + + + + + Middle foot + + + + + Buckle the bottom line + + + + + Top and bottom lines + + + + + Lower scissors to cut thread + + + + + Sandwich line + + + + + Elastic thread + + + + + Elastic thread 2 + + + + + Laser control + + + + + Laser blow + + + + + Oil + + + + + Headlamp + + + + + Sewing Blow + + + + + Hookline ext + + + + + Hookline open and close + + + + + Sewing machine head lifting + + + + + Spindle clutch + + + + + Pen + + + + + All to zero + + + + + Needle shuttle reset + + + + + Back thread + + + + + Back offset + + + + + Back shuttle + + + + + Back work + + + + + Set anchor + + + + + Back anchor + + + + + + Back start + + + + + Forwrak or back + + + + + Bottom count reset + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + SoftwareSet + + + + + Authorization + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Select + + + + + Para + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ControlActionWidget + + + Form + + + + + Control action + 控制动作 + + + + + Control action < Auxiliary function + 控制动作 < 辅助功能 + + + + + PageNums: 1/1 + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PushButton + + + + + pageNum: + + + + + The machine is about to move, please pay attention to safety! + + + + + All to zero + + + + + DebugInfoDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + DebugInfo: + + + + + pageNum: 0/0 + + + + + pageNum: + + + + + FileSelectDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + pageNum: + + + + + FiveHeadPrecisionSewing + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + + + + + + + + + + + + + + + + + + + mm + + + + + Left + + + + + Front + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + Y Sewing area Negative boundary + + + + + sewing work speed + + + + + + r/min + + + + + Bobbin thread length + Bottom line length + + + + + Refueling method selection + + + + + Head 4 shuttle refueling + Refueling needles interval + + + + + Refueling duration + + + + + Production preset + + + + + Sewing machine head 2 - surface thread breakage inspection + Thread trimming moving frame direction + + + + + Pin 1 motor + + + + + Allow for needle starting and thread loosening + + + + + Allow for loose thread during thread cutting + + + + + Allow needle withdrawal during thread cutting + + + + + Automatically thread back points during sewing + + + + + Allow for loose lines when moving boxes + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + Shuttle 1 motor + + + + + Spindle 2 motor + + + + + Pin 2 motor + + + + + Shuttle 2 motor + + + + + Spindle 3 motor + + + + + Pin 3 motor + + + + + Shuttle 3 motor + + + + + Spindle 4 motor + + + + + Pin 4 motor + + + + + Spindle 5 motor + + + + + Pin 5 motor + + + + + Shuttle 5 motor + + + + + Head 1 Elastic thread + + + + + Head 2 Elastic thread + + + + + Head 3 Elastic thread + + + + + Head 4 Elastic thread + + + + + Head 5 Elastic thread + + + + + Head 1 blow + + + + + Head 2 blow + + + + + Head 3 blow + + + + + Head 4 blow + + + + + Head 5 blow + + + + + Head 1 trim + + + + + Head 2 trim + + + + + Head 3 trim + + + + + Head 4 trim + + + + + Head 5 trim + + + + + Head 1 needle refueling + + + + + Head 2 needle refueling + + + + + Head 3 needle refueling + + + + + Head 4 needle refueling + + + + + Head 5 needle refueling + + + + + Head 1 shuttle refueling + + + + + Head 2 shuttle refueling + + + + + Head 3 shuttle refueling + + + + + Head 5 shuttle refueling + + + + + Head 1 lifting + + + + + Head 2 lifting + + + + + Head 3 lifting + + + + + Head 4 lifting + + + + + Head 5 lifting + + + + + X Sewing area positive boundary + + + + + Y Sewing area positive boundary + + + + + Zero position coordinate of head 2 + + + + + Zero position coordinate of head 3 + + + + + Zero position coordinate of head 4 + + + + + Zero position coordinate of head 5 + + + + + Sewing motion frame method + + + + + Xy continuous moving box:0;Xy intermittent moving frame:1 + + + + + Thread cutting allowed + + + + + No. of stitch detect if thread broken + Number of thread breakage detection needles + + + + + Bobbin change reminder function + Change shuttle core reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + do not enable this feature:0;Count delay reminders by length:1;Count by number of pieces:2;Prompt immediately based on length:3 + + + + + Count of shuttle change pieces + + + + + Times + + + + + not refueling:0;Intermittent refueling according to worktime:1;Intermittent refueling according to the number of working stitches:2;Continuously refueling:3 + + + + + Interval between refueling stitches + + + + + + + second + + + + + Cutting and parting angle + + + + + Thread trimming completion angle + + + + + Software limit: xy movement + + + + + Automatic sewing speed regulation + Sewing speed reduction mode + + + + + Circular working function + + + + + Duration of shuttle refueling + + + + + Sewing and blowing time + + + + + Sewing hook angle + + + + + Continuous angle of sewing frame + + + + + Zero All + + + + + X to move motor + + + + + Y to move motor + + + + + Head moving motor + + + + + All spindle zero positions + + + + + Spindle 1 motor + Spindle motor + + + + + Shuttle 4 motor + Shuttle motor + + + + + Lock frame cylinder + + + + + Flap control + + + + + Barcode testing + + + + + AllSpleHook + AllSpindleJogs + + + + + Spindle thread cutting speed + + + + + Allowing for wire clamping during wire cutting + + + + + Number of stitches for surface thread clamping + + + + + Head 1 ThreadCuttingAction + + + + + Head 2 ThreadCuttingAction + + + + + Head 3 ThreadCuttingAction + + + + + Head 4 ThreadCuttingAction + + + + + Head 5 ThreadCuttingAction + + + + + Head 1 Clamp wire + + + + + Head 2 Clamp wire + + + + + Head 3 Clamp wire + + + + + Head 4 Clamp wire + + + + + Head 5 Clamp wire + + + + + MU_Canl + makeupCanl + + + + + Makeup1 + makeup1 + + + + + Makeup2 + makeup2 + + + + + Makeup3 + makeup3 + + + + + Makeup4 + makeup4 + + + + + Makeup5 + makeup5 + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + ThCutAct1 + + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Coordinate of threading point X + + + + + Coordinate of threading point Y + + + + + ThCutAct2 + + + + + ThCutAct3 + + + + + ThCutAct4 + + + + + ThCutAct5 + + + + + SetStart + + + + + ProcReset + + + + + Simulate + + + + + HeadLifting + + + + + GoFeedt + + + + + Back start + + + + + Select + + + + + X negative limit + + + + + Y negative limit + + + + + freedom from error + + + + + Not powered on + + + + + + Insufficient air pressure + + + + + + Safe Area Intervention + + + + + + The usage deadline has expired + + + + + Filling data error + + + + + + Working status not allowed + + + + + control error + + + + + Motion control chip version error + + + + + Waiting for button to lift timeout + + + + + FPGA reset error + + + + + Peripheral not ready + + + + + Transmission data error + + + + + Program version error + + + + + Production completed + + + + + forward limit + + + + + Reverse limit + + + + + Motion alarm + + + + + Motion limit + + + + + Exercise emergency stop + + + + + + Motion parameter error + + + + + + Machine parameter error + + + + + + Input parameter error + + + + + The file is correct + + + + + Waiting for files + + + + + Zero successfully + + + + + Zero error + + + + + + Coordinate system error + + + + + + Target position out of range + + + + + + X forward limit + + + + + + X reverse limit + + + + + + Y forward limit + + + + + + Y reverse limit + + + + + + No Data + + + + + data error + + + + + + Spindle not in zero position + + + + + + Rotary shuttle not in zero position + + + + + Needle shuttle out of sync + + + + + Rotation out of sync + + + + + The scissors are not returning to their original position + + + + + + Machine head not in high position + + + + + Machine head not in low position + + + + + Light curtain intervention + + + + + + Broken surface thread + + + + + Bottom line disconnection + + + + + + Head lifting timeout + + + + + + Replacing the shuttle core + + + + + Abnormal feeding pressure roller + + + + + Abnormal discharge pressure roller + + + + + Abnormal discharge and pressing + + + + + Tensioning device abnormal + + + + + Abnormal cloth clamping device + + + + + Edge cutting motor blocked + + + + + Cross cutting motor abnormality + + + + + Password set successfully + + + + + Password setting failed + + + + + Needle motor alarm + + + + + Shuttle motor alarm + + + + + X motor alarm + + + + + Y motor alarm + + + + + Needle motor reset failed + + + + + Shuttle motor reset failed + + + + + X motor reset failed + + + + + Y motor reset failed + + + + + Slave board communication timeout + + + + + X motor not in zero position + + + + + The safety door is not closed + + + + + The machine head is not in a safe area + + + + + Template not in place + + + + + Para + + + + + Starting angle of sewing frame + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + AllSpleJogs + + + + + N/S_Proof + + + + + AMShaftRun + + + + + Setting + + + + + Authorize + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Jog button 1 + + + + + Open frame button 1 + + + + + Manual operation button 1 + + + + + Be ready button 1 + + + + + Key button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + Template in position 1 + + + + + Template in position 2 + + + + + MOTOR_ALM1 + + + + + MOTOR_ALM9 + + + + + MOTOR_ALM17 + + + + + MOTOR_ALM25 + + + + + MOTOR_ALM33 + + + + + MOTOR_ALM41 + + + + + X zero position + + + + + Y zero position + + + + + X deceleration + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Sewing machine head 2 lifting upper limit + + + + + Sewing machine head 3 lifting upper limit + + + + + Sewing machine head 4 lifting upper limit + + + + + Lower lifting limit of sewing machine head 0 + + + + + Lower lifting limit of sewing machine head 1 + + + + + Lower lifting limit of sewing machine head 2 + + + + + Lower lifting limit of sewing machine head 3 + + + + + Moving up motor limit on head 1 + + + + + Moving down motor limit on head 1 + + + + + Sewing needle parking space 1 + + + + + Sewing needle parking space 2 + + + + + Sewing needle parking space 3 + + + + + Embroidery spindle zero position 9 + + + + + Embroidery spindle zero position 10 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing shuttle 2- parking space + + + + + Sewing shuttle 3- parking space + + + + + Sewing shuttle 4- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + Sewing machine head 3 - surface thread breakage inspection + + + + + Sewing machine head 4 - surface thread breakage inspection + + + + + Sewing thread trimming return 1 + + + + + Sewing thread trimming return 2 + + + + + Sewing thread trimming return 3 + + + + + Sewing thread trimming return 4 + + + + + GLOBAL + + + Resolution + + + + + Language + + + + + Machine type + + + + + Product type + + + + + Year + + + + + Month + + + + + Day + + + + + Hour + + + + + Minute + + + + + Second + + + + + Communication method + + + + + Network:0;SerialPort:1 + + + + + Chinese:0;English:1 + + + + + Server IP settings + Gateway server IP settings + + + + + Server port settings + Gateway server port settings + + + + + Local IP settings + + + + + Local port settings + + + + + 001 McHighSingleQui:0;002 FiveHeadPrecisionSewing:1;003 ClothingMac:2;004 multineedlerotary:3 + + + + + ProductNull: + + + + + Whether there is a Automatic shuttle change function + + + + + Is there a Richpeace logo + + + + + Parameter is classified + + + + + HMI decrypt + + + + + Gateway connection method + + + + + Serial port:0; Network port:1 + Serial port1:0;Serial port2:1;Network port:2 + + + + + Input rack number + + + + + Network settings + + + + + Factory expects delivery time + + + + + Debugging progress + + + + + HeadSpacingSheetDialog + + + Dialog + + + + + PageNums: 0/0 + + + + + Sub title + + + + + Sub title < Title + + + + + pageNum: + + + + + PageNum: 0/0 + + + + + + + + Prompt + + + + + + USB flash drive is not detected! + + + + + Export successful + + + + + Import successful! + + + + + HighSingleQui + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + % + + + + + Step size + + + + + Reinforcement method + + + + + Tight locking:0;Reinforced locking:1 + + + + + Reinforcement needles + + + + + pin + + + + + Reinforcement frequency + + + + + Angle correction offset + + + + + Angle correction x positive + + + + + Angle correction x negative + + + + + Angle correction y positive + + + + + Angle correction y negative + + + + + Left + + + + + Front + + + + + Automatic shuttle changing device + + + + + + + + + + No:0;Have:1 + + + + + Infrared device + + + + + + + + + Normally closed:0;Normally open:1 + + + + + Pneumatic device + + + + + Power-on device + + + + + Safety door device + + + + + Manual and automatic button device + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + X Sewing area Positive margin + + + + + Y Sewing area Negative boundary + + + + + Y Sewing area Positive margin + + + + + Encoder coefficient molecule + + + + + Zero tangent distance + + + + + Feeding device + + + + + Crosscutting device + + + + + Cloth clamping device + + + + + Tensioning device + + + + + Edge cutting device + + + + + sewing work speed + + + + + + + + r/min + + + + + Spindle Back needle speed + + + + + Sewing moving frame + + + + + Continuous:0;Intermittent:1 + + + + + Sewing acceleration and deceleration mode + + + + + No acceleration or deceleration:0;Xy sine acceleration and deceleration:1 + + + + + Sewing machine head rotating manner + + + + + Continuous rotation:0;Xy intermittent rotation:1 + + + + + Sewing head deceleration mode + + + + + No acceleration or deceleration:0;Intermittent acceleration and deceleration:1 + + + + + + + + + + + Not allow:0;Allowed:1 + + + + + Cut lines allow + + + + + Equal ratio + + + + + Thread loosening is allowed during thread cutting + + + + + During thread cutting, the stay wire is allowed + + + + + Thread clamping is allowed during thread cutting + + + + + It is allowed to lift the presser foot during thread trimming + + + + + Lifting machine head thread cutting is allowed during thread cutting + + + + + The thread clamping of the lifting head is allowed during thread cutting + + + + + It is allowed to hook the thread at the foot of the presser during thread cutting + + + + + Needle withdrawal allowed during thread trimming + + + + + Buckle the thread allowed during thread trimming + + + + + Number of broken wires + + + + + + Needles + + + + + Change bobbin Reminder function + + + + + Not:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bottom line length + + + + + Number of shuttles + + + + + times + + + + + Refueling method selection + + + + + No:0; According to working hours:1; According to the number of working stitches:2; Persistent refueling:3 + + + + + Refueling needles interval + + + + + Refueling duration + + + + + + + s + + + + + Parking position selection after completion + + + + + Current:0;Starting:1;Anchor:2;Feeding:3;Offset:4 + + + + + Offset point coordinate valid flag + + + + + + Invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate effective mark + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Trimming frame displacement + + + + + Automatic threading back point is allowed during sewing + + + + + Lifting and lowering of frame crossing machine head in sewing room + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Frame moving and automatic frame pressing allowed + + + + + Allowed to move frame and thread + + + + + Software limit XY move allowed + + + + + Thread trimming moving frame direction + + + + + Fixed frame:0;Left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Auto Zero after power on + + + + + Automatic drawing is allowed + + + + + The opposite side is allowed when feeding + + + + + Allowing distribution during feeding + + + + + Medium cutting is allowed during feeding + + + + + During feeding, it is allowed to cut across the edge + + + + + The thread loosening is allowed when the head is lifting + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe input emergency door allowed + + + + + Manual and automatic safe input + + + + + Loop work allowed + + + + + Shuttle refueling duration + + + + + + Replace the punch count value + + + + + Starting angle of sewing frame + + + + + Trimming completion angle + + + + + Spindle parking sensor angle + + + + + Spindle thread cutting speed + + + + + Enable + + + + + Disable + + + + + JogP + + + + + JogN + + + + + Zero + + + + + Open + + + + + Close + + + + + X to move motor + + + + + Y to move motor + + + + + Spindle motor + + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + + + + + Lower scissors to cut thread + + + + + Buckle the bottom line + + + + + Elastic thread + + + + + oil + + + + + headlamp + + + + + Sewing machine head lifting + + + + + Sandwich line + + + + + Shuttle changing device grabbing + + + + + Shuttle changer swing + + + + + Shuttle changer rotation + + + + + Sewing Blow + + + + + AllToZero + + + + + BackThread + + + + + BackOffset + + + + + BackZero + + + + + CountReset + + + + + OutputReset + + + + + NeedZeroPos + + + + + ShutZeroPos + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + SoftwareSet + + + + + Authorization + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Select + + + + + Para + + + + + Width + + + + + Height + + + + + Allow for needle starting and thread loosening + + + + + Needle and thread clamping allowed + + + + + Do not trim:0;Automatic thread trim:1;Finally trim:2;Data trim:3 + Do not trim: 0;Automatic thread trim:1;Finally trim:2;Data trim:3 + + + + + Sewing speed reduction mode + + + + + Auto:0;Param:1;Not:2 + + + + + Front_Back + + + + + N/S_Proof + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ImportHPGL + + + Encrypted file parsing error! + + + + + MainWidget + + + Richpeace Embroidery Control System + 富怡绣花控制系统 + + + + + 2021/03/08 8:37:16 + + + + + + + + + + + + + + + + + + PatternSet + + + + + Assist + 辅助功能 + + + + + ParaSet + 参数设定 + + + + + Shortcut + 快捷功能 + + + + + Main + 主界面 + + + + + 4999 + + + + + XPlatForm-RP-HMI-L1910-V210713 + + + + + + + Root + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + shortcut + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + assist + + + + + Pattern + 花样设置 + + + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + labelParaType + + + + + Forward or back + 快进快退 + + + + + Init windows... + + + + + Init communication... + + + + + Connnecting... + Status:Connnecting... + + + + + + Connected + Status:Connected + + + + + + + Not connected + Status:Not connected + 状态 + + + + + Ready + Status:Ready + + + + + Working + Status: Working + + + + + + Pattern para + + + + + Prompt + + + + + Loading patterns, please wait... + + + + + Setting workable area + + + + + + + Parameter setting + + + + + Pattern selection + + + + + Pattern import + + + + + Pattern export + + + + + Pattern delete + + + + + Richpeace Quilting Control System + + + + + Quilting Control System + + + + + FileName + + + + + Index + + + + + StartPoint + + + + + LocatePoint + + + + + Range + + + + + Position + + + + + Production + + + + + Pattern setting > Pattern selection + + + + + Auxiliary function > Sensor signal + + + + + Auxiliary function > Control action + + + + + Accessibility > Software setting + + + + + Accessibility > Network Manage + + + + + Accessibility > Time setting + + + + + Accessibility > Spindle test + + + + + + + Accessibility > Root + + + + + Pattern setting > Pattern import + + + + + Pattern setting > Pattern export + + + + + Pattern setting > Pattern delete + + + + + Simulated sewing + + + + + Normal operation + + + + + Undefined error, + + + + + Pattern setting > Head spacing + + + + + Pattern setting > Pattern para + + + + + Limit parameter + + + + + Speed control parameters + + + + + Action settings + + + + + Operating parameters + + + + + Machine parameters + + + + + Parameter setting > + + + + + Parameter setting > Parameter setting + + + + + Sensor signal + + + + + Control action + + + + + + Accessibility + + + + + Time setting + + + + + Spindle test + + + + + MainWidgetFunction + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Prompt + + + + + + + + USB flash drive is not detected! + + + + + The program is corrupted, please re-upgrade after replacing the program! + + + + + The file format is wrong, please select again! + + + + + + File size not match, invalid file! + + + + + Data check error, invalid file! + + + + + Parameters imported successfully! + + + + + File head not match, invalid file! + + + + + Parameter Import + + + + + Auxiliary Function > Parameter Import + + + + + + + + MC Upgrade + + + + + Auxiliary Function > MC Upgrade + MC Upgrade < Auxiliary Function + + + + + Error Log + + + + + Auxiliary Function > Error Log + + + + + Breakage Log + + + + + Auxiliary Function > Breakage Log + + + + + Debug Info + + + + + Auxiliary Function >Debug Info + + + + + ErrorLog + + + + + Auxiliary Function > ErrorLog + + + + + + ssid is empty! + + + + + + Settings require screen restart to take effect! + + + + + IP input + + + + + Journal exported successfully! + + + + + Journal exported failed! + + + + + Password input * + + + + + Password input ** + + + + + Password input **** + + + + + reset parameters password successfully logged in! + + + + + Whether to exit the program? + + + + + Simulated sewing + + + + + Whether to switch working status + + + + + Manual thread cutting + + + + + makeup sewing + + + + + Head lifting and lowering + + + + + Head lifting + + + + + Set anchor point + + + + + Back shuttle pos + + + + + Needle shuttle adjust + + + + + AllSpindleZeroPositions + + + + + AllSpindleHookLines + + + + + AllSpindleJogs + + + + + NeedleShuttleProofreading + + + + + AllMainShaftRun + + + + + HMI Upgrade + + + + + Parameters exported successfully! + + + + + All to zero + + + + + + + + + + + + + + + + + + + + + + + + + The machine is about to move, please pay attention to safety! + + + + + + All to reset + + + + + Whether to reset the output? + + + + + If all process to reset? + + + + + Spindle jog + + + + + Spindle rotate angle + + + + + Back work point + + + + + Back to origin + + + + + Set start point + Set embroidery point + + + + + + Whether to set the current point as the start point? + + + + + Back anchor point + + + + + File bytes are 0, please check the file! + + + + + Back embroidery point + + + + + Set offset point + + + + + Whether to set the current point as the offset point? + + + + + Back offset point + + + + + Border check + + + + + Trim + + + + + Password input + + + + + Whether to set to change a shuttle automatically? + + + + + The machine is about to cut the thread, please pay attention to safety! + + + + + Failed to initialize wlan0! + + + + + Failed to search for WiFi list. Please try again later! + + + + + dynamic + + + + + static + + + + + Failed to obtain IP. Please check the settings! + + + + + WIFI + + + + + Auxiliary Function > WIFI + + + + + Lower cutter + + + + + The scissors are about to move, please pay attention to safety! + + + + + Simulate frame + + + + + Process reset + + + + + The machine is about to reset, please pay attention to safety! + + + + + The machine is about to oil! + + + + + Goto zero pos + + + + + Set work range + + + + + If automatically set work range? + + + + + Manual oil + + + + + Bottom line detection + + + + + Face line detection + + + + + Exit successfully! + + + + + Shuttle count reset + Shuttle change + + + + + The machine is about to change the shuttle automatically! + + + + + System info + + + + + Is the bottom line count reset? + Is the bottom line count reset ? + + + + + Are you sure to ManualSwitch? + Are you sure to ManualSwitch? + + + + + Are you sure to AutoSwitch? + Are you sure to AutoSwitch? + + + + + Undefined error, + + + + + Is the version restored? + + + + + Modify the first level password + + + + + The two passwords are inconsistent! + + + + + Password reset complete! + + + + + Do you delete the configuration file? + + + + + The settings take effect after restarting the interface! + + + + + Import csv file successful! + + + + + Do you delete the csv file? + + + + + Reset succeeded! + + + + + Whether to enter debug mode? + + + + + whether to exit debug mode? + + + + + Please log in to super user again! + + + + + Is the pattern clear? + + + + + Delete complete! + + + + + Whether to shut down the computer? + + + + + Production statistics + + + + + Setting workable area + + + + + No connection + + + + + Warrant + + + + + Total number of patterns processed: + + + + + Total number of embroidery: + + + + + Pattern name: + + + + + Pattern break line num: + + + + + Head + + + + + break line num: + + + + + Day + + + + + Hour + + + + + Minutes + + + + + The remaining available time of the machine is + + + + + Failed to upgrade the main control system! + + + + + Failed to send data file! + + + + + The main control system has been successed, waiting until machine restart + + + + + System will restart %1 s later + + + + + The data file is send successfully! + + + + + Main control system is being upgraded... + + + + + Auxiliary Function > HMI Upgrade + + + + + Auxiliary Function > Production statistics + + + + + Data file sending... + + + + + + + The password is wrong,please re-enter! + + + + + HMI decrypt + + + + + The interface program is licensed, and then take effect after restarting, please restart manually! + + + + + Password error, interface program authorization failed! + + + + + McHeadDialog + + + Dialog + + + + + + + + + + + + PushButton + + + + + MultiNeedleRotary + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + startX + + + + + + + + mm + + + + + startrY + + + + + + + r/min + + + + + Sewing main shaft working speed + + + + + Main shaft zero reset speed + + + + + Main shaft running speed + + + + + + XY zero reset speed + + + + + + + + + mm/s + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + Work head selection 1 + + + + + + Not allow:0;allowed:1 + + + + + Work head selection 2 + + + + + Production preset + + + + + + No. of stitch detect if thread broken + + + + + Needle + + + + + + Bobbin thread length + + + + + Bobbin change reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe door allowed + + + + + X to move motor + + + + + Y to move motor + + + + + All spindle zero positions + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + Setting + + + + + Authorize + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Para + + + + + Select + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + + + + + Pause button 1 + + + + + Jog button 1 + + + + + Open frame button 1 + + + + + NumerInputDialog + + + Dialog + + + + + C + + + + + (0~3000)rmp + + + + + Number input + + + + + ← + + + + + ParameterSetDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + Sub title + + + + + Sub title < Title + + + + + Repetitions + + + + + + pageNum: + + + + + Machine parameters + + + + + Work parameters + + + + + Root > Machine parameters + + + + + Input + + + + + HMI Configuration + + + + + Root > HMI Configuration + + + + + Root > Work parameters + + + + + Local port settings + + + + + + Local IP settings + + + + + IOT Configuration + + + + + Root > IOT Configuration + Root >IOT Configuration + + + + + Network Settings + + + + + IOT Configuration > Network Settings + IOT Configuration >Network Settings + + + + + Server IP settings + + + + + Server Port settings + + + + + Local Port settings + + + + + Board IP settings + + + + + Board port settings + + + + + + + + + + Network error + + + + + + + read parameter... + + + + + + + No connection + + + + + Repetitions : 0 + + + + + + + + + + + Prompt + + + + + + The settings take effect after restarting the interface! + + + + + + Network settings are completed, re-establish after reboot + + + + + The time setting is completed and will take effect after restart + + + + + Unreasonable time setting, please reset + + + + + Time setting failed, please reset + + + + + Connection mode changes, take effect after the reboot! + + + + + + + Root + + + + + + + Accessibility > Root + + + + + Whether to recover the default parameters for the board? + + + + + PassWordDialog + + + Dialog + + + + + Password + + + + + 9 + + + + + 1 + + + + + 2 + + + + + ← + + + + + 3 + + + + + 6 + + + + + 8 + + + + + C + + + + + 0 + + + + + 5 + + + + + 7 + + + + + 4 + + + + + Prompt + + + + + IP settings are unreasonable! + + + + + PatternManageWidget + + + Form + + + + + PageNums: 0/0 + + + + + Sub title < Title + + + + + Sub title + + + + + + 1000.0 + + + + + W + + + + + 500.0 + + + + + 999 + + + + + H + + + + + 1000000 + + + + + Y + + + + + X + + + + + 800.0 + + + + + dst + + + + + C + + + + + N + + + + + pageNum: + + + + + + + + + + Prompt + + + + + Over 1.28 million stitches, can not be imported! + + + + + Format error, can not be imported! + + + + + This file already exists! + + + + + Rename + + + + + Importing + + + + + Exporting + + + + + Import complete + + + + + Export complete + + + + + USB flash drive is not detected! + + + + + Whether to delete the pattern? + + + + + Operation screen + + + + + USB + + + + + + + Pattern Import + + + + + + + Pattern Import < Pattern setting + + + + + Pattern Export + + + + + Pattern Export < Pattern setting + + + + + new folder + + + + + This folder already exists! + + + + + PatternSelectWidget + + + Form + + + + + Name: + 花样名: + + + + + N + + + + + H + C + + + + + W + + + + + + X + + + + + + Y + + + + + Width + + + + + NeedleNum + + + + + Name + + + + + Height + + + + + Pattern Select + 花样选择 + + + + + Pattern Select < Pattern Setting + 花样选择 < 花样设置 + + + + + PageNums: 0/0 + + + + + PageNum: 0/0 + + + + + pageNum: + + + + + Prompt + + + + + The number of stitches of the selected pattern has reached the upper limit (2 million stitches), and it cannot be embroidered! + + + + + PromptDialog + + + Dialog + + + + + Prompt + + + + + ID: + + + + + Password: + 密码: + + + + + ID + + + + + DecryptInfo + + + + + DecryptInfo: + 解密信息: + + + + + Spindle angle: + 主轴角度: + + + + + deg + + + + + + New Password: + 密码: + + + + + Confirm Password: + 解密信息: + + + + + X + + + + + + X - + + + + + Y + + + + + + Y - + + + + + Board + + + + + Build Time: + + + + + Unlimited time + + + + + Time has run out + + + + + Day + + + + + Hour + + + + + Minutes + + + + + ID: %1 + + + + + + Password: %1 + + + + + + Time: %1 + + + + + Warrant + + + + + HMI decrypt + + + + + Spindle angle rotation + + + + + New Password input + + + + + Confirm Password input + + + + + QObject + + + (0x0002)Insufficient air pressure + Insufficient air pressure + + + + + (0x0003)safe area error + safe area error + + + + + (0x0004)Expiration of use + Expiration of use + + + + + (0x0005)Driver alarm + Driver alarm + + + + + (0x0006)Fill data error + Fill data error + + + + + (0x0007)Not allowed to work + Not allowed to work + + + + + (0x0008)Control error + Control error + + + + + (0x0009)Motion control chip version error + Motion control chip version error + + + + + (0x000A)Waiting for button to lift timeout + Waiting for button to lift timeout + + + + + (0x000B)FPGA Reset + FPGA Reset + + + + + (0x000C)Peripheral Device not ready + Peripheral Device not ready + + + + + (0x000D)Transmission data error + Transmission data error + + + + + (0x000E)Program version error + Program version error + + + + + (0x000F)Complete output + Complete output + + + + + (0x0010)Positive limit + Positive limit + + + + + (0x0011)Negative limit + Negative limit + + + + + (0x0012)Motion alarm + Motion alarm + + + + + (0x0013)Motion limit + Motion limit + + + + + (0x0014)Emergency stop + Emergency stop + + + + + (0x0015)Motion parameters error + Motion parameters error + + + + + (0x0016)Machine parameters error + Machine parameters error + + + + + (0x0017)Input parameters error + Input parameters error + + + + + (0x001A)Not in work status error + Not in work status error + + + + + (0x001B)Prohibited frame moving state + Prohibited frame moving state + + + + + (0x001F)Zero success + Zero success + + + + + (0x0020)Return to zero error + Return to zero error + + + + + (0x0021)Coordinate system error + Coordinate system error + + + + + (0x0022)Target position out of bounds + Target position out of bounds + + + + + (0x0023)X Positive limit + X Positive limit + + + + + (0x0024)X Negative limit + X Negative limit + + + + + (0x0025)Y Positive limit + Y Positive limit + + + + + (0x0026)Y Negative limit + Y Negative limit + + + + + (0x002B)Safety door error + + + + + (0x002C)Entering the light curtain 1 + Entering the light curtain 1 + + + + + (0x002D)Entering the light curtain 2 + Entering the light curtain 2 + + + + + (0x0040)None data + None data + + + + + (0x0041)Data error + Data error + + + + + (0x0042)Graphics out of range + Graphics out of range + + + + + (0x0050)Spindle is not in zero position + Spindle is not in zero position + + + + + (0x0051)Rotary hook is not in zero position + + + + + (0x0054)Scissors are not in position + Scissors are not in position + + + + + (0x0056)Nose not in low position + + + + + (0x0058)Thread is broken + Thread is broken + + + + + (0x0059)Bottom thread disconnected + Bottom thread disconnected + + + + + (0x005D)Execution command timed out + Execution command timed out + + + + + (0x005F)Head lifting timeout + + + + + (0x00F0)Change the bobbin + Change the bobbin + + + + + (0x00F1)Replace bobbin A + Replace bobbin A + + + + + (0x00F2)Replace bobbin B + Replace bobbin B + + + + + (0x00F3)The machine is in the state of replacing the bobbin + The machine is in the state of replacing the bobbin + + + + + (0x002E)Insufficient air pressure + + + + + Normal stop + (0x0100)Normal stop + + + + + Find zero success + (0x0101)Find zero success + + + + + work pause + (0x0102)work pause + + + + + End of work + (0x0103)End of work + + + + + Work done + (0x0104)Work done + + + + + Complete production + (0x0105)Complete production + + + + + (0x0106)Execute success + Execute success + + + + + (0x0107)Execute false + Execute false + + + + + (0x0108)wait file + wait file + + + + + (0x0109)change the bobbin + change the bobbin + + + + + (0x010A)Execute finish + Execute finish + + + + + (0x010B)Execute runnibng + Execute runnibng + + + + + Enable + + + + + Disable + + + + + JogP + + + + + JogN + + + + + Turn + + + + + Zero + + + + + Open + + + + + Close + + + + + Ascending + + + + + descending + + + + + Trim + + + + + SensorInputWidget + + + Form + + + + + + Sensor + + + + + PageNums: 1/1 + + + + + pageNum: + + + + + SetWorkArea + + + Form + + + + + Prompt + + + + + X + + + + + + X - + + + + + Y + + + + + + Y - + + + + + SystemManageDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + + Update + + + + + 192.168.2.196 + + + + + StaticIP + + + + + DynamicIP + + + + + *Before setting the static IP, you need to first set the dynamic IP. After the dynamic IP is set, you need to return to this interface to continue setting the static IP + 设置静态IP前需要先设置动态IP,动态IP设置完成后需要返回此界面继续设置静态IP + + + + + pageNum: 0/0 + + + + + pageNum: + + + + + + + + Prompt + + + + + The upgrade needs to restart the program. Do you need to restart to upgrade? + + + + + Do you want to clear the production statistics? + + + + + Do you want to clear the journal? + + + + + Do you want to export journal? + + + + + WordsInputDialog + + + Dialog + + + + + Words input + + + + + Name: + + + + + ← + + + + + old + + + + diff --git a/items/assistitem.cpp b/items/assistitem.cpp new file mode 100644 index 0000000..d09deea --- /dev/null +++ b/items/assistitem.cpp @@ -0,0 +1,43 @@ +#include "assistitem.h" + +AssistItem::AssistItem(QObject *parent) : QObject(parent) +{ + clean(); +} + +AssistItem::~AssistItem() +{ + clean(); +} + +AssistItem::AssistItem(const AssistItem & item) : QObject() +{ + copyData(item); +} + +AssistItem & AssistItem::operator= (const AssistItem & item) +{ + copyData(item); + return *this; +} + +void AssistItem::clean() +{ + m_macType = 0; + m_showPriority = 0; + m_name.clear(); + m_topImageName.clear(); + m_enumFunction = 0; +} + +void AssistItem::copyData(const AssistItem &item) +{ + if (this != &item) + { + this->m_macType = item.m_macType; + this->m_showPriority = item.m_showPriority; + this->m_name = item.m_name; + this->m_topImageName = item.m_topImageName; + this->m_enumFunction = item.m_enumFunction; + } +} diff --git a/items/assistitem.h b/items/assistitem.h new file mode 100644 index 0000000..36a7192 --- /dev/null +++ b/items/assistitem.h @@ -0,0 +1,36 @@ +#ifndef ASSISTITEM_H +#define ASSISTITEM_H + +#include + +class AssistItem : public QObject +{ + Q_OBJECT +public: + explicit AssistItem(QObject *parent = 0); + + ~AssistItem(); + +public: + AssistItem(const AssistItem & item); + AssistItem & operator= (const AssistItem & item); + +public: + void clean(); + +private: + void copyData(const AssistItem & item); + +public: + int m_macType; // 机器类型 + int m_showPriority; // 显示优先级 + QString m_name; // label名称 + QString m_topImageName; // 顶图图标logo名称 + int m_enumFunction; // 对应的事件的枚举值 + +signals: + +public slots: +}; + +#endif // ASSISTITEM_H diff --git a/items/cmdconfig.h b/items/cmdconfig.h new file mode 100644 index 0000000..e232b41 --- /dev/null +++ b/items/cmdconfig.h @@ -0,0 +1,218 @@ +#ifndef CMDCONFIG_H +#define CMDCONFIG_H + +//点击触发型参数枚举(绣花机超级用户参数、冲缝绣产线软件设置参数、网络管理参数) +enum CLICK_ALL_FUNCTION { + ROOT_HMICONFIGURATION = 0, //界面配置 + ROOT_MACHINEPARA, // 机器参数 + ROOT_WORKPARA, // 工作参数 + ROOT_CLEARPATTERN, //花样总清 + ROOT_VERSIONRECOVERY, //版本恢复 + ROOT_DEBUGMODE, //界面进入调试模式 + ROOT_RESOLUTION, //分辨率 + ROOT_MACTYPE, //机器类型 + ROOT_PRODUCTTYPE, //产品类型 + ROOT_SHUTTLECHANGE, //自动换梭 + ROOT_WATERMARKSET, //主背景水印设置(是否带水印) + ROOT_WIFI, + ROOT_PARASORTSET, //参数分类设置(是否分类) + ROOT_HMIDECRYPT, // 界面解密 + ROOT_CHANGEPASSWORD, //修改一级密码 + ROOT_IOTCONFIGURATION, //物联网配置-物联网配置 + ROOT_GATEWAYCONNECTIONMETHOD, //物联网配置-网关连接方式 + ROOT_RACKNUMBERINPUT, //物联网配置-机架号输入 + ROOT_NETWORKSETTINGS, //物联网配置-网络设置 + ROOT_DELIVERYTIME, //物联网配置-工厂预计交货时间 + ROOT_DEBUGPROGRESS, //物联网配置-调试进度 + ROOT_DELETEINI, //删除配置文件 + PSE_SOFTWAREPARA_IMPORTPARA, // 参数导入 + PSE_SOFTWAREPARA_EXPORTPARA, // 参数导出 + PSE_SOFTWAREPARA_HMIUPDATE, // 界面升级 + PSE_SOFTWAREPARA_MCUPDATE, // 主控升级 + PSE_SOFTWAREPARA_EXIT // 退出程序 + }; + +enum MC_TYPE { NUM1 = 1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7, NUM8, NUM9 };//板卡号 + +//此头文件定义了常用功能的枚举 +enum SHORTCUT_FUNCTION { + FUN_ALLTOZERO = 1, // 全部归零 + FUN_SPINDLEJOG, // 主轴点动 + FUN_SPINDLEENABLE, // 主轴使能 + FUN_SPINDLEDISABLE, // 主轴失能 + FUN_SPINDLETEST, // 主轴研车 + FUN_SPINDLEROTATE, // 主轴旋转 + FUN_BACKWORKPOINT, // 回工作点 + FUN_BACKTOORIGIN, // 回原点 + FUN_SETOFFSETPOINT, // 定偏移点 + FUN_BACKOFFSETPOINT, // 回偏移点 + FUN_SETSTARTPOINT, // 定起始点 + FUN_BACKSTARTPOINT, // 回起始点 + FUN_CHECKFRAME, // 边框检查 + FUN_FORWARDORBACK, // 前进回退 + FUN_SIMULATEFRAME, //空走边框 + FUN_PROCESSRESET, //流程复位 + FUN_MANUALOIL, //手动加油 + FUN_PATTERNSELECT, // 花样选择 + FUN_SEWAUTOCHANGESHUTTLE, //自动换梭 + FUN_SEWBUFF, //缝纫状态 + FUN_SHUTTLEDISKBUFF, //换梭盘状态 + FUN_BACKTHREADPOINT, //回穿线点 + FUN_SETANCHORPOINT, // 定定位点(服装机) + FUN_BACKANCHORPOINT, // 回定位点(服装机) + FUN_BACKSHUTTLE, //回换梭位(服装机) + FUN_NEEDLESHUTTLERESET, //针梭校对(服装机) + FUN_BACKZEROPOINT, //回零点 + FUN_SHUTTLETOHEAD, //将旋梭从梭盘到机头 + FUN_HEADTOSHUTTLE, //将旋梭从机头到梭盘 + FUN_COUNTRESET, //底线计数清零 + FUN_OUTPUTRESET, //产量清零 + FUN_NEDDLEZEROPOS, //对针零位 + FUN_SHUTTLEZEROPOS, //对梭零位 + FUN_MT_ALLZ, // 所有主轴 零位 + FUN_MT_ALLG, // 所有主轴 勾线 + FUN_MT_ALLM, // 所有主轴 点动 + FUN_MAINSHAFT_ADJUST, // 针梭校对 + FUN_SIMULATED_STATUS, // 模拟缝纫状态 + FUN_MANUAL_THREAD_CUTTING, // 手动剪线 + FUN_HEAD_LIFTUPDOWN, //机头升降 + FUN_HEAD_LIFTING, //机头上升 + FUN_GOTO_FEEDT,//回穿线点 + FUN_MAKEUP_NOHEAD, // 取消补缝 + FUN_MAKEUP_HEAD1, // 机头1补缝 + FUN_MAKEUP_HEAD2, // 机头2补缝 + FUN_MAKEUP_HEAD3, // 机头3补缝 + FUN_MAKEUP_HEAD4, // 机头4补缝 + FUN_MAKEUP_HEAD5, // 机头5补缝 + ASSIST_ThCutAct1,//机头1 剪线动作 + ASSIST_ThCutAct2,//机头2 剪线动作 + ASSIST_ThCutAct3,//机头3 剪线动作 + ASSIST_ThCutAct4,//机头4 剪线动作 + ASSIST_ThCutAct5,//机头5 剪线动作 + FUN_NULL // 无功能 无功能应该放在最后一位,因为常用功能得最大值就是无功能,否则无法一一对应 + }; + +//辅助功能的枚举 +enum ASSIST_FUNCTION { + ASSIST_SENSOR = 1, // 传感器信号 + ASSIST_CONTROLACTION, // 控制动作 + ASSIST_HMIUPGRADE, // 界面升级 + ASSIST_MCUPGRADE, // 主控升级 + ASSIST_PARAIMPORT, // 参数导入 + ASSIST_PARAEXPORT, // 参数导出 + ASSIST_SOFTWARESET, // 软件设置 + ASSIST_AUTHORIZATION, // 软件授权 + ASSIST_NETWORK, // 网络管理 + ASSIST_WIFI, + ASSIST_TIMESET, // 时间设置 + ASSIST_PRODUCTSTATICS, // 生产统计 + ASSIST_LOGFILE,//文件日志 + ASSIST_ERRORLOG,//错误日志 + ASSIST_BREAKAGELOG,//断线日志 + ASSIST_MCVERSION, // 版本信息 + ASSIST_BOTTOMLINEDETECT, //底线检测 + ASSIST_FACELINEDETECT, //面线检测 + ASSIST_SPINDLETEST, //主轴研车 + ASSIST_CHANGEASHUTTLE ,// 自动换一个梭 + ASSIST_ROOT, //超级用户 + ASSIST_SHUTDOWN, //关机 + ASSIST_BOTTOMLINECOUNTRESET, // 底线计数复位 + ASSIST_DEBUGINFO,//调试信息 + ASSIST_ScanTest,//扫码测试 + ASSIST_NULL // 无功能 + }; + +//花样设置功能的枚举 +enum PATTERNSET_FUNCTION { + PATTERNSET_PATTERNSELECT = 1, // 花样选择 + PATTERNSET_PATTERNPARA, // 花样参数 + PATTERNSET_PATTERNCOLOR, // 花样色序 + PATTERNSET_PATTERNIMPORT, // 花样导入 + PATTERNSET_PATTERNEXPORT, // 花样导出 + PATTERNSET_PATTERNDELETE, // 花样删除 + PATTERNSET_NULL // 无功能 + }; + +//参数设置参数类型的枚举 +enum PARASET_FUNCTION { + PARASET_POSITION = 1, // 位置参数 + PARASET_SPEED, // 速度参数 + PARASET_ACTION, // 动作参数 + PARASET_DETECT, // 检测参数 + PARASET_SETTING , // 设置参数 + PARASET_SHUTTLE //自动换梭参数 + }; + +enum OUTCONTROL_FUN { + OUTCONTROL_ENABLE = 1, // 使能 + OUTCONTROL_DISABLE, // 失能 + OUTCONTROL_MS_ENABLE, // 主轴电机使能 + OUTCONTROL_MS_DISABLE, // 主轴电机失能 + OUTCONTROL_JOGP, // 正转 + OUTCONTROL_JOGN, // 反转 + OUTCONTROL_STOP, // 停止 + OUTCONTROL_ZERO, // 归零 + OUTCONTROL_LEFT, // 左位 + OUTCONTROL_MIDDLE, // 中位 + OUTCONTROL_RIGHT, // 右位 + OUTCONTROL_UP, // 上升 + OUTCONTROL_DOWN, // 下降 + MANUALACTION_RUN, // 执行 + OUTCONTROL_OPEN, // 打开 + OUTCONTROL_CLOSE, // 关闭 + OUTCONTROL_STARTOIL, // 开始 + OUTCONTROL_STOPOIL, // 停止 + MOTORHEADO_UP, // 缝纫机头1升降 + MOTORHEADO_DOWN, //缝纫机头1下降 + MOTORHEADT_UP, // 缝纫机头2升降 + MOTORHEADT_DOWN, // 缝纫机头2下降 + ALLTO_ZERO, // 全部归零 + }; + +//软件设置的顺序枚举 +enum ENUM_SOFTWARESET { +// SET_THEME = 0, // 主题 + SET_LANGUAGE = 0, // 语言 + SET_FONTSIZE, //字体大小 + SET_CONNECTMODE, //连接方式(通讯方式) + SET_TITLEBAR //设置标题栏 + //参数设置界面参数显示方式 + }; + +//花样参数的顺序枚举 +enum ENUM_PATTERNPARA { + SET_ROTATESTYLE = 0, // 旋转式样 + SET_HORIZONTALSTYLE, // 水平翻转样式 + SET_VERTICALSTYLE, // 垂直翻转样式 + SET_ROTATEANGLE, // 旋转角度 + SET_SETSTEPSIZE, // 针步大小 + SET_REINMODE , // 加固方式 + SET_REINNEEDLE , // 加固针数 + SET_REINNUM , // 加固次数 + SET_ANGLECORROFFSET, // 角度修正量 + SET_ANGLECORRPOSX, // 角度修正x正 + SET_ANGLECORRNEGX, // 角度修正x负 + SET_ANGLECORRPOSY, // 角度修正y正 + SET_ANGLECORRNEGY, // 角度修正y负 + SET_SETLEFT, // 左边 + SET_SETFRONT , // 前边 + SET_SCANX, // 缩放x + SET_SCANY , // 缩放y + SET_STARTX, // 起始点x + SET_STARTY , // 起始点y + SET_ANCHORX, // 定位点x + SET_ANCHORY, // 定位点y + SET_EQUAL //等比缩放 + }; + +//网络管理设置的顺序枚举 +enum ENUM_NETWORKSET { + SET_MQTT_SERVERIP = 0, // 网关服务器IP + SET_MQTT_SERVERPORT, // 网关服务器端口 + SET_MACHINE_SERVERIP, // 机器服务器IP + SET_MACHINE_SERVERPORT, // 机器服务器端口 + SET_LOCALIP, // 本地IP + SET_LOCALPORT, // 本地端口 + }; + +#endif // CMDCONFIG_H diff --git a/items/errorcodestateitem.cpp b/items/errorcodestateitem.cpp new file mode 100644 index 0000000..db31d2c --- /dev/null +++ b/items/errorcodestateitem.cpp @@ -0,0 +1,37 @@ +#include "errorcodestateitem.h" + +ErrorCodeStateItem::ErrorCodeStateItem(QObject *parent) : QObject(parent) +{ + clean(); +} + +ErrorCodeStateItem::~ErrorCodeStateItem() +{ + clean(); +} + +ErrorCodeStateItem::ErrorCodeStateItem(const ErrorCodeStateItem &item) : QObject() +{ + copyData(item); +} + +ErrorCodeStateItem &ErrorCodeStateItem::operator=(const ErrorCodeStateItem &item) +{ + copyData(item); + return *this; +} + +void ErrorCodeStateItem::clean() +{ + m_code = 0; + m_name.clear(); +} + +void ErrorCodeStateItem::copyData(const ErrorCodeStateItem &item) +{ + if (this != &item) + { + this->m_code = item.m_code ; // 代码 + this->m_name = item.m_name ; // 代码对应的名称 + } +} diff --git a/items/errorcodestateitem.h b/items/errorcodestateitem.h new file mode 100644 index 0000000..8eacea3 --- /dev/null +++ b/items/errorcodestateitem.h @@ -0,0 +1,33 @@ +#ifndef ERRORCODESTATEITEM_H +#define ERRORCODESTATEITEM_H + +#include + +class ErrorCodeStateItem : public QObject +{ + Q_OBJECT +public: + explicit ErrorCodeStateItem(QObject *parent = 0); + + ~ErrorCodeStateItem(); + +public: + ErrorCodeStateItem(const ErrorCodeStateItem & item); + ErrorCodeStateItem & operator= (const ErrorCodeStateItem & item); + +public: + void clean(); + +private: + void copyData(const ErrorCodeStateItem & item); + +public: + unsigned int m_code; // 代码 + QString m_name; // 代码对应的名称 + +signals: + +public slots: +}; + +#endif // ERRORCODESTATEITEM_H diff --git a/items/fileitem.cpp b/items/fileitem.cpp new file mode 100644 index 0000000..eb77a73 --- /dev/null +++ b/items/fileitem.cpp @@ -0,0 +1,63 @@ +#include "fileitem.h" + +FileItem::FileItem(QObject *parent) : + QObject(parent) +{ + clear(); +} + +FileItem::~FileItem() +{ + clear(); +} + +FileItem::FileItem(const FileItem & item) : + QObject(item.parent()) +{ + copyData(item); +} + +FileItem & FileItem::operator=(const FileItem & item) +{ + copyData(item); + return *this; +} + +void FileItem::clear() +{ + m_filePathName.clear(); // 文件路径 + m_showInfo.clear(); // 显示信息 + m_imagePath.clear(); // 图片路径 + m_previewImage = QImage(); // 图形预览 +} + +// 拷贝 +void FileItem::copyData(const FileItem & item) +{ + if (this != &item) + { + this->m_filePathName = item.m_filePathName; // 文件路径 + this->m_showInfo = item.m_showInfo; // 显示信息 + this->m_imagePath = item.m_imagePath; // 图片路径 + this->m_previewImage = item.m_previewImage; // 图形预览 + } +} + +#if (1) +void FileItem::setFileInfo(QString & path, QString & show, QImage & previewImg) +#else +void FileItem::setFileInfo(QString path, QString show, QImage previewImg) +#endif +{ + m_filePathName = path; // 文件路径 + m_showInfo = show; // 显示信息 + m_previewImage = previewImg; // 预览图形 +} + + +void FileItem::setFileInfo(QString path, QString show, QString imagePath) +{ + m_filePathName = path; // 文件路径 + m_showInfo = show; // 显示信息 + m_imagePath = imagePath; // 图片路径 +} diff --git a/items/fileitem.h b/items/fileitem.h new file mode 100644 index 0000000..5e130d9 --- /dev/null +++ b/items/fileitem.h @@ -0,0 +1,48 @@ +#ifndef FILEITEM_H +#define FILEITEM_H + +#include +#include +#include + +// 文件条目项 +class FileItem : public QObject +{ + Q_OBJECT +public: + explicit FileItem(QObject *parent = NULL); + FileItem(const FileItem & item); + ~FileItem(); +public: + FileItem &operator=(const FileItem & item); + +public: + void clear(); +private: + void copyData(const FileItem & item); + +public: +#if (1) + void setFileInfo(QString & path, QString & show, QImage & previewImg); +#else + void setFileInfo(QString path, QString show, QImage previewImg); +#endif + void setFileInfo(QString path, QString show, QString imagePath); + +public: + inline const QString & getFilePath() const {return m_filePathName;} // 文件路径 + inline const QString & getShowInfo() const {return m_showInfo;} // 显示信息 + inline const QString & getImagePath() const {return m_imagePath;} // 图片路径 + inline const QImage & getPreviewImage() const {return m_previewImage;} // 图形预览 +private: + QImage m_previewImage; // 图形预览 + QString m_filePathName; // 文件路径名称 + QString m_imagePath; // 图片路径 + QString m_showInfo; // 显示信息(文件名称) + +signals: + +public slots: +}; + +#endif // FILEITEM_H diff --git a/items/itemsmanage.cpp b/items/itemsmanage.cpp new file mode 100644 index 0000000..f40977f --- /dev/null +++ b/items/itemsmanage.cpp @@ -0,0 +1,484 @@ +#include "itemsmanage.h" + +ParaItem makeAParaItem( + int64_t mcenSel, + int paraType, + int paraTypeSort, + int indexInPara, + int bitInWord, + int readonly, + int valueType, + QString paraName, + int64_t value, + int64_t minval, + int64_t maxval, + int64_t defvalue, + int afterpoint, + QString unitstr, + QString valuestr, + QString selList, + int selIdx, + int defIdx, + int showPriority, + int authority) +{ + ParaItem item; + + item.clean(); + + item.mcenSel = mcenSel; /* 机型选择 */ + item.paraType = paraType; /* 参数类型(机器参数、工作参数、花样设置参数...) */ + item.paraTypeSort = paraTypeSort; /* 参数类型分类(机器参数的速度参数、机器参数的动作参数...) */ + + item.indexInPara = indexInPara; /* 参数索引,-1,提示型显示; >= 0,该条目在参数中的位置*/ + item.bitInWord = bitInWord; /* 参数位索引 */ + item.readonly = readonly; /* 只读标志 */ + item.valueType = valueType; /* 参数值类型 = 0, 无值; = 1, 数字输入型; = 2, 开关选择型; = 3, 列表选择型 */ + + item.paraName = paraName; /* 参数名称 */ + + item.value = value; /* int输入型或选择型参数值 */ + item.minVal = minval; /* int输入型参数值范围下限 */ + item.maxVal = maxval; /* int输入型参数值范围上限 */ + item.defValue = defvalue; /* int输入型或选择型默认参数值 */ + item.afterPoint = afterpoint; /* int输入型保留小数位数 */ + item.unitStr = unitstr; /* int输入型单位字符串 */ + item.valueStr = valuestr; /* 字符输入型参数字符串 */ + + item.selList = selList; /* 列表选择型的参数列表, 通过"\n"来分割 */ + item.selIdx = selIdx; /* 当前选择项索引 */ + item.defIdx = defIdx; /* 默认选择项索引 */ + item.showPriority = showPriority; /* 显示优先级 */ + item.authority = authority; /* 显示优先级 */ + + return item; +} + +bool comparePriority(const ParaItem &item1, const ParaItem &item2) +{ + int pr1, pr2; + pr1 = item1.showPriority; + pr2 = item2.showPriority; + if (pr1 < 0) + { + pr1 = 0; + } + if (pr2 < 0) + { + pr2 = 0; + } + + return (pr1 < pr2); +} + +//各个机型通用参数-软件设置参数 +void initSoftwareParasList(QList & parasList) +{ + //软件设置参数--------------------------- + //软件设置参数-主题;单位:无 ,范围1-3,默认1 + /* + parasList.append(makeAParaItem(0, + PARA_TYPE_SOFTWARESET, + 0 , + SET_THEME, 0, 1, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Theme"),//主题 + 1, 1, 3, 1, 0, "", "", + QCoreApplication::translate("GLOBAL", "Theme1:1;Theme2:2;Theme3:3"),//主题1:1;主题2:2;主题3:3 + 0, 0, 0x0001, operate)); + */ + + //软件设置参数-语言;单位:无 ,范围0-1,默认0 + parasList.append(makeAParaItem(0, + PARA_TYPE_SOFTWARESET, + 0 , + SET_LANGUAGE, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Language"),//语言 + 0, 0, 5, 0, 0, "", "", + QCoreApplication::translate("GLOBAL", "Chinese:0;English:1"), + 0, 0, 0x0002, operate)); + + //软件设置参数-字体大小;单位:无 ,范围0-1,默认0 + /* + parasList.append(makeAParaItem(0, + PARA_TYPE_SOFTWARESET, + 0 , + SET_FONTSIZE, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Fontsize"),//字体大小 + 0, 0, 1, 0, 0, "", "", + QCoreApplication::translate("GLOBAL", "Normal:0;Larger:1"), + 0, 0, 0x0002, operate)); + */ + + //软件设置参数--------------------------- +} + +//各个机型通用参数-时间设置参数 +void initTimeParasList(QList & parasList) +{ + //时间设置参数--------------------------- + //时间设置参数-年;单位:无 ,范围1000-9999,默认1000 + parasList.append(makeAParaItem(0, + PARA_TYPE_TIMESET, + 0 , + 1, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Year"),//年 + 1000, 1000, 9999, 1000, 0, "", "", + "", 0, 0, 0x0000, operate)); + + //时间设置参数-月;单位:无 ,范围1-12,默认1 + parasList.append(makeAParaItem(0, + PARA_TYPE_TIMESET, + 0 , + 2, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Month"),//月 + 1, 1, 12, 1, 0, "", "", + "", 0, 0, 0x0001, operate)); + + //时间设置参数-日;单位:无 ,范围1-31,默认1 + parasList.append(makeAParaItem(0, + PARA_TYPE_TIMESET, + 0 , + 3, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Day"),//日 + 1, 1, 31, 1, 0, "", "", + "", 0, 0, 0x0002, operate)); + + //时间设置参数-时;单位:无 ,范围0-23,默认0 + parasList.append(makeAParaItem(0, + PARA_TYPE_TIMESET, + 0 , + 4, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Hour"),//时 + 0, 0, 23, 0, 0, "", "", + "", 0, 0, 0x0003, operate)); + + //时间设置参数-分;单位:无 ,范围0-59,默认0 + parasList.append(makeAParaItem(0, + PARA_TYPE_TIMESET, + 0 , + 5, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Minute"),//分 + 0, 0, 59, 0, 0, "", "", + "", 0, 0, 0x0004, operate)); + + //时间设置参数-秒;单位:无 ,范围0-59,默认0 + parasList.append(makeAParaItem(0, + PARA_TYPE_TIMESET, + 0 , + 6, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Second"),//秒 + 0, 0, 59, 0, 0, "", "", + "", 0, 0, 0x0005, operate)); + //时间设置参数--------------------------- +} + +//各个机型通用参数-网络管理参数 +void initNetworkParasList(QList & parasList) +{ + + //网络管理参数-服务器IP设置;单位:无 ,范围无,默认192.168.16.253 + parasList.append(makeAParaItem(0, + PARA_TYPE_NETWORKSET, + 0 , + SET_MACHINE_SERVERIP, 0, 0, PARA_VALUE_TYPE_STRINPUT, + QCoreApplication::translate("GLOBAL", "Server IP settings"),//服务器IP设置 + 0, 0, 0, 0, 0, "", "192.168.16.253", + "", + 0, 0, 0x0007, operate)); + + //网络管理参数-服务器端口设置;单位:无 ,范围0-65535,默认5000 + parasList.append(makeAParaItem(0, + PARA_TYPE_NETWORKSET, + 0 , + SET_MACHINE_SERVERPORT, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Server port settings"),//服务器端口设置 + 5000, 0, U16_MAX, 5000, 0, "", "", + "", 0, 0,0x0008, operate)); + + //网络管理参数-本地IP设置;单位:无 ,范围无,默认192.168.16.41 + parasList.append(makeAParaItem(0, + PARA_TYPE_NETWORKSET, + 0 , + SET_LOCALIP, 0, 0, PARA_VALUE_TYPE_STRINPUT, + QCoreApplication::translate("GLOBAL", "Local IP settings"),//本地IP设置 + 0, 0, 0, 0, 0, "", "192.168.16.41", + "", + 0, 0, 0x0009, operate)); + + //网络管理参数-本地端口设置;单位:无 ,范围0-65535,默认5001 + parasList.append(makeAParaItem(0, + PARA_TYPE_NETWORKSET, + 0 , + SET_LOCALPORT, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Local port settings"),//本地端口设置 + 5001, 0, U16_MAX, 5001, 0, "", "", + "", 0, 0,0x000A, operate)); + //网络管理参数--------------------------- +} + +OutCtrlItem makeAOutCtrlItem(int macType, int showPriority, QString name, int def, + QString btn1Str, bool btn1Visible, int btn1ClickFun, int btn1PreFun, int btn1RelFun, + QString btn2Str, bool btn2Visible, int btn2ClickFun, int btn2PreFun, int btn2RelFun, + QString btn3Str, bool btn3Visible, int btn3ClickFun, int btn3PreFun, int btn3RelFun, + QString btn4Str, bool btn4Visible, int btn4ClickFun, int btn4PreFun, int btn4RelFun, + QString btn5Str, bool btn5Visible, int btn5ClickFun, int btn5PreFun, int btn5RelFun) +{ + OutCtrlItem item; + item.clean(); + + item.m_macType = macType; + item.m_showPriority = showPriority; + item.m_name = name; + item.m_def = def; + + item.m_btn1Str = btn1Str; + item.m_btn1Visible = btn1Visible; + item.m_btn1ClickFun = btn1ClickFun; + item.m_btn1PreFun = btn1PreFun; + item.m_btn1RelFun = btn1RelFun; + + item.m_btn2Str = btn2Str; + item.m_btn2Visible = btn2Visible; + item.m_btn2ClickFun = btn2ClickFun; + item.m_btn2PreFun = btn2PreFun; + item.m_btn2RelFun = btn2RelFun; + + item.m_btn3Str = btn3Str; + item.m_btn3Visible = btn3Visible; + item.m_btn3ClickFun = btn3ClickFun; + item.m_btn3PreFun = btn3PreFun; + item.m_btn3RelFun = btn3RelFun; + + item.m_btn4Str = btn4Str; + item.m_btn4Visible = btn4Visible; + item.m_btn4ClickFun = btn4ClickFun; + item.m_btn4PreFun = btn4PreFun; + item.m_btn4RelFun = btn4RelFun; + + item.m_btn5Str = btn5Str; + item.m_btn5Visible = btn5Visible; + item.m_btn5ClickFun = btn5ClickFun; + item.m_btn5PreFun = btn5PreFun; + item.m_btn5RelFun = btn5RelFun; + + return item; +} + +ShortCutItem makeAShortCutItem(int macType, int showPriority, QString name, QString topImageName, int enumFunction) +{ + ShortCutItem item; + item.clean(); + + item.m_macType = macType; + item.m_showPriority = showPriority; + item.m_name = name; + item.m_topImageName = topImageName; + item.m_enumFunction = enumFunction; + + return item; +} + +//添加辅助功能item +AssistItem makeAAssistItem(int macType, int showPriority, QString name, QString topImageName, int enumFunction) +{ + AssistItem item; + item.clean(); + + item.m_macType = macType; + item.m_showPriority = showPriority; + item.m_name = name; + item.m_topImageName = topImageName; + item.m_enumFunction = enumFunction; + + return item; +} + +PatternSetItem makeAPatternSetItem(int macType, int showPriority, QString name, QString topImageName, int enumFunction) +{ + PatternSetItem item; + item.clean(); + + item.m_macType = macType; + item.m_showPriority = showPriority; + item.m_name = name; + item.m_topImageName = topImageName; + item.m_enumFunction = enumFunction; + + return item; +} + +void initRootHMIConfigurationList(QList ¶sList) +{ + //超级用户界面配置参数-分辨率;单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_HMICONFIGURATION, + 0 , + ROOT_RESOLUTION, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Resolution"),//分辨率 + 0, 0, 2, 0, 0, "", "", + "1920x1080:0;1024x600:1;", + 0, 0, 0x0001, root)); + + //软件设置参数-通讯方式;单位:无 ,范围0-2,默认0 + parasList.append(makeAParaItem(0, + PARA_TYPE_HMICONFIGURATION, + 0 , + SET_CONNECTMODE, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Communication method"),//通讯方式 + 0, 0, 1, 0, 0, "", "", + QCoreApplication::translate("GLOBAL", "Network:0;SerialPort:1"),//网口:0;串口:1 + 0, 0, 0x0011, operate)); + + ///添加新机型注意及时翻译 否则无法启动 + parasList.append(makeAParaItem(0, + PARA_TYPE_HMICONFIGURATION, + 0 , + ROOT_MACTYPE, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Machine type"),//机器类型 + //值,最小值,最大值,默认值 + MACHINE_HIGHSPEEDSINGLEQUI, MACHINE_HIGHSPEEDSINGLEQUI, MACHINE_MULTINEEDLEROTARY, MACHINE_HIGHSPEEDSINGLEQUI, 0, "", "", + QString(QCoreApplication::translate("GLOBAL", "001 McHighSingleQui:0;002 FiveHeadPrecisionSewing:1;003 ClothingMac:2;004 multineedlerotary:3")), + //001 高速单针机:0;002 五头精密缝:1;003 服装机:2;004 多针旋梭:3 + 0, 0, 0x0012, operate)); + + //超级用户界面配置参数-产品类型;单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_HMICONFIGURATION, + 0 , + ROOT_PRODUCTTYPE, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Product type"),//产品类型 + PRODUCT_NULL, PRODUCT_NULL, PRODUCT_NULL, PRODUCT_NULL, 0, "", "", + QCoreApplication::translate("GLOBAL","ProductNull:")+QString::number(PRODUCT_NULL),//无 + 0, 0, 0x0013, root)); + + //超级用户界面配置参数-是否有自动换梭功能;单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_HMICONFIGURATION, + 0 , + ROOT_SHUTTLECHANGE, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Whether there is a Automatic shuttle change function"),//是否有自动换梭功能 + 1, 0, 1, 1, 0, "", "", + "No:0;Yes:1", + 1, 1, 0x0016, root)); + + //超级用户界面配置参数-主背景是否带水印;单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_HMICONFIGURATION, + 0 , + ROOT_WATERMARKSET, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Is there a Richpeace logo"),//是否有富怡标志 + 1, 0, 1, 1, 0, "", "", + "No:0;Yes:1", + 1, 1, 0x0017, factory)); + + //超级用户界面配置参数-参数是否分类显示;单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_HMICONFIGURATION, + 0 , + ROOT_PARASORTSET, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Parameter is classified"),//参数是否分类显示 + 0, 0, 1, 0, 0, "", "", + "No:0;Yes:1", + 0, 0, 0x0018, factory)); + + //超级用户界面配置参数-界面解密;单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_HMICONFIGURATION, + 0 , + ROOT_HMIDECRYPT, 0, 0, PARA_VALUE_TYPE_CLICK, + QCoreApplication::translate("GLOBAL", "HMI decrypt"),//界面解密 + 0, 0, 0, 0, 0, "", "", "", + 0, 0, 0x0019, factory)); +} + +//物联网配置参数 +void initRootIOTConfigurationList(QList ¶sList) +{ + //超级用户物联网配置-网关连接方式;单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_IOTCONFIGURATION, + 0 , + ROOT_GATEWAYCONNECTIONMETHOD, 0, 0, PARA_VALUE_TYPE_LIST, + QCoreApplication::translate("GLOBAL", "Gateway connection method"),//网关连接方式 + 0, 0, 2, 0, 0, "", "", + QCoreApplication::translate("GLOBAL","Serial port:0; Network port:1"), + 0, 0, 0x0011, factory)); + + //超级用户物联网配置-机架号输入; 单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_IOTCONFIGURATION, + 0 , + ROOT_RACKNUMBERINPUT, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Input rack number"),//机架号输入 + 111189, 0, INT_MAX, 111189, 0, "", "", + "", + 0, 0, 0x0012, factory)); + + //超级用户物联网配置-网络设置; 单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_IOTCONFIGURATION, + 0 , + ROOT_NETWORKSETTINGS, 0, 0, PARA_VALUE_TYPE_CLICK, + QCoreApplication::translate("GLOBAL", "Network settings"),//网络设置 + 0, 0, 0, 0, 0, "", "", + "", + 0, 0, 0x0013, factory)); + + //超级用户物联网配置-工厂预计交货时间; 单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_IOTCONFIGURATION, + 0 , + ROOT_DELIVERYTIME, 0, 0, PARA_VALUE_TYPE_STRINPUT, + QCoreApplication::translate("GLOBAL", "Factory expects delivery time"),//工厂预计交货时间 + 0, 0, 0, 0, 0, "", "", + "", + 0, 0, 0x0014, factory)); + + //超级用户物联网配置-调试进度; 单位:无 + parasList.append(makeAParaItem(0, + PARA_TYPE_IOTCONFIGURATION, + 0 , + ROOT_DEBUGPROGRESS, 0, 0, PARA_VALUE_TYPE_INT, + QCoreApplication::translate("GLOBAL", "Debugging progress"),//调试进度 + 0, 1, 100, 0, 0, "", "", + "", + 0, 0, 0x0015, factory)); +} + +ParaSetItem makeAParaSetItem(int macType, int showPriority, QString name, QString topImageName, int paraType) +{ + ParaSetItem item; + item.clean(); + + item.m_macType = macType; + item.m_showPriority = showPriority; + item.m_name = name; + item.m_topImageName = topImageName; + item.m_paraType = paraType; + + return item; +} + +SensorItem makeASensorItem(int byte, int bit, QString name, int type) +{ + SensorItem item; + item.clean(); + + item.m_byte_offset = byte; + item.m_bit_offset = bit; + item.m_name = name; + item.m_type = type; + + return item; +} + +ErrorCodeStateItem makeAErrorStateItem(int code, QString name) +{ + ErrorCodeStateItem item; + item.clean(); + + item.m_code = code; + item.m_name = name; + + return item; +} diff --git a/items/itemsmanage.h b/items/itemsmanage.h new file mode 100644 index 0000000..dcc2148 --- /dev/null +++ b/items/itemsmanage.h @@ -0,0 +1,96 @@ +#ifndef ITEMSMANAGE_H +#define ITEMSMANAGE_H + +#include "paraitem.h" +#include "outctrlitem.h" +#include "shortcutitem.h" +#include "assistitem.h" +#include "patternsetitem.h" +#include "parasetitem.h" +#include "nineitem.h" +#include "sensoritem.h" +#include "errorcodestateitem.h" +#include "main.h" +#include +#include + +//添加快捷功能item +ShortCutItem makeAShortCutItem(int macType,int showPriority, + QString name,QString topImageName, + int enumFunction); + +//添加辅助功能item +AssistItem makeAAssistItem(int macType,int showPriority, + QString name,QString topImageName, + int enumFunction); + +//花样设置功能item +PatternSetItem makeAPatternSetItem(int macType,int showPriority, + QString name,QString topImageName, + int enumFunction); + +//参数设置功能item +ParaSetItem makeAParaSetItem(int macType,int showPriority, + QString name,QString topImageName, + int paraType); + +//传感器信号item +SensorItem makeASensorItem(int byte,int bit,QString name,int type = -1); + +//错误代码/状态item +ErrorCodeStateItem makeAErrorStateItem(int code,QString name); + +//添加控制动作item +OutCtrlItem makeAOutCtrlItem(int macType,int showPriority,QString name,int def, + QString btn1Str,bool btn1Visible, + int btn1ClickFun,int btn1PreFun,int btn1RelFun, + QString btn2Str,bool btn2Visible, + int btn2ClickFun,int btn2PreFun,int btn2RelFun, + QString btn3Str,bool btn3Visible, + int btn3ClickFun,int btn3PreFun,int btn3RelFun, + QString btn4Str,bool btn4Visible, + int btn4ClickFun,int btn4PreFun,int btn4RelFun, + QString btn5Str,bool btn5Visible, + int btn5ClickFun,int btn5PreFun,int btn5RelFun); + + +//添加参数item +ParaItem makeAParaItem( + int64_t mcenSel, /* 机型选择 */ + int paraType, /* 参数类型(机器参数、工作参数、花样设置参数...) */ + int paraTypeSort, /* 参数类型分类(机器参数的速度参数、机器参数的动作参数...) */ + int indexInPara, /* 参数索引,-1,提示型显示; >= 0,该条目在参数中的位置*/ + int bitInWord, /* 参数位索引 */ + int readonly, /* 只读标志 */ + int valueType, /* 参数值类型 = 0, 无值; = 1, 数字输入型; = 2, 开关选择型; = 3, 列表选择; = 4, 字符输入型*/ + + QString paraName, /* 参数名称 */ + + int64_t value, /* int输入型或选择型参数值 */ + int64_t minval, /* int输入型参数值范围下限 */ + int64_t maxval, /* int输入型参数值范围上限 */ + int64_t defvalue, /* int输入型或选择型默认参数值 */ + int afterpoint, /* int输入型保留小数位数 */ + QString unitstr, /* int输入型单位字符串 */ + QString valuestr, /* 字符输入型参数字符串 */ + + QString selList, /* 列表选择型的参数列表, 通过"\n"来分割 */ + int selIdx, /* 当前选择项索引 */ + int defIdx, /* 默认选择项索引 */ + + int showPriority, /* 显示优先级 */ + int authority /* 参数权限 */ + ); + + + +//比较参数优先级 +bool comparePriority(const ParaItem & item1, const ParaItem & item2); + +//各个机型通用参数 +void initSoftwareParasList(QList & parasList);//软件参数 +void initTimeParasList(QList & parasList);//时间设置参数 +void initNetworkParasList(QList & parasList);//网络管理参数 +void initRootHMIConfigurationList(QList & parasList);//界面配置参数 +void initRootIOTConfigurationList(QList ¶sList); //物联网配置参数 +#endif // ITEMSMANAGE_H diff --git a/items/nineitem.cpp b/items/nineitem.cpp new file mode 100644 index 0000000..1c86980 --- /dev/null +++ b/items/nineitem.cpp @@ -0,0 +1,44 @@ +#include "nineitem.h" + +NineItem::NineItem(QObject *parent) : QObject(parent) +{ + clean(); +} + +NineItem::NineItem(int fun, QString ImageName) +{ + clean(); + m_topImageName = ImageName; + m_enumFunction = fun; +} + +NineItem::~NineItem() +{ + clean(); +} + +NineItem::NineItem(const NineItem &item) : QObject(0) +{ + copyData(item); +} + +NineItem &NineItem::operator=(const NineItem &item) +{ + copyData(item); + return *this; +} + +void NineItem::clean() +{ + m_topImageName.clear(); + m_enumFunction = 0; +} + +void NineItem::copyData(const NineItem &item) +{ + if (this != &item) + { + this->m_topImageName = item.m_topImageName; + this->m_enumFunction = item.m_enumFunction; + } +} diff --git a/items/nineitem.h b/items/nineitem.h new file mode 100644 index 0000000..950c641 --- /dev/null +++ b/items/nineitem.h @@ -0,0 +1,30 @@ +#ifndef NINEITEM_H +#define NINEITEM_H + +#include + +class NineItem : public QObject +{ + Q_OBJECT +public: + explicit NineItem(QObject *parent = 0); + NineItem(int fun,QString ImageName); + ~NineItem(); + +public: + NineItem(const NineItem & item); + NineItem & operator= (const NineItem & item); + +public: + void clean(); + +private: + void copyData(const NineItem & item); + +public: + QString m_topImageName; // 顶图图标logo名称 + int m_enumFunction; // 对应的事件的枚举值 + +}; + +#endif // NINEITEM_H diff --git a/items/outctrlitem.cpp b/items/outctrlitem.cpp new file mode 100644 index 0000000..f02181c --- /dev/null +++ b/items/outctrlitem.cpp @@ -0,0 +1,101 @@ +#include "outctrlitem.h" + +OutCtrlItem::OutCtrlItem(QObject *parent) : QObject(parent) +{ + clean(); +} + +OutCtrlItem::~OutCtrlItem() +{ + clean(); +} + +OutCtrlItem::OutCtrlItem(const OutCtrlItem & item) : QObject() +{ + copyData(item); +} + +OutCtrlItem & OutCtrlItem::operator= (const OutCtrlItem & item) +{ + copyData(item); + return *this; +} + +void OutCtrlItem::clean() +{ + m_macType = 0; + m_showPriority = 0; + m_name.clear(); // 名称 + m_def = -1; + + m_btn1Str.clear(); + m_btn1Visible = false; + m_btn1ClickFun = -1; + m_btn1PreFun = -1; + m_btn1RelFun = -1; + + m_btn2Str.clear(); + m_btn2Visible = false; + m_btn2ClickFun = -1; + m_btn2PreFun = -1; + m_btn2RelFun = -1; + + m_btn3Str.clear(); + m_btn3Visible = false; + m_btn3ClickFun = -1; + m_btn3PreFun = -1; + m_btn3RelFun = -1; + + m_btn4Str.clear(); + m_btn4Visible = false; + m_btn4ClickFun = -1; + m_btn4PreFun = -1; + m_btn4RelFun = -1; + + m_btn5Str.clear(); + m_btn5Visible = false; + m_btn5ClickFun = -1; + m_btn5PreFun = -1; + m_btn5RelFun = -1; +} + +void OutCtrlItem::copyData(const OutCtrlItem & item) +{ + if (this != &item) + { + this->m_macType = item.m_macType; + this->m_showPriority = item.m_showPriority; + this->m_name = item.m_name; // 名称 + this->m_def = item.m_def; + + this->m_btn1Str = item.m_btn1Str; + this->m_btn1Visible = item.m_btn1Visible; + this->m_btn1ClickFun = item.m_btn1ClickFun; + this->m_btn1PreFun = item.m_btn1PreFun; + this->m_btn1RelFun = item.m_btn1RelFun; + + this->m_btn2Str = item.m_btn2Str; + this->m_btn2Visible = item.m_btn2Visible; + this->m_btn2ClickFun = item.m_btn2ClickFun; + this->m_btn2PreFun = item.m_btn2PreFun; + this->m_btn2RelFun = item.m_btn2RelFun; + + this->m_btn3Str = item.m_btn3Str; + this->m_btn3Visible = item.m_btn3Visible; + this->m_btn3ClickFun = item.m_btn3ClickFun; + this->m_btn3PreFun = item.m_btn3PreFun; + this->m_btn3RelFun = item.m_btn3RelFun; + + this->m_btn4Str = item.m_btn4Str; + this->m_btn4Visible = item.m_btn4Visible; + this->m_btn4ClickFun = item.m_btn4ClickFun; + this->m_btn4PreFun = item.m_btn4PreFun; + this->m_btn4RelFun = item.m_btn4RelFun; + + this->m_btn5Str = item.m_btn5Str; + this->m_btn5Visible = item.m_btn5Visible; + this->m_btn5ClickFun = item.m_btn5ClickFun; + this->m_btn5PreFun = item.m_btn5PreFun; + this->m_btn5RelFun = item.m_btn5RelFun; + } +} diff --git a/items/outctrlitem.h b/items/outctrlitem.h new file mode 100644 index 0000000..388d39b --- /dev/null +++ b/items/outctrlitem.h @@ -0,0 +1,68 @@ +#ifndef OUTCTRLITEM_H +#define OUTCTRLITEM_H + +#include +#include "items/cmdconfig.h" + +typedef short int s16; + +class OutCtrlItem : public QObject +{ + Q_OBJECT +public: + explicit OutCtrlItem(QObject *parent = 0); + + ~OutCtrlItem(); + +public: + OutCtrlItem(const OutCtrlItem & item); + OutCtrlItem & operator= (const OutCtrlItem & item); + +public: + void clean(); + +private: + void copyData(const OutCtrlItem & item); + +public: + int m_macType; // 机器类型 + int m_showPriority; // 显示优先级 + QString m_name; // 名称 + int m_def; // 对应的事件宏定义 + + QString m_btn1Str; // 按钮1上的文本 + bool m_btn1Visible; // 按钮1是否可见 + s16 m_btn1ClickFun; // 按钮1对应的点击事件 -1:代表没有 + s16 m_btn1PreFun; // 按钮1对应的按下事件 -1:代表没有 + s16 m_btn1RelFun; // 按钮1对应的抬起事件 -1:代表没有 + + QString m_btn2Str; // 按钮2上的文本 + bool m_btn2Visible; // 按钮2是否可见 + s16 m_btn2ClickFun; // 按钮2对应的点击事件 -1:代表没有 + s16 m_btn2PreFun; // 按钮2对应的按下事件 -1:代表没有 + s16 m_btn2RelFun; // 按钮2对应的抬起事件 -1:代表没有 + + QString m_btn3Str; // 按钮3上的文本 + bool m_btn3Visible; // 按钮3是否可见 + s16 m_btn3ClickFun; // 按钮3对应的点击事件 -1:代表没有 + s16 m_btn3PreFun; // 按钮3对应的按下事件 -1:代表没有 + s16 m_btn3RelFun; // 按钮3对应的抬起事件 -1:代表没有 + + QString m_btn4Str; // 按钮4上的文本 + bool m_btn4Visible; // 按钮4是否可见 + s16 m_btn4ClickFun; // 按钮4对应的点击事件 -1:代表没有 + s16 m_btn4PreFun; // 按钮4对应的按下事件 -1:代表没有 + s16 m_btn4RelFun; // 按钮4对应的抬起事件 -1:代表没有 + + QString m_btn5Str; // 按钮5上的文本 + bool m_btn5Visible; // 按钮5是否可见 + s16 m_btn5ClickFun; // 按钮5对应的点击事件 -1:代表没有 + s16 m_btn5PreFun; // 按钮5对应的按下事件 -1:代表没有 + s16 m_btn5RelFun; // 按钮5对应的抬起事件 -1:代表没有 + +signals: + +public slots: +}; + +#endif // OUTCTRLITEM_H diff --git a/items/paraitem.cpp b/items/paraitem.cpp new file mode 100644 index 0000000..a58bbe1 --- /dev/null +++ b/items/paraitem.cpp @@ -0,0 +1,77 @@ +#include "paraitem.h" + + +ParaItem::ParaItem(QObject *parent) : QObject(parent) +{ + clean(); +} + +ParaItem::~ParaItem() +{ + paraName.clear(); + selList.clear(); + unitStr.clear(); + valueStr.clear(); +} + +ParaItem::ParaItem(const ParaItem & item) : QObject() +{ + copyData(item); +} + +ParaItem & ParaItem::operator=(const ParaItem & item) +{ + copyData(item); + return *this; +} + +void ParaItem::clean() +{ + mcenSel = 0; + paraType = 0; + paraTypeSort = 0; + indexInPara = -1; + bitInWord = 0; + readonly = 0; + valueType = 0; + paraName = ""; + value = 0; + minVal = 0; + maxVal = 0; + defValue = 0; + afterPoint = 0; + unitStr = ""; + valueStr = ""; + selList = ""; + selIdx = -1; + defIdx = -1; + showPriority = 0; + authority = 0; +} + +void ParaItem::copyData(const ParaItem & item) +{ + if (this != &item) + { + this->mcenSel = item.mcenSel; + this->paraType = item.paraType; + this->paraTypeSort = item.paraTypeSort; + this->indexInPara = item.indexInPara; + this->bitInWord = item.bitInWord; + this->readonly = item.readonly; + this->valueType = item.valueType; + this->paraName = item.paraName; + this->value = item.value; + this->minVal = item.minVal; + this->maxVal = item.maxVal; + this->defValue = item.defValue; + this->afterPoint = item.afterPoint; + this->unitStr = item.unitStr; + this->valueStr = item.valueStr; + this->selList = item.selList; + this->selIdx = item.selIdx; + this->defIdx = item.defIdx; + this->showPriority = item.showPriority; + this->authority = item.authority; + } +} diff --git a/items/paraitem.h b/items/paraitem.h new file mode 100644 index 0000000..9a5d38e --- /dev/null +++ b/items/paraitem.h @@ -0,0 +1,90 @@ +#ifndef PARAITEM_H +#define PARAITEM_H + +#include +#include +#include +#include "items/cmdconfig.h" + +class ParaItem : public QObject +{ + Q_OBJECT +public: + explicit ParaItem(QObject *parent = 0); + ParaItem(const ParaItem & item); + ~ParaItem(); + +public: + ParaItem &operator=(const ParaItem & item); + +public: + void clean(); + +private: + void copyData(const ParaItem & item); + +public: + int64_t mcenSel; // 机型选择 + int paraType; // 参数类型(机器参数、工作参数、花样设置参数...) + int paraTypeSort; // 参数类型分类(机器参数的速度参数、机器参数的动作参数...) + + int indexInPara; // 参数索引,-1,提示型显示; >= 0,该条目在参数中的位置 + int bitInWord; // 参数位索引 + int readonly; // 只读标志 + int valueType; // 参数值类型 = 0, 无值; = 1, 数字输入型; = 2, 开关选择型; = 3, 列表选择型; = 4, 字符输入型 +public: + QString paraName; // 参数名称 +public: + int64_t value; // 数字输入型数值 + int64_t minVal; // 输入值范围下限 + int64_t maxVal; // 输入值范围上限 + int64_t defValue; // 默认值 + int afterPoint; // 保留小数位数 + QString unitStr; // 单位 + QString valueStr; // 字符输入型字符 + +public: + QString selList; // 列表选择型参数列表,通过"\n"来分割 + int selIdx; // 选择项目 + int defIdx; // 默认选择 +public: + int showPriority; // 显示优先级 + int authority; // 参数权限 + +}; + +#define PARA_VALUE_TYPE_NONE 0 // 无 +#define PARA_VALUE_TYPE_INT 1 // 数值输入型 +#define PARA_VALUE_TYPE_SW 2 // 开关型 +#define PARA_VALUE_TYPE_LIST 3 // 列表选择型 +#define PARA_VALUE_TYPE_STRINPUT 4 // 字符串输入型 +#define PARA_VALUE_TYPE_CLICK 5 // 点击触发型 + +//参数类型(点击触发型的参数种类) +#define PARA_TYPE_MACH 0x00000001 // 主控机器参数 +#define PARA_TYPE_WORK 0x00000002 // 主控工作参数 +#define PARA_TYPE_DEF_MC 0x00000004 // 出厂默认机器配置参数(读取有效) +#define PARA_TYPE_DEF_WK 0x00000008 // 出厂默认机器工作参数(读取有效) +#define PARA_TYPE_PATTERN 0x00000010 // 花样参数 +#define PARA_TYPE_SOFTWARESET 0x00000020 // 软件设置参数 +#define PARA_TYPE_TIMESET 0x00000040 // 时间设置参数 +#define PARA_TYPE_COMMONFUN 0x00000080 // 常用功能设置参数 +#define PARA_TYPE_NETWORKSET 0x00000100 // 网络管理设置参数 +#define PARA_TYPE_ROOT 0x00000200 // 超级用户参数 +#define PARA_TYPE_SPINDLETEST 0x00000400 //主轴研车参数 +#define PARA_TYPE_HMICONFIGURATION 0x00000800 //界面配置 +#define PARA_TYPE_IOTCONFIGURATION 0x00001000 //物联网配置 +#define PARA_TYPE_NETWORKSETTINGS 0x00002000 //网络设置 + +//参数分类 +#define MC_SORT_SPEED 0x0001 // 速度参数 +#define MC_SORT_ACTION 0x0002 // 动作参数 +#define MC_SORT_DETECT 0x0004 // 检测参数 +#define MC_SORT_POSITION 0x0008 // 位置参数 +#define MC_SORT_SETTING 0x0010 // 设置参数 + +//花样参数分类 +#define PATTERNPARA_SORT_DSTR 0x0001 // dst和dsr文件花样参数 +#define PATTERNPARA_SORT_QUI 0x0002 // qui文件花样参数 + +#endif // PARAITEM_H diff --git a/items/parasetitem.cpp b/items/parasetitem.cpp new file mode 100644 index 0000000..9d798b4 --- /dev/null +++ b/items/parasetitem.cpp @@ -0,0 +1,44 @@ +#include "parasetitem.h" + +ParaSetItem::ParaSetItem(QObject *parent) : QObject(parent) +{ + clean(); +} + +ParaSetItem::~ParaSetItem() +{ + clean(); +} + +ParaSetItem::ParaSetItem(const ParaSetItem & item) : QObject() +{ + copyData(item); +} + +ParaSetItem & ParaSetItem::operator= (const ParaSetItem & item) +{ + copyData(item); + return *this; +} + +void ParaSetItem::clean() +{ + m_macType = 0; + m_showPriority = 0; + m_name.clear(); + m_topImageName.clear(); + m_paraType = 1; +} + +void ParaSetItem::copyData(const ParaSetItem &item) +{ + if (this != &item) + { + this->m_macType = item.m_macType; + this->m_showPriority = item.m_showPriority; + this->m_name = item.m_name; + this->m_topImageName = item.m_topImageName; + this->m_paraType = item.m_paraType; + } +} + diff --git a/items/parasetitem.h b/items/parasetitem.h new file mode 100644 index 0000000..92122cd --- /dev/null +++ b/items/parasetitem.h @@ -0,0 +1,36 @@ +#ifndef PARASETITEM_H +#define PARASETITEM_H + +#include + +class ParaSetItem : public QObject +{ + Q_OBJECT +public: + explicit ParaSetItem(QObject *parent = 0); + + ~ParaSetItem(); + +public: + ParaSetItem(const ParaSetItem & item); + ParaSetItem & operator= (const ParaSetItem & item); + +public: + void clean(); + +private: + void copyData(const ParaSetItem & item); + +public: + int m_macType; // 机器类型 + int m_showPriority; // 显示优先级 + QString m_name; // label名称 + QString m_topImageName; // 顶图图标logo名称 + int m_paraType; // 参数类型 + +signals: + +public slots: +}; + +#endif // PARASETITEM_H diff --git a/items/patternsetitem.cpp b/items/patternsetitem.cpp new file mode 100644 index 0000000..d24a25c --- /dev/null +++ b/items/patternsetitem.cpp @@ -0,0 +1,43 @@ +#include "patternsetitem.h" + +PatternSetItem::PatternSetItem(QObject *parent) : QObject(parent) +{ + clean(); +} + +PatternSetItem::~PatternSetItem() +{ + clean(); +} + +PatternSetItem::PatternSetItem(const PatternSetItem & item) : QObject() +{ + copyData(item); +} + +PatternSetItem & PatternSetItem::operator= (const PatternSetItem & item) +{ + copyData(item); + return *this; +} + +void PatternSetItem::clean() +{ + m_macType = 0; + m_showPriority = 0; + m_name.clear(); + m_topImageName.clear(); + m_enumFunction = 0; +} + +void PatternSetItem::copyData(const PatternSetItem &item) +{ + if (this != &item) + { + this->m_macType = item.m_macType; + this->m_showPriority = item.m_showPriority; + this->m_name = item.m_name; + this->m_topImageName = item.m_topImageName; + this->m_enumFunction = item.m_enumFunction; + } +} diff --git a/items/patternsetitem.h b/items/patternsetitem.h new file mode 100644 index 0000000..c9579ac --- /dev/null +++ b/items/patternsetitem.h @@ -0,0 +1,36 @@ +#ifndef PATTERNSETITEM_H +#define PATTERNSETITEM_H + +#include + +class PatternSetItem : public QObject +{ + Q_OBJECT +public: + explicit PatternSetItem(QObject *parent = 0); + + ~PatternSetItem(); + +public: + PatternSetItem(const PatternSetItem & item); + PatternSetItem & operator= (const PatternSetItem & item); + +public: + void clean(); + +private: + void copyData(const PatternSetItem & item); + +public: + int m_macType; // 机器类型 + int m_showPriority; // 显示优先级 + QString m_name; // label名称 + QString m_topImageName; // 顶图图标logo名称 + int m_enumFunction; // 对应的事件的枚举值 + +signals: + +public slots: +}; + +#endif // PATTERNSETITEM_H diff --git a/items/sensoritem.cpp b/items/sensoritem.cpp new file mode 100644 index 0000000..90d657e --- /dev/null +++ b/items/sensoritem.cpp @@ -0,0 +1,46 @@ +#include "sensoritem.h" + +SensorItem::SensorItem(QObject *parent) : QObject(parent) +{ + clean(); +} + +SensorItem::~SensorItem() +{ + clean(); +} + +SensorItem::SensorItem(const SensorItem & item) : QObject() +{ + copyData(item); +} + +SensorItem & SensorItem::operator= (const SensorItem & item) +{ + copyData(item); + return *this; +} + +void SensorItem::clean() +{ + m_byte_offset = -1; // 字节偏移值 + m_bit_offset = -1; // 字节内位偏移值 + m_name.clear(); // 名称 + m_type = -1; // 传感器类型 +} + +void SensorItem::copyData(const SensorItem & item) +{ + m_byte_offset = item.m_byte_offset ; // 字节偏移值 + m_bit_offset = item.m_bit_offset ; // 字节内位偏移值 + m_name = item.m_name ; // 名称 + m_type = item.m_type; // 传感器类型 +} + +void SensorItem::setItemValue(int woffset, int boffset, QString name, int type) +{ + m_byte_offset = woffset ; // 字节偏移值 + m_bit_offset = boffset ; // 字节内位偏移值 + m_name = name ; // 名称 + m_type = type; // 传感器类型 +} diff --git a/items/sensoritem.h b/items/sensoritem.h new file mode 100644 index 0000000..da59709 --- /dev/null +++ b/items/sensoritem.h @@ -0,0 +1,35 @@ +#ifndef __SENSORITEM_H__ +#define __SENSORITEM_H__ + +#include + +#define MAX_SENSOR_NUM (1024*8) + +class SensorItem : public QObject +{ + Q_OBJECT +public: + explicit SensorItem(QObject *parent = 0); + ~SensorItem(); +public: + SensorItem(const SensorItem & item); + SensorItem & operator= (const SensorItem & item); + +public: + void clean(); + +private: + void copyData(const SensorItem & item); + +public: + void setItemValue(int woffset, int boffset, QString name, int type = -1); + +public: + int m_byte_offset; // 字节偏移值 + int m_bit_offset; // 字节内的位偏移值 + QString m_name; // 名称 + int m_type; // 传感器类型 + +}; + +#endif // __SENSORITEM_H__ diff --git a/items/shortcutitem.cpp b/items/shortcutitem.cpp new file mode 100644 index 0000000..3e5cf44 --- /dev/null +++ b/items/shortcutitem.cpp @@ -0,0 +1,43 @@ +#include "shortcutitem.h" + +ShortCutItem::ShortCutItem(QObject *parent) : QObject(parent) +{ + clean(); +} + +ShortCutItem::~ShortCutItem() +{ + clean(); +} + +ShortCutItem::ShortCutItem(const ShortCutItem & item) : QObject() +{ + copyData(item); +} + +ShortCutItem & ShortCutItem::operator= (const ShortCutItem & item) +{ + copyData(item); + return *this; +} + +void ShortCutItem::clean() +{ + m_macType = 0; + m_showPriority = 0; + m_name.clear(); + m_topImageName.clear(); + m_enumFunction = 0; +} + +void ShortCutItem::copyData(const ShortCutItem &item) +{ + if (this != &item) + { + this->m_macType = item.m_macType; + this->m_showPriority = item.m_showPriority; + this->m_name = item.m_name; + this->m_topImageName = item.m_topImageName; + this->m_enumFunction = item.m_enumFunction; + } +} diff --git a/items/shortcutitem.h b/items/shortcutitem.h new file mode 100644 index 0000000..069cf37 --- /dev/null +++ b/items/shortcutitem.h @@ -0,0 +1,35 @@ +#ifndef SHORTCUTITEM_H +#define SHORTCUTITEM_H + +#include + +class ShortCutItem : public QObject +{ + Q_OBJECT +public: + explicit ShortCutItem(QObject *parent = 0); + + ~ShortCutItem(); +public: + ShortCutItem(const ShortCutItem & item); + ShortCutItem & operator= (const ShortCutItem & item); + +public: + void clean(); + +private: + void copyData(const ShortCutItem & item); + +public: + int m_macType; // 机器类型 + int m_showPriority; // 显示优先级 + QString m_name; // label名称 + QString m_topImageName; // 顶图图标logo名称 + int m_enumFunction; // 对应的事件的枚举值 + +signals: + +public slots: +}; + +#endif // SHORTCUTITEM_H diff --git a/machine/comm/comm.cpp b/machine/comm/comm.cpp new file mode 100644 index 0000000..97917cc --- /dev/null +++ b/machine/comm/comm.cpp @@ -0,0 +1,438 @@ +//------------------------------------------------------------------------------- +// File Name: comm.cpp +// Brief: +// Version: 1.0.0 +// Create Date: 2017/05/08 +// Create by: Marshal Lee +// Copyright: +// Copyright (c) 2017, Richpeace Co., LTD. +// All rights reserved. +// +// Modify by: Marshal Lee +// Modify Date: 2017/05/08 +//------------------------------------------------------------------------------- + +#define _IN_COMM_CPP + +#include "comm.h" +#include "crc16.h" + + +//-------------------------------------------------------------------------------------------------- + +// 读空缓冲区 +void readBuffEmpty(DataExFuns * funs) +{ + int rslt, len; + u8 temp; + + len = funs->getRsvLen(); + + while (len > 0) + { + rslt = funs->getCommData(&temp, 1); + if (rslt != 1) + { + rslt = 0; + break; + } + len--; + } +} + +//-------------------------------------------------------------------------------------------------- +// 功能: 从通讯口接收缓冲区中得到一个数据包, 如果有附加数据,包括附加数据 +// 参数: pPacket, 数据包指针 +// 返回: >=0, 成功取得一个数据包,包括定长数据包和可变长度数据包,返回值为数据包长度 +// -1, 参数错误 +// -2, CRC错误 +// -3, 数据不足 +// -4, 没有找到同步序列 +// -5,等待接收数据超时 +// -6, 数据包参数错误 +// -7, 附加数据CRC错误 +// -8, 发生未知错误 + +// 结果: 如果正确取得数据包,或通讯口没有命令, 循环队列尾指针回向后移动 + +int getANormalPacket(DataExFuns * funs, DataPacket * pPacket) +{ + int rslt, len; + int i; + int phase; + int status; + int exlen; + static int rdstatus = 0; + static u8 odBuf[LEN_NORMAL_PACKET]; + + u8 temp; + u8 rdBuf[LEN_NORMAL_PACKET]; + DataPacket * pDat; + + u8 getBuf[LEN_NORMAL_PACKET-DP_SYNC_LEN]; + int getBuflen; + int getIdx; + + u8 tmpBuf[LEN_NORMAL_PACKET-DP_SYNC_LEN]; + int tmpBuflen; + + if (funs == NULL || pPacket == NULL) + { + return -1; + } + + rslt = 0; + i = 0; // 扫描字节计数器 + getBuflen = 0; + getIdx = 0; + tmpBuflen = 0; + pDat = (DataPacket *)rdBuf; + + if (rdstatus == 0) + { + do + { + len = funs->getRsvLen(); // 得到接收长度 + len += getBuflen; // 加上已经获取的长度 + + if (len < LEN_NORMAL_PACKET) + { + rslt = -3; + break; // 没有足够数据 + } + + phase = 0; + status = 0; + rslt = 0; + + // 从接收缓冲区中找数据包 + while(((len + phase) >= LEN_NORMAL_PACKET) && (phase < LEN_NORMAL_PACKET)) + { + if (getBuflen == 0) + { + if (phase == 0 && i > MAX_ONCE_SCAN) + { + rslt = -4; + break; // 查找同步序列超出最大单次扫描字节数 + } + + rslt = funs->getCommData(&temp, 1); + if (rslt != 1) + { + printf("error at GetCommData rslt\r\n"); + rslt = -8; + break; + } + rslt = 0; + i++; // 扫描字数增加 + } + else + { + temp = getBuf[getIdx]; + getIdx++; + getBuflen--; + } + + len--; // 剩余长度减小 + + pDat->buff.normal[phase] = temp; + if (phase < DP_SYNC_LEN) // 识别同步序列 + { + tmpBuflen = 0; + + if (phase == 0) + { + if (temp == FLDP_SYNC[0]) + { + status = 1; + } + else if (temp == VLDP_SYNC[0]) + { + status = 2; + } + else + { + status = 0; + phase = 0; + rslt = 0; // 非同步序列 + break; + } + } + else + { + if (status == 1) + { + if (temp != FLDP_SYNC[phase]) + { + status = 0; + phase = 0; + rslt = 0; + break; + } + } + else if (status == 2) + { + if (temp != VLDP_SYNC[phase]) + { + status = 0; + phase = 0; + rslt = 0; + break; + } + } + else + { + printf("error status in GetANormalPacket\r\n"); + rslt = -8; + break; + } + } + } + else + { + tmpBuf[tmpBuflen] = temp; + tmpBuflen++; + } + + phase++; + } + + if (rslt != 0) + { + break; + } + + if (phase >= LEN_NORMAL_PACKET) // 得到数据包 + { + u16 crc; + crc = calcCrc16(pDat->normal.content, DP_CONT_LEN); + if (crc == pDat->normal.crc) + { + // 得到正确数据包 + memcpy(pPacket, pDat, LEN_NORMAL_PACKET); + + // printf("GetANormalPacket ok\r\n"); + rslt = LEN_NORMAL_PACKET; + break; + } + else + { + // CRC 不正确 + printf("crc error in GetANormalPacket\r\n"); + // 拷贝需要再判断的数据 + if (tmpBuflen != 0) + { + memcpy(getBuf, tmpBuf, tmpBuflen); + } + getBuflen = tmpBuflen; + getIdx = 0; + // continue; + } + } + else + { + // 没有找到同步序列的情况 + getBuflen = 0; + getIdx = 0; + // continue; + } + }while(1); + } + + if (rdstatus == 1) + { + memcpy(pPacket, odBuf, LEN_NORMAL_PACKET); + rslt = LEN_NORMAL_PACKET; + } + + // 附加数据 + if (rslt == LEN_NORMAL_PACKET) + { + if (memcmp(pPacket->normal.sync, VLDP_SYNC, DP_SYNC_LEN) == 0) // 是可变长度数据包 + { + exlen = pPacket->vldp.exlen; + if (exlen > MAX_EXDP_LEN) + { + printf("data exlen error, len=%d\r\n", exlen); + return -6; // 数据包参数错误 + } + + memset(pPacket->buff.exData, 0, MAX_EXDP_LEN); + + i = 0; + status = 0; // 作为历史计数器 + // 读取附加数据 + do + { + rslt = funs->getCommData(pPacket->buff.exData, exlen); + if (rslt == exlen) + { + u16 crc; + // 校验CRC + crc = calcCrc16(pPacket->buff.exData, exlen); + if (crc == pPacket->vldp.excrc) + { +// printf("get exdata ok\r\n"); + rslt = exlen+LEN_NORMAL_PACKET; + } + else + { + printf("crc error at get exdata\r\n"); + rslt = -7; // CRC错误 + } + rdstatus = 0; + break; // 得到数据 + } + else if (rslt == 0) + { + memcpy(odBuf, pPacket, LEN_NORMAL_PACKET); + rdstatus = 1; + rslt = -3; + break; + /* + // 数据不足 + if (funs->delay != NULL) + { + funs->delay(1); // 延时等待 + } + len = funs->getRsvLen(); // 得到接收数据长度 + qDebug()<<"getRsvLen"< GTEX_TIME_OUT) // 如果无变化计数器值大于超时值 + { + qDebug()<<"call GetCommData timeout"; + rslt = -5; + break; + } + } + */ + } + else + { + qDebug()<<"error after call GetCommData"; + break; + } + }while(1); + + } + } + return rslt; +} + +//-------------------------------------------------------------------------------------------------- + +// 功能: 添加数据到发送队列中, 通过通讯口发送数据 +// 参数: pPacket, 需要发送的数据,已经正确存放在了相应字段。 +// 结果: +// 0, 可以发送, 添加到了发送数据队列中 +// -1, 参数错误 +// -2,发送错误 +// 1, 队列已满, 不能发送 +int sendAPacket(DataExFuns * funs, DataPacket * pPacket) +{ + int rslt; + int freelen, sendlen; + + if (pPacket == NULL) + { + return -1; + } + + if (memcmp(pPacket->normal.sync, FLDP_SYNC, DP_SYNC_LEN) == 0) + { + sendlen = LEN_NORMAL_PACKET; + } + else if (memcmp(pPacket->normal.sync, VLDP_SYNC, DP_SYNC_LEN) == 0) + { + sendlen = LEN_NORMAL_PACKET + pPacket->vldp.exlen; + } + else + { + printf("para err, not a corrected packet\r\n"); + return -1; + } + + freelen = funs->getTrsFreeLen(); + + if (freelen < sendlen) + { +// printf("buff is full in SendAPacket\r\n"); + return 1; + } + + rslt = funs->sendCommData(pPacket->datbuff, sendlen); + if (rslt != sendlen) + { + printf("error at call SendCommData, rslt=%d\r\n", rslt); + return -2; + } + + return 0; +} + +//-------------------------------------------------------------------------------------------------- + +// 功能: 打包一个固定长度数据包 +// 参数: +// pPacket, 需要打包的数据包,其中除了sync和crc的部分已经就绪 +// 结果: +// 0, 打包好数据 +// -1, 参数错误 + +int packetAFLDP(DataPacket * pPacket) +{ + if (pPacket == NULL) + { + return -1; + } + + memcpy(pPacket->normal.sync, FLDP_SYNC, DP_SYNC_LEN); + pPacket->normal.crc = calcCrc16(pPacket->normal.content, DP_CONT_LEN); + + return 0; +} + +//-------------------------------------------------------------------------------------------------- + +// 功能: 打包一个可变长度数据包 +// 参数: pPacket, 需要打包的数据包,需要填充其中的 SYNC EXLEN EXCRC 和 EXDAT 等部分 +// pExdat, 附加数据,可以为空 +// exlen,附加数据长度,可以为0 +// 结果: +// 0, 打包好数据 +// -1, 参数错误 +// -2, + +int packetAVLDP(DataPacket * pPacket, u8 * pExdat, u16 exlen) +{ + if (pPacket == NULL) + { + return -1; + } + + if (pExdat == NULL) + { + exlen = 0; + } + + memcpy(pPacket->vldp.sync, VLDP_SYNC, DP_SYNC_LEN); + pPacket->vldp.exlen = exlen; + pPacket->vldp.excrc = calcCrc16(pExdat, exlen); + pPacket->vldp.crc = calcCrc16(pPacket->normal.content, DP_CONT_LEN); + if (exlen != 0) + { + memcpy(pPacket->vldp.exData, pExdat, exlen); + } + return 0; +} + +//-------------------------------------------------------------------------------------------------- + + diff --git a/machine/comm/comm.h b/machine/comm/comm.h new file mode 100644 index 0000000..1925382 --- /dev/null +++ b/machine/comm/comm.h @@ -0,0 +1,205 @@ +//------------------------------------------------------------------------------- +// File Name: comm.h +// Brief: +// Version: 1.0.0 +// Create Date: 2017/05/08 +// Create by: Marshal Lee +// Copyright: +// Copyright (c) 2017, Richpeace Co., LTD. +// All rights reserved. +// +// Modify by: Marshal Lee +// Modify Date: 2017/05/08 +//------------------------------------------------------------------------------- + +#ifndef __COMM_H__ +#define __COMM_H__ + +#include "typedef.h" +#include +#include +#include +//------------------------------------------------------------------------ + +// 通讯数据包定义 + +//------------------------------------ +/* +一、数据包格式 + + 1. 固定长度数据包格式 + + |-------------------------------------------------------------------|-----------| + | 数据识别序列 | 数据内容 | 校验字 | + |-------------------------------------------------------------------|-----------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 B8 B9 B10 B11 B12 B13 | B14 B15 | + |-------------------------------------------------------------------|-----------| + | 固定序列如下 | | 参数,不同命令定义不同 | B4--B13的 | + | | 数据包ID | 具体定义参考命令详细说明 | | + | 'F','L','D','P' | | | 16位CRC | + |-------------------------------------------------------------------|-----------| + + 2. 可变长度数据包格式 + + |---------------------------------------------------------------------------|-----------|---------------- + | 数据识别序列 | 数据内容 | 校验字 | 附加数据 | + |---------------------------------------------------------------------------|-----------|---------------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 | B8 B9 | B10 B11 B12 B13 | B14 B15 | B16--Bn | + |---------------------------------------------------------------------------|-----------|---------------| + | 固定序列如下 | | 附加 | 附加 | 参数,不同命令 | B4--B13的 | 数据内容 | + | | 数据包ID | 数据 | 数据 | 定义不同,定义 | | | + | 'V','L','D','P' | | 长度 | 校验字 | 参考命令详细说明 | 16位CRC | | + |---------------------------------------------------------------------------|-----------|---------------| + + 附加数据长度取值范围为 0--1024 +*/ + +//------------------------------------ + +#define DP_SYNC_LEN 4 // 数据识别序列长度 +#define DP_CONT_LEN 10 // 数据内容长度 +#define DP_CRC_LEN 2 // 校验字长度 +#define MAX_EXDP_LEN 1024 // 最大附加数据长度 + +#define LEN_NORMAL_PACKET (DP_SYNC_LEN+DP_CONT_LEN+DP_CRC_LEN) + +#define MAX_INDP_PARA 8 + +#ifdef _IN_COMM_CPP + +const u8 FLDP_SYNC[DP_SYNC_LEN] = +{ + 'F','L','D','P', +}; + +const u8 VLDP_SYNC[DP_SYNC_LEN] = +{ + 'V','L','D','P', +}; + +#else + +extern const u8 FLDP_SYNC[DP_SYNC_LEN]; +extern const u8 VLDP_SYNC[DP_SYNC_LEN]; + +#endif + +//----------------------------------------------------------------------- + +typedef union +{ + u8 datbuff[LEN_NORMAL_PACKET+MAX_EXDP_LEN]; // dat buff 方式 + + struct + { + u8 normal[LEN_NORMAL_PACKET]; + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) buff; // buff方式 + + struct + { + u8 sync[DP_SYNC_LEN]; + u8 content[DP_CONT_LEN]; + u16 crc; + } __attribute__ ((packed)) normal; // 通用方式 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmd; + u8 para[8]; + u16 crc; + } __attribute__ ((packed)) fldp; // fldp方式 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmd; + u16 exlen; + u16 excrc; + u8 para[4]; + u16 crc; + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) vldp; // vldp方式 + +} DataPacket; + +//----------------------------------------------------------------------- + +typedef struct +{ + int (*sendCommData)(u8 *, int); + int (*getCommData)(u8 *, int); + int (*getRsvLen)(void); + int (*getTrsFreeLen)(void); + void (*delay)(u32); +} DataExFuns; + + +//----------------------------------------------------------------------- + +// 读空缓冲区 +void readBuffEmpty(DataExFuns * funs); + + +//----------------------------------------------------------------------- + +// 功能: 从通讯口接收缓冲区中得到一个数据包, +// 只能取得普通数据包结构. 如果数据包还有附加数据, 那么需要用 GetExCommData 函数取得 +// 参数: pPacket, 数据包指针 +// 返回: >=0, 成功取得一个数据包,包括定长数据包和可变长度数据包,返回值为数据包长度 +// -1, 参数错误 +// -2, CRC错误 +// -3, 数据不足 +// -4, 没有找到同步序列 +// -5,等待接收数据超时 +// -6, 数据包参数错误 +// -7, 附加数据CRC错误 +// -8, 发生未知错误 + +// 结果: 如果正确取得数据包,或通讯口没有命令, 循环队列尾指针回向后移动 + +#define MAX_ONCE_SCAN (LEN_NORMAL_PACKET*10) // 一次扫描最大字节数 +#define GTEX_TIME_OUT 100 // 得到数据包超时时间,单位是ms + +int getANormalPacket(DataExFuns * funs, DataPacket * pPacket); + +//-------------------------------------------------------------------------------------------------- + +// 功能: 添加数据到发送队列中, 通过通讯口发送数据 +// 参数: pPacket, 需要发送的数据,已经正确存放在了相应字段。 +// 结果: +// 0, 可以发送, 添加到了发送数据队列中 +// -1, 参数错误 +// -2,发送错误 +// 1, 队列已满, 不能发送 +int sendAPacket(DataExFuns * funs, DataPacket * pPacket); + +//-------------------------------------------------------------------------------------------------- + +// 功能: 打包一个固定长度数据包 +// 参数: +// pPacket, 需要打包的数据包,其中除了sync和crc的部分已经就绪 +// 结果: +// 0, 打包好数据 +// -1, 参数错误 + +int packetAFLDP(DataPacket * pPacket); + +//-------------------------------------------------------------------------------------------------- + +// 功能: 打包一个可变长度数据包 +// 参数: pPacket, 需要打包的数据包,需要填充其中的 SYNC EXLEN EXCRC 和 EXDAT 等部分 +// pExdat, 附加数据,可以为空 +// exlen,附加数据长度,可以为0 +// 结果: +// 0, 打包好数据 +// -1, 参数错误 +// -2, + +int packetAVLDP(DataPacket * pPacket, u8 * pExdat, u16 exlen); + +//-------------------------------------------------------------------------------------------------- + + +#endif diff --git a/machine/comm/config.h b/machine/comm/config.h new file mode 100644 index 0000000..a5b2e71 --- /dev/null +++ b/machine/comm/config.h @@ -0,0 +1,16 @@ +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + + + +#include "typedef.h" +#include + + +#define EMBROIDERY +#define MAX_EXDP_LEN 1024 // 最大附加数据长度 + +#define SEW 8 //缝纫 +#define IMAGE_TYPE (QImage::Format_ARGB32) + +#endif diff --git a/machine/comm/crc16.cpp b/machine/comm/crc16.cpp new file mode 100644 index 0000000..8fbf1f7 --- /dev/null +++ b/machine/comm/crc16.cpp @@ -0,0 +1,159 @@ + +//------------------------------------------------------------------------------- +// File Name: crc16.cpp +// Brief: +// Version: 1.0.0 +// Create Date: 2017/05/08 +// Create by: Marshal Lee +// Copyright: +// Copyright (c) 2017, Richpeace Co., LTD. +// All rights reserved. +// +// Modify by: Marshal Lee +// Modify Date: 2017/05/08 +//------------------------------------------------------------------------------- + + +#include "crc16.h" + +//------------------------------------------------------------------------------- + +#ifdef USE_CRC_TABLE + +// 16 位 crc 列表 +u16 CRC16_LIST[256] = +{ + 0x0000, 0x3096, 0x612C, 0x51BA, 0xC419, 0xF48F, 0xA535, 0x95A3, + 0x8832, 0xB8A4, 0xE91E, 0xD988, 0x4C2B, 0x7CBD, 0x2D07, 0x1D91, + 0x1064, 0x20F2, 0x7148, 0x41DE, 0xD47D, 0xE4EB, 0xB551, 0x85C7, + 0x9856, 0xA8C0, 0xF97A, 0xC9EC, 0x5C4F, 0x6CD9, 0x3D63, 0x0DF5, + 0x20C8, 0x105E, 0x41E4, 0x7172, 0xE4D1, 0xD447, 0x85FD, 0xB56B, + 0xA8FA, 0x986C, 0xC9D6, 0xF940, 0x6CE3, 0x5C75, 0x0DCF, 0x3D59, + 0x30AC, 0x003A, 0x5180, 0x6116, 0xF4B5, 0xC423, 0x9599, 0xA50F, + 0xB89E, 0x8808, 0xD9B2, 0xE924, 0x7C87, 0x4C11, 0x1DAB, 0x2D3D, + 0x4190, 0x7106, 0x20BC, 0x102A, 0x8589, 0xB51F, 0xE4A5, 0xD433, + 0xC9A2, 0xF934, 0xA88E, 0x9818, 0x0DBB, 0x3D2D, 0x6C97, 0x5C01, + 0x51F4, 0x6162, 0x30D8, 0x004E, 0x95ED, 0xA57B, 0xF4C1, 0xC457, + 0xD9C6, 0xE950, 0xB8EA, 0x887C, 0x1DDF, 0x2D49, 0x7CF3, 0x4C65, + 0x6158, 0x51CE, 0x0074, 0x30E2, 0xA541, 0x95D7, 0xC46D, 0xF4FB, + 0xE96A, 0xD9FC, 0x8846, 0xB8D0, 0x2D73, 0x1DE5, 0x4C5F, 0x7CC9, + 0x713C, 0x41AA, 0x1010, 0x2086, 0xB525, 0x85B3, 0xD409, 0xE49F, + 0xF90E, 0xC998, 0x9822, 0xA8B4, 0x3D17, 0x0D81, 0x5C3B, 0x6CAD, + 0x8320, 0xB3B6, 0xE20C, 0xD29A, 0x4739, 0x77AF, 0x2615, 0x1683, + 0x0B12, 0x3B84, 0x6A3E, 0x5AA8, 0xCF0B, 0xFF9D, 0xAE27, 0x9EB1, + 0x9344, 0xA3D2, 0xF268, 0xC2FE, 0x575D, 0x67CB, 0x3671, 0x06E7, + 0x1B76, 0x2BE0, 0x7A5A, 0x4ACC, 0xDF6F, 0xEFF9, 0xBE43, 0x8ED5, + 0xA3E8, 0x937E, 0xC2C4, 0xF252, 0x67F1, 0x5767, 0x06DD, 0x364B, + 0x2BDA, 0x1B4C, 0x4AF6, 0x7A60, 0xEFC3, 0xDF55, 0x8EEF, 0xBE79, + 0xB38C, 0x831A, 0xD2A0, 0xE236, 0x7795, 0x4703, 0x16B9, 0x262F, + 0x3BBE, 0x0B28, 0x5A92, 0x6A04, 0xFFA7, 0xCF31, 0x9E8B, 0xAE1D, + 0xC2B0, 0xF226, 0xA39C, 0x930A, 0x06A9, 0x363F, 0x6785, 0x5713, + 0x4A82, 0x7A14, 0x2BAE, 0x1B38, 0x8E9B, 0xBE0D, 0xEFB7, 0xDF21, + 0xD2D4, 0xE242, 0xB3F8, 0x836E, 0x16CD, 0x265B, 0x77E1, 0x4777, + 0x5AE6, 0x6A70, 0x3BCA, 0x0B5C, 0x9EFF, 0xAE69, 0xFFD3, 0xCF45, + 0xE278, 0xD2EE, 0x8354, 0xB3C2, 0x2661, 0x16F7, 0x474D, 0x77DB, + 0x6A4A, 0x5ADC, 0x0B66, 0x3BF0, 0xAE53, 0x9EC5, 0xCF7F, 0xFFE9, + 0xF21C, 0xC28A, 0x9330, 0xA3A6, 0x3605, 0x0693, 0x5729, 0x67BF, + 0x7A2E, 0x4AB8, 0x1B02, 0x2B94, 0xBE37, 0x8EA1, 0xDF1B, 0xEF8D +}; + +#else + +#ifdef SHIFT_RIGHT // 如果是右移 + +#define CRC_GEN 0xa001 // 使用多项式 0xa001 + +#else // 如果是左移 + +#define CRC_GEN 0x8005 // 使用多项式 0x8005 + +#endif // #ifdef SHIFT_RIGHT + +#endif + +//------------------------------------------------------------------------------- + +u16 addCrc16(u16 crcword, u8 dat) +{ +#ifdef USE_CRC_TABLE // 查表法crc + crcword = (crcword >> 8) ^ CRC16_LIST[(crcword ^ dat) & 0xFF]; +#else + u8 i; + crcword ^= dat; + for (i = 0; i < 8; i++) + { +#ifdef SHIFT_RIGHT // 右移计算crc + if ((LOBYTE(crcword) & 0x01) != 0) + { + crcword >>= 1; + crcword ^= CRC_GEN; + } + else + { + crcword >>= 1; + } +#else // 左移计算crc + if ((HIBYTE(crcword) & 0x80) != 0) + { + crcword <<= 1; + crcword ^= CRC_GEN; + } + else + { + crcword <<= 1; + } +#endif + } + +#endif + return crcword; +} + +//------------------------------------------------------------------------------- + +u16 calcCrc16(u8 * pBuf, int lenBuf) +{ + int i; + u16 crcword = CRC_INIT; + + for (i = 0; i < lenBuf; i++) + { + crcword = addCrc16(crcword, pBuf[i]); + } + + return crcword; +} + +//------------------------------------------------------------------------------- + +u8 calcCheckSum8(u8 * pBuf, int lenBuf) +{ + int i; + u8 checksum = 0; + + for (i = 0; i < lenBuf; i++) + { + checksum += pBuf[i]; + } + + return checksum; + +} + +//------------------------------------------------------------------------------- + +u32 calcCheckSum32(u8 * pBuf, int lenBuf) +{ + int i; + u32 checksum = 0; + + for (i = 0; i < lenBuf; i++) + { + checksum += pBuf[i]; + } + + return checksum; + +} + + diff --git a/machine/comm/crc16.h b/machine/comm/crc16.h new file mode 100644 index 0000000..25dc808 --- /dev/null +++ b/machine/comm/crc16.h @@ -0,0 +1,60 @@ +//------------------------------------------------------------------------------- +// File Name: crc16.h +// Brief: +// Version: 1.0.0 +// Create Date: 2017/05/08 +// Create by: Marshal Lee +// Copyright: +// Copyright (c) 2017, Richpeace Co., LTD. +// All rights reserved. +// +// Modify by: Marshal Lee +// Modify Date: 2017/05/08 +//------------------------------------------------------------------------------- + + +#ifndef __CRC16_H__ +#define __CRC16_H__ + +/* + + CRC16 算法模块 + + 提供查表法和移位法两种 CRC16 算法 + +*/ + +#include "typedef.h" + +#define USE_CRC_TABLE // 用查表法crc, 否则, 用移位法计算 +#define SHIFT_RIGHT // 右移位 + +#ifdef USE_CRC_TABLE + +#define CRC_INIT 0x0000 // 并且crc初值为0 + +#else + +#ifdef SHIFT_RIGHT // 如果是右移 + +#define CRC_INIT 0xFFFF // crc初值为0xFFFF + +#else // 如果是左移 + +#define CRC_INIT 0x0000 // 并且crc初值为0 + +#endif // #ifdef SHIFT_RIGHT + +#endif + + +u16 calcCrc16(u8 * pBuf, int lenBuf); + + +u8 calcCheckSum8(u8 * pBuf, int lenBuf); + +u32 calcCheckSum32(u8 * pBuf, int lenBuf); + + +#endif + diff --git a/machine/comm/crc32.cpp b/machine/comm/crc32.cpp new file mode 100644 index 0000000..bb93930 --- /dev/null +++ b/machine/comm/crc32.cpp @@ -0,0 +1,74 @@ + +//------------------------------------------------------------------------------- +// File Name: crc32.c +// Brief: +// Version: 1.0.0 +// Create Date: 2018/08/13 +// Create by: Marshal Lee +// Copyright: +// Copyright (c) 2019, Richpeace Co., LTD. +// All rights reserved. +// +// Modify by: Marshal Lee +// Modify Date: 2018/08/13 +//------------------------------------------------------------------------------- + + +#include "crc32.h" + +//------------------------------------------------------------------------------- + +static const u32 CRC32_LIST[256] = +{ + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, + 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, + 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, + 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, + 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, + 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, + 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, + 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, + 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, + 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, + 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, + 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, + 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, + 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, + 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, + 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, + 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, + 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, + 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, + 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, + 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, + 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, + 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, + 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, + 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, + 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL, +}; + + +u32 addCrc32(u32 crcword, u8 dat) +{ + return (crcword >> 8) ^ CRC32_LIST[((crcword ^ dat) & 0xFF)]; +} + +u32 calcCrc32(u8 * pBuf, int lenBuf) +{ + int i; + u32 crcword = CRC32_INIT; + + for (i = 0; i < lenBuf; i++) + { + crcword = addCrc32(crcword, pBuf[i]); + } + + return crcword; +} diff --git a/machine/comm/crc32.h b/machine/comm/crc32.h new file mode 100644 index 0000000..c89f3d8 --- /dev/null +++ b/machine/comm/crc32.h @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------------- +// File Name: crc32.h +// Brief: +// Version: 1.0.0 +// Create Date: 2018/08/13 +// Create by: Marshal Lee +// Copyright: +// Copyright (c) 2019, Richpeace Co., LTD. +// All rights reserved. +// +// Modify by: Marshal Lee +// Modify Date: 2018/08/13 +//------------------------------------------------------------------------------- + + +#ifndef __CRC32_H__ +#define __CRC32_H__ + +/* + CRC32 算法模块 +*/ + +#include "typedef.h" + +#define CRC32_INIT 0xffffffff // crc初值 + + +u32 addCrc32(u32 crcword, u8 dat); +u32 calcCrc32(u8 * pBuf, int lenBuf); + + + +#endif diff --git a/machine/comm/datadef.h b/machine/comm/datadef.h new file mode 100644 index 0000000..9a7d4bc --- /dev/null +++ b/machine/comm/datadef.h @@ -0,0 +1,395 @@ +#ifndef __DATADEF_H__ +#define __DATADEF_H__ + +#include "typedef.h" +#include "config.h" +//------------------------------------------------------------------------- + +#define PATTERN_LARGE_NEEDLES 1280000 + +// 绝对位置数据 +typedef struct +{ + u8 ctrl; //控制字节 + u8 attr; //属性字节 + WORD action;//控制动作 + double ax; //X位置 + double ay; //Y位置 + double ar; //R角度 + +}__attribute__ ((packed)) DsAbsItem; + +typedef struct +{ + QList absItemList; + +}LineItem; + +// 画图格式数据 +typedef struct +{ + u8 ctrl;//控制字节 + u8 attr;//属性字节 + + WORD action;// 附加动作 + s16 bx, by;//绘制起点 + s16 ex, ey;//绘制终点 + s16 ar;//角度 + u32 rgb; + +}__attribute__ ((packed)) DispItem; + + +//机头间距表地址 +typedef struct { + unsigned char iswork; //1-8机头是否工作 + unsigned char doubleHead; //双机头 + unsigned short int distance1_2; //机头2和机头1的机头间距(单位0.1mm,范围0-5000.0) + unsigned short int distance1_3; + unsigned short int distance1_4; + unsigned short int distance1_5; + unsigned short int distance1_6; + unsigned short int distance1_7; + unsigned short int distance1_8; + +} HeadTable; + +// 画图格式数据 +typedef struct +{ + u8 ctrl;//控制字节 + u8 attr;//属性字节 + + WORD action;// 附加动作 + s16 bx, by;//绘制起点 + s16 ex, ey;//绘制终点 + s16 ar;//角度 + HeadTable headtable; + u32 rgb; + +}__attribute__ ((packed)) Disp_HeadItem; + +// 执行数据定义 +typedef struct +{ + u8 ctrl; // 控制字节 + u8 attr; // 属性字节 + s16 dx; // X偏移 + s16 dy; // Y偏移 + s16 dr; // R偏移 + u16 len; // xy分量合成长度 + u8 action[2]; //附加动作 + + u8 rev[4]; // 保留 + +}__attribute__ ((packed)) DataItem, Ds16Item; + +// ds8格式 +typedef struct +{ + u8 ctrl; // 控制字节 + u8 attr; // 属性字节 + s16 dx; // X偏移 + s16 dy; // Y偏移 + s16 dr; // R偏移 + +}__attribute__ ((packed)) Ds8Item; + +// 兼容dsr格式 +typedef struct +{ + u8 ctrl; // 控制字节 + u8 attr; // 属性字节 + u8 dx; // X偏移 + u8 dy; // Y偏移 + +}__attribute__ ((packed)) DsrItem, Ds4Item; + + +// 双字节压缩格式 +typedef struct +{ + s8 cdx; // X数据 + s8 cdy; // Y数据 + + /* + 格式定义 + cdx x分量控制数据 + cdy y分量控制数据 + + 每个字节的最低位为控制位,高7个位为数据位。数据位的最高位是符号位。 + + 两个控制位合在一起形成4种控制数据,定义如下: + cdx.0 cdy.0 + 0 0 缝纫数据,数据范围从-128 -- +126, 只有偶数可用(精度0.2mm),单位0.1mm + 0 1 空走数据,数据范围从-128 -- +126, 只有偶数可用(精度0.2mm),单位0.1mm + 1 0 大步空走数据,数据范围从-128 -- +126, 只有偶数可用(精度2mm),单位1mm + 1 1 控制数据,数据位定义为控制码和参数 cdx 为控制码, cdx 为参数 + +*/ +}__attribute__ ((packed)) ToBItem, Ds2Item; + + +// ctrl 定义 +// 控制字节, 作为功能码,定义如下 + +#define DATA_NULL 0x00 // 文件结束 +#define DATA_SEWING 0x01 // 缝纫数据, 该数据需要缝纫机针扎一次(主轴可以转动多圈(如果有跳针功能的话)), 同时 X, Y,R 偏移运动dx,dy,dr, 框步进式运动或连续运动 +#define DATA_OFFSET 0x02 // 偏移数据, 该数据只移动 X, Y,R 偏移 dx,dy,dr,连续运动 +#define DATA_CUTTING 0x03 // 切刀数据, 该数据需要切刀先运转,同时 X, Y,R 偏移 dx,dy,dr,根据切刀类型选择动框方式 +#define DATA_LASER 0x04 // 激光数据, 该数据需要激光出光, 同时X, Y,R偏移 dx,dy,dr,框连续运动,激光强度和运动线速度有关系 +#define DATA_DRAWING 0x05 // 记号数据, 该数据需要记号笔先放下来, 同时X, Y,R偏移dx,dy,dr,框连续运动 +#define DATA_SEWING_R 0x06 // 右机头缝纫,该数据需要缝纫机针扎一次(主轴可以转动多圈(如果有跳针功能的话)), 同时 X, Y,R 偏移运动dx,dy,dr, 框步进式运动或连续运动 + +#define DATA_SECF_SEW 0x11 // 第二框缝纫 +#define DATA_SECF_OFST 0x12 // 第二框偏移 + +#define DATA_SECF_SEW_R 0x16 // 第二框右机头缝纫,该数据需要缝纫机针扎一次(主轴可以转动多圈(如果有跳针功能的话)), 同时 X, Y,R 偏移运动dx,dy,dr, 框步进式运动或连续运动 + +// 兼容DSR控制码 +#define DATA_SYNCSEW 0x07 // 同步缝纫数据, 该数据需要缝纫机针扎一次, 同时 X, Y,R 偏移运动 dx,dy,dr,X2, Y2 也运动 dx,dy,框步进式运动或连续运动 +#define DATA_PAUSE_OLD 0x08 // 暂停 +#define DATA_ANGLE_OLD 0x09 // 拐点 +#define DATA_CUT_OLD 0x0A // 剪线 +#define DATA_END_OLD 0x10 // 结束码 + +#define DATA_JUMP 0x0B // 跳针数据,该数据要求缝纫机主轴不动, 但 X, Y,R 偏移运动 dx,dy,dr, 框步进式运动或连续运动 +#define DATA_PUNCH 0x0C // 冲孔数据, 该数据需要冲孔主轴运转一圈,同时 X, Y,R 偏移 dx,dy,dr, +#define DATA_EMB 0x0D // 绣花数据,该数据需要平绣针扎一次, 同时 X, Y,偏移运动dx,dy, 框步进式运动 +#define DATA_CHGND_OLD 0x0E // 换色功能码 lxs 20220628添加 +#define DATA_SYNCOFST 0x0F // 同步偏移数据 + +#define DATA_MILLING 0x21 // 铣刀数据 +#define DATA_DRILL 0x22 // 钻孔数据 +#define DATA_RKNIFE 0x23 // 圆刀数据, 该数据需要震刀先运转,同时 X, Y,R 偏移 dx,dy,dr, +#define DATA_SKNIFE 0x24 // 震刀数据, 该数据需要震刀先运转,同时 X, Y,R 偏移 dx,dy,dr, + +#define DATA_END 0x80 // 结束码 +#define DATA_PAUSE 0x81 // 暂停功能码 +#define DATA_CHGND 0x82 // 换色 +#define DATA_CUTTRD 0x83 // 剪线功能码 + +#define DATA_ANGLE 0x89 // 拐点 + +// atrr, 属性字节,作为运动属性字节 + +// 缝纫针步的属性定义: +// dx, x向偏移值, 有符号数, 范围为 -32768--32767, 单位为 0.01mm +// dy, y向偏移值, 有符号数, 范围为 -32768--32767, 单位为 0.01mm +// dr, r向偏移值, 有符号数, 范围为 -32768--32767, 单位为 0.0001 弧度 +// len, xy 分量的合成长度,无符号数,范围0--65535, 单位为 0.01mm + +#define HEAD_NAME_STR_LEN 0x20 +#define HEAD_FIX_INFO_LEN 0x32 + + +#pragma pack(1)//设定为1字节对齐 +//ds16头文件-发给下位机的 +typedef struct +{ + // 0x00 + char fileName[32]; // 文件名称 + + // 0x20 + u32 dataSize; // 数据字节数 + u32 itemNums; // 数据项个数 + u16 bytesPerItem; // 每项占的字节数 + u16 bytesPerBlk; // 数据内容划分块大小 + u32 dataChecksum; // 数据累加校验和 + u16 checkCrc; // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + + // 0x32 + u16 rev0; + u32 fileid; // 文件唯一标识符,识别是否为同一个文件 + + // 0x38 + u8 reserved1[0x40-0x38]; // 保留区1 + + // 0x40 + s32 anchorX; // 定位点坐标X + s32 anchorY; // 定位点坐标Y + + // 0x48 + s32 beginX; // 数据起点坐标X + s32 beginY; // 数据起点坐标Y + s32 beginR; // 数据起点坐标R + + // 0x54 + s32 minX; + s32 maxX; + s32 minY; + s32 maxY; // 轮廓范围 + + // 0x64 + u32 sizeX; + u32 sizeY; // 裁片大小 + + // 0x6C + s32 anchorX2; // 定位点坐标X2 + s32 anchorY2; // 定位点坐标Y2 + s32 beginX2; // 数据起点坐标X2 + s32 beginY2; // 数据起点坐标Y2 + s32 beginR2; // 数据起点坐标Z2 + + // 0x80 + u32 runAct; // 附加动作, + // bit0: 0:完成后不拍照 1:完成后拍照 + + // 0x84 + u8 reserved3[0x100-0x84]; + + // 100 + s32 pullMateOffset[6]; + u8 reserved4[0x200-0x118]; + + // 0x200 + u8 switchNeedleTable[0x400-0x200]; // 色序设定表, 支持512个色序设定 + +}__attribute__ ((packed)) DataDs16FileHead;//下发给主控的ds16文件头 +#pragma pack(1)//恢复对齐状态 + +typedef struct +{ + // 0 + char HMIVerStr[16]; // 界面版本 + + // 4 + u32 machineNumber; // 机器编号 + + // 5 + u16 motorNum; //电机个数 + u16 debugProgress; //调试进度 + // 6 + char fileName[32]; // 文件名称 + +#if(0) + // 52 + char sensorStartBtn; // 启动按钮1 + char sensorStopBtn; // 暂停按钮1 + char sensorJogBtn; // 点动按钮1 + char sensorMainFrameXZeroPos; // 主框架X零位 + char sensorMainFrameYZeroPos; // 主框架Y零位 + char sensorMainFrameXNegLimit; // 主框架X负限位 + char sensorMainFrameYNegLimit; // 主框架Y负限位 + char sensorMainFrameXPosLimit; // 主框架X正限位 + char sensorMainFrameYPosLimit; // 主框架Y正限位 + char sensorScissorsReturn; // 剪刀回位 +#endif + + //14 + char deliveryTime[32]; //交付日期 + + //22 + u32 workProgress; //机器工作进度(花样执行进度) + + //26 + u32 rev2[256-26]; + +} __attribute__ ((packed)) HMILotData; // 界面物联网数据 + +//------------------------------------------------------------------------- + + +// 升级文件头 +typedef struct +{ + // 0x00 + char fileName[32]; // 文件名称 + // 0x20 + u32 dataSize; // 数据字节数 + u32 dataChecksum; // 数据累加校验和 + + // 0x28 + u8 reserved1[0x30-0x28]; // 保留区1 + // 0x30 + u8 reserved2[0x64-0x30]; // 保留区1 + + // 0x64 + u8 reserved3[0x80-0x64]; // 保留区2 + + // 0x80 + u8 reserved4[0x100-0x80]; +}__attribute__ ((packed)) AppFileHead; + + +// 文件参数结构 +typedef struct +{ + // 0x00 + u8 hdIdenti[0x40]; + + // 0x40 + s32 anchorX; // 定位点坐标X + s32 anchorY; // 定位点坐标Y + // 0x48 + s32 beginX; // 数据起点坐标X + s32 beginY; // 数据起点坐标Y + s32 beginR; // 数据起点坐标Z + + // 0x54 + s32 minX; + s32 maxX; + s32 minY; + s32 maxY; // 轮廓范围 + + // 0x64 + u32 sizeX; + u32 sizeY; // 裁片大小 + + // 0x6C + s32 anchorX2; // 定位点坐标X2 + s32 anchorY2; // 定位点坐标Y2 + s32 beginX2; // 数据起点坐标X2 + s32 beginY2; // 数据起点坐标Y2 + s32 beginR2; // 数据起点坐标Z2 + + // 0x80 + u8 reserved0[0x200-0x80]; + // 0x200 + u8 reserved1[0x400-0x200]; + +}__attribute__ ((packed)) DataFilePara; + + +typedef struct +{ + s32 anchorX; // 定位点坐标X + s32 anchorY; // 定位点坐标Y + s32 beginX; // 数据起点坐标X + s32 beginY; // 数据起点坐标Y + +}__attribute__ ((packed)) DataFilePos; +//------------------------------------------------------------------------- + +// 文件执行参数结构 +typedef struct +{ + u32 newIdx; + s32 newXPos; + s32 newYPos; + s32 newRPos; + u32 newColorIdx; // 新针位 + u32 rev[256-5]; +}__attribute__ ((packed)) FileExecPara; + +//------------------------------------------------------------------------- + +//参数文件头 +struct ParaFile +{ + unsigned char s_head[4] ; // 默认 PARA + int s_type ; // 默认 0 + int s_len ; // 数据 默认 4096 + + unsigned int s_para_buff[1024] ; //工作 参数体 + + unsigned short s_crc ; //参数体的CRC + + unsigned short rev ; //预留 保持 结构体四字节对齐 +}; + +//------------------------------------------------------------------------- + +#endif + + diff --git a/machine/comm/protocol.h b/machine/comm/protocol.h new file mode 100644 index 0000000..4b12e59 --- /dev/null +++ b/machine/comm/protocol.h @@ -0,0 +1,1752 @@ +#ifndef __PROTOCOL_H__ +#define __PROTOCOL_H__ + +#include "comm.h" +#include "datadef.h" + +#pragma pack(1)//设定为1字节对齐 + +// 和下位机的通讯协议 + +/* +// 通讯数据包定义 + +一、数据包格式 + + 1. 固定长度数据包格式 + + |-------------------------------------------------------------------|-----------| + | 数据识别序列 | 数据内容 | 校验字 | + |-------------------------------------------------------------------|-----------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 B8 B9 B10 B11 B12 B13 | B14 B15 | + |-------------------------------------------------------------------|-----------| + | 固定序列如下 | | 参数,不同命令定义不同 | B4--B13的 | + | | 数据包ID | 具体定义参考命令详细说明 | | + | 'F','L','D','P' | | | 16位CRC | + |-------------------------------------------------------------------|-----------| + + 2. 可变长度数据包格式 + + |---------------------------------------------------------------------------|-----------|---------------- + | 数据识别序列 | 数据内容 | 校验字 | 附加数据 | + |---------------------------------------------------------------------------|-----------|---------------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 | B8 B9 | B10 B11 B12 B13 | B14 B15 | B16--Bn | + |---------------------------------------------------------------------------|-----------|---------------| + | 固定序列如下 | | 附加 | 附加 | 参数,不同命令 | B4--B13的 | 数据内容 | + | | 数据包ID | 数据 | 数据 | 定义不同,定义 | | | + | 'V','L','D','P' | | 长度 | 校验字 | 参考命令详细说明 | 16位CRC | | + |---------------------------------------------------------------------------|-----------|---------------| + + 附加数据长度取值范围为 0--1024 + + +//------------------------------------ +二、通讯命令一览表 + + 1. 上位机发送命令 + + 名称 符号 代码 类型 回复 说明 + 读取机器信息 UCMD_GET_MC_INFO 0x0001 FLDP 有 机器信息包括机器种类,配置,控制系统版本等信息 + 读取机器状态 UCMD_GET_MC_STATUS 0x0002 FLDP 有 读取机器的运行状态,包括机器工作状态,常用输入状态,电机位置,工作进度,文件信息等。 + 读取机器参数 UCMD_GET_MC_PARAS 0x0003 FLDP 有 读取内存中机器参数列表 + 读取内存数据 UCMD_GET_MEM_DATA 0x0004 FLDP 有 读取机器存储器数据,包括片内SRAM,片外SRAM,NAND FLASH等的内容 + 读取传感信号 UCMD_GET_SENSORS 0x0005 FLDP 有 读取IO信号状态及电机位置,编码器位置等信息 + 读取文件信息 UCMD_GET_FILE_INFO 0x0006 FLDP 有 读取数据文件的信息 + 读取传输结果 UCMD_GET_TRANS_RESULT 0x0007 FLDP 有 读取文件传输的结果位图,包括数据文件和升级文件 + 读取传感器位图 UCMD_GET_SENSOR_BMP 0x0008 FLDP 有 读取传感器配置位图 + + 设置机器配置 UCMD_SET_MC_CONFIG 0x0101 VLDP 无 设置机器的配置,包括信号使用的端口等信息 + 设置机器状态 UCMD_SET_MC_STATUS 0x0102 FLDP 无 设置机器的工作状态,包括是否允许工作,清除报警等。 + 设置机器参数 UCMD_SET_MC_PARAS 0x0103 VLDP 无 传输机器参数列表到下位机 + 设置内存数据 UCMD_SET_MEM_DATA 0x0104 FLDP 无 改变某个内存单元的数据内容 + 设置文件参数 UCMD_SET_FILE_PARAS 0x0105 FLDP 无 设置文件参数 + 设置执行进度 UCMD_SET_EXEC_PROGRESS 0x0106 FLDP 无 设置文件执行进度 + 设置分期密码 UCMD_SET_INSTALLMENT 0x0107 FLDP 无 设置分期密码 + 设置经过的时间 UCMD_SET_ELAPSED_TIME 0x0108 FLDP 无 设置经过的时间 + 设置默认参数 UCMD_SET_DEF_PARA 0x0109 FLDP 无 设置默认参数 + + 手动控制命令 UCMD_ACT_BYHAND 0x0201 FLDP 无 手动控制电机转动,OUTPUT信号开关等动作 + 机器工作命令 UCMD_MC_WORK 0x0202 FLDP 无 控制机器的工作命令,包括启动,停止,结束,或运动到某个位置等 + 移动XY命令 UCMD_MOVE_TO 0x0203 FLDP 无 移动XY到坐标 + + 启动文件传输 UCMD_START_TRANS 0x0301 VLDP 无 启动文件传输 + 文件传输命令 UCMD_TRANS_FILE_DATA 0x0302 VLDP 无 传输文件数据包 + 设置文件列表 UCMD_SET_FILE_LIST 0x0304 VLDP 无 设置文件列表 + 获取文件列表 UCMD_GET_FILE_LIST 0x0305 FLDP 有 获取下位机文件列表 + + 下位机升级 UCMD_MC_UPDATE 0x0401 VLDP 无 包括升级主控,外围板控制器等 + + 2. 下位机发送命令 + + 名称 符号 代码 类型 回复 说明 + 发送机器信息 DCMD_SEND_MC_INFO 0x8001 VLDP 无 发送机器信息包括机器种类,配置,控制系统版本等信息 + 发送机器状态 DCMD_SEND_MC_STATUS 0x8002 VLDP 无 发送取机器的运行状态,包括机器工作状态,常用输入状态,电机位置,工作进度,文件信息等。 + 发送机器参数 DCMD_SEND_MC_PARAS 0x8003 VLDP 无 发送内存中机器参数列表 + 发送内存数据 DCMD_SEND_MEM_DATA 0x8004 VLDP 无 发送机器存储器数据,包括片内SRAM,片外SRAM,NAND FLASH等的内容 + 发送传感信号 DCMD_SEND_SENSORS 0x8005 VLDP 无 发送IO信号状态及电机位置,编码器位置等信息 + 发送文件信息 DCMD_SEND_FILE_INFO 0x8006 VLDP 无 发送数据文件的信息 + 发送传输结果 DCMD_SEND_TRANS_RESULT 0x8007 VLDP 无 发送文件传输的结果位图 + 发送传感器位图 DCMD_SEND_SENSOR_BMP 0x8008 VLDP 无 发送传感器配置位图 + 发送张力传感器值 DCMD_SEND_TENSION 0x8009 VLDP 无 发送张力传感器值 +*/ + +// 上位机发送命令 +#define UCMD_GET_MC_INFO 0x0001 // 读取机器信息 +#define UCMD_GET_MC_STATUS 0x0002 // 读取机器状态 +#define UCMD_GET_MC_PARAS 0x0003 // 读取机器参数 +#define UCMD_GET_SENSORS 0x0005 // 读取传感信号 +#define UCMD_GET_TRANS_RESULT 0x0007 // 读取传输结果 +#define UCMD_GET_SENSOR_BMP 0x0008 // 读取传感器位图 +#define UCMD_GET_TENSION_DAT 0x0009 // 读取张力数据 +#define UCMD_GET_LOT_DATA 0x000D // 读取物联网数据 +#define UCMD_SET_MC_CONFIG 0x0101 // 设置机器配置 +#define UCMD_SET_MC_STATUS 0x0102 // 设置机器状态 +#define UCMD_SET_MC_PARAS 0x0103 // 设置机器参数 +#define UCMD_SET_MEM_DATA 0x0104 // 设置内存数据 +#define UCMD_SET_FILE_PARAS 0x0105 // 设置文件参数 +#define UCMD_SET_EXEC_PROGRESS 0x0106 // 设置执行进度 +#define UCMD_SET_INSTALLMENT 0x0107 // 设置分期密码 +#define UCMD_SET_ELAPSED_TIME 0x0108 // 设置经过的时间 +#define UCMD_SET_DEF_PARA 0x0109 // 设置默认参数 +#define UCMD_ACT_BYHAND 0x0201 // 手动控制命令 +#define UCMD_MC_WORK 0x0202 // 机器工作命令 +#define UCMD_MOVE_TO 0x0203 // 移动XY到坐标 +#define UCMD_MOVE_OFST 0x0205 // XY移动偏移量 +#define UCMD_START_TRANS 0x0301 // 启动文件传输 +#define UCMD_TRANS_FILE_DATA 0x0302 // 文件传输命令 +//#define UCMD_TRANS_FILE_DATA 0x0303 // 文件失效命令 +#define UCMD_SET_FILE_LIST 0x0304 // 设置文件列表 +#define UCMD_GET_FILE_LIST 0x0305 // 获取下位机文件列表 +#define UCMD_MC_UPDATE 0x0401 // 下位机升级 + + +// 下位机发送命令 +#define DCMD_REQUEST_DAT 0x8000 // 请求文件数据 +#define DCMD_SEND_MC_INFO 0x8001 // 发送机器信息 +#define DCMD_SEND_MC_STATUS 0x8002 // 发送机器状态 +#define DCMD_SEND_MC_PARAS 0x8003 // 发送机器参数 +#define DCMD_SEND_SENSORS 0x8005 // 发送传感信号 +#define DCMD_SEND_FILE_INFO 0x8006 // 发送文件信息 +#define DCMD_SEND_TRANS_RESULT 0x8007 // 发送传输结果 +#define DCMD_SEND_SENSOR_BMP 0x8008 // 发送传感器位图 +#define DCMD_SEND_LOTDATA 0x800D // 发送物联网数据 + + + + +// 三、命令详解 +/* + 工作流程 + 1. 上位机发送 UCMD_GET_MC_INFO 命令, 命令格式如下: + + |-------------------------------------------------------------------------------------------------------| + |-------------------------------------------------------------------------------------------------------| + | 数据识别序列 | 数据内容 | 校验字 | + |-------------------|-----------------------------------------------------------------------|-----------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 | B8 B9 B10 B11 B12 B13 | B14 B15 | + |-------------------|-------------------|-------------------|-------------------------------|-----------| + | 固定序列如下 | 数据包ID | 命令切换标志字 | 保留 | B4--B13的 | + | |-------------------|-------------------|-------------------------------| | + | 'F','L','D','P' | UCMD_GET_MC_INFO | 可能是随机数 | | 16位CRC | + |-------------------------------------------------------------------------------------------------------| + |-------------------------------------------------------------------------------------------------------| + + 2. 下位机收到后,回复 DCMD_SEND_MC_INFO 命令, 格式定义如下 + + |-----------------------------------------------------------------------------------------------------------------------| + |-------------------------------------------------------------------------------------------|-----------|---------------| + | 数据识别序列 | 数据内容 | 校验字 | 附加数据 | + |-------------------------------------------------------------------------------------------|-----------|---------------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 | B8 B9 | B10 B11 | B12 B13 | B14 B15 | B16--Bn | + |-------------------------------------------------------------------------------------------|-----------|---------------| + | 固定序列如下 | | 附加 | 附加 | 和上位机命令 | | B4--B13的 | 机器信息结构 | + | | DCMD_SEND_MC_INFO | 数据 | 数据 | 相同的 | 保留 | | | + | 'V','L','D','P' | | 长度 | 校验字 | 命令切换标志字 | | 16位CRC | | + |-------------------------------------------------------------------------------------------|-----------|---------------| + |-----------------------------------------------------------------------------------------------------------------------| + + 3. 上位机收到下位机的回复命令后,通过比对 命令标志切换字 , 可以确认是否是刚刚发送命令的回复(对于连续发送命令有用),根据情况确定是否重新发送命令。 + + 注意: + 对于没有时序要求的数据包,可以不在意 命令标志切换字。 +*/ + +// 机器信息结构定义 +typedef struct +{ + // 0 + char mBoardVerStr[16]; // 主板(n1)板卡版本 + char exBoardVerStr[16]; // 扩展板(n1-1)板卡版本 + char softwareVerStr[32]; // 软件版本 + char buildInfoStr[32]; // 编译日期信息 + char boardId[32]; // 板卡ID + char installment[32]; // 最后一次的分期密码字符串 + + // 160 + char rev1[512-160]; + + // 512 + u32 localIP; // 板卡IP地址 + u32 submask; // 子网掩码 + u32 gateIP; // 网关IP + // 524 + u8 curN1Ver; //软件编译N1板卡版本 + // 525 + u8 rev2[1024-525]; + +} __attribute__ ((packed)) MCInfo; + +typedef struct +{ + char debugInfoStr[1024]; // 调试信息 + +} __attribute__ ((packed)) DebugInfo; // 调试信息 + +typedef struct +{ + // 0 + char mBoardVerStr[16]; // 主板(n1)板卡版本 + + // 4 + char exBoardVerStr[16]; // 扩展板(n1-1)板卡版本 + + // 8 + char softwareVerStr[32]; // 软件版本 + + // 16 + char boardId[32]; // 板卡ID + + // 24 + char installment[32]; // 最后一次的分期密码字符串 + + // 32 + u32 rev10[32]; + + // 64 + u32 errorCode; // 报警信息 + s32 workableTimer; // 可工作时间计数器,剩余时间计数(分钟为单位) + u32 bootTimer; // 开机时间(单位分钟) + u32 workTimer; // 工作时间(单位分钟) + u32 workRpm; // 工作转速 + u32 curOutCounter; // 当前产量计数,由界面记录 + u32 totalOutCounter; // 累计产量计数 + u32 expectedOutput; // 产量预设 + + u32 spindleZeroSta; // 主轴零位状态 + // bit0:绣花主轴 + // bit1:冲孔主轴 + // bit2:缝纫主轴 + + u32 spindleAngle; // 主轴角度 + s32 motosPos[6]; // 电机坐标 + + // 80 + u32 sensorSignal[8]; // 传感器信号 + + // 88 + u32 machinecfg; //机器配置 + //勾线模式 bit0 0:单独勾线;1:集中勾线 + //锁头模式 bit1 0:电机锁头;1电磁铁锁头 + //89 + u32 sewHeadNumbers;//缝纫机头个数 + //90 + u32 embHeadNumbers; //绣花机头个数 + //91 + u32 embneedleNumbers;//绣花机针个数 + //92 + u32 punchHeadNumbers;//冲孔机头个数 + //93 + u32 punchneedleNumbers;//冲孔机针个数 + //94 + u32 sensonNumbers;//传感器信号总数 + + u32 rev20[128-95]; + + // 128 + u32 rev30[192-128]; + + //192 + u32 rev40[256-192]; + +} __attribute__ ((packed)) McLotData; // 主控物联网数据 + + +#define BOARD_VER_LEN 32 // 外围板程序版本长度 +#define MAX_SUPPORT_N5 48 +#define MAX_SUPPORT_N6 2 +#define MAX_SUPPORT_D86 1 + +#define PARA_NUM 256 + +//动框角度参数 +#define MAX_HOR 12 // 横,下标2最大值,针步 +#define MAX_VER 21 // 竖,下标1最大值,转速 + +typedef struct +{ + char softwareVerStr[BOARD_VER_LEN]; // 机头板程序版本 + u32 paraBuf[PARA_NUM]; //机头板参数 + u8 nodeType; // 节点类型 +}__attribute__ ((packed)) HeadInfo; + +typedef struct +{ + char softwareVerStr[BOARD_VER_LEN]; // 勾剪扣换控制板程序版本 + u32 paraBuf[PARA_NUM]; //换色板参数 +}__attribute__ ((packed)) HcpsInfo; + +typedef struct +{ + char softwareVerStr[BOARD_VER_LEN]; // D86程序版本 + u32 paraBuf[PARA_NUM]; //换色板参数 +}__attribute__ ((packed)) D86Info; + +typedef struct +{ + HeadInfo headInfo[MAX_SUPPORT_N5]; //最大支持32个机头 + HcpsInfo hcpsInfo[MAX_SUPPORT_N6]; //最大支持2个N6 + D86Info d86Info[MAX_SUPPORT_D86]; //1 + +}__attribute__ ((packed)) ExBoardInfo; + + +/* + 流程 + 1. 上位机发送命令 UCMD_SET_MC_CONFIG, 命令结构定义如下: + + |---------------------------------------------------------------------------------------------------------------| + |-----------------------------------------------------------------------------------|-----------|---------------| + | 数据识别序列 | 数据内容 | 校验字 | 附加数据 | + |-----------------------------------------------------------------------------------|-----------|---------------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 | B8 B9 | B10 B11 B12 B13 | B14 B15 | B16--Bn | + |-----------------------------------------------------------------------------------|-----------|---------------| + | 固定序列如下 | | 附加 | 附加数据 | | B4--B13的 | 机器信息结构 | + | | UCMD_SET_MC_CONFIG | 数据 | 校验字或 | 保留 | | | + | 'V','L','D','P' | | 长度 | 字段ID | | 16位CRC | | + |-----------------------------------------------------------------------------------|-----------|---------------| + |---------------------------------------------------------------------------------------------------------------| + + 附加数据结构定义和MCInfo相同。不过前面512字节是只读的信息,不能改变。 + + 2. 下位机收到命令后,设置相关配置。 + +*/ + +// 读取机器状态 +/* + 工作流程 + 1. 上位机发送 UCMD_GET_MC_STATUS 命令, 命令格式如下: + + |-------------------------------------------------------------------------------------------------------| + |-------------------------------------------------------------------------------------------------------| + | 数据识别序列 | 数据内容 | 校验字 | + |-------------------|-----------------------------------------------------------------------|-----------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 | B8 B9 B10 B11 B12 B13 | B14 B15 | + |-------------------|---------------------|-----------------|-------------------------------|-----------| + | 固定序列如下 | 数据包ID | 命令切换标志字 | 保留 | B4--B13的 | + | |---------------------|-----------------|-------------------------------| | + | 'F','L','D','P' | UCMD_GET_MC_STATUS | 可能是随机数 | | 16位CRC | + |-------------------------------------------------------------------------------------------------------| + |-------------------------------------------------------------------------------------------------------| + + 2. 下位机收到后,回复 DCMD_SEND_MC_STATUS 命令, 格式定义如下 + + |-----------------------------------------------------------------------------------------------------------------------| + |-------------------------------------------------------------------------------------------|-----------|---------------| + | 数据识别序列 | 数据内容 | 校验字 | 附加数据 | + |-------------------------------------------------------------------------------------------|-----------|---------------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 | B8 B9 | B10 B11 | B12 B13 | B14 B15 | B16--Bn | + |-------------------------------------------------------------------------------------------|-----------|---------------| + | 固定序列如下 | | 附加 | 附加 | 和上位机命令 | | B4--B13的 | 机器状态结构 | + | | DCMD_SEND_MC_STATUS | 数据 | 数据 | 相同的 | 保留 | | | + | 'V','L','D','P' | | 长度 | 校验字 | 命令切换标志字 | | 16位CRC | | + |-------------------------------------------------------------------------------------------|-----------|---------------| + |-----------------------------------------------------------------------------------------------------------------------| + + 3. 上位机收到下位机的回复命令后,通过比对 命令标志切换字 , 可以确认是否是刚刚发送命令的回复(对于连续发送命令有用),根据情况确定是否重新发送命令。 + + 注意: + 1. 对于没有时序要求的数据包,可以不在意 命令标志切换字。 + 2. 下位机会在状态发生变化的时候主动发送 DCMD_SEND_MC_STATUS 命令 + +*/ + +// 机器状态数据结构定义 +typedef struct +{ + // 0 + u32 workStatus; // 工作状态位图 + // .0 允许时限。=0,使用时限已到,不允许下位机工作;=1,允许下位机工作; + // .1 允许状态。=0,界面钳制,不允许下位机工作;=1,允许下位机工作; + // .2 机器状态。=0,手动工作状态; =1,自动工作状态 + // .3 钥匙状态。=0,关闭状态; =1,打开状态 + // .4 文件接收标志。= 0,初始状态。= 1,收到了文件 + // .5 参数接收标志。= 0,初始状态。= 1,收到了参数 + // .6 正在忙标志。= 0,空闲(可以接收文件和参数)。= 1,工作中(不会接收文件和参数) + // .7 上料状态。=0,手动上料状态; =1,自动上料状态 + // .8 参数更新标志。 =1,下位机更新了参数 + // .9 模拟工作标志。=1, 处于模拟工作状态 + // .10 允许扫描条码状态。=1, 允许 + // .11 允许拍照状态。=1, 允许 + // .12 正在工作标志 + // .13 传感信号扫描中标志 + // .14 相机校准模式中标志 + // .15 + // .16 + // .17 + // .18 + // .19 取模板框状态 + // .20 放模板框状态 + // .21 匹绣, 0:退出匹绣,主轴归零 1:进入匹绣,扎针,允许移框 + // .22 断线检测, 0:退出断线检测状态, 1:进入断线检测状态 + + // 1 + u32 errorCode; // 错误代码 + u32 fileIdx; // 文件序号 + u32 dataIdx; // 数据索引 + u32 runSpeed; // 运动速度 主轴转速 + u32 runAction; // 执行动作代码 * + u32 runSteps; // 当前执行步骤 * + u32 outCounter; // 产量计数 + + // 8 + s32 xPos; // x电机当前坐标 + s32 yPos; // y电机当前坐标 + u32 workNoseHead; //当前工作机头(平绣或毛巾或缠绕) + u32 tempdat1[2]; // 自定义状态1 + s32 spindleAngle; // 主轴角度 + u32 traverseState; // 机头板遍历状态 + u32 workTimer; // 工作时长 + u32 showSta; // bit0是平绣ZP主轴是否在位,0是在位,1是不在位 + u32 UThreadBkSta; // 面线断线状态,每一位对应一个机头 + u32 DThreadBkSta; // 底线断线状态,每一位对应一个机头 + u32 tempdat2; // 自定义状态2 + + // 20 + s32 btrdPics; // 底线片数计数 + s32 btrdLength; // 底线长度计数 + + // 22 + u32 colorIdx; // 色序编码 + s32 needleIdx; // 针位号 + + // 24 + u32 potval; //电位器值 + u32 tempdat3; // 提升电机档位值或松紧线位置 + + // 26 + //u32 laserIntensity; // 激光强度 + u32 iterationsNum; // 反复绣,当前反复次数 + + // 27 + s32 workableTimer; // 可工作时间计数器(分钟) + + u32 needleNum; // 缝纫针数 + + //29 + u32 UThreadBkSta1[32-29]; + + u32 tempdat4[8]; + + u32 tempdat5[8]; + + u32 tempdat6[8]; + + u32 tempdat7[8]; + +} __attribute__ ((packed)) MCStatus; + + +//机器状态 +#define WORK_STA_ENTIME 0x00000001 // 允许时限 +#define WORK_STA_ENSTATE 0x00000002 // 允许状态 +#define WORK_STA_WKAUTO 0x00000004 // 工作状态,手动自动 +#define WORK_STA_KEYEN 0x00000008 // 钥匙开关状态 +#define WORK_STA_FILEOK 0x00000010 // 文件接收标志。= 0,初始状态。= 1,收到了文件 +#define WORK_STA_PARAOK 0x00000020 // 参数接收标志。= 0,初始状态。= 1,收到了参数 +#define WORK_STA_BUSY 0x00000040 // 正在忙标志。= 0,空闲(可以接收文件和参数)。= 1,忙中(不会接收文件和参数) +#define WORK_STA_FEED 0x00000080 // 上料状态。=0,手动上料状态; =1,自动上料状态 +#define WORK_STA_NEW_PARA 0x00000100 // 参数更新标志。 =1,下位机更新了参数。上位机需要读取下位机的参数文件并更新 +#define WORK_STA_SIMULATE 0x00000200 // 模拟工作标志。 =1,机器处于模拟工作 +#define WORK_STA_EN_SCAN 0x00000400 // 扫码允许。 =1,允许扫码状态 +#define WORK_STA_EN_PHOTO 0x00000800 // 拍照允许。 =1,允许拍照状态 +#define WORK_STA_WORKING 0x00001000 // 工作标志。= 1,工作中 + + +//通用错误 +#define ERR_NONE 0x0000 // 没有错误 +#define ERR_NO_AIR 0x0002 // 气压不足 +#define ERR_NOT_SAFE 0x0003 // 安全区域介入 +#define ERR_EXPIRATION 0x0004 // 使用时限已到 +#define ERR_DRIVER 0x0005 // 驱动器报警 +#define ERR_FILL_DATA 0x0006 // 填充数据错误 +#define ERR_NOT_ALLOWED 0x0007 // 不允许工作状态 +#define ERR_CTRL_ERR 0x0008 // 控制错误 +#define ERR_FPGA_ERR 0x0009 // 运动控制芯片版本错误 +#define ERR_BUTTON_NOUP 0x000A // 等待按钮抬起超时 +#define ERR_FPGA_RESET 0x000B // FPGA复位错误 +#define ERR_NO_READY 0x000C // 外设未就绪 +#define ERR_NO_SEND_ERR 0x000D // 传输数据错误 +#define ERR_EDTION_ERR 0x000E // 程序版本错误 +#define ERR_WORK_DONE 0x000F // 完成产量 +#define ERR_LMT_POSITIVE 0x0010 // 正向限位 +#define ERR_LMT_NEGATIVE 0x0011 // 反向限位 +#define ERR_RUN_ALM 0x0012 // 运动报警 +#define ERR_RUN_LIMIT 0x0013 // 运动限位 +#define ERR_RUN_EMS 0x0014 // 运动急停 +#define ERR_MV_PARA 0x0015 // 运动参数错误 +#define ERR_MC_PARA 0x0016 // 机器参数错误 +#define ERR_IN_PARA 0x0017 // 输入参数错误 +#define ERR_NOT_WORKSTA 0x001A // 不能工作状态 +#define ERR_NOT_MOVESTA 0x001B // 禁止移框状态 +#define ERR_MTZ_RIGHT 0x001F // 归零成功 +#define ERR_MTZ_ERROR 0x0020 // 归零错误 +#define ERR_COOR_SYSTM 0x0021 // 坐标系统错误 +#define ERR_OUT_RANGE 0x0022 // 目标位置越界 +#define ERR_X_LIT_POSI 0x0023 // X正向限位 +#define ERR_X_LIT_NEGA 0x0024 // X反向限位 +#define ERR_Y_LIT_POSI 0x0025 // Y正向限位 +#define ERR_Y_LIT_NEGA 0x0026 // Y反向限位 +#define ERR_ALM_WATERTANK 0x002A // 水箱报警 +#define ERR_ALM_COVEROPEN 0x002B // 开盖报警 +#define ERR_LIGHTCURTAINS1 0x002C // 光幕1介入 +#define ERR_LIGHTCURTAINS2 0x002D // 光幕2介入 +#define ERR_AIR_POWER 0x002E // 气压不足 +#define ERR_NO_DATA 0x0040 // 无数据 +#define ERR_DATA_ERROR 0x0041 // 数据错误 +#define ERR_GRAPH_OUT_RANGE 0x0042 // 图形超出范围 +#define ERR_MS_NOT_ZERO 0x0050 // 主轴不在零位 +#define ERR_HK_NOT_ZERO 0x0051 // 旋梭不在零位 +#define ERR_MS_NOT_SYNC 0x0052 // 针梭不同步 +#define ERR_RO_NOT_SYNC 0x0053 // 旋转不同步 +#define ERR_CUTTER_NOT_POS 0x0054 // 剪刀不在回位 +#define ERR_HEAD_NOT_HIGH 0x0055 // 机头不在高位 +#define ERR_HEAD_NOT_LOW 0x0056 // 机头不在低位 +#define ERR_LIGHTCURTAINS 0x0057 // 光幕介入 +#define ERR_UPER_TBREAK 0x0058 // 面线断线 +#define ERR_BOBBIN_TBREAK 0x0059 // 底线断线 +#define ERR_NEEDLE_NOT_HIGH 0x005A // 机针不在高位 +#define ERR_SEND_N1CMD_TIMOUT 0x005B // 发送主轴命令超时 +#define ERR_SEND_N1CMD_FAIL 0x005C // 发送主轴命令失败 +#define ERR_TRANS_TIMEOUT 0x005D // 执行命令超时 +#define ERR_NOT_AT_POS 0x005E // 模版不到位 +#define ERR_LIFT_TIMEOUT 0x005F // 机头升降超时 +#define ERR_HEAD_NOT_SAFE 0x0060 // 机头不在安全区域 +#define ERR_HD1_ND_NOT_ZERO 0x0061 // 机头1针不在零位 +#define ERR_HD1_CUTTER_NOT_POS 0x0071 // 机头1剪刀不在回位 +#define ERR_R_LIT_POSI 0x0081 // 旋转正向限位 +#define ERR_R_LIT_NEGA 0x0082 // 旋转反向限位 +#define ERR_XY_NOT_WP 0x0085 // XY不在工作位置 +#define ERR_HEAD_NOT_POS 0x0086 // 机头不到位 +#define ERR_TO_ZERO_TIMOUT 0x008E // 等待运动结束超时 +#define ERR_MOVE_POS_ERR 0x008F // 移动位置错误 +#define ERR_FOOT_POS 0x0093 // 压脚位置错误 +#define ERR_FOOT_OUT_RANGE 0x0094 // 压脚电机位置越界 +#define ERR_LIFT_OUT_RANGE 0x0095 // 机头升降位置越界 +#define ERR_ROT_OUT_RANGE 0x0096 // 旋转位置越界 +#define ERR_ROT_ECD_ERROR 0x0097 // 旋转编码器错误 +#define ERR_LIFT_ULIMIT 0x0098 // 机头升降上限位 +#define ERR_LIFT_DLIMIT 0x0099 // 机头升降下限位 +#define ERR_LIFT_SYNC_ERR 0x009A // 机头升降同步错误 +#define ERR_NOTIN_SAFE_AREA 0x009E // 机头不在安全区域 +#define ERR_BUS_ERR 0x00AD // 总线错误 +#define ERR_CHANGE_BOBBIN 0x00F0 // 更换梭芯 +#define ERR_CHANGE_BOBBIN_A 0x00F1 // 更换梭芯A +#define ERR_CHANGE_BOBBIN_B 0x00F2 // 更换梭芯B +#define ERR_CHANGE_BOBBIN_STA 0x00F3 // 机器处于更换梭芯状态 +#define ERR_WORK_HEAD 0x00D6 // 工作机头错误 +#define ERR_CHANGE_SHUT 0x00D7 // 换梭异常 + + +// 设置机器状态 +/* + 工作流程 + 1. 上位机发送命令 UCMD_SET_MC_STATUS, 命令结构定义如下: + + |-------------------------------------------------------------------------------------------------------| + |-------------------------------------------------------------------------------------------------------| + | 数据识别序列 | 数据内容 | 校验字 | + |-------------------|-----------------------------------------------------------------------|-----------| + | B0 B1 B2 B3 | B4 B5 | B6 B7 | B8 B9 | B10 B11 B12 B13 | B14 B15 | + |-------------------|--------------------|------------------|-----------|-------------------|-----------| + | 固定序列如下 | 数据包ID | 状态码 | 参数 | 保留 | B4--B13的 | + | |--------------------|------------------|-----------|-------------------| | + | 'F','L','D','P' | UCMD_SET_MC_STATUS | | | | 16位CRC | + |-------------------------------------------------------------------------------------------------------| + |-------------------------------------------------------------------------------------------------------| + + + 2. 下位机收到命令后,根据状态码设置相关状态。 + +*/ + +// 状态码定义如下-设置 +#define MC_STA_CLENA_ERR 0x0000 // 清除错误 +#define MC_STA_EN_WORK 0x0001 // 允许工作(状态) +#define MC_STA_DIS_WORK 0x0002 // 禁止工作(状态) +#define MC_STA_EN_TIME 0x0003 // 允许工作(时间) +#define MC_STA_DIS_TIME 0x0004 // 禁止工作(时间) +#define MC_CLEAN_COUNT 0x0005 // 产量计数清零 +#define MC_STA_MANUAL 0x0006 // 手动工作状态 +#define MC_STA_AUTO 0x0007 // 自动工作状态 +#define MC_FILE_SWITCH 0x0008 // 文件切换 +#define MC_INVALID_FILE 0x0009 // 文件失效命令 +#define MC_CLEAN_PARA_REF 0x000A // 清除刷新参数标志 +#define MC_SET_TO_NORMAL 0x000B // 设置为正常工作状态 +#define MC_SET_TO_SIMULATE 0x000C // 设置为模拟工作状态 +#define MC_SET_ERR_STA 0x000D // 设置为错误状态(报错) +#define MC_CLEAN_FIDX 0x000F // 索引复位 +#define MC_CLEAN_BOBBIN 0x0010 // 底线计数复位 +#define MC_SET_ENTRY_SCAN_SENSOR 0x0011 // 设置为 进入 扫描传感器状态 +#define MC_SET_EXIT_SCAN_SENSOR 0x0012 // 设置为 退出 扫描传感器状态 +#define MC_SET_ENTER_TEST_OUTPUT 0x0013 // 设置为 进入 测试输出状态 +#define MC_SET_EXIT_TEST_OUTPUT 0x0014 // 设置为 退出 测试输出状态 +#define MC_STA_EXIT_THREADBK 0x0024 // 退出断线测试 +#define STA_NORMAL_STOP 0x0100 // 正常停止 +#define STA_MTZ_SUCCESS 0x0101 // 归零成功 +#define STA_WORK_PAUSE 0x0102 // 工作暂停 +#define STA_WORK_OVER 0x0103 // 工作结束 +#define STA_WORK_FINISH 0x0104 // 工作完成 +#define STA_WORK_DONE 0x0105 // 完成产量 +#define STA_EXEC_SUCCESS 0x0106 // 执行成功 +#define STA_EXEC_FAILED 0x0107 // 执行失败 +#define STA_WAIT_FILE 0x0108 // 等待文件 +#define STA_CHANGE_BOBBIN 0x0109 // 更换梭芯 +#define STA_PROCESS_FINISH 0x010A // 执行完成 +#define STA_PROCESS_RUNNING 0x010B // 执行过程中 +#define STA_LINE_TBREAK 0x0152 // 断线停止 + + +typedef struct +{ + u32 buf[PARA_NUM]; +} __attribute__ ((packed)) ParaStruct; + + + +// 参数类型定义 +#define SEW_MCPARA_MACH 0 // 缝纫机器参数 +#define SEW_MCPARA_WORK 1 // 缝纫工作参数 +#define SEW_MCPARA_DEF_MC 2 // 出厂默认机器配置参数(读取有效) +#define SEW_MCPARA_DEF_WK 3 // 出厂默认机器工作参数(读取有效) +#define SEW_REVMCPARA_MACH 0x07 // 预留机器配置参数 +#define SEW_REVMCPARA_WORK 0x08 // 预留机器工作参数 + +#define SEW_MCPARA_EX1 0x20 // 机器扩展参数1 +#define SEW_MCPARA_EX2 0x21 // 机器扩展参数2 + +// 缝纫机器参数 +typedef struct +{ +// 0 + u32 machineType; // 机器类型 + u32 productType; // 产品类型 + u32 headNumbers; // 机头个数 + u32 needleNumbers; // 每头机针个数 +// 4 + u32 rev0[10-0]; + +// 10 + u32 xConfig; // x配置 + u32 yConfig; // y配置 + u32 x2Config; // x2配置 + u32 y2Config; // y2配置 + + // config.0, = 0, 无该轴; = 1, 有该轴; + // config.1, = 0, 单电机驱动; = 1, 双电机驱动; + // config.2, = 0, 坐标系统为正; = 1, 坐标系统为反; + // config.3, = 0, 移动对象为机头 = 1, 移动对象为框; + // config.4, = 0, 没有零位传感器; = 1, 有零位传感器; + // config.5, = 0, 没有降速传感器; = 1, 有降速传感器; + // config.6, = 0, 没有正向限位传感器; = 1, 有正向限位传感器; + // config.7, = 0, 没有负向限位传感器; = 1, 有负向限位传感器; + // config.8, = 0, 向负方向找零位传感器; = 1, 向正方向找零位传感器; + // config.9, = 0, 零位单独起作用; = 1, 零位和降速一起起作用; + + u32 mConfig; // 缝纫主轴配置 + // config.0, = 0, 无该轴; = 1, 有该轴; + // config.1, = 0, 针梭一体; = 1, 针梭分离(双电机); + + u32 uConfig; // 升降电机配置 + // config.0, = 0, 无该轴; = 1, 有该轴; + + u32 fConfig; // 压脚电机配置 + // config.0, = 0, 无该轴; = 1, 有该轴; + + u32 rConfig; // 旋转电机配置 + // config.0, = 0, 无该轴; = 1, 有该轴; + // config.1, = 0, 单电机驱动; = 1, 双电机驱动; + // config.2, = 0, 坐标系统为正; = 1, 坐标系统为反; + // config.3, = 0, 转动对象为机头 = 1, 转动对象为框; + // config.4, = 0, 无旋转范围限制 = 1, 有旋转范围限制; +// 18 + u32 cutDTrdDev; // 下剪刀驱动装置选择, 0, 无下剪线装置; 1, 气缸; 2, 交流电机; 3, 步进电机; 4, 电磁铁 + u32 cutDTrdMode; // 下剪线模式选择, 0, 静态剪线; 1, 动态剪线; 2, 凸轮剪线; 3, 凸轮分别剪线 + u32 cutUTrdDev; // 上剪刀驱动装置选择, 0, 无上剪线装置; 1, 气缸; +// 21 + u32 utbdDev; // 面线断线检测装置选择; 0, 无装置; 1, 挑线簧; 2, 电子断线器; + u32 dtbdDev; // 底线断线检测装置选择; 0, 无装置, 1, 光栅轮; 2, 磁编码器; + u32 tbdMode; // 断线检测模式选择; 0, 直接检测; 1, 外围板检测; +// 24 + u32 hookTrdDev; // 勾面线装置选择, 0, 无勾面线装置; 1, 气缸; 2, 电磁铁 + u32 looseTrdDev; // 松面线装置选择, 0, 无松线装置; 1, 气缸; 2, 电磁铁 + u32 pullTrdDev; // 拉面线装置选择, 0, 无拉面线装置; 1, 气缸; + u32 pushTrdDev; // 扣底线装置选择, 0, 无扣底线装置; 1, 气缸; 2, 电磁铁 + u32 looseTrdDev2; // 第二松面线装置选择, 0, 无松线装置; 1, 气缸; 2, 电磁铁 + u32 templateId; // 模版识别装置, 0, 无识别装置; 1, 条形码; 2, 编码孔 + +// 30 + u32 hookFaceTo; // 旋梭面对方向, 0, 向前; 1, 向左; 2, 向右; 3, 向上 +// 31 + u32 templateDect; // 模版检测装置, 0, 无检测装置; 1, 检测 + u32 rev1[50-32]; + +// 50 + // 位置,尺寸 + s32 xSensorPos; // X框传感器坐标,单位 0.01mm + s32 ySensorPos; // Y框传感器坐标,单位 0.01mm + s32 mStopAng; // 主轴停车传感器角度,单位 0.01度 + s32 uSensorPos; // 升降传感器坐标,单位 0.01mm + s32 fSensorPos; // 压脚传感器坐标,单位 0.01mm + s32 rSensorAng; // 旋转传感器角度,单位 0.01度 +// 56 + s32 mHkSensorAng; // 主轴勾线传感器角度,单位 0.01度 +// 57 + s32 pStopAng; // 冲头停车角度,单位 0.01度 +// 58 + s32 cStopAng; // 裁刀主轴停车角度 +// 59 + s32 x2SensorPos; // X2框传感器坐标,单位 0.01mm + s32 y2SensorPos; // Y2框传感器坐标,单位 0.01mm + s32 plSensorPos; // 拉料电机传感器坐标,单位 0.01mm +// 62 + s32 mJogSensorAng; // 主轴点动停车角度,单位 0.01度 + s32 emStopAng; // 平绣主轴停车角度,单位 0.01度 + +// 64 + u32 rev2[70-64]; + +// 70 + s32 xNegaBorder; // x可移动区域负边界(X-), 范围 -2147483648--2147483647,单位0.01mm + s32 xPosiBorder; // x可移动区域正边界(X+), 范围 -2147483648--2147483647,单位0.01mm + s32 yNegaBorder; // y可移动区域负边界(Y-), 范围 -2147483648--2147483647,单位0.01mm + s32 yPosiBorder; // y可移动区域正边界(Y+), 范围 -2147483648--2147483647,单位0.01mm + +// 74 + s32 headudUper; // 机头升降可移动上边界,单位0.01mm + s32 headudLower; // 机头升降可移动下边界,单位0.01mm + +// 76 + s32 footudUper; // 压脚升降可移动上边界,单位0.01mm + s32 footudLower; // 压脚升降可移动下边界,单位0.01mm + u32 fppmmNumerator; // 电机压脚脉冲当量分子 + u32 fppmmDenominator; // 电机压脚脉冲当量分母 + +// 80 + s32 rLimitAnglePosi; // 旋转范围正向限制角度,单位 0.01度 + s32 rLimitAngleNega; // 旋转范围正向限制角度,单位 0.01度 + +// 82 + s32 punchOffsetX; // 冲孔机头偏移X, 范围 -2147483648--2147483647,单位0.01mm + s32 punchOffsetY; // 冲孔机头偏移Y, 范围 -2147483648--2147483647,单位0.01mm + s32 sewingAreaXN; // x可缝纫区域负边界(X-), 范围 -2147483648--2147483647,单位0.01mm + s32 sewingAreaXP; // x可缝纫区域正边界(X+), 范围 -2147483648--2147483647,单位0.01mm + s32 sewingAreaYN; // y可缝纫区域负边界(Y-), 范围 -2147483648--2147483647,单位0.01mm + s32 sewingAreaYP; // y可缝纫区域正边界(Y+), 范围 -2147483648--2147483647,单位0.01mm + s32 punchAreaXN; // x可冲孔区域负边界(X-), 范围 -2147483648--2147483647,单位0.01mm + s32 punchAreaXP; // x可冲孔区域正边界(X+), 范围 -2147483648--2147483647,单位0.01mm + s32 punchAreaYN; // y可冲孔区域负边界(Y-), 范围 -2147483648--2147483647,单位0.01mm + s32 punchAreaYP; // y可冲孔区域正边界(Y+), 范围 -2147483648--2147483647,单位0.01mm + + s32 sewingROffsetX; // 缝纫右机头偏移X, 范围 -2147483648--2147483647,单位0.01mm + s32 sewingROffsetY; // 缝纫右机头偏移Y, 范围 -2147483648--2147483647,单位0.01mm + + s32 cutterOffsetX; // 切刀机头偏移X, 范围 -2147483648--2147483647,单位0.01mm + s32 cutterOffsetY; // 切刀机头偏移Y, 范围 -2147483648--2147483647,单位0.01mm + + s32 cuttingAreaXN; // x可裁切区域负边界(X-), 范围 -2147483648--2147483647,单位0.01mm + s32 cuttingAreaXP; // x可裁切区域正边界(X+), 范围 -2147483648--2147483647,单位0.01mm + s32 cuttingAreaYN; // y可裁切区域负边界(Y-), 范围 -2147483648--2147483647,单位0.01mm + s32 cuttingAreaYP; // y可裁切区域正边界(Y+), 范围 -2147483648--2147483647,单位0.01mm + +// u32 rev3[100-100]; + +// 100 + // 速度参数 + u32 xymvstspSpd; // xy启动停止速度, 范围 1--100,单位mm/s,默认 10 + u32 xymvzSpd; // xy归零运行速度, 范围 1--100,单位mm/s,默认 100 + u32 xymvlSpd; // xy空走运行速度, 范围 1--1000,单位mm/s,默认 300 + u32 xymvSAdd; // xy行走加速度, 范围 1--10000,单位mm/s2,默认 1000 + u32 xymvbrkAdd; // xy刹车加速度 1--10000,单位mm/s2,默认 10000 + u32 xymvhSpd1; // xy手动移动速度1, 范围 1--1000,单位mm/s,默认 10 + u32 xymvhSpd2; // xy手动移动速度2, 范围 1--1000,单位mm/s,默认 100 + u32 xymvhSpd3; // xy手动移动速度3, 范围 1--1000,单位mm/s,默认 300 + u32 xymaxSpd; // xy最高移动速度, 范围 1--1000,单位mm/s,默认 300 + +// 109 + u32 msrstspRpm; // 主轴启动停止转速, 范围 1--300,单位r/min,默认 100 + u32 mstzRpm; // 主轴归零转速, 范围 1--3000,单位r/min,默认 120 + u32 msrunRpm; // 主轴运转转速, 范围 1--3000,单位r/min,默认 300 + u32 msrAddRpss; // 主轴运转加速度, 范围 1--100,单位r/ss,默认 50 + u32 msrbrkAdd; // 主轴刹车加速度, 范围 1--100,单位r/ss,默认 100 + u32 msHightRpm; // 主轴缝纫最高转速, 范围 1--3000,单位r/min,默认 3000 + +// 115 + u32 ustspSpd; // 机头升降起停速度, 范围 1--250,单位mm/s,默认 10 + u32 umvtzSpd; // 机头升降归零速度, 范围 1--250,单位mm/s,默认 50 + u32 umoveSpd; // 机头升降行走速度, 范围 1--250,单位mm/s,默认 200 + u32 uliftAdd; // 机头升降行走加速度, 1--10000,单位mm/s2,默认 500 + u32 uBrkAdd; // 机头升降刹车加速度, 1--10000,单位mm/s2,默认 1000 + +// 120 + u32 fstspSpd; // 压脚升降起停速度, 范围 1--100,单位mm/s,默认 10 + u32 fmvtzSpd; // 压脚升降归零速度, 范围 1--100,单位mm/s,默认 30 + u32 fmoveSpd; // 压脚升降行走速度, 范围 1--100,单位mm/s,默认 100 + u32 fliftAdd; // 压脚升降行走加速度, 1--10000,单位mm/s2,默认 500 + u32 fBrkAdd; // 压脚升降刹车加速度, 1--10000,单位mm/s2,默认 1000 + +// 125 + u32 rotstspDps; // 机头旋转启动停止速度, 范围 1--720, 单位 deg/s(度/秒),默认 10 + u32 rottzDps; // 机头旋转归零速度, 1--720, 单位 deg/s(度/秒),默认 50 + u32 rotrunDps; // 机头旋转运转速度, 范围 1--720, 单位 deg/s(度/秒),默认 360 + u32 rotAddDpss; // 机头旋转运动加速度, 范围 1--10000, 单位 deg/s(度/秒方),默认 500 + u32 rotBrkDpss; // 机头旋转刹车加速度, 范围 1--10000, 单位 deg/s(度/秒方),默认 5000 + u32 rotmaxDps; // 机头旋转最高速度, 范围 1--720,单位 deg/s,默认 720 + +// 131 + u32 minDrawSpd; // 最小画笔绘画速度, 范围 1--100,单位mm/s,默认 10 + u32 maxDrawSpd; // 最大画笔绘画速度, 范围 1--1200,单位mm/s,默认 1000 + u32 drawAdd; // 画笔绘画加速度, 范围 1--4000,单位mm/s2,默认 500 + u32 drawSlowAngle; // 画笔绘画降速最小偏差角度,范围 0--18000,单位 0.01度,默认 3000 + +// 135 + u32 rev4[150-135]; + +// 150 + s32 embOffsetX; // 平绣机头偏移X, 范围 -2147483648--2147483647,单位0.01mm + s32 embOffsetY; // 平绣机头偏移Y, 范围 -2147483648--2147483647,单位0.01mm + s32 embAreaXN; // 平绣x可绣花区域负边界(X-), 范围 -2147483648--2147483647,单位0.01mm + s32 embAreaXP; // 平绣x可绣花区域正边界(X+), 范围 -2147483648--2147483647,单位0.01mm + s32 embAreaYN; // 平绣y可绣花区域负边界(Y-), 范围 -2147483648--2147483647,单位0.01mm + s32 embAreaYP; // 平绣y可绣花区域正边界(Y+), 范围 -2147483648--2147483647,单位0.01mm + // 156 + u32 rev5[200-156]; + +// 200 + s32 penOffsetX; // 画笔偏移X, 范围 -2147483648--2147483647,单位0.01mm + s32 penOffsetY; // 画笔偏移Y, 范围 -2147483648--2147483647,单位0.01mm + s32 PressOffsetX; // 压枣偏移X, 范围 -2147483648--2147483647,单位0.01mm + s32 PressOffsetY; // 压枣偏移Y, 范围 -2147483648--2147483647,单位0.01mm + +// 204 + u32 EncoderMolecule; // 编码器系数分子, 范围 1--100000,单位 无 + u32 EncoderDeno; // 编码器系数分母, 范围 1--100000,单位 无 + u32 ZeroCutDistance; // 零切距离, 范围 1--500000,单位 0.01mm + u32 FeedClothDev; // 进料装置选择, 0, 无进料装置; 1, 有进料装置 + u32 CrossCutDev; // 横切装置选择, 0, 无横切装置; 1, 有横切装置 + u32 ClipClothDev; // 夹布装置选择, 0, 无夹布装置; 1, 有夹布装置 + u32 TensionDev; // 张紧装置选择, 0, 无张紧装置; 1, 有张紧装置 + u32 SideCutDev; // 边切装置选择, 0, 无边切装置; 1, 有边切装置 + +// 212 + u32 rev6[256-212]; + +} __attribute__ ((packed)) SewingMcPara; + + + +// 缝纫工作参数 +typedef struct +{ +// 0 + u32 msWorkRpm; // 主轴缝纫工作转速, 范围 1--3000,单位r/min,默认 2000 + u32 mscutRpm; // 主轴剪线转速, 范围 1--500,单位r/min,默认 120 + u32 msRevRpm; // 主轴回针转速, 范围 1--500,单位r/min,默认 200 + u32 msStSlowRpm; // 主轴启动慢动转速, 范围 1--500,单位r/min,默认 200 + u32 msBackEquRpm; // 倒车等效主轴转速,, 范围 1--3000,单位r/min,默认 1000 +// 5 + u32 sewMoveType; // 缝纫动框方式, 位图 + // bit0 = 0, xy连续动框; bit = 1, xy间歇式动框; + // bit1 = 0, xy间歇式脉冲无加减速; bit1 = 1, xy间歇式脉冲正弦加减速; + // bit2 = 0, 机头连续旋转; bit2 = 1, 机头间歇式旋转; + // bit3 = 0, 机头间歇式脉冲无加减速; bit3 = 1, 间歇式脉冲正弦加减速; + u32 sewMoveStAng; // 缝纫动框起始角度, 0--36000, 单位 0.01度,默认 28000 + u32 sewMoveCtnAng;// 缝纫动框持续角度, 0--36000, 单位 0.01度,默认 15000 +// 8 + u32 stSlowNum; // 起针慢动针数, 0--10,单位 针, ,默认 3 + u32 actionWhenStart; // 起针动作允许; 位图选择, 0, 不允许; 1, 允许; bit0, 松线允许; bit1, 顶线允许; bit2, 夹线允许; + +// 10 + u32 cutTrdEn; // 剪线允许; 0, 不剪线; 1, 自动剪线; 2, 数据剪线 ,默认1 + u32 cutTrdDivAngle; // 剪线分线角度,0--36000, 单位 0.01度,默认 20000 + u32 cutTrdEndAngle; // 剪线完成角度,0--36000, 单位 0.01度,默认 6000 + u32 actionWhenCut; // 剪线时动作允许, 位图选择, bit0, 松线允许; bit1, 拉线允许; bit2, 夹线允许; + +// 14 + u32 tbdNumber; // 断线检测针数; 0, 不检测断线; 其他, 断线信号连续针数,默认3 + u32 tbdAngle; // 断线检测主轴角度,0--36000, 单位 0.01度,默认 3000 + +// 16 + u32 changeBobbinMode; // 换梭芯提醒功能, 0, 不启用该功能; 1, 按长度计数延迟提醒; 2, 按片数计数; 3, 按长度立刻提醒; 默认0 + u32 changeBobbinLength; // 底线长度, 单位 0.01mm,默认 10000000 + u32 cblenFixed; // 每针底线修正量, 单位 0.01mm,默认 0 + u32 changeBobbinNums; // 换梭片数计数, 单位 次,默认 0 + +// 20 + u32 oilMode; // 加油方式选择, 0, 不加油; 1, 按工作时间间歇加油; 2, 按工作针数间歇加油; 3, 持续不停加油,默认0 + u32 addOilGapStitch; // 加油针数间隔, 单位针, 加油方式为按针数加油时有用,默认 10000 + u32 addOilGapTime; // 加油时间间隔, 单位秒, 加油方式为按工作时间加油时有用; + u32 addOilTime; // 加油持续时长, 单位秒, + +// 24 + u32 finishStopSel; // 完成后停车位置选择, 0, 当前位置; 1,起点,2,定位点,3,上料点; 4,偏移点 + +// 25 + u32 offsetEn; // 偏移点坐标有效标志; 0, 无效; 1, x有效; 2, y有效; 3, xy同时有效 + s32 offsetX; + s32 offsetY; // 偏移点坐标 +// 28 + u32 fixPosEn; // 穿线点坐标有效标志; 0, 无效; 1, x有效; 2, y有效; 3, xy同时有效 + s32 fixPosX; + s32 fixPosY; // 穿线点坐标 +// 31 + s32 headLowPos; // 机头升降低位高度 + s32 headHighPos; // 机头升降高位高度 + +// 33 + u32 expectedOutput; // 产量预设 +// 34 + u32 lightingBrightness; // 照明亮度,0--255; 默认128 +// 35 + u32 delayAfterFrameClose; // 气框关闭后延时, 0--2000, 单位ms, 默认500 +// 36 + u32 msAddRpss; // 缝纫加速度, 1--100, 单位r/ss , 默认5 +// 37 + u32 cutXYMovement; // 剪线动框位移, 1--1000, 单位0.01mm, 默认500 +// 38 + u32 sewingBlowEn; // 缝纫吹气允许, 0, 不允许; 1, 允许 + u32 punchBlowEn; // 冲孔吹气允许, 0, 不允许; 1, 允许 + u32 cleanerCloseDelay; // 吸尘器关闭延时,单位秒 +// 41 + u32 pmWorkRpm; // 冲孔主轴工作转速, 范围 1--3000,单位r/min,默认 2000 + u32 pmAddRpss; // 冲孔加速度, 1--100, 单位r/ss , 默认20 + + u32 pmMoveType; // 冲孔动框方式, 位图 + // bit0 = 0, xy连续动框; bit = 1, xy间歇式动框; + // bit1 = 0, xy间歇式脉冲无加减速; bit1 = 1, xy间歇式脉冲正弦加减速; + u32 pmMoveStAng; // 冲孔动框起始角度, 0--36000, 单位 0.01度,默认 24000 + u32 pmMoveCtnAng; // 冲孔动框持续角度, 0--36000, 单位 0.01度,默认 15000 + +// 46 + u32 liftHeadWhenSewing; // 缝纫间越框机头升降, 0, 不允许; 1, 允许 + u32 liftHeadWhenPunch; // 冲孔间越框机头升降, 0, 不允许; 1, 允许 +// 48 + u32 actionWhenMove; // 移框时动作选择; 位图选择, 0, 不允许; 1, 允许; bit0, 松线允许; bit2, 夹线允许; +// 49 + u32 softwareLimit; // 软件限位; 位图选择, 0, 不允许; 1, 允许; bit0, xy移动; bit1, 缝纫头升降限制; bit2, 冲孔头升降限制; bit3, 裁刀机头升降限制 + +// 50 + s32 changeBobbinAng; // 换梭旋转机头角度, 0--36000, 单位 0.01度,默认 18000 + u32 rotMoveCtnAng; // 旋转持续角度, 0--36000, 单z位 0.01度,默认 36000 +// 52 + u32 hookThreadNum; // 面线勾线针数,1--5,单位 针,默认1 + u32 sewFootHeight; // 缝纫工作时压脚高度,单位 0.01mm + u32 simuHeadHeight; // 模拟工作时机头高度,单位 0.01mm +// 55 + u32 cutterWorkRpm; // 切刀工作转速, 范围 1--3000,单位r/min,默认 1200 + u32 cutterAddRpss; // 切刀加速度, 1--100, 单位r/ss , 默认20 + +// 57 + u32 cutMoveDir; // 剪线动框方向, 0, 不动框; 1, 向左; 2, 向前; 3, 向右; 4, 向后 + +// 58 + u32 pressKnotHigh; // 压枣升降行程,单位 0.01mm + +// 59 + u32 msCornerRpm; // 主轴拐角转速, 范围 1--3000,单位r/min,默认 1000 + u32 slowAngle; // 降速最小偏差角度,单位度,范围0--180,默认 180 + +// 61 + u32 rev2[100-61]; +// 100 + u32 workHeadSel; // 工作机头选择,位图选择,共支持32个机头; 0, 不允许工作; 1, 允许工作; bit0 第一个机头, bit1, 第二个机头...... + u32 safetyEn; // 安全输入允许,位图选择,0, 不允许; 1, 允许; bit0 光幕; bit1, 气压; bit2 上电信号 + u32 autoFrameEn; // 自动气框允许,0, 不允许; 1, 允许; + u32 autoFrameDelay; // 自动气框闭合延时,单位ms + u32 sewoffsetAsCmd; // 线迹偏移功能,0, 不允许; 1, 允许; + u32 autoworkstart; // 循环工作功能,0, 不允许; 1, 允许; + u32 workHeadSelR; // 右工作机头选择,位图选择,共支持32个机头; 0, 不允许工作; 1, 允许工作; bit0 第一个机头, bit1, 第二个机头...... + u32 PullingPos; // 拉料电机拉料位置,单位 0.01mm + u32 pullingLength; // 拉料长度,单位 0.01mm + u32 cuttingLength; // 裁切长度,单位 0.01mm + +// 110 + u32 addOilHookTime; // 梭加油持续时长, 单位秒, (针梭独立加油时有效) + u32 clampingForce1; // 夹线力度1: 0~100 % + u32 clampingForce2; // 夹线力度2: 0~100 % + u32 clampingForce3; // 夹线力度3: 0~100 % + u32 clampingForce4; // 夹线力度4: 0~100 % + +// 115 + u32 emWorkRpm; // 平绣主轴工作转速, 范围 1--3000,单位r/min,默认 1000 + u32 emAddRpss; // 平绣加速度, 1--100, 单位r/ss , 默认5 + + u32 emMoveType; // 平绣动框方式, 位图 + // bit0 = 0, xy连续动框; bit = 1, xy间歇式动框; + // bit1 = 0, xy间歇式脉冲无加减速; bit1 = 1, xy间歇式脉冲正弦加减速; + u32 emMoveStAng; // 平绣动框起始角度, 0--36000, 单位 0.01度,默认 24000 + u32 emMoveCtnAng; // 平绣动框持续角度, 0--36000, 单位 0.01度,默认 20000 +// 120 + u32 rev3[150-120]; + +// 150 + u32 rev4[200-150]; +// 200 + u32 rev5[256-200]; + +} __attribute__ ((packed)) SewingWkPara; + + +//回复的定义 +#define REV_TYPE_ONCE 0 // 单次回复;下位机收到命令后发送一次回复数据 +#define REV_TYPE_BEGIN 1 // 多次回复;下位机收到命令后,会主动开始发送回复数据,直到被其他命令打断。 + + +// 传感信号位定义,传感器信号位图和传感器信号的位定义相同 +typedef struct +{ +// 0 + u8 bitmap[1024]; + +} __attribute__ ((packed)) SensorsBitmap; + + +// 传输文件类型 +#define FILE_TYPE_DAT 0x00 // 数据文件 +#define FILE_TYPE_PGM 0x02 // 升级文件 + + +// 文件传输控制结构 +#define LEN_RSV_BMP MAX_EXDP_LEN // 位图大小 +#define MAX_FILE_SIZE (LEN_RSV_BMP*MAX_EXDP_LEN*16) // 最大文件字节数 按位图大小设定 + +typedef struct +{ + int transphase; + int filetransing; + int waitcount; + + u8 transActive; // 传输结构有效 + u8 transflag; // 接收进度标志 = 0, 接收未开始; = 1, 正在接收; = 2,接收完成。 + u8 fileType; // 文件类型 + u8 fileIdx; // 为文件编号,最多支持16个文件 + u16 fileId; // 文件ID + u16 packetSize; // 包的大小 + u32 packetNum; // 包的个数 + + DataDs16FileHead * pFileHead; + AppFileHead * pAppHead; + + u8 * pDatBuff; + + u16 lenBmp; // 位图有效长度 + u8 rsvBitmap[LEN_RSV_BMP]; // 文件接收进度标志位图 + +}FileTransCtrl; + + +// 传输有效标志定义 +#define TRANS_NONE 0x00 // 无效 +#define TRANS_ACTIVE 0x5A // 有效 + +// 传输结果代码定义 +#define TRANS_NOT_BEG 0x00 // 没有收到启动命令 +#define TRANS_READY 0x01 // 准备好接收 +#define TRANS_DOING 0x02 // 正在接收 +#define TRANS_DONE 0x03 // 接收完成 +#define TRANS_REQUEST 0x04 // 请求传输模式 + + +// 控制动作定义 +#define MOTO_TO_ZERO 0x0001 // 电机归零(辅助调试的功能,无安全保护和逻辑关系) +#define MOVE_BY_HAND 0x0002 // 电机手动移动(辅助调试的功能,无安全保护和逻辑关系) +#define OUTPUT_CTRL 0x0003 // 输出控制(辅助调试的功能,无安全保护和逻辑关系) +#define MOTO_EN_CTRL 0x0004 // 电机使能控制(辅助调试的功能,无安全保护和逻辑关系) +#define MANUAL_ACTION 0x0005 // 手动动作功能(日常使用功能,有安全保护和逻辑时序关系) +#define TEST_OUTPUT 0x0006 // 测试输出OUTPUT端口(obj输出端口 1~26:主板output1~26 101~356:扩展板output1~256) +#define TEST_THREADBK 0x0007// 测试断线检测 + +// 归零和手动移动和电机使能的 控制参数1 定义 +#define MT_LX 0x0001 // X向移动电机 +#define MT_LY 0x0002 // Y向移动电机 +#define MT_LM 0x0003 // 主轴电机 +#define MT_LN 0x0004 // 针电机 +#define MT_LH 0x0005 // 梭电机 +#define MT_LU 0x0006 // 升降电机 +#define MT_ALLZ 0x0004 // 所有主轴 零位 +#define MT_ALLG 0x0005 // 所有主轴 勾线 +#define MT_ALLM 0x0006 // 所有主轴 点动 +#define MT_LF 0x0007 // 压脚电机 +#define MT_LR 0x0008 // 旋转电机 +#define MT_LRU 0x0009 // 上旋转电机 +#define MT_LRD 0x000A// 下旋转电机 +#define CUT_THREAD 0x0001 // 手动剪线 +#define ALL_MS_RUN 0x0002 // 所有主轴研车 +#define ROTATE_ADJUST 0x0003 // 旋转校对 +#define HEAD_LIFT_UP 0x0004 // 机头上升 +#define HEAD_LIFT_DOWN 0x0005 // 机头下降 +#define HEAD_LIFT_UPDW 0x0006 // 机头升降 +#define MAINSHAFT_ADJUST 0x0007 // 针梭校对 +#define SEWING_MS_RUN 0x0009 // 缝纫主轴研车 +#define SEWING_MS_JOG 0x0084 // 缝纫机头点动 +#define SEW_HEAD_LIFT 0x0012 // 缝纫机头升降(根据传感器状态确定上升还是下降) +#define SEW_MS_RESET 0x0013 // 缝纫针梭复位(回到停车位) +#define SEW_MS_TO_FIX 0x0014 // 缝纫针梭去穿线位(回到穿线位) +#define SEW_LOCLIP_TRD 0x0015 // 松紧线(根据状态松线或紧线) +#define XY_MOVE_LEFT 0x0016 // X左移 +#define XY_MOVE_RIGHT 0x0017 // X右移 +#define XY_MOVE_FRONT 0x0018 // Y前移 +#define XY_MOVE_BACK 0x0019 // Y后移 + +#define MAKEUP_NOHEAD 0x0020 // 取消补缝 +#define MAKEUP_HEAD1 0x0021 // 机头1补缝 +#define MAKEUP_HEAD2 0x0022 // 机头2补缝 +#define MAKEUP_HEAD3 0x0023 // 机头3补缝 +#define MAKEUP_HEAD4 0x0024 // 机头4补缝 +#define MAKEUP_HEAD5 0x0025 // 机头5补缝 + +#define XY_MOVE_STOP 0x001A // XY停止 +#define SET_WORK_AREA 0x0001 // 设置可工作区域 手动控制功能,para2是机头 para3选X- X+ Y- Y+,分别对应1234 +#define ALL_MOVE_STOP 0x0040 // 移动停止 +#define AUTO_CHANGE_ONE_SHUT 0x0060 // 自动换一个梭 +#define INSTALL_FIRST_BOBBIN 0x0061 // 安装第一个梭壳 +#define SHUT_FROM_PLATE_TO_HEAD 0x0062 // 将旋梭从梭盘拿到机头 +#define SHUT_FROM_HEAD_TO_PLATE 0x0063 // 将旋梭从机头拿到梭盘 +#define SHUT_INTO_TAKE_PLATE 0x0065 // 进入换梭盘状态 +#define SHUT_INTO_INDX_STA 0x0066 // 进入缝纫状态 +#define HEAD_MOVING_MOTOR 0x0067 //机头移动电机 +// 手动 控制参数2 定义 +#define MT_MOVE_DIR_STOP 0x0000 // 停止转动 +#define MT_MOVE_DIR_POSI 0x0001 // 正向移动(x向右,y向上,升降向上) +#define MT_MOVE_DIR_NEGA 0x0002 // 反向移动(x向左,y向下,升降向下) +#define MT_SERVO_ON 0x0001 // 电机使能开 +#define MT_SERVO_OFF 0x0002 // 电机使能关 + + +// 通用输出控制定义 +// 输出控制参数1代码定义 +#define OT_LOOSE_THREAD 0x0001 // 松紧线 +#define OT_UCUTTER_LIFT 0x0002 // 上剪刀升降 +#define OT_UCUT_THREAD 0x0003 // 上剪刀剪线 +#define OT_DCUT_THREAD 0x0004 // 下剪刀剪线 +#define OT_FRAME 0x0005 // 气框 +#define OT_OIL 0x0006 // 加油 +#define OT_LIGHT 0x0007 // 照明灯 +#define OT_BIT_FOOT 0x0008 // 大压脚 +#define OT_MID_FOOT 0x0009 // 中压脚 +#define OT_PUSH_BTRD 0x000A// 扣底线 +#define OT_STAND_BTRD 0x000B// 顶底线 +#define OT_CLIP_UTRD 0x000C// 夹面线 +#define OT_LOOSE_UTRD2 0x000D// 松紧线2 +#define OT_SEW_LIFT 0x000E // 缝纫机头升降 +#define OT_SEW_BLOW 0x0010 // 缝纫吹气 +#define OT_HEAD_L_CLUTH 0x001A// 左机头主轴离合 +#define OT_HEAD_R_CLUTH 0x001B// 右机头主轴离合 +#define OT_CLIP_EXTEND 0x0024 // 勾线动作-伸出 +#define OT_CLIP_EXTEND_R 0x0025 // 右机头勾线动作 +#define OT_CLIP_OPEN 0x0026 // 勾线动作-开合 +#define OT_PEN_DOWN 0x0028 // 画笔升降 +#define OT_CHBOB_GRAB_OPEN 0x0070 // 换梭装置抓取 +#define OT_CHBOB_SWAY_PUSH 0x0071 // 换梭装置摆动 +#define OT_CHBOB_SPIN 0x0073 // 换梭装置旋转 +#define OT_LASER_CTRL 0x00F0 // 激光控制 +#define OT_LASER_BLOW 0x00F1 // 激光吹气 +// 输出参数2 +#define OT_STOP 0x0000 // 停止 +#define UP_OPEN_ON 0x0001 // 上升、打开、放松、伸出 +#define DOWN_CLOSE_OFF 0x0002 // 下降、关闭、加紧、收回 +#define OT_ACTION 0x0003 // 动作 + + +// 通用工作控制功能 +#define WORK_START 0x0001 // 启动工作 +#define WORK_PAUSE 0x0002 // 暂停工作 +#define WORK_FINISH 0x0003 // 结束工作(流程复位) +#define WORK_FIND_ZERO 0x0004 // 自动找零 +#define WORK_GOTO_START 0x0005 // 回起点 +#define WORK_GOTO_ANCHOR 0x0006 // 回定位点 +#define WORK_GOTO_OFFSET 0x0007 // 回偏移点 +#define WORK_CHECK_FRAME 0x0008 // 边框检查 +#define WORK_CUT_FRAME 0x0009 // 边框切割 +#define WORK_CUT_XLINE 0x000A // 手动断布 +#define WORK_FAST_JUMP 0x000B // 快速进退 +#define WORK_GOTO_WKPOS 0x000C // 回工作点 +#define WORK_GOTO_FEEDT 0x000D // 回穿线点 +#define WORK_GOTO_CHGBO 0x000E // 回换梭位 +#define WORK_FEED_MOVE 0x000F // 进料退料 +#define WORK_GOTO_FINISH 0x0011 // 回结束点 +#define WORK_GOTO_ZERO 0x0012 // 回零点(框架归零) +#define WORK_GOTO_GORNER 0x0013 // 回角点 +#define WORK_MS_JOG 0x0013 // 主轴点动 +#define WORK_FIX_MVFRAME 0x0017 // 定量移框 +#define WORK_RPM_CHG 0x0020 // 速度改变 +#define WORK_SIMULATION_FRAME 0x0026 // 空走边框 +#define WORK_GOTO_FEED 0x0027 // 回上料点 +#define WORK_SET_OFFSET 0x0028 // 定偏移点 +#define WORK_SET_FEED 0x0029 // 定上料点 +#define WORK_ACT_OIL 0x0050 // 工作中加油 +#define AUTO_CHANGE_ONE_SHUT 0x0060 // 自动换一个梭 +#define RESET_SHUT_COUNTER 0x0067 // 梭盘计数复位 + +// 启动工作的参数1定义 +#define WKMD_NORMAL 1 // 正常 +#define WKMD_SIMULATION 2 // 模拟(空走) +#define WKMD_BACKWORD 3 // 回退 + + + +// 命令结构定义 +typedef union +{ + DataPacket packet; + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 toggle; + u8 rev[6]; + u16 crc; + } __attribute__ ((packed)) getMcInfo; // UCMD_GET_MC_INFO 读取机器信息 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 toggle; + u8 rev[6]; + u16 crc; + } __attribute__ ((packed)) getMcStatus; // UCMD_GET_MC_STATUS 读取机器状态 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 paraType; + u16 paraId; + u8 rev[4]; + u16 crc; + } __attribute__ ((packed)) getMcParas; // UCMD_GET_MC_PARAS 读取机器参数 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 fromObj; + u32 begAddr; + u16 rdSize; + u16 crc; + } __attribute__ ((packed)) getMemData; // UCMD_GET_MEM_DATA 读取内存数据 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 backType; + u8 rev[6]; + u16 crc; + } __attribute__ ((packed)) getSensors; // UCMD_GET_SENSORS 读取传感信号 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u8 fileType; + u8 fileIdx; + u8 rev[6]; + u16 crc; + } __attribute__ ((packed)) getFileInfo; // UCMD_GET_FILE_INFO 读取文件信息 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 fileId; + u8 rev[6]; + u16 crc; + } __attribute__ ((packed)) getTransResult; // UCMD_GET_TRANS_RESULT 读取传输结果 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u8 rev[8]; + u16 crc; + } __attribute__ ((packed)) getSensorBmp; // UCMD_GET_SENSOR_BMP 读取传感信号 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u16 cfgItem; + u8 rev[2]; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) setMcConfig; // UCMD_SET_MC_CONFIG 设置机器配置 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 staCode; + u16 para; + u8 rev[4]; + u16 crc; + } __attribute__ ((packed)) setMcStatus; // UCMD_SET_MC_STATUS 设置机器状态 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u16 paraType; + u16 paraId; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) setParas; // UCMD_SET_MC_PARAS 设置下位机参数 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u8 setObj; + u8 setWord; + u32 setAddr; + u16 setData; + u16 crc; + } __attribute__ ((packed)) setMemData; // UCMD_SET_MEM_DATA 设置内存数据 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u8 fileType; + u8 fileIdx; + u16 fileId; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) setFileParas; // UCMD_SET_FILE_PARAS 设置文件参数 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u8 fileType; + u8 fileIdx; + u16 fileId; + + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + + } __attribute__ ((packed)) setExecProgress; // UCMD_SET_EXEC_PROGRESS 设置进度命令 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u8 rev[4]; + + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + + } __attribute__ ((packed)) setInstallment; // UCMD_SET_INSTALLMENT 设置分期密码 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u8 type; + u32 time; + + u8 rev[3]; + u16 crc; + + } __attribute__ ((packed)) setElapsedTime; // UCMD_SET_ELAPSED_TIME 设置经过的时间 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + u8 id; + u8 nodeType; + u8 rev[6]; + u16 crc; + + } __attribute__ ((packed)) setDefParas; // UCMD_SET_DEF_PARA 设置默认参数 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 actCode; + u16 para1; + u16 para2; + u16 para3; + u16 crc; + } __attribute__ ((packed)) actByhand; // UCMD_ACT_BYHAND 手动动作功能 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 workCode; + u32 para1; + u16 para2; + u16 crc; + } __attribute__ ((packed)) mcWork; // UCMD_MC_WORK 机器工作命令 + +#pragma pack(1)//设定为1字节对齐 + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + s32 posx; + s32 posy; + u16 crc; + } __attribute__ ((packed)) moveFrameTo; // UCMD_MOVE_TO 移动框架到位置命令 +#pragma pack(1)//设定为1字节对齐 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u8 fileType; + u8 fileIdx; + u16 fileId; + + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) startTrans; // UCMD_START_TRANS 启动文件传输 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u16 pktIdx; + u16 fileId; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) transFileData; // UCMD_TRANS_FILE_DATA 文件数据传输 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u32 fileIdxMap; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) setFilesList; // UCMD_SET_FILE_LIST 设置文件列表 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u8 rev[8]; + + u16 crc; + + } __attribute__ ((packed)) getFilesList; // UCMD_GET_FILE_LIST 读取文件列表 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 upObj; + u16 upFileID; + u32 checksum; + u16 crc; + } __attribute__ ((packed)) mcUpdate; // UCMD_MC_UPDATE 系统升级 + + + //---------------------------------- + // 下位机发送命令 + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u8 fileType; + u8 fileIdx; + u16 fileId; + u32 datBlockIdx; // 数据包索引(每个包1024字节) + + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) dRequestDatBlock; // DCMD_REQUEST_DAT 请求文件数据 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u16 toggle; + u8 rev[2]; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) dSendMcInfo; // DCMD_SEND_MC_INFO 发送机器信息 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u16 toggle; + u8 rev[2]; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) dSendMcStatus; // DCMD_SEND_MC_STATUS 发送机器状态 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u16 paraType; + u16 paraId; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) dSendMcParas; // DCMD_SEND_MC_PARAS 发送机器参数 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u32 begAddr; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) dSendMemData; // DCMD_SEND_MEM_DATA 发送内存数据 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u8 rev[4]; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) dSendSensors; // DCMD_SEND_SENSORS 发送传感信号 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u8 fileType; + u8 fileIdx; + u8 rev[2]; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) dSendFileInfo; // DCMD_SEND_FILE_INFO 发送文件信息 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u16 fileId; + u8 active; + u8 result; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) dSendTransResult; // DCMD_SEND_TRANS_RESULT 发送传输结果 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + + u16 exLen; + u16 exCrc; + + u8 rev[4]; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) dSendSensorBmp; // DCMD_SEND_SENSOR_BMP 发送传输结果 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u8 fileType; + u8 fileIdx; + u16 fileId; + + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + + } __attribute__ ((packed)) setMacKey; // setMacKey + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u8 protocolType; // 协议类型 + u8 nodeType; // 遍历节点类型 + u8 traNum; // 遍历个数 + u8 nodeId; // 遍历起始节点ID + u8 rev[4]; + u16 crc; + } __attribute__ ((packed)) traverse; // 遍历命令 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u8 rev[8]; + u16 crc; + } __attribute__ ((packed)) rdBoardVer; // 读取外围板程序版本 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u8 protocolType; // 协议类型 + u8 nodeId; // 节点ID + u8 rev[6]; + u16 crc; + } __attribute__ ((packed)) updateBoard; // 升级外围板 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u8 protocolType; + u8 nodeId; //节点ID + u8 nodeType; //节点类型 -rq + u8 rev; + u16 crc; + + u32 ver[8]; + u8 exData[MAX_EXDP_LEN-32]; + } __attribute__ ((packed)) sendBoardVer; // 发送外围板程序版本 + + struct + { + u8 sync[DP_SYNC_LEN]; + u16 cmdCode; + + u16 exLen; + u16 exCrc; + + u8 nodeId; + u8 nodeType; // 节点类型 + u8 rev[2]; + u16 crc; + + u8 exData[MAX_EXDP_LEN]; + } __attribute__ ((packed)) boardPara; // 发送外围板非易失性参数 + +}OperPacket; +#pragma pack(1)//设定为1字节对齐 + + +#endif diff --git a/machine/comm/typedef.h b/machine/comm/typedef.h new file mode 100644 index 0000000..cf4918e --- /dev/null +++ b/machine/comm/typedef.h @@ -0,0 +1,107 @@ +#ifndef TYPEDEF_H +#define TYPEDEF_H + +//--------------------------------------------------------------- + + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + + +//--------------------------------------------------------------- + + +#define DATA_VALID 0x55AA + +//--------------------------------------------------------------- + +typedef int BOOL; +typedef unsigned char BYTE; +typedef unsigned short int WORD; +typedef unsigned long int DWORD; + +typedef unsigned char u8; +typedef unsigned short int u16; +typedef unsigned int u32; +typedef char s8; +typedef short int s16; +typedef int s32; + +//--------------------------------------------------------------- + +#define U8_MAX ((u8)255) +#define S8_MAX ((s8)127) +#define S8_MIN ((s8)(-128)) +#define U16_MAX ((u16)65535u) +#define S16_MAX ((s16)32767) +#define S16_MIN ((s16)(-32768)) +#define U32_MAX ((u32)4294967295uL) +#define S32_MAX ((s32)2147483647uL) +#define S32_MIN ((s32)(-2147483648uL)) + +//--------------------------------------------------------------- +#ifndef LOBYTE +#define LOBYTE(w) ((BYTE)(((WORD)(w)) & 0xff)) +#endif + +#ifndef HIBYTE +#define HIBYTE(w) ((BYTE)((((WORD)(w)) >> 8) & 0xff)) +#endif + +#ifndef LOWORD +#define LOWORD(l) ((WORD)(((DWORD)(l)) & 0xffff)) +#endif + +#ifndef HIWORD +#define HIWORD(l) ((WORD)((((DWORD)(l)) >> 16) & 0xffff)) +#endif + +#ifndef MAKEWORD +#define MAKEWORD(a, b) ((WORD)((BYTE)(a)) | (((WORD)((BYTE)(b))) << 8)) +#endif + +#ifndef MAKEDWORD +#define MAKEDWORD(a, b) ((DWORD)((WORD)(a)) | (((DWORD)((WORD)(b))) << 16)) +#endif + +#ifndef LOHFBYTE +#define LOHFBYTE(b) ((BYTE)((b) & 0x0f)) +#endif + +#ifndef HIHFBYTE +#define HIHFBYTE(b) ((BYTE)(((b) >> 4) & 0x0f)) +#endif + +#ifndef MAKEBYTE +#define MAKEBYTE(a, b) ((BYTE)((BYTE)((a) & 0x0f)) | ((BYTE)(((BYTE)((b) & 0x0f)) << 4))) +#endif + +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + +//--------------------------------------------------------------- + +#ifndef PI + +#define PI 3.1415926535897932 + +#endif + + + + +#endif // TYPEDEF_H diff --git a/machine/comport.cpp b/machine/comport.cpp new file mode 100644 index 0000000..f2a29d8 --- /dev/null +++ b/machine/comport.cpp @@ -0,0 +1,157 @@ +#include "comport.h" +#include +#include + +//----------------------------------------------------------------------------------------------------- + +ComPort::ComPort(QObject *parent) : + QObject(parent), + m_pSerialport(NULL), + m_running(0), + m_pReadTimer(NULL) +{ + m_pReadTimer = new QTimer(this); + m_pReadTimer->setInterval(20); + connect(m_pReadTimer, SIGNAL(timeout()), this, SLOT(getDataFromPort())); +} + +ComPort::~ComPort() +{ + m_pReadTimer->stop(); + delete m_pReadTimer; + + if (m_pSerialport != NULL) + { + m_pSerialport->close(); + delete m_pSerialport; + m_pSerialport = NULL; + } +} + +void ComPort::setComPortName(QString portName) +{ + m_portName.clear(); + + if(portName.length() > 0)//串口名称不为空 + { + m_portName = portName; + return; + } + + //windows平台下 +#ifdef Q_OS_WIN + //得到串口设备 + QString path = "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM"; + QSettings *settings = new QSettings(path,QSettings::NativeFormat); + QStringList key = settings->allKeys(); + int num = (int)key.size(); + + //打开注册表 + unsigned long keysize,type,valuesize; + wchar_t keyname[256]; //键名数组 + char keyvalue[256]; //键值数组 + keysize = sizeof(keyname); + valuesize = sizeof(keyvalue); + int indexnum; + HKEY hKey; + QString commresult = ""; + QString valuemessage = "";//键值 + QString strkey = "HARDWARE\\DEVICEMAP\\SERIALCOMM";//子键路径 + LPCWSTR subkey = reinterpret_cast(strkey.utf16()); + + if(::RegOpenKeyEx(HKEY_LOCAL_MACHINE,subkey,0,KEY_READ,&hKey)!=0) + { + return; + } + + //循环得到串口设备的名称 + for(int i = 0; i < num; i++) + { + valuemessage.clear(); + commresult.clear(); + keysize=sizeof(keyname); + valuesize=sizeof(keyvalue); + indexnum=i;//要读取键值的索引号 + + if(::RegEnumValue(hKey,indexnum,keyname,&keysize,0,&type,(BYTE*)keyvalue,&valuesize) == 0)//列举键名和值 + { + for(unsigned int j = 0; j < valuesize; j++) + { + if(keyvalue[j]!=0x00) + { + valuemessage.append(keyvalue[j]); + } + } + if(m_portName.length() <= 0) + { + m_portName = valuemessage; + } + } + else + { + commresult="nokey"; + } + } + ::RegCloseKey(hKey);//关闭注册表 +#endif + +#ifdef Q_OS_LINUX + m_portName = COMNAME; +#endif + return; +} + +void ComPort::initComm() +{ + if (m_running == 0) + { + qDebug() << "InitComm ComPort at thread" << QThread::currentThread() << "name" << m_portName; + + struct PortSettings myComSetting = {BAUD115200, DATA_8, PAR_NONE, STOP_1, FLOW_OFF, 0, 20}; + m_pSerialport = new QextSerialPort(m_portName, myComSetting); + bool bOpen = m_pSerialport->open(QIODevice::ReadWrite | QIODevice::Unbuffered); + if(bOpen == false) + { + emit siSerialPortOpenState(m_running); + qDebug()<<"m_pSerialport->open fail "; + return; + }else + { + qDebug()<<"m_pSerialport->open success "; + } + + qDebug() << "Start timer"; + + m_pReadTimer->start(); + m_running = 1; + emit siSerialPortOpenState(m_running); + } +} + +void ComPort::getDataFromPort() +{ +// qDebug("GetDataFromPort"); +// qDebug() << "ComPort GetDataFromPort" << QThread::currentThread(); + + if (m_running != 0 && m_pSerialport != NULL) + { + QByteArray dat = m_pSerialport->readAll(); + if (dat.size() != 0) + { + //qDebug()<<"dat.size()="<readAll() :"<write(dat.data(), dat.size()); + } +} diff --git a/machine/comport.h b/machine/comport.h new file mode 100644 index 0000000..6b32e0f --- /dev/null +++ b/machine/comport.h @@ -0,0 +1,43 @@ +#ifndef COMPORT_H +#define COMPORT_H + + +#include +#include +#include + +#include "qextserial/qextserialport.h" + +#ifdef Q_OS_LINUX +#define COMNAME "/dev/ttyS1" +#define COMNAME485 "/dev/ttyS2" +#endif + +class ComPort : public QObject +{ + Q_OBJECT +public: + explicit ComPort(QObject *parent = 0); + ~ComPort(); +private: + QextSerialPort * m_pSerialport; + int m_running; + QTimer * m_pReadTimer; + QString m_portName; + +public: + void setComPortName(QString portName);//获取所有串口名称 + +private slots: + void getDataFromPort(); + +signals: + void siReceiveData(QByteArray dat); + void siSerialPortOpenState(int val); + +public slots: + void initComm(); + void slotSendData(QByteArray dat); +}; + +#endif // COMTHREAD_H diff --git a/machine/error.cpp b/machine/error.cpp new file mode 100644 index 0000000..5ab14ef --- /dev/null +++ b/machine/error.cpp @@ -0,0 +1,105 @@ + +#include "error.h" +#include "comm/protocol.h" +#include + +#define CASE_OP(cd, str) \ +{\ + case cd:\ + errinfo = str;\ + break;\ +} + +QString getErrStr(u32 code) +{ + QString errinfo; + errinfo.clear(); + QString errorCode; + errorCode.clear(); + + switch (code) + { + //通用的错误代码 + CASE_OP(ERR_NONE, QObject::tr("")); // 没有错误 + CASE_OP(ERR_NO_AIR, QObject::tr("(0x0002)Insufficient air pressure")); // 气压不足 + CASE_OP(ERR_NOT_SAFE, QObject::tr("(0x0003)safe area error")); // 安全区域介入 + CASE_OP(ERR_EXPIRATION, QObject::tr("(0x0004)Expiration of use")); // 使用时限已到 + CASE_OP(ERR_DRIVER, QObject::tr("(0x0005)Driver alarm")); // 驱动器报警 + CASE_OP(ERR_FILL_DATA, QObject::tr("(0x0006)Fill data error")); // 填充数据错误 + CASE_OP(ERR_NOT_ALLOWED, QObject::tr("(0x0007)Not allowed to work")); // 不允许工作状态 + CASE_OP(ERR_CTRL_ERR, QObject::tr("(0x0008)Control error")); // 控制错误 + CASE_OP(ERR_FPGA_ERR, QObject::tr("(0x0009)Motion control chip version error")); // 运动控制芯片版本错误 + CASE_OP(ERR_BUTTON_NOUP, QObject::tr("(0x000A)Waiting for button to lift timeout")); // 等待按钮抬起超时 + CASE_OP(ERR_FPGA_RESET, QObject::tr("(0x000B)FPGA Reset")); // FPGA复位 + CASE_OP(ERR_NO_READY, QObject::tr("(0x000C)Peripheral Device not ready")); // 外设未就绪 + CASE_OP(ERR_NO_SEND_ERR, QObject::tr("(0x000D)Transmission data error")); // 传输数据错误 + CASE_OP(ERR_EDTION_ERR, QObject::tr("(0x000E)Program version error")); // 程序版本错误 + CASE_OP(ERR_WORK_DONE, QObject::tr("(0x000F)Complete output")); // 完成产量 + CASE_OP(ERR_LMT_POSITIVE, QObject::tr("(0x0010)Positive limit")); // 正向限位 + CASE_OP(ERR_LMT_NEGATIVE, QObject::tr("(0x0011)Negative limit")); // 反向限位 + CASE_OP(ERR_RUN_ALM, QObject::tr("(0x0012)Motion alarm")); // 运动报警 + CASE_OP(ERR_RUN_LIMIT, QObject::tr("(0x0013)Motion limit")); // 运动限位 + CASE_OP(ERR_RUN_EMS, QObject::tr("(0x0014)Emergency stop")); // 运动急停 + CASE_OP(ERR_MV_PARA, QObject::tr("(0x0015)Motion parameters error")); // 运动参数错误 + CASE_OP(ERR_MC_PARA, QObject::tr("(0x0016)Machine parameters error")); // 机器参数错误 + CASE_OP(ERR_IN_PARA, QObject::tr("(0x0017)Input parameters error")); // 输入参数错误 + CASE_OP(ERR_NOT_WORKSTA, QObject::tr("(0x001A)Not in work status error")); // 不能工作状态 + CASE_OP(ERR_NOT_MOVESTA, QObject::tr("(0x001B)Prohibited frame moving state")); // 禁止移框状态 + CASE_OP(ERR_MTZ_RIGHT, QObject::tr("(0x001F)Zero success")); // 归零成功 + CASE_OP(ERR_MTZ_ERROR, QObject::tr("(0x0020)Return to zero error")); // 归零错误 + CASE_OP(ERR_COOR_SYSTM, QObject::tr("(0x0021)Coordinate system error")); // 坐标系统错误 + CASE_OP(ERR_OUT_RANGE, QObject::tr("(0x0022)Target position out of bounds")); // 目标位置越界 + CASE_OP(ERR_X_LIT_POSI, QObject::tr("(0x0023)X Positive limit")); // X正向限位 + CASE_OP(ERR_X_LIT_NEGA, QObject::tr("(0x0024)X Negative limit")); // X反向限位 + CASE_OP(ERR_Y_LIT_POSI, QObject::tr("(0x0025)Y Positive limit")); // Y正向限位 + CASE_OP(ERR_Y_LIT_NEGA, QObject::tr("(0x0026)Y Negative limit")); // Y反向限位 + CASE_OP(ERR_ALM_COVEROPEN, QObject::tr("(0x002B)Safety door error")); // 开盖报警,安全门错误 + CASE_OP(ERR_LIGHTCURTAINS1, QObject::tr("(0x002C)Entering the light curtain 1")); // 光幕1介入 + CASE_OP(ERR_LIGHTCURTAINS2, QObject::tr("(0x002D)Entering the light curtain 2")); // 光幕2介入 + CASE_OP(ERR_NO_DATA, QObject::tr("(0x0040)None data")); // 无数据 + CASE_OP(ERR_DATA_ERROR, QObject::tr("(0x0041)Data error")); // 数据错误 + CASE_OP(ERR_GRAPH_OUT_RANGE, QObject::tr("(0x0042)Graphics out of range")); // 图形超出范围 + CASE_OP(ERR_MS_NOT_ZERO, QObject::tr("(0x0050)Spindle is not in zero position")); // 主轴不在零位 + CASE_OP(ERR_HK_NOT_ZERO, QObject::tr("(0x0051)Rotary hook is not in zero position")); // 旋梭不在零位 + CASE_OP(ERR_CUTTER_NOT_POS, QObject::tr("(0x0054)Scissors are not in position")); // 剪刀不在回位 + CASE_OP(ERR_HEAD_NOT_LOW, QObject::tr("(0x0056)Nose not in low position")); // 机头不在低位 + CASE_OP(ERR_UPER_TBREAK, QObject::tr("(0x0058)Thread is broken"));// 断线 + CASE_OP(ERR_BOBBIN_TBREAK, QObject::tr("(0x0059)Bottom thread disconnected")); // 底线断线 + CASE_OP(ERR_TRANS_TIMEOUT, QObject::tr("(0x005D)Execution command timed out")); // 执行命令超时 + CASE_OP(ERR_LIFT_TIMEOUT, QObject::tr("(0x005F)Head lifting timeout")); // 机头升降超时 + CASE_OP(ERR_CHANGE_BOBBIN, QObject::tr("(0x00F0)Change the bobbin")); // 更换梭芯 + CASE_OP(ERR_CHANGE_BOBBIN_A, QObject::tr("(0x00F1)Replace bobbin A")); // 更换梭芯A + CASE_OP(ERR_CHANGE_BOBBIN_B, QObject::tr("(0x00F2)Replace bobbin B")); // 更换梭芯B + CASE_OP(ERR_CHANGE_BOBBIN_STA, QObject::tr("(0x00F3)The machine is in the state of replacing the bobbin")); // 机器处于更换梭芯状态 + CASE_OP(ERR_AIR_POWER, QObject::tr("(0x002E)Insufficient air pressure")); // 气压不足 + + //通用的状态信息 + CASE_OP(STA_NORMAL_STOP, QObject::tr("Normal stop")); // 正常停止 + CASE_OP(STA_MTZ_SUCCESS, QObject::tr("Find zero success")); // 归零成功 + CASE_OP(STA_WORK_PAUSE, QObject::tr("work pause")); // 工作暂停 + CASE_OP(STA_WORK_OVER, QObject::tr("End of work")); // 工作结束 + CASE_OP(STA_WORK_FINISH, QObject::tr("Work done")); // 工作完成 + CASE_OP(STA_WORK_DONE, QObject::tr("Complete production")); // 完成产量 + CASE_OP(STA_EXEC_SUCCESS, QObject::tr("(0x0106)Execute success")); // 执行成功 + CASE_OP(STA_EXEC_FAILED, QObject::tr("(0x0107)Execute false")); // 执行失败 + CASE_OP(STA_WAIT_FILE, QObject::tr("(0x0108)wait file")); // 等待文件 + CASE_OP(STA_CHANGE_BOBBIN, QObject::tr("(0x0109)change the bobbin")); // 更换梭芯 + CASE_OP(STA_PROCESS_FINISH, QObject::tr("(0x010A)Execute finish")); // 执行完成 + CASE_OP(STA_PROCESS_RUNNING, QObject::tr("(0x010B)Execute runnibng")); // 执行过程中 + + default: + //errorCode.sprintf("CODE 0x%x", code); + //errinfo.append(QObject::tr("Undefined error,") + errorCode); + break; + } + return errinfo; +} + +QString getPromptStr(u32 code) +{ + QString errinfo; + switch (code) + { + } + return errinfo; +} diff --git a/machine/error.h b/machine/error.h new file mode 100644 index 0000000..124086c --- /dev/null +++ b/machine/error.h @@ -0,0 +1,12 @@ +#ifndef ERROR_H +#define ERROR_H + +#include +#include "comm/typedef.h" + + +QString getErrStr(u32 code); +QString getPromptStr(u32 code); + + +#endif // ERROR_H diff --git a/machine/gatewaytcpclient.cpp b/machine/gatewaytcpclient.cpp new file mode 100644 index 0000000..6e1e3d0 --- /dev/null +++ b/machine/gatewaytcpclient.cpp @@ -0,0 +1,334 @@ +#include "gatewaytcpclient.h" + +#include +#include +#include + +GatewayTcpClient::GatewayTcpClient(QObject *parent) : + QObject(parent), + m_pClientSocket(NULL), + m_pConnectCheckTimer(NULL), + m_connected(0), + m_pConnectDetectThread(NULL), + m_pConnectDetect(NULL), + m_detect(0), + m_localip(DEF_LOCAL_IP), + m_localport(DEF_LOCAL_PORT), + m_serverip(DEF_SERVER_IP), + m_serverport(DEF_SERVER_PORT) +{ + m_pClientSocket = new QBindTcpSocket(this); + m_pClientSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); + connect(m_pClientSocket, SIGNAL(readyRead()), this, SLOT(receiveServerData())); + connect(m_pClientSocket, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(displaySocketError(QAbstractSocket::SocketError))); + // connect(m_pClientSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(netStateChanged(QAbstractSocket::SocketState))); + + m_pConnectCheckTimer = new QTimer(this); + connect(m_pConnectCheckTimer, SIGNAL(timeout()), this, SLOT(connectCheck())); + + + m_pConnectDetectThread = new QThread(); +} + +GatewayTcpClient::~GatewayTcpClient() +{ + m_pConnectCheckTimer->stop(); + delete m_pConnectCheckTimer; + + m_pClientSocket->disconnectFromHost(); + m_pClientSocket->waitForDisconnected(); + m_pClientSocket->close(); + delete m_pClientSocket; + + if (m_connected != 0) + { + m_pConnectDetectThread->quit(); + m_pConnectDetectThread->wait(); + } + + delete m_pConnectDetectThread; +} + +void GatewayTcpClient::setConfigFileName(QString configfilename) +{ + m_configFileName = configfilename; +} + +void GatewayTcpClient::connectToServer() +{ + if (m_pClientSocket == NULL) + { + qDebug() << "m_pClientSocket not alloc"; + return; + } + + if (m_connected == 0) + { + loadIpAndPort(); + if (m_pConnectDetect == NULL) + { + m_pConnectDetect = new TcpConnectDetect; + } + qDebug() << "ConnectToServer"; + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + qDebug() << "serverip=" << m_serverip << "serverport=" << m_serverport; + + m_pConnectDetect->setIpAndPort(m_localip, m_localport, m_serverip, m_serverport); + + m_pConnectDetect->moveToThread(m_pConnectDetectThread); + + connect(this, SIGNAL(siDetectHost()), m_pConnectDetect, SLOT(connectDetect()), Qt::QueuedConnection); + connect(m_pConnectDetect, SIGNAL(siConnectSta(int)), this, SLOT(detectStatus(int)), Qt::QueuedConnection); + + // 20191226由于检测线程会造成网络重连,所以将检测线程注释 lft +/* + connect(m_pConnectDetectThread, SIGNAL(started()), m_pConnectDetect, SLOT(detectStart()) ); + connect(m_pConnectDetectThread, SIGNAL(finished()), m_pConnectDetect, SLOT(deleteLater()) ); // 退出删除对象 + + m_pConnectDetectThread->start(); // 启动线程 +*/ + m_pConnectCheckTimer->start(1000); + m_connected = 1; + m_detect = 1; + } +} + +void GatewayTcpClient::disConnectFromServer() +{ + if (m_connected != 0) + { + m_pConnectCheckTimer->stop(); + + if (m_pClientSocket != NULL) + { + m_pClientSocket->disconnectFromHost(); + m_pClientSocket->waitForDisconnected(); + m_pClientSocket->close(); + } + + m_pConnectDetectThread->quit(); + m_pConnectDetectThread->wait(); + + m_connected = 0; + m_detect = 0; + } +} + +void GatewayTcpClient::loadIpAndPort() +{ + if (!m_configFileName.isEmpty()) + { + // 机器的IP和端口 和 连接机器的本地IP和端口 + QSettings configIni(m_configFileName, QSettings::IniFormat); + QString serverip, localip; + quint16 serverport, localport; + + serverip = configIni.value("server/ip", QVariant("192.168.16.253")).toString(); + serverport = configIni.value("server/port", QVariant(5000)).toInt(); + localip = configIni.value("local/ip", QVariant("192.168.16.41")).toString(); + localport = configIni.value("local/port", 5001).toInt(); + + // 回写参数 + configIni.setValue("server/ip", serverip); + configIni.setValue("server/port", serverport); + configIni.setValue("local/ip", localip); + configIni.setValue("local/port", localport); + + m_localip = localip; + m_localport = localport; + m_serverip = serverip; + m_serverport = serverport; + } +} + +// 发送数据的槽 +void GatewayTcpClient::slotSendData(QByteArray dat) +{ + if (m_pClientSocket != NULL) + { + m_pClientSocket->write(dat); + } +} + +// 自动检测连接 +void GatewayTcpClient::connectCheck() +{ + if (m_pClientSocket == NULL) + { + qDebug() << "Socket is not alloced"; + return; + } + +// qDebug() << "check client connect"; + if (m_connected == 1) + { + if (m_localip.isEmpty() == false) + { + m_pClientSocket->bindAddrAndPort(m_localip, m_localport); + } + m_pClientSocket->abort(); + m_pClientSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); + m_pClientSocket->connectToHost(m_serverip, m_serverport); + int rslt = m_pClientSocket->waitForConnected(2000); + if (rslt == 0) + { + + } + /* + qDebug("bind connect and waitForConnected 2000, rslt=%d", rslt); + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + qDebug() << "serverip=" << m_serverip << "serverport=" << m_serverport; + */ + m_connected = 2; + } + else if (m_connected != 0) + { + switch(m_pClientSocket->state()) + { + case QAbstractSocket::ConnectedState: + { + if (m_connected != 3) + { + /* + qDebug() << "net State is Connected"; + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + */ + m_connected = 3; // 检测连接状态 + } + + break; + } + case QAbstractSocket::ConnectingState: + { + if (m_connected != 2) + { + qDebug() << "net State is Connecting"; + // qDebug() << "localip=" << m_localip << "localport=" << m_localport; + } + m_connected = 2; + break; + } + case QAbstractSocket::UnconnectedState: + { + if (m_connected != 1) + { + // qDebug() << "net State is unconnected"; + // qDebug() << "localip=" << m_localip << "localport=" << m_localport; + } + m_connected = 1; + break; + } + default: + { + /* + QAbstractSocket::HostLookupState + QAbstractSocket::BoundState + QAbstractSocket::ListeningState + QAbstractSocket::ClosingState + */ + { + qDebug("net State is %d\r\n", m_pClientSocket->state()); + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + qDebug() << "serverip=" << m_serverip << "serverport=" << m_serverport; + } + m_connected = 1; + } + } + } + else + { + + } + + if (m_connected == 3) // 已连接 + { + if (m_detect == 1) + { + // qDebug() << "Machine " << QThread::currentThread(); + m_detect = 0; + emit(siDetectHost()); + // qDebug() << "after send SiDetectHost "; + } + } + + emit (siConnectSta(m_connected)); // 网络连接信号 +} + +void GatewayTcpClient::detectStatus(int sta) +{ + // qDebug("host detect sta=%d", sta); + + m_detect = 1; + if (sta == 1) // 网络已断开 + { + qDebug("disconnect ClientSocket by detect"); + m_pClientSocket->disconnectFromHost(); +// m_pClientSocket->waitForDisconnected(); + m_pClientSocket->close(); + m_connected = 1; + } + else if (sta == 2) // 网络连接还在 + { + + } + else + { + + } +} + +void GatewayTcpClient::receiveServerData() +{ + if (m_pClientSocket != NULL) + { + QByteArray tmpDat; + tmpDat = m_pClientSocket->readAll(); // 读取 +// qDebug("ReceiveServerData, size = %d", tmpDat.size()); +// PrintAsHex(&tmpDat); + + emit(siReceiveData(tmpDat)); // 发送收到数据信号 + } +} + +void GatewayTcpClient::displaySocketError(QAbstractSocket::SocketError err) +{ + QString errinfo; + + errinfo.sprintf("Err: code=%d, errorString=", err); + errinfo += m_pClientSocket->errorString(); + +// qDebug() << errinfo; + + emit(siConnectErr(errinfo)); // 网络错误信息 +} + +void GatewayTcpClient::netStateChanged(QAbstractSocket::SocketState sta) +{ + switch (sta) + { + /* + case UnconnectedState: + case HostLookupState: + case ConnectingState: + case ConnectedState: + case BoundState: + case ListeningState: + case ClosingStat: + */ + default: + break; + } + +} +void GatewayTcpClient::hostFound() +{ + qDebug("found host"); +} + + + + + + + diff --git a/machine/gatewaytcpclient.h b/machine/gatewaytcpclient.h new file mode 100644 index 0000000..6840275 --- /dev/null +++ b/machine/gatewaytcpclient.h @@ -0,0 +1,72 @@ +#ifndef GATEWAYTCPCLIENT_H +#define GATEWAYTCPCLIENT_H + +#include +#include +#include +#include +#include +#include +#include + +#include "qbindtcpsocket.h" + +class ConnectDetectThread; + + +class GatewayTcpClient : public QObject +{ + Q_OBJECT +public: + explicit GatewayTcpClient(QObject *parent = NULL); + virtual ~GatewayTcpClient(); + +public: + void setConfigFileName(QString configfilename); +signals: + void siConnectSta(int sta); // 网络连接信号 + void siConnectErr(QString errinfo); // 网络错误信息 + void siReceiveData(QByteArray dat); // 收到数据包信号 +signals: + void siDetectHost(void); +public: + + +public slots: + void slotSendData(QByteArray dat); // 发送数据的槽 + void connectToServer();//连接到服务器 + void disConnectFromServer(); + void detectStatus(int); +public: + +private slots: + void connectCheck(); + void receiveServerData(); + void displaySocketError(QAbstractSocket::SocketError err); + void netStateChanged(QAbstractSocket::SocketState sta); + void hostFound(); + +private: + void loadIpAndPort(); +private: + QBindTcpSocket * m_pClientSocket; + + QTimer * m_pConnectCheckTimer; + +public: + int m_connected; // 连接状态; 0, 初始化; 1, 未连接; 2, 连接中; 3, 已连接 + +private: + QThread * m_pConnectDetectThread; + TcpConnectDetect * m_pConnectDetect; + int m_detect; // 连接测试状态 +private: + QString m_configFileName; +private: + QString m_localip; + quint16 m_localport; + QString m_serverip; + quint16 m_serverport; +}; + +#endif // GATEWAYTCPCLIENT_H diff --git a/machine/lotmachine.cpp b/machine/lotmachine.cpp new file mode 100644 index 0000000..0c7d09d --- /dev/null +++ b/machine/lotmachine.cpp @@ -0,0 +1,289 @@ +#include "lotmachine.h" +#include +#include + +LotMachine::LotMachine(QObject *parent) : + QObject(parent), + m_pTcpThread(NULL), + m_pTcpClient(NULL), + m_pComThread(NULL), + m_pComPort(NULL), + m_startComm(0) +{ + m_receiveBuff.clear(); + m_keyBuff.clear(); + m_reFlag = 0; + m_connected = 0; +} + +LotMachine::~LotMachine() +{ + if (m_startComm != 0) + { + if(m_connectMode == USE_TCP_COMM) + { + m_pTcpThread->quit(); + m_pTcpThread->wait(); + } + else if(m_connectMode == USE_SERIAL_COMM) + { + m_pComThread->quit(); + m_pComThread->wait(); + } + } + + if(m_connectMode == USE_TCP_COMM) + { + if(m_pTcpThread != NULL) + { + delete m_pTcpThread; + } + } + else if(m_connectMode == USE_SERIAL_COMM) + { + if(m_pComThread != NULL) + { + delete m_pComThread; + } + } +} + +//初始化通讯连接方式 +void LotMachine::initConnectMode(s16 val) +{ + m_connectMode = val; + if(m_connectMode == USE_TCP_COMM)//网口 + { + m_pTcpThread = new QThread(); + m_pTcpClient = new GatewayTcpClient(); + } + else if(m_connectMode == USE_SERIAL_COMM)//串口 + { + m_pComThread = new QThread(); + m_pComPort = new ComPort(); + connect(m_pComPort, SIGNAL(siSerialPortOpenState(int)), this, SLOT(slotIfOpenSerialPort(int)) ); + } +} + +void LotMachine::setConfigFileName(QString configfilename) +{ + m_configFileName = configfilename; + if(m_connectMode == USE_TCP_COMM)//网口 + { + m_pTcpClient->setConfigFileName(m_configFileName); + } +} + +//设置串口名称 +void LotMachine::setComportName(QString portName) +{ + if(m_pComPort == NULL) + { + return; + } + + if(m_connectMode == USE_SERIAL_COMM)//串口 + { + m_pComPort->setComPortName(portName); + } +} + +QString LotMachine::getConfigFileName() +{ + return m_configFileName; +} + +int LotMachine::startCommunication() +{ + if (m_startComm == 0) + { + // qDebug() << "Machine " << QThread::currentThread(); + + if(m_connectMode == USE_TCP_COMM)//网口 + { + if (m_configFileName.isEmpty()) + { + qDebug() << "mast call SetConfigFileName first "; + } + + m_pTcpClient->moveToThread(m_pTcpThread); // 移动对象到线程中 + + // connect(qApp, SIGNAL(finished()), m_pTcpThread, SLOT(finished())); + + connect(m_pTcpThread, SIGNAL(started()), m_pTcpClient, SLOT(connectToServer()) ); + connect(m_pTcpThread, SIGNAL(finished()), m_pTcpClient, SLOT(deleteLater()) ); // 退出删除对象 + + connect(m_pTcpClient, SIGNAL(siConnectSta(int)), + this, SLOT(slotConnectSta(int)), Qt::AutoConnection); // 连接状态改变 + connect(m_pTcpClient, SIGNAL(siConnectErr(QString)), + this, SLOT(slotConnectErr(QString)), Qt::AutoConnection); // 接收到通讯错误 + connect(m_pTcpClient, SIGNAL(siReceiveData(QByteArray)), + this, SLOT(slotReceiveData(QByteArray)), Qt::AutoConnection); // 接收到数据 + connect(this, SIGNAL(siSendData(QByteArray)), + m_pTcpClient, SLOT(slotSendData(QByteArray)), Qt::AutoConnection); // 发送数据的槽 + + m_pTcpThread->start(); // 启动线程 + } + + if(m_connectMode == USE_SERIAL_COMM)//串口 + { + m_pComPort->moveToThread(m_pComThread); + + connect(m_pComThread, SIGNAL(started()), m_pComPort, SLOT(initComm()) ); + connect(m_pComThread, SIGNAL(finished()), m_pComPort, SLOT(deleteLater()) ); // 退出删除对象 + + connect(m_pComPort, SIGNAL(siReceiveData(QByteArray)), + this, SLOT(slotReceiveData(QByteArray)), Qt::QueuedConnection); // 接收到数据 + connect(this, SIGNAL(siSendData(QByteArray)), + m_pComPort, SLOT(slotSendData(QByteArray)), Qt::QueuedConnection); // 发送数据的槽 + + m_pComThread->start(); // 启动线程 + } + m_startComm = 1; + } + return m_startComm; +} + +// 连接状态改变的槽函数 +void LotMachine::slotConnectSta(int sta) +{ + // qDebug() << "SlotConnectSta" << sta; + if(m_connected != sta) + { + m_connected = sta; + if(m_connected == 3)//已连接 + { + emit siConnectToMqtt(); + } + } +} + +// 接收到通讯错误槽函数 +void LotMachine::slotConnectErr(QString errinfo) +{ + qDebug() << "SlotConnectErr" << errinfo; +} + + +// 接收到数据的槽函数 +void LotMachine::slotReceiveData(QByteArray dat) +{ + m_receiveBuff.append(dat); + int size = m_receiveBuff.length(); + QString str = m_receiveBuff; + if(str == "success") + { + m_receiveBuff.remove(0, size); + return; + } + + //QString rackNumStr = getJsonValue("device");//机架号 + QString bootCmd = getJsonValue("data","boot");//执行命令 + + if(bootCmd.length() > 0) + { + emit siRunLotDataAction(bootCmd); + } + + m_receiveBuff.remove(0, size); +} + +//串口是否打开 +void LotMachine::slotIfOpenSerialPort(int val) +{ + if(val != 0) + { + if(m_connectMode == USE_SERIAL_COMM) + { + m_connected = 3;//串口已打开 + } + } +} + +//获取键值对属性值 +QString LotMachine::getJsonValue(QString name1, QString name2) +{ + QString rstr; + rstr.clear(); + + if(name1.length() <= 0 && name2.length() <= 0) + { + return rstr; + } + + //QString str = "{\"device\":\"xiuhuaji133\",\"data\":{\"boot\":9}}"; + QString str = m_receiveBuff; + + QStringList vallist; + if(str.indexOf(",") == -1) + { + return rstr; + } + else + { + vallist = str.split(",", QString::SkipEmptyParts); + } + + if(name2.length() <= 0) + { + if(vallist.size() >= 1) + { + QStringList vallist1; + if(QString(vallist[0]).indexOf(":") == -1) + { + return rstr; + } + else + { + vallist1 = QString(vallist[0]).split(":", QString::SkipEmptyParts); + } + + if(QString(vallist1[0]).indexOf(name1) == -1) + { + return rstr; + } + else + { + rstr = QString(vallist1[1]).remove("\""); + } + } + } + else + { + if(vallist.size() >= 2) + { + QStringList vallist1; + if(QString(vallist[1]).indexOf(":") == -1) + { + return rstr; + } + else + { + vallist1 = QString(vallist[1]).split(":", QString::SkipEmptyParts); + } + + for(int i = 0; i < vallist1.size(); i++) + { + if(QString(vallist1[i]).indexOf(name2) != -1) + { + if(i+1 < vallist1.size()) + { + rstr = QString(vallist1[i+1]).remove("\"").remove("}"); + } + } + } + } + } + + return rstr; +} + +//发送物联数据到网关 +void LotMachine::sendLotDataToGateway(QString str) +{ + QByteArray dat; + dat.clear(); + dat = str.toLatin1(); + + emit(siSendData(dat)); +} diff --git a/machine/lotmachine.h b/machine/lotmachine.h new file mode 100644 index 0000000..f47c28c --- /dev/null +++ b/machine/lotmachine.h @@ -0,0 +1,73 @@ +#ifndef LOTMACHINE_H +#define LOTMACHINE_H + +#include "gatewaytcpclient.h" +#include "comport.h" +#include "comm/typedef.h" + +#include +#include +#include +#include + +#define USE_TCP_COMM 0 +#define USE_SERIAL_COMM 1 + +class LotMachine: public QObject +{ + Q_OBJECT + +public: + explicit LotMachine(QObject *parent = NULL); + virtual ~LotMachine(); + +public: + void initConnectMode(s16 val = 0);//初始化通讯连接方式 + void setConfigFileName(QString configfilename); + void setComportName(QString portName);//设置串口名称 + QString getConfigFileName(); + int startCommunication(); + +private: + QString m_configFileName; + QByteArray m_receiveBuff;//接收到的buf + QByteArray m_keyBuff;//键值对buf + s16 m_reFlag; + +private: + s16 m_connectMode; //通讯连接方式 0:网口,1:串口 + // 通讯线程和网络连接 + QThread * m_pTcpThread; + GatewayTcpClient * m_pTcpClient; + QThread * m_pComThread; + ComPort * m_pComPort; + + // 连接 +public: + inline int isConnected() const { return m_connected; } + +private: + int m_startComm; + int m_connected; // 机器连接状态. 0, 未连接; 1, 连接中; 2, + +signals: // 发送数据到机器的信号 + void siSendData(QByteArray dat); + void siRunLotDataAction(QString cmd);//执行物联网数据动作 + void siConnectToMqtt();//与网关已连接 + +private slots: // 和线程通讯的槽 + void slotConnectSta(int sta); // 连接状态改变的槽函数 + void slotConnectErr(QString errinfo); // 接收到通讯错误槽函数 + void slotReceiveData(QByteArray dat); // 接收到数据的槽函数 + void slotIfOpenSerialPort(int val);//串口是否打开 + +private: + QString getJsonValue(QString name1,QString name2 = NULL);//获取键值对属性值 + +public: + void sendLotDataToGateway(QString str);//发送物联数据到网关 + +}; + +#endif // LOTMACHINE_H + diff --git a/machine/machine.cpp b/machine/machine.cpp new file mode 100644 index 0000000..20f06bc --- /dev/null +++ b/machine/machine.cpp @@ -0,0 +1,1962 @@ +#include "machine.h" +#include +#include + +/* +Machine的dll如果是Release版本的在应用程序中只能在Release下调用, +否则调用不成功(连接不上),Machine的dll如果是Debug版本, +应用程序中在Debug下调用成功; +*/ + +//------------------------------------------ + +QByteArray g_receiveBuff; +DataExFuns g_exfuns = {NULL,NULL,NULL,NULL,NULL}; + +// 发送数据 +int operatorSendData(u8 * pDatBuf, int len) +{ + if (pDatBuf != NULL && len != 0) + { + // 不准备通过该函数发送数据 + } + return 0; +} + +// 得到发送缓冲区空闲长度 +int operatorGetSdFreeLen(void) +{ + return 0; // 认没有空间 +} + +// 接收数据 +int operatorGetData(u8 * pDat, int expectLen) +{ + int len = g_receiveBuff.size(); + if (len > expectLen) + { + len = expectLen; + } + + //if (len != 0 && pDat != NULL) + if (len == expectLen && pDat != NULL) //使len等于expectLen(串口下接收数据暴露的问题) + { + memcpy(pDat, g_receiveBuff.data(), len); + g_receiveBuff.remove(0, len); + } + else + { + len = 0; + } + + return len; +} + +// 已接收数据长度 +int operatorGetRsLen(void) +{ + return g_receiveBuff.size(); +} + +void delayMs(u32 ms) +{ + QDateTime oldTime, curTime; + oldTime = QDateTime::currentDateTime(); + while(1) + { + curTime = QDateTime::currentDateTime(); + if(oldTime.msecsTo(curTime) > ms) + { + break; + } + } +} + +void initDataExFuns(void) +{ + g_exfuns.sendCommData = operatorSendData; + g_exfuns.getCommData = operatorGetData; + g_exfuns.getRsvLen = operatorGetRsLen; + g_exfuns.getTrsFreeLen = operatorGetSdFreeLen; + + g_exfuns.delay = delayMs; +} + +//------------------------------------------ + + +Machine::Machine(QObject *parent) : + QObject(parent), + m_pTcpThread(NULL), + m_pTcpClient(NULL), + m_pComThread(NULL), + m_pComPort(NULL), + m_startComm(0) +{ + memset(&m_mcStatus, 0, sizeof(MCStatus)); // 机器状态 + memset(&m_mcPara, 0, sizeof(ParaStruct)); // 机器参数信息 + memset(&m_wkPara, 0, sizeof(ParaStruct)); // 工作参数信息 + memset(&m_mcPrePara, 0, sizeof(ParaStruct)); // 机器预留参数信息 + memset(&m_wkPrePara, 0, sizeof(ParaStruct)); // 工作预留参数信息 + memset(&m_mcInfo,0,sizeof(MCInfo)); // 机器信息 + memset(&m_lotData,0,sizeof(McLotData)); // 物联数据 + + memset(&m_sensorsStaDat, 0, sizeof(SensorsBitmap)); // 传感器信号状态位图 + memset(&m_sensorEnBmp, 0, sizeof(SensorsBitmap)); // 传感器信号有效位图 + + memset(&m_transCtrl, 0, sizeof(FileTransCtrl)); // 文件传输信息 + + m_pSendTimer = new QTimer(this); + m_pSendTimer->setInterval(100); // 设置定时间隔100毫秒 + connect(m_pSendTimer, SIGNAL(timeout()), this, SLOT(onSendTimer())); + m_transCtrl.pFileHead = new DataDs16FileHead; + m_transCtrl.pAppHead = new AppFileHead; + m_transCtrl.pDatBuff = new u8[MAX_FILE_SIZE]; + m_startComm = 0; + m_connected = 0; + m_statusEn = 0; + m_mcParaEn = 0; + m_wkParaEn = 0; + m_mcPreParaEn = 0; + m_wkPreParaEn = 0; + m_sensorStaEn = 0; + m_sensorBmpEn = 0; + + m_statusToggle = 0; + m_fileTransEn = 0; + m_transBreak = 0; + m_totalSendNum = 0; + m_totalPacketNum = 0; + m_connectMode = 0; + + initDataExFuns(); +} + +Machine::~Machine() +{ + if (m_startComm != 0) + { + if(m_connectMode == USE_TCP_COMM) + { + m_pTcpThread->quit(); + m_pTcpThread->wait(); + } + else if(m_connectMode == USE_SERIAL_COMM) + { + m_pComThread->quit(); + m_pComThread->wait(); + } + } + if (m_transCtrl.pFileHead != NULL) + { + delete []m_transCtrl.pFileHead; + m_transCtrl.pFileHead = NULL; + } + if (m_transCtrl.pDatBuff != NULL) + { + delete []m_transCtrl.pDatBuff; + m_transCtrl.pDatBuff = NULL; + } + + if(m_connectMode == USE_TCP_COMM) + { + if(m_pTcpThread != NULL) + { + delete m_pTcpThread; + } + } + else if(m_connectMode == USE_SERIAL_COMM) + { + if(m_pComThread != NULL) + { + delete m_pComThread; + } + } +} + +//初始化通讯连接方式 +void Machine::initConnectMode(s16 val) +{ + m_connectMode = val; + if(m_connectMode == USE_TCP_COMM)//网口 + { + m_pTcpThread = new QThread(); + m_pTcpClient = new TcpClient(); + } + else if(m_connectMode == USE_SERIAL_COMM)//串口 + { + m_pComThread = new QThread(); + m_pComPort = new ComPort(); + connect(m_pComPort, SIGNAL(siSerialPortOpenState(int)), this, SLOT(slIfOpenSerialPort(int)) ); + } +} + +void Machine::setConfigFileName(QString configfilename) +{ + m_configFileName = configfilename; + if(m_connectMode == USE_TCP_COMM)//网口 + { + m_pTcpClient->setConfigFileName(m_configFileName); + } +} + +//设置串口名称 +void Machine::setComportName(QString portName) +{ + if(m_pComPort == NULL) + { + return; + } + + if(m_connectMode == USE_SERIAL_COMM)//串口 + { + m_pComPort->setComPortName(portName); + } +} + +QString Machine::getConfigFileName() +{ + return m_configFileName; +} + +int Machine::startCommunication() +{ + if (m_startComm == 0) + { + // qDebug() << "Machine " << QThread::currentThread(); + + if(m_connectMode == USE_TCP_COMM)//网口 + { + if (m_configFileName.isEmpty()) + { + qDebug() << "mast call SetConfigFileName first "; + } + + m_pTcpClient->moveToThread(m_pTcpThread); // 移动对象到线程中 + + // connect(qApp, SIGNAL(finished()), m_pTcpThread, SLOT(finished())); + + connect(m_pTcpThread, SIGNAL(started()), m_pTcpClient, SLOT(connectToServer()) ); + connect(m_pTcpThread, SIGNAL(finished()), m_pTcpClient, SLOT(deleteLater()) ); // 退出删除对象 + + connect(m_pTcpClient, SIGNAL(siConnectSta(int)), + this, SLOT(slotConnectSta(int)), Qt::AutoConnection); // 连接状态改变 + connect(m_pTcpClient, SIGNAL(siConnectErr(QString)), + this, SLOT(slotConnectErr(QString)), Qt::AutoConnection); // 接收到通讯错误 + connect(m_pTcpClient, SIGNAL(siReceiveData(QByteArray)), + this, SLOT(slotReceiveData(QByteArray)), Qt::AutoConnection); // 接收到数据 + connect(this, SIGNAL(siSendData(QByteArray)), + m_pTcpClient, SLOT(slotSendData(QByteArray)), Qt::AutoConnection); // 发送数据的槽 + + m_pTcpThread->start(); // 启动线程 + } + + if(m_connectMode == USE_SERIAL_COMM)//串口 + { + m_pComPort->moveToThread(m_pComThread); + + connect(m_pComThread, SIGNAL(started()), m_pComPort, SLOT(initComm()) ); + connect(m_pComThread, SIGNAL(finished()), m_pComPort, SLOT(deleteLater()) ); // 退出删除对象 + + connect(m_pComPort, SIGNAL(siReceiveData(QByteArray)), + this, SLOT(slotReceiveData(QByteArray)), Qt::QueuedConnection); // 接收到数据 + connect(this, SIGNAL(siSendData(QByteArray)), + m_pComPort, SLOT(slotSendData(QByteArray)), Qt::QueuedConnection); // 发送数据的槽 + + m_pComThread->start(); // 启动线程 + } + m_startComm = 1; + } + return m_startComm; +} + +// 连接状态改变的槽函数 +void Machine::slotConnectSta(int sta) +{ + // qDebug() << "SlotConnectSta" << sta; + m_connected = sta; +} + +// 接收到通讯错误槽函数 +void Machine::slotConnectErr(QString errinfo) +{ + if(errinfo.length() <= 0){} + //qDebug() << "SlotConnectErr" << errinfo; +} + +void Machine::setMcStatusAsMc(u8* buff, int toggle) +{ + memcpy(&m_mcStatus, buff, sizeof(MCStatus)); + m_statusEn = 1; + emit(siStatusChange(toggle)); +} + +// 接收到数据的槽函数 +void Machine::slotReceiveData(QByteArray dat) +{ + int rslt; + DataPacket packet; + OperPacket * operpkt = (OperPacket *)(&packet); + + // qDebug() << "SlotReceiveData size=" << dat.size(); + + g_receiveBuff.append(dat); + //qDebug()<<"append dat size"< 0) // 收到数据包 + { + //qDebug()<<"getANormalPacket rslt="<packet.fldp.cmd; + switch(operpkt->packet.fldp.cmd) // 先按固定长度解析 + { + case DCMD_REQUEST_DAT: // 请求文件数据 + { + if (m_transCtrl.transActive == TRANS_ACTIVE) + { + if (1 && + m_transCtrl.transflag == TRANS_REQUEST && // 请求传输数据模式 + m_transCtrl.fileType == operpkt->dRequestDatBlock.fileType && + m_transCtrl.fileIdx == operpkt->dRequestDatBlock.fileIdx && + m_transCtrl.fileId == operpkt->dRequestDatBlock.fileId && + 1 ) + { + qDebug("in request mode, send block idx=%d", operpkt->dRequestDatBlock.datBlockIdx); + transFileData(m_transCtrl, operpkt->dRequestDatBlock.datBlockIdx); + } + } + break; + } + case DCMD_SEND_MC_INFO: // 发送机器信息 + { + memcpy(&m_mcInfo, operpkt->dSendMcInfo.exData, sizeof(MCInfo)); + emit(siMcInfoChange( )); + + break; + } + + case DCMD_SEND_MC_STATUS: // 发送机器状态 + { + setMcStatusAsMc(operpkt->dSendMcStatus.exData, operpkt->dSendMcStatus.toggle); + break; + } + + case DCMD_SEND_MC_PARAS: // 发送机器参数 + { + int type; + + type = operpkt->dSendMcParas.paraType; + if (operpkt->dSendMcParas.exLen == sizeof(ParaStruct)) + { + if (type == SEW_MCPARA_MACH || type == SEW_MCPARA_DEF_MC) + { + memcpy(&m_mcPara, operpkt->dSendMcParas.exData, sizeof(ParaStruct)); + m_mcParaEn = 1; + } + else if (type == SEW_MCPARA_WORK || type == SEW_MCPARA_DEF_WK) + { + memcpy(&m_wkPara, operpkt->dSendMcParas.exData, sizeof(ParaStruct)); + m_wkParaEn = 1; + } + else if (type == SEW_REVMCPARA_MACH || type == SEW_MCPARA_DEF_MC) + { + memcpy(&m_mcPrePara, operpkt->dSendMcParas.exData, sizeof(ParaStruct)); + m_mcPreParaEn = 1; + } + else if (type == SEW_REVMCPARA_WORK || type == SEW_MCPARA_DEF_WK) + { + memcpy(&m_wkPrePara, operpkt->dSendMcParas.exData, sizeof(ParaStruct)); + m_wkPreParaEn = 1; + } + else + { + break; + } + + //因为之前请求了机器参数和工作参数,所以当两个参数都返回时,再触发信号和槽 + // if( m_mcParaEn==1 && m_wkParaEn==1) + { + printf("emit SiParaChange\r\n"); + emit(siParaChange(type, 0)); + } + } + else if (operpkt->dSendMcParas.exLen == sizeof(u32)) + { + int id, idx; + id = operpkt->dSendMcParas.paraId; + idx = id - 1; + if (idx > 0 && idx < PARA_NUM) + { + idx *= sizeof(u32); + if (type == SEW_MCPARA_MACH) + { + memcpy((u8*)(&m_mcPara)+idx, operpkt->dSendMcParas.exData, sizeof(u32)); + m_mcParaEn = 1; + } + else if (type == SEW_MCPARA_WORK) + { + memcpy((u8*)(&m_wkPara)+idx, operpkt->dSendMcParas.exData, sizeof(u32)); + m_wkParaEn = 1; + } + else if (type == SEW_REVMCPARA_MACH) + { + memcpy((u8*)(&m_mcPrePara)+idx, operpkt->dSendMcParas.exData, sizeof(u32)); + m_mcPreParaEn = 1; + } + else if (type == SEW_REVMCPARA_WORK) + { + memcpy((u8*)(&m_wkPrePara)+idx, operpkt->dSendMcParas.exData, sizeof(u32)); + m_wkPreParaEn = 1; + } + else + { + break; + } + emit(siParaChange(type, id)); + } + } + + break; + } + case DCMD_SEND_SENSORS: // 发送传感信号 + { + int len; + len = sizeof(SensorsBitmap); + if (len > operpkt->dSendSensors.exLen) + { + len = operpkt->dSendSensors.exLen; + } + memset(m_sensorsStaDat.bitmap, 0, sizeof(SensorsBitmap)); + memcpy(m_sensorsStaDat.bitmap, operpkt->dSendSensors.exData, len); + m_sensorStaEn = 1; + //qDebug("get DCMD_SEND_SENSORS"); + emit(siSensorChange(m_sensorsStaDat)); + break; + } + case DCMD_SEND_FILE_INFO: // 发送文件信息 + { + + break; + } + case DCMD_SEND_TRANS_RESULT: // 发送传输结果 + { + printf("get DCMD_SEND_TRANS_RESULT\r\n"); + m_transCtrl.lenBmp = operpkt->dSendTransResult.exLen; + m_transCtrl.transActive = operpkt->dSendTransResult.active; + m_transCtrl.transflag = operpkt->dSendTransResult.result; + if (m_transCtrl.lenBmp != 0) + { + memcpy(m_transCtrl.rsvBitmap, operpkt->dSendTransResult.exData, m_transCtrl.lenBmp); + } + m_fileTransEn = 1; + + emit (siTransResultChange()); + + break; + } + case DCMD_SEND_SENSOR_BMP: // 传感器信号有效位图 + { + int len; + len = sizeof(SensorsBitmap); + if (len > operpkt->dSendSensorBmp.exLen) + { + len = operpkt->dSendSensorBmp.exLen; + } + memset(m_sensorEnBmp.bitmap, 0, sizeof(SensorsBitmap)); + memcpy(m_sensorEnBmp.bitmap, operpkt->dSendSensorBmp.exData, len); + m_sensorBmpEn = 1; + qDebug("get DCMD_SEND_SENSOR_BMP"); + + emit (siSensorEnBitmap(m_sensorEnBmp)); + break; + } + + case DCMD_SEND_LOTDATA:// 发送物联网数据 + { + memcpy(&m_lotData, operpkt->dSendMcInfo.exData, sizeof(McLotData)); + //再定义一个结构体 + emit(siReceiveLotData()); + + break; + } + + case UCMD_SET_FILE_PARAS://边框检查超限后重新设置起始点 + { + DataFilePos newPos; + memset(&newPos, 0, sizeof(DataFilePos)); + memcpy((u8*)&newPos, operpkt->setFileParas.exData, sizeof(DataFilePos)); + //qDebug()<<"siDataFilePos"; + emit(siDataFilePos(newPos)); + break; + } + + default: + break; + } + } + else + { + break; + } + }while(1); +} + +//------------------------------------------------------------------- +// 读取机器信息 +void Machine::getInfoFromMachine() +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.getMcInfo.cmdCode = UCMD_GET_MC_INFO; + + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +// 读取机器状态 +int Machine::getStatusFromMachine() +{ + int rslt; + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.getMcStatus.cmdCode = UCMD_GET_MC_STATUS; + sendPacket.getMcStatus.toggle = m_statusToggle; + rslt = m_statusToggle; + m_statusToggle++; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); + return rslt; +} + +// 读取机器物联数据 +void Machine::getNetDataFromMachine() +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.boardPara.cmdCode = UCMD_GET_LOT_DATA; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +// 读取机器参数 +void Machine::getParasFromMachine(int type, int id) +{ + int mctype = -1; + int wktype = -1; + if (type == -1) + { + mctype = SEW_MCPARA_MACH; + wktype = SEW_MCPARA_WORK; + m_mcParaEn = 0; + m_wkParaEn = 0; + } + else + { + if(type == SEW_MCPARA_MACH ) + { + mctype = SEW_MCPARA_MACH; + m_mcParaEn = 0; + } + if(type == SEW_MCPARA_WORK ) + { + wktype = SEW_MCPARA_WORK; + m_wkParaEn = 0; + } + } + + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.getMcParas.cmdCode = UCMD_GET_MC_PARAS; + + if (mctype == SEW_MCPARA_MACH) + { + sendPacket.getMcParas.paraType = (u16)mctype; + sendPacket.getMcParas.paraId = (u16)id; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); + } + + if (wktype == SEW_MCPARA_WORK) + { + sendPacket.getMcParas.paraType = (u16)wktype; + sendPacket.getMcParas.paraId = id; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); + } +} + +// 读取传感信号 +void Machine::getSensorsFromMachine(int backtype) +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.getSensors.cmdCode = UCMD_GET_SENSORS; + sendPacket.getSensors.backType = (u16)backtype; + + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +// 读取传输结果 +void Machine::getTransResultFromMachine(int fileid) +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.getTransResult.cmdCode = UCMD_GET_TRANS_RESULT; + sendPacket.getTransResult.fileId = (u16)fileid; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +// 获取传感器有效标志位图 +void Machine::getSensorEnBmpFromMachine() +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.getSensorBmp.cmdCode = UCMD_GET_SENSOR_BMP; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +//------------------------------------------------------------------- +//----------------------------设置状态命令 +#ifdef UCMD_SET_MC_STATUS +// 清除错误 + +void Machine::setMcStatus(int stacode, int para) +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setMcStatus.cmdCode = UCMD_SET_MC_STATUS; + sendPacket.setMcStatus.staCode = (u16)stacode; + sendPacket.setMcStatus.para = (u16)para; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +void Machine::cleanError() +{ + setMcStatus(MC_STA_CLENA_ERR); +} + +// 设置允许工作状态 +void Machine::setEnableWorkSta() +{ + setMcStatus(MC_STA_EN_WORK); +} + +// 设置禁止工作状态 +void Machine::setDisableWorkSta() +{ + setMcStatus(MC_STA_DIS_WORK); +} + +// 设置允许工作时间状态 +void Machine::setEnableWorkTime() +{ + setMcStatus(MC_STA_EN_TIME); +} + +// 设置禁止工作时间状态 +void Machine::setDisableWorkTime() +{ + setMcStatus(MC_STA_DIS_TIME); +} + +// 重置产量 +void Machine::resetOutput() +{ + setMcStatus(MC_CLEAN_COUNT); +} + +// 手动工作状态 +void Machine::setToManualWork() +{ + setMcStatus(MC_STA_MANUAL); +} + +// 自动工作状态 +void Machine::setToAutoWork() +{ + setMcStatus(MC_STA_AUTO); +} + +// 文件切换 +void Machine::switchWorkFile(int idx) +{ + setMcStatus(MC_FILE_SWITCH, idx); +} + +// 设置经过的时间(即关机时间) +void Machine::setShutDownTime(u8 type, u32 time) +{ + int rslt; + OperPacket sendPacket; + //int size = sizeof(ParaStruct); + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setElapsedTime.cmdCode = UCMD_SET_ELAPSED_TIME; + sendPacket.setElapsedTime.type = type; + sendPacket.setElapsedTime.time = time; + + rslt = packetAFLDP(&sendPacket.packet); + + if (rslt == 0) + { + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); + } +} + +void Machine::setHeadSpacingToMachine(int type, QByteArray data, u16 paraId) +{ + int rslt; + OperPacket sendPacket; + int size = data.size(); + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setParas.cmdCode = UCMD_SET_MC_PARAS; + sendPacket.setParas.paraType = (u16)type; + sendPacket.setParas.paraId = paraId; + + rslt = packetAVLDP(&sendPacket.packet, (u8*)data.data(), size); + + if(rslt == 0) + { + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET + size); + emit siSendData(dat); + } +} + +// 文件失效 +void Machine::invalidateWorkFile(int idx) +{ + setMcStatus(MC_INVALID_FILE, idx); +} + +// 清除刷新参数标志 +void Machine::cleanNewParaFlag() +{ + setMcStatus(MC_CLEAN_PARA_REF); +} + +// 模拟工作状态 +void Machine::setSimulateWork() +{ + setMcStatus(MC_SET_TO_SIMULATE); +} + +// 正常工作状态 +void Machine::setNormalWork() +{ + setMcStatus(MC_SET_TO_NORMAL); +} + +//退出断线测试 +void Machine::exitDetectTest() +{ + setMcStatus(MC_STA_EXIT_THREADBK); +} + +// 底线计数复位 +void Machine::resetBobbinCounter() +{ + setMcStatus(MC_CLEAN_BOBBIN); +} +// 产量清零 +void Machine::outputReset() +{ + setMcStatus(MC_CLEAN_COUNT); +} + +// 设置为 进入 扫描传感器状态 +void Machine::entrySensorScan() +{ + // + setMcStatus(MC_SET_ENTRY_SCAN_SENSOR); +} + +// 设置为 退出 扫描传感器状态 +void Machine::exitSensorScan() +{ + // + setMcStatus(MC_SET_EXIT_SCAN_SENSOR); +} + + +#endif + +//---------------------------- + +void Machine::setParasToMachine(int type, ParaStruct & para) +{ + int rslt; + OperPacket sendPacket; + int size = sizeof(ParaStruct); + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setParas.cmdCode = UCMD_SET_MC_PARAS; + sendPacket.setParas.paraType = (u16)type; + + rslt = packetAVLDP(&sendPacket.packet, (u8*)¶, size); + + if (rslt == 0) + { + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET + size); + emit(siSendData(dat)); + } +} + +void Machine::setAParasToMachine(int type, int idx, u32 value) +{ + int rslt; + OperPacket sendPacket; + int size = sizeof(value); + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setParas.cmdCode = UCMD_SET_MC_PARAS; + sendPacket.setParas.paraType = (u16)type; + sendPacket.setParas.paraId = idx; + + rslt = packetAVLDP(&sendPacket.packet, (u8*)&value, size); + + if (rslt == 0) + { + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET + size); + emit(siSendData(dat)); + } +} + +void Machine::setMcPara(ParaStruct * pPara) +{ + if (pPara == NULL) + { + return; + } + int size = sizeof(ParaStruct); + memcpy(&m_mcPara, pPara, size); + setParasToMachine(SEW_MCPARA_MACH, m_mcPara); +} + +void Machine::setWkPara(ParaStruct * pPara) +{ + if (pPara == NULL) + { + return; + } + int size = sizeof(ParaStruct); + memcpy(&m_wkPara, pPara, size); + setParasToMachine(SEW_MCPARA_WORK, m_wkPara); +} + +void Machine::setMcPrePara(ParaStruct *pPara) +{ + if (pPara == NULL) + { + return; + } + int size = sizeof(ParaStruct); + memcpy(&m_mcPrePara, pPara, size); + setParasToMachine(SEW_REVMCPARA_MACH, m_mcPrePara); +} + +void Machine::setWkPrePara(ParaStruct *pPara) +{ + if (pPara == NULL) + { + return; + } + int size = sizeof(ParaStruct); + memcpy(&m_wkPrePara, pPara, size); + setParasToMachine(SEW_REVMCPARA_WORK, m_wkPrePara); +} + +void Machine::setAMcPara(int id, u32 value) +{ + setAParasToMachine(SEW_MCPARA_MACH, id, value); +} + +void Machine::setAWkPara(int id, u32 value) +{ + setAParasToMachine(SEW_MCPARA_WORK, id, value); +} + +void Machine::setAMcPrePara(int id, u32 value) +{ + setAParasToMachine(SEW_REVMCPARA_MACH, id, value); +} + +void Machine::setAWkPrePara(int id, u32 value) +{ + setAParasToMachine(SEW_REVMCPARA_WORK, id, value); +} + +void Machine::setHeadSpacing(DsrHeadEx62 para) +{ + //分两个包发送 + QByteArray pkg1((char *)(¶), sizeof(DsrHeadEx62)/2); + QByteArray pkg2((char *)(¶) + sizeof(DsrHeadEx62)/2, sizeof(DsrHeadEx62)/2); + setHeadSpacingToMachine(SEW_MCPARA_EX1, pkg1, 0); + setHeadSpacingToMachine(SEW_MCPARA_EX2, pkg2, 1); +} + +// 设置文件参数 +void Machine::setFilePara(int fileidx, int fileid, DataFilePara & filePara) +{ + int rslt; + OperPacket sendPacket; + int size = sizeof(DataFilePara); + + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setFileParas.cmdCode = UCMD_SET_FILE_PARAS; + sendPacket.setFileParas.fileType = FILE_TYPE_DAT; + sendPacket.setFileParas.fileIdx = (u8)fileidx; + sendPacket.setFileParas.fileId = (u16)fileid; + + rslt = packetAVLDP(&sendPacket.packet, (u8*)&filePara, size); + + if (rslt == 0) + { + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET + size); + emit(siSendData(dat)); + } +} + +// 设置执行进度 +void Machine::setFileExecProgress(int fileidx, int fileid, FileExecPara & fileExecPara) +{ + int rslt; + OperPacket sendPacket; + int size = sizeof(FileExecPara); + + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setFileParas.cmdCode = UCMD_SET_EXEC_PROGRESS; + sendPacket.setFileParas.fileType = FILE_TYPE_DAT; + sendPacket.setFileParas.fileIdx = (u8)fileidx; + sendPacket.setFileParas.fileId = (u16)fileid; + + rslt = packetAVLDP(&sendPacket.packet, (u8*)&fileExecPara, size); + if (rslt == 0) + { + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET + size); + emit(siSendData(dat)); + } +} + +// 设置默认参数 +void Machine::setToDefaultParas(int type, u8 id, u8 nodeType) +{ + int rslt; + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setDefParas.cmdCode = (u16)type; + sendPacket.setDefParas.id = id; + sendPacket.setDefParas.nodeType = nodeType; + rslt = packetAFLDP(&sendPacket.packet); + + if(rslt != 0) + { + //为了去掉构建警告 + } + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +//------------------------------------------------------------------- +// 手动动作 +void Machine::actionByhand(int actcode, int para1, int para2, int para3) +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.actByhand.cmdCode = UCMD_ACT_BYHAND; + sendPacket.actByhand.actCode = (u16)actcode; + sendPacket.actByhand.para1 = (u16)para1; + sendPacket.actByhand.para2 = (u16)para2; + sendPacket.actByhand.para3 = (u16)para3; + + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} +//------------------------------------------------------------------- + +// 电机归零(辅助调试的功能,无安全保护和逻辑关系) +void Machine::motoToZero(int obj) +{ + actionByhand(MOTO_TO_ZERO, obj); +} + +// 电机移动(辅助调试的功能,无安全保护和逻辑关系) +void Machine::motoMove(int obj, int dir, int spd) +{ + actionByhand(MOVE_BY_HAND, obj, dir, spd); +} + +// 输出控制(辅助调试的功能,无安全保护和逻辑关系) +void Machine::outputCtrl(int obj, int act, int para) +{ + actionByhand(OUTPUT_CTRL, obj, act, para); +} + +// 电机使能控制(辅助调试的功能,无安全保护和逻辑关系) +void Machine::motoServoCtrl(int obj, int onoff) +{ + actionByhand(MOTO_EN_CTRL, obj, onoff); +} + +// 缝纫主轴使能控制 +void Machine::sewingMsServoOn() +{ + motoServoCtrl(MT_LM, MT_SERVO_ON); +} +void Machine::sewingMsServoOff() +{ + motoServoCtrl(MT_LM, MT_SERVO_OFF); +} + +// 手动动作功能(日常使用功能,有安全保护和逻辑时序关系) +void Machine::manualAction(int obj, int para2, int para3) +{ + actionByhand(MANUAL_ACTION, obj, para2, para3); +} + +// 手动剪线 +void Machine::cutThreadByhand() +{ + manualAction(CUT_THREAD); +} + +void Machine::makeup(int mode) +{ + manualAction(mode); +} + +// 针梭校对 +// step是指执行针梭校对的第几步 +// 1表示高位提升 2表示梭归零, 3表示针归零 4表示针梭复位 0表示自动执行步骤1234 +void Machine::msAdjust(int step) +{ + manualAction(MAINSHAFT_ADJUST, step); +} + +// 旋转校对 +void Machine::rotaAdjust(int step) +{ + manualAction(ROTATE_ADJUST, step); +} + +// 机头升降 +void Machine::sewHeadLiftUpDown() +{ + manualAction(HEAD_LIFT_UPDW); +} + +// 机头上升 +void Machine::sewHeadLiftUp() +{ + manualAction(HEAD_LIFT_UP); +} +// 机头下降 +void Machine::sewHeadLiftDown() +{ + manualAction(HEAD_LIFT_DOWN); +} + +// 缝纫主轴研车 +void Machine::sewingMsRun() +{ + manualAction(SEWING_MS_RUN); +} + +// 回角点 +void Machine::gotoGorner(int nNum) +{ + mcWorkCmd(WORK_GOTO_GORNER,nNum); +} + +// 手动加油 +void Machine::manualOil(int nNum) +{ + mcWorkCmd(WORK_ACT_OIL,nNum); +} + //梭盘计数复位 +void Machine::shuttleCounter() +{ + manualAction(RESET_SHUT_COUNTER); +} +//自动换一个梭 +void Machine::changeOneShuttle() +{ + manualAction(AUTO_CHANGE_ONE_SHUT); +} +//安装第一个梭壳 +void Machine::installShuttle() +{ + manualAction(INSTALL_FIRST_BOBBIN); +} +//缝纫状态 +void Machine::sewBuff() +{ + manualAction(SHUT_INTO_INDX_STA); +} +//换梭盘状态 +void Machine::shuttleDiskBuff() +{ + manualAction(SHUT_INTO_TAKE_PLATE); +} +//将旋梭从梭盘到机头 +void Machine::shuttleToHead() +{ + manualAction(SHUT_FROM_PLATE_TO_HEAD); +} +// 将旋梭从机头拿到梭盘 +void Machine::headToShuttle() +{ + manualAction(SHUT_FROM_HEAD_TO_PLATE); +} + +// 所有主轴研车 +void Machine::allMsRun() +{ + manualAction(ALL_MS_RUN); +} + +// 机头升降 +void Machine::headLift() +{ + manualAction(SEW_HEAD_LIFT); +} + +// 针梭复位 +void Machine::msReset() +{ + manualAction(SEW_MS_RESET); +} + +// 针梭去穿线位 +void Machine::msToFix() +{ + manualAction(SEW_MS_TO_FIX); +} + +// 手动移框 +void Machine::moveFrameByHand(char xy, char dir, int spd) +{ + int para1, para2; + + if (xy == 'x' || xy == 'X') + { + if (dir == 'l' || dir == 'L') + { + para1 = XY_MOVE_LEFT; + } + else if (dir == 'r' || dir == 'R') + { + para1 = XY_MOVE_RIGHT; + } + else + { + para1 = XY_MOVE_STOP; + } + } + else if (xy == 'y' || xy == 'Y') + { + if (dir == 'f' || dir == 'F') + { + para1 = XY_MOVE_FRONT; + } + else if (dir == 'b' || dir == 'B') + { + para1 = XY_MOVE_BACK; + } + else + { + para1 = XY_MOVE_STOP; + } + } + else + { + para1 = XY_MOVE_STOP; + } + + para2 = spd; + manualAction(para1, para2); +} + +// 缝纫剪线 +void Machine::sewCutThread(int nNum) +{ + manualAction(CUT_THREAD,0,nNum); // 加0的原因是主控上用的是para3 +} + +// 缝纫主轴点动 +void Machine::sewJog() +{ + manualAction(SEWING_MS_JOG); +} + +void Machine::mcWorkCmd(int workcode, int para1, int para2) +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.mcWork.cmdCode = UCMD_MC_WORK; + sendPacket.mcWork.workCode = (u16)workcode; + sendPacket.mcWork.para1 = (u32)para1; + sendPacket.mcWork.para2 = (u16)(para2); + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +// 启动工作 +void Machine::startWork() +{ + mcWorkCmd(WORK_START); +} + +// 暂停工作 +void Machine::pauseWork() +{ + mcWorkCmd(WORK_PAUSE); +} + +// 流程复位(结束工作) +void Machine::allToReset() +{ + mcWorkCmd(WORK_FINISH); +} + +// 自动找零(全部归零) +void Machine::allToZero() +{ + mcWorkCmd(WORK_FIND_ZERO); +} + +// 回起针点 +void Machine::gotoStartPos() +{ + mcWorkCmd(WORK_GOTO_START); +} + +// 回定位点 +void Machine::gotoAnchor() +{ + mcWorkCmd(WORK_GOTO_ANCHOR); +} + +// 定偏移点 +void Machine::setOffsetPos() +{ + mcWorkCmd(WORK_SET_OFFSET); +} + +// 回偏移点 +void Machine::gotoOffsetPos() +{ + mcWorkCmd(WORK_GOTO_OFFSET); +} + +// 边框检查 +void Machine::checkFrame() +{ + mcWorkCmd(WORK_CHECK_FRAME); +} + +// 空走边框 +void Machine::simulateFrame() +{ + mcWorkCmd(WORK_SIMULATION_FRAME); +} + +/* +#define WORK_CUT_FRAME 0x0009 // 边框切割 +#define WORK_CUT_XLINE 0x000A // 手动断布 +*/ + +// 快速进退 +void Machine::fastJump(int idx) +{ + mcWorkCmd(WORK_FAST_JUMP, idx); +} + +// 回工作点 +void Machine::gotoWorkPos() +{ + mcWorkCmd(WORK_GOTO_WKPOS); +} + +// 回穿线点 +void Machine::gotoFixPos() +{ + mcWorkCmd(WORK_GOTO_FEEDT); +} + +void Machine::gotoShuttlePos() +{ + mcWorkCmd( WORK_GOTO_CHGBO ); +} + +/* +#define WORK_GOTO_CHGBO 0x000E // 回换梭位 +#define WORK_FEED_MOVE 0x000F // 进料退料 +#define WORK_DRAW_LATTICE 0x0010 // 画格子图 +#define WORK_GOTO_FINISH 0x0011 // 回结束点 +*/ + +// 回零点(框架归零) +void Machine::gotoZeroPos() +{ + mcWorkCmd(WORK_GOTO_ZERO); +} + +// 主轴点动 +void Machine::mainShaftJog() +{ + mcWorkCmd(WORK_MS_JOG); +} + +// 速度改变 +// chgram 主轴转速改变值。例如:参数为10表示速度加10(升速),参数为-10表示速度减10(降速) +void Machine::msRpmChange(int chgram, int flag) +{ + mcWorkCmd(WORK_RPM_CHG, chgram, flag); +} + +//---------------------------- +// 移动到XY坐标命令 +void Machine::moveFrameTo(int x, int y) +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.moveFrameTo.cmdCode = UCMD_MOVE_TO; + sendPacket.moveFrameTo.posx = x; + sendPacket.moveFrameTo.posy = y; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +void Machine::breakFileTrans() +{ + m_transBreak = 1; +} + +#define SEND_STEP0 0 +#define SEND_STEP1 1 +#define SEND_STEP2 2 +#define SEND_STEP3 3 +#define SEND_STEP4 4 +#define SEND_STEP5 5 + +#define SEND_STEP_MAX 10 + +#define SEND_ANSWER 100 + +void Machine::onSendTimer(void) +{ + int rslt; + rslt = 0; + + //qDebug("file trans timer"); + + if (m_transBreak != 0) // 中断传输 + { + qDebug("break file trans"); + m_transCtrl.transphase = SEND_STEP5; + } + + if (m_transCtrl.transphase == SEND_STEP0) // 文件失效 + { + m_fileTransEn = 0; + qDebug("SEND_STEP1 InvalidateWorkFile "); + invalidateWorkFile(m_transCtrl.fileIdx); // 文件失效 + m_transCtrl.transphase = SEND_STEP1; + rslt = 1; + } + else if (m_transCtrl.transphase == SEND_STEP1) // 启动文件传输 + { + m_fileTransEn = 0; + startFileTrans(m_transCtrl); + + qDebug("StartFileTrans "); + + qDebug("trans progress %d/%d", 0, m_transCtrl.packetNum); + m_totalSendNum = 0; + m_totalPacketNum = m_transCtrl.packetNum; + emit(siTransProgress(m_transCtrl.fileType, m_totalSendNum, m_totalPacketNum)); // 发送进度信号 + m_transCtrl.transphase = SEND_STEP2; + rslt = 1; + + } + else if (m_transCtrl.transphase == SEND_STEP2) // 读取传输结果 + { + qDebug("SEND_STEP2 send GetTransResult cmd "); + + m_fileTransEn = 0; + getTransResultFromMachine(m_transCtrl.fileId); + m_transCtrl.transphase = SEND_STEP3; + rslt = 1; + } + else if (m_transCtrl.transphase == SEND_STEP3) // 根据传输结果传输文件数据 + { + if (m_fileTransEn == 1) + { + qDebug("GetTransResult from machine"); + + if (m_transCtrl.transActive == TRANS_ACTIVE) + { + if ( m_transCtrl.transflag == TRANS_READY || // 准备好接收 + m_transCtrl.transflag == TRANS_DOING || // 正在接收 + 0 ) + { + qDebug("trans sta = TRANS_READY or TRANS_DOING flag=%d", m_transCtrl.transflag); + +#if (1) + int i, j; + int thissendnum = 0; + int totalsendnum = 0; + int send_count = 1000; + +#if(1)//发一个包查询一次结果 + if ( m_transCtrl.fileType == FILE_TYPE_DAT )//花样文件(大文件) + { + if(m_connectMode == USE_TCP_COMM)//网口 + { + send_count = 400; + } + else if(m_connectMode == USE_SERIAL_COMM)//串口 + { + send_count = 10; + } + } + else if ( m_transCtrl.fileType == FILE_TYPE_PGM ) //升级等文件(小文件) + { + send_count = 25; + } +#endif + + u8 mod, temp; + for (i = 0; i < m_transCtrl.lenBmp; i++) + { + temp = m_transCtrl.rsvBitmap[i]; + mod = 0x01; + for (j = 0; j < 8; j++) + { + if ((temp & mod) == 0) + { + if (thissendnum < send_count ) // 每发送send_count个包,查询一次结果 + { + thissendnum++; + + transFileData(m_transCtrl, i*8+j); + + } + } + else + { + totalsendnum++; + } + mod <<= 1; + } + } + m_totalSendNum = totalsendnum; + m_totalPacketNum = m_transCtrl.packetNum; + emit(siTransProgress(m_transCtrl.fileType, m_totalSendNum, m_totalPacketNum)); // 发送进度信号 + m_transCtrl.transphase = SEND_STEP2; // 重新发送查询命令 +#else + int i, j; + int thissendnum = 0; + int totalsendnum = 0; + u8 mod, temp; + for (i = 0; i < m_transCtrl.lenBmp; i++) + { + temp = m_transCtrl.rsvBitmap[i]; + mod = 0x01; + for (j = 0; j < 8; j++) + { + if ((temp & mod) == 0) + { + if (thissendnum < 200) // 每发送200个包,查询一次结果, + { + thissendnum++; + TransFileData(m_transCtrl, i*8+j); + qDebug("TransFileData idx=%d", i*8+j); + } + } + else + { + totalsendnum++; + } + mod <<= 1; + } + } + qDebug("trans progress = %d/%d", totalsendnum , m_transCtrl.packetNum); + + emit(SiTransProgress(totalsendnum, m_transCtrl.packetNum)); // 发送进度信号 + m_transCtrl.transphase = SEND_STEP2; // 重新发送查询命令 +#endif + } + else if (m_transCtrl.transflag == TRANS_DONE) // 接收完成 + { + qDebug("trans sta = TRANS_DONE"); + + emit siSendDataDone(); + + m_totalSendNum = m_transCtrl.packetNum; + m_totalPacketNum = m_transCtrl.packetNum; + emit(siTransProgress(m_transCtrl.fileType, m_totalSendNum, m_totalPacketNum)); // 发送进度信号 + m_transCtrl.transphase = SEND_STEP4; + + //qDebug()<<"m_transCtrl.fileType"< SEND_STEP_MAX) // 1秒没有回复 + { + qDebug("waitcount > SEND_STEP_MAX, back to SEND_STEP2 "); + m_transCtrl.transphase = SEND_STEP2; // 重新发送查询命令 + rslt = 1; + } + } + } + + if (rslt == 0) + { + m_transCtrl.waitcount++; + } + else + { + m_transCtrl.waitcount = 0; + } + + if ( m_transCtrl.transphase != SEND_STEP1 && + m_transCtrl.transphase != SEND_STEP2 && + m_transCtrl.transphase != SEND_STEP3 ) // 结束 + { + qDebug("trans file over, step=%d", m_transCtrl.transphase); + if (m_transCtrl.transphase == SEND_STEP4) + { + m_totalSendNum = 0; + m_totalPacketNum = 0; + emit(siTransProgress(m_transCtrl.fileType, m_totalSendNum, m_totalPacketNum)); // 发送结束信号(成功) + } + else + { + m_totalSendNum = -1; + m_totalPacketNum = -1; + emit(siTransProgress(m_transCtrl.fileType, m_totalSendNum, m_totalPacketNum)); // 发送结束信号(失败) + } + m_pSendTimer->stop(); // 停止定时器 + m_transCtrl.filetransing = 0; + } +} + +//串口是否打开 +void Machine::slIfOpenSerialPort(int val) +{ + if(val != 0) + { + if(m_connectMode == USE_SERIAL_COMM) + { + m_connected = 3;//串口已打开 + } + } +} + +// 发送文件过程 +int Machine::sendFileProc(int type, int idx, int id, DataDs16FileHead & fileHead, u8 * pDatBuff) +{ + return sendFileProc(type, idx, id, &fileHead, pDatBuff); +} +int Machine::sendFileProc(int type, int idx, int id, DataDs16FileHead * pfileHead, u8 * pDatBuff) +{ + if (pDatBuff == NULL || pfileHead == NULL) + { + return -1; + } + + if ( pfileHead->dataSize <= 0 || pfileHead->dataSize > MAX_FILE_SIZE) + { + qDebug("pfileHead->dataSize <= 0 || pfileHead->dataSize > MAX_FILE_SIZE, not support"); + return -2; + } + + QTime delayTime; + int counter = 0; + delayTime.start(); + + if (m_transCtrl.filetransing != 0) // 已经有文件在传输 + { + return -3; + } + + while (m_transCtrl.filetransing != 0) // 已经有文件在传输 + { + if (delayTime.elapsed() > 1000) + { + counter++; + qDebug("%d. wait old file trans over", counter); + delayTime.restart(); + } + + QCoreApplication::processEvents(QEventLoop::AllEvents, 100); + } + + m_transBreak = 0; + + m_transCtrl.fileType = (u8)type; + m_transCtrl.fileIdx = (u8)idx; + m_transCtrl.fileId = (u16)id; + memcpy(m_transCtrl.pFileHead, pfileHead, sizeof(DataDs16FileHead)); + memcpy(m_transCtrl.pDatBuff, pDatBuff, pfileHead->dataSize); + m_transCtrl.packetSize = MAX_EXDP_LEN; + m_transCtrl.packetNum = (pfileHead->dataSize + MAX_EXDP_LEN - 1) / MAX_EXDP_LEN; + + qDebug("StartFileTrans, fileType=%d, fileIdx=%d, fileId=%d, packetNum=%d, ", + m_transCtrl.fileType, m_transCtrl.fileIdx, m_transCtrl.fileId, m_transCtrl.packetNum); + + m_transCtrl.transphase = SEND_STEP1; + m_transCtrl.filetransing = 1; + + m_pSendTimer->start(); + return 0; +} + +// 发送文件过程 +int Machine::sendAPPFileProc(int type, int idx, int id, AppFileHead & fileHead, u8 * pDatBuff) +{ + if (pDatBuff == NULL || fileHead.dataSize <= 0) + { + return -1; + } + + if (fileHead.dataSize > MAX_FILE_SIZE) + { + qDebug("fileHead.dataSize > MAX_FILE_SIZE, not support"); + return -2; + } + + QTime delayTime; + int counter = 0; + delayTime.start(); + + while (m_transCtrl.filetransing != 0) // 已经有文件在传输 + { + if (delayTime.elapsed() > 1000) + { + counter++; + qDebug("%d. wait old file trans over", counter); + delayTime.restart(); + } + + QCoreApplication::processEvents(QEventLoop::AllEvents, 100); + } + + m_transBreak = 0; + + // 拷贝数据到传输控制结构 + m_transCtrl.fileType = (u8)type; + m_transCtrl.fileIdx = (u8)idx; + m_transCtrl.fileId = (u16)id; + memcpy(m_transCtrl.pAppHead, &fileHead, sizeof(AppFileHead)); + memcpy(m_transCtrl.pDatBuff, pDatBuff, fileHead.dataSize); + m_transCtrl.packetSize = MAX_EXDP_LEN; + m_transCtrl.packetNum = (fileHead.dataSize + MAX_EXDP_LEN - 1 ) / MAX_EXDP_LEN; + + qDebug("StartFileTrans, fileType=%d, fileIdx=%d, fileId=%d, packetNum=%d, ", + m_transCtrl.fileType, m_transCtrl.fileIdx, m_transCtrl.fileId, m_transCtrl.packetNum); + + m_transCtrl.transphase = SEND_STEP1; + m_transCtrl.filetransing = 1; + + // 启动定时器 + m_pSendTimer->start(); + return 0; +} + +// 启动文件传输 +void Machine::startFileTrans(FileTransCtrl & transCtrl) +{ + int rslt; + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.startTrans.cmdCode = UCMD_START_TRANS; + sendPacket.startTrans.fileType = transCtrl.fileType; + sendPacket.startTrans.fileIdx = transCtrl.fileIdx; + sendPacket.startTrans.fileId = transCtrl.fileId; + + if( transCtrl.fileType == FILE_TYPE_DAT) + { + rslt = packetAVLDP(&sendPacket.packet, (u8*)transCtrl.pFileHead, sizeof(DataDs16FileHead)); + } + else if( transCtrl.fileType == FILE_TYPE_PGM ) + { + rslt = packetAVLDP(&sendPacket.packet, (u8*)transCtrl.pAppHead, sizeof(AppFileHead)); + } + else + { + return ; + } + + if (rslt == 0) + { + if( transCtrl.fileType == FILE_TYPE_DAT) + { + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET+sizeof(DataDs16FileHead)); + emit(siSendData(dat)); + } + else if( transCtrl.fileType == FILE_TYPE_PGM ) + { + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET+sizeof(AppFileHead)); + emit(siSendData(dat)); + } + } +} + +// 文件数据传输 +void Machine::transFileData(FileTransCtrl & transCtrl, int pktidx) +{ + int rslt; + int actsize; + u8 buff[MAX_EXDP_LEN]; + + if (pktidx < 0 || transCtrl.pDatBuff == NULL) + { + return; + } + + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.transFileData.cmdCode = UCMD_TRANS_FILE_DATA; + sendPacket.transFileData.fileId = transCtrl.fileId; + sendPacket.transFileData.pktIdx = pktidx; + + if (pktidx < (int)transCtrl.packetNum) + { + if( transCtrl.fileType == FILE_TYPE_DAT) + { + actsize = transCtrl.pFileHead->dataSize - pktidx*transCtrl.packetSize; + + if (actsize >= transCtrl.packetSize) + { + actsize = transCtrl.packetSize; + } + else + { + memset(buff, 0, MAX_EXDP_LEN); + } + } + else if( transCtrl.fileType == FILE_TYPE_PGM ) + { + actsize = transCtrl.pAppHead->dataSize - pktidx*transCtrl.packetSize; + + if (actsize >= transCtrl.packetSize) + { + actsize = transCtrl.packetSize; + } + else + { + memset(buff, 0XFF, MAX_EXDP_LEN); + } + } + else + { + actsize = 0; + } + + memcpy(buff, &(transCtrl.pDatBuff[pktidx*transCtrl.packetSize]), actsize); + //qDebug("TransFileData pktidx=%d", pktidx); +#if (0) + int i; + for (i = 0; i < MAX_EXDP_LEN/16; i++) + { + qDebug("0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x", + buff[i*16+0], buff[i*16+1],buff[i*16+2],buff[i*16+3],buff[i*16+4],buff[i*16+5],buff[i*16+6],buff[i*16+7], + buff[i*16+8],buff[i*16+9],buff[i*16+10],buff[i*16+11],buff[i*16+12],buff[i*16+13],buff[i*16+14],buff[i*16+15]); + } + +#endif + rslt = packetAVLDP(&sendPacket.packet, buff, MAX_EXDP_LEN); + if (rslt == 0) + { + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET+MAX_EXDP_LEN); + emit(siSendData(dat)); + } + } +} +// 下位机升级 +void Machine::updateFirmware() +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.mcUpdate.cmdCode = UCMD_MC_UPDATE; + sendPacket.mcUpdate.upObj = 0; + sendPacket.mcUpdate.upFileID = 0; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +// 恢复出厂设置 +void Machine::restoreFactorySetting(int type) +{ + int mctype = -1; + int wktype = -1; + if (type == -1) + { + mctype = SEW_MCPARA_DEF_MC; + wktype = SEW_MCPARA_DEF_WK; + m_mcParaEn = 0; + m_wkParaEn = 0; + } + else + { + if(type == SEW_MCPARA_DEF_MC ) + { + mctype = SEW_MCPARA_DEF_MC; + m_mcParaEn = 0; + } + if(type == SEW_MCPARA_DEF_WK ) + { + wktype = SEW_MCPARA_DEF_WK; + m_wkParaEn = 0; + } + } + + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.getMcParas.cmdCode = UCMD_GET_MC_PARAS; + + if (mctype == SEW_MCPARA_DEF_MC) + { + sendPacket.getMcParas.paraType = (u16)mctype; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); + } + + if (wktype == SEW_MCPARA_DEF_WK) + { + sendPacket.getMcParas.paraType = (u16)wktype; + packetAFLDP(&sendPacket.packet); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); + } + + sleep(3); + setMcPara(&m_mcPara); + setWkPara(&m_wkPara); + setMcPara(&m_mcPrePara); + setWkPara(&m_wkPrePara); +} + +void Machine::sleep(int sec) +{ + QTime dieTime = QTime::currentTime().addSecs(sec);//延时sec秒 + //QTime dieTime = QTime::currentTime().addMSecs(msec);//延时msec毫秒 + while( QTime::currentTime() < dieTime ) + QCoreApplication::processEvents(QEventLoop::AllEvents, 100); +} + +void Machine::setTcpConnectState(int state) +{ + if(state == 0){}//为了去掉串口下的构建警告 + if(m_connectMode == USE_TCP_COMM) + { + if(m_pTcpClient != NULL) + { + m_pTcpClient->m_connected = state; + } + } + else if(m_connectMode == USE_SERIAL_COMM)//串口 + { + //注释掉此行代码,因为串口发送文件较慢,若是超过5秒不给上位机返状态就会检测断开,其实并未断开 + //m_connected = state;//改变连接状态 + } +} + +// 设置经过的时间 +void Machine::setElapsed(unsigned char i_type , unsigned char i_time) +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setElapsedTime.cmdCode = UCMD_SET_ELAPSED_TIME; + + sendPacket.setElapsedTime.type = i_type ; + sendPacket.setElapsedTime.time = i_time ; + + packetAFLDP(&sendPacket.packet); + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET); + emit(siSendData(dat)); +} + +// 测试断线检测,1是面线,2是底线 +void Machine::testThreadBK(int type,int needle) +{ + actionByhand(TEST_THREADBK, type, needle); +} + +// 设置机器的密钥 +void Machine::setMacKey(unsigned char * p_dat , int i_size) +{ + OperPacket sendPacket; + memset(&sendPacket, 0, sizeof(OperPacket)); + sendPacket.setMacKey.cmdCode = UCMD_SET_INSTALLMENT; + + memcpy( sendPacket.setMacKey.exData , p_dat , i_size); + + packetAVLDP(&sendPacket.packet, (u8*)p_dat, i_size); + + QByteArray dat((char*)(&sendPacket.packet), LEN_NORMAL_PACKET + i_size ); + + emit(siSendData(dat)); +} diff --git a/machine/machine.h b/machine/machine.h new file mode 100644 index 0000000..66900bd --- /dev/null +++ b/machine/machine.h @@ -0,0 +1,299 @@ +#ifndef MACHINE_H +#define MACHINE_H + +#include "tcpclient.h" +#include "comport.h" +#include "datafile/datafiledsr.h" + +#include +#include +#include + +#include "comm/datadef.h" +#include "comm/protocol.h" + +#define USE_TCP_COMM 0 +#define USE_SERIAL_COMM 1 + +class Machine: public QObject +{ + Q_OBJECT + +public: + explicit Machine(QObject *parent = NULL); + virtual ~Machine(); + +public: + void initConnectMode(s16 val = 0);//初始化通讯连接方式 + void setConfigFileName(QString configfilename); + void setComportName(QString portName);//设置串口名称 + QString getConfigFileName(); + int startCommunication(); + +private: + QString m_configFileName; + +private: + s16 m_connectMode; //通讯连接方式 0:网口,1:串口 + // 通讯线程和网络连接 + QThread * m_pTcpThread; + TcpClient * m_pTcpClient; + QThread * m_pComThread; + ComPort * m_pComPort; + + // 连接 +public: + inline int isConnected() const { return m_connected; } + +private: + int m_startComm; + int m_connected; // 机器连接状态. 0, 未连接; 1, 连接中; 2, + +signals: // 发送数据到机器的信号 + void siSendData(QByteArray dat); + void siSendDataDone(); + +private slots: // 和线程通讯的槽 + void slotConnectSta(int sta); // 连接状态改变的槽函数 + void slotConnectErr(QString errinfo); // 接收到通讯错误槽函数 + void slotReceiveData(QByteArray dat); // 接收到数据的槽函数 + +//---------------------------------------- +// 通讯命令 + + // 机器信息 +public: +private: + + // 机器状态 +public: + inline int isStatusEn() const { return m_statusEn; } + inline const MCStatus & getMcStatus() {m_statusEn = 0; return m_mcStatus; } + void setMcStatusAsMc(u8 * buff, int toggle); + + //机器信息 + inline const MCInfo &getMcInfo(){return m_mcInfo;} + //物联数据 + inline const McLotData &getMcLotData(){return m_lotData;} + //调试信息 + inline const DebugInfo &getDebugInfo(){return m_debugInfo;} + +private: + int m_statusEn; // 状态有效标志 + int m_statusToggle; + MCStatus m_mcStatus; // 机器状态 + MCInfo m_mcInfo; // 机器信息 + McLotData m_lotData; // 物联数据 + DebugInfo m_debugInfo;//调试信息 + + // 机器参数 +public: + inline const ParaStruct & getMcPara() {/*m_mcParaEn = 0; */ return m_mcPara; } + inline const ParaStruct & getWkPara() {/*m_wkParaEn = 0; */ return m_wkPara; } + inline const ParaStruct & getPreMcPara() {/*m_mcParaEn = 0; */ return m_mcPrePara; } + inline const ParaStruct & getPreWkPara() {/*m_wkParaEn = 0; */ return m_wkPrePara; } + +private: + ParaStruct m_mcPara; // 机器参数信息 配置信息 + ParaStruct m_wkPara; // 工作参数信息 + ParaStruct m_mcPrePara; // 机器预留参数 + ParaStruct m_wkPrePara; // 工作预留参数 + int m_mcParaEn; + int m_wkParaEn; + int m_mcPreParaEn; + int m_wkPreParaEn; + +public: + inline int isSensorBmpEn() const { return m_sensorBmpEn; } + inline const SensorsBitmap & getSensorDat() {/* m_sensorStaEn = 0; */ return m_sensorsStaDat; } + inline const SensorsBitmap & getSensorBmp() {/* m_sensorBmpEn = 0; */ return m_sensorEnBmp; } + inline int getTotalSendNum() { return m_totalSendNum; } + inline int getTotalPacketNum() { return m_totalPacketNum; } + +private: + SensorsBitmap m_sensorsStaDat; // 传感器信号状态位图 + SensorsBitmap m_sensorEnBmp; // 传感器信号有效位图 + int m_sensorStaEn; + int m_sensorBmpEn; + +public: + void setTcpConnectState(int state); + void setMacKey(unsigned char * p_dat , int i_size); // 设置机器的密钥 + // 文件传输结果 +public: + +private: + QTimer * m_pSendTimer; + FileTransCtrl m_transCtrl; + int m_fileTransEn; + int m_transBreak; + int m_totalSendNum;//传输文件时总共发送的包数 + int m_totalPacketNum;//传输文件时总的包数 + +private slots: + void onSendTimer(void); + void slIfOpenSerialPort(int val);//串口是否打开 + +signals: // 发送给UI的信号 + void siMcInfoChange(); // 机器信息改变信号 + void siDebugInfo(); //调试信息改变信号 + void siReceiveLotData(); // 接收物联数据信号 + void siStatusChange(int); // 状态改变信号 + void siParaChange(int type, int id); // 参数更新信号 + void siMemDataChange(int beginAddr); // 内存数据更新信号 + void siSensorChange(SensorsBitmap map); // 传感信号更新信号 + void siFileInfoChange(); // 文件信息更新信号 + void siTransResultChange(); // 文件传输结果信号 + void siTransProgress(u8 fileType, int send, int total); // 文件传输结果信号 + void siSensorEnBitmap(SensorsBitmap map); // 传感信号有效位图更新信号 + void siDataFilePos(DataFilePos pos); // 边框检查时起始点超出范围后下位机自动定新的起始点后发给上位机 + +public slots: + void breakFileTrans(); // 打断文件传输 + +public: // 机器执行命令,读取下位机数据 + void getInfoFromMachine(); + int getStatusFromMachine(); + void getNetDataFromMachine(); // 读取机器物联数据 + void getParasFromMachine(int type = -1, int id = 0); // 读取机器参数 + void restoreFactorySetting(int type = -1); // 恢复出厂设置 + void getSensorsFromMachine(int backtype = 0); + void getTransResultFromMachine(int fileid); + void getSensorEnBmpFromMachine(); // 获取传感器有效标志位图 + void sleep(int sec); + +public: // 设置机器配置 +// #define UCMD_SET_MC_CONFIG 0x0101 VLDP 无 设置机器的配置,包括信号使用的端口等信息 + +public: // 设置机器状态 + void setMcStatus(int stacode, int para = 0); + void cleanError(); // 清除错误 + void setEnableWorkSta(); // 设置允许工作状态 + void setDisableWorkSta(); // 设置禁止工作状态 + void setEnableWorkTime(); // 设置允许工作时间状态 + void setDisableWorkTime(); // 设置禁止工作时间状态 + void resetOutput(); // 重置产量 + void setToManualWork(); // 手动工作状态 + void setToAutoWork(); // 自动工作状态 + void switchWorkFile(int idx = 0); // 文件切换 + void invalidateWorkFile(int idx = 0); // 文件失效 + void cleanNewParaFlag(); // 清除新参数标志 + void setSimulateWork(); // 模拟工作状态 + void setNormalWork(); // 正常工作状态 + void exitDetectTest(); //退出断线测试 + void resetBobbinCounter(); // 底线计数复位 + void outputReset(); // 产量清零 + void entrySensorScan(); // 进入扫描传感器状态 + void exitSensorScan(); // 退出扫描传感器状态 + void setElapsed(unsigned char i_type , unsigned char i_time); // 设置经过的时间 + void testThreadBK(int type,int needle); // 测试断线检测,1是面线,2是底线 + +public: // 设置机器参数 + void setParasToMachine(int type, ParaStruct & para); + void setAParasToMachine(int type, int idx, u32 value); + void setShutDownTime(u8 type, u32 time); + void setHeadSpacingToMachine(int type, QByteArray data, u16 paraId); + void setMcPara(ParaStruct * pPara); + void setWkPara(ParaStruct * pPara); + void setMcPrePara(ParaStruct * pPara);//预留参数 + void setWkPrePara(ParaStruct * pPara);//预留参数 + void setAMcPara(int id, u32 value); + void setAWkPara(int id, u32 value); + void setAMcPrePara(int id, u32 value);//预留参数 + void setAWkPrePara(int id, u32 value);//预留参数 + + void setHeadSpacing(DsrHeadEx62 para); + +public: // 设置内存数据 +// #define UCMD_SET_MEM_DATA 0x0104 // 设置内存数据 + +public: // 设置文件参数 + void setFilePara(int fileidx, int fileid, DataFilePara & filePara); + +public: // 设置执行进度 + void setFileExecProgress(int fileidx, int fileid, FileExecPara & fileExecPara); + void setToDefaultParas(int type, u8 id = 0, u8 nodeType = 0); + +public slots: // 手动控制命令 + void actionByhand(int actcode, int para1, int para2 = 0, int para3 = 0); + void motoToZero(int obj); // 电机归零(辅助调试的功能,无安全保护和逻辑关系) + void motoMove(int obj, int dir, int spd); // 电机移动(辅助调试的功能,无安全保护和逻辑关系) + void outputCtrl(int obj, int act, int para); // 输出控制(辅助调试的功能,无安全保护和逻辑关系) + void motoServoCtrl(int obj, int onoff); // 电机使能控制(辅助调试的功能,无安全保护和逻辑关系) + + void sewingMsServoOn(); + void sewingMsServoOff(); // 缝纫主轴使能控制 + + void manualAction(int obj, int para2 = 0, int para3 = 0); // 手动动作功能(日常使用功能,有安全保护和逻辑时序关系) + + void cutThreadByhand(); // 手动剪线 + void makeup(int mode); //补缝 + void msAdjust(int step); // 针梭校对 + void rotaAdjust(int step); // 旋转校对 + + void sewHeadLiftUpDown(); // 机头升降 + void sewHeadLiftUp(); // 机头上升 + void sewHeadLiftDown(); // 机头下降 + void sewingMsRun(); // 缝纫主轴研车 + void gotoGorner(int nNum);// 回角点 + void manualOil(int nNum); // 手动加油 + void shuttleCounter(); //梭盘计数复位 + void changeOneShuttle();//自动换一个梭 + void installShuttle(); //安装第一个梭壳 + void sewBuff(); //缝纫状态 + void shuttleDiskBuff(); //换梭盘状态 + void shuttleToHead(); //将旋梭从梭盘到机头 + void headToShuttle(); //将旋梭从机头拿到梭盘 + void allMsRun(); // 所有主轴研车 + + void headLift(); // 机头升降 + void msReset(); // 针梭复位 + void msToFix(); // 针梭去穿线位 + void sewCutThread(int nNum); // 缝纫剪线 + + void moveFrameByHand(char xy, char dir, int spd); // 手动移框 + void sewJog(); // 缝纫点动 + +public: // 机器工作命令 + void mcWorkCmd(int workcode, int para1 = 0 , int para2 = 0); + + void startWork(); // 启动工作 + void pauseWork(); // 暂停工作 + void allToReset(); // 流程复位 + void allToZero(); // 全部归零 + + void gotoStartPos(); // 回起针点 + void gotoAnchor(); // 回定位点 + void setOffsetPos(); // 定偏移点 + void gotoOffsetPos(); // 回偏移点 + + void checkFrame(); // 边框检查 + void simulateFrame(); // 空走边框 + + void fastJump(int idx); // 前进回退 + void gotoWorkPos(); // 回工作点 + void gotoFixPos(); // 回穿线点 + void gotoShuttlePos(); // 回换梭位 + + void gotoZeroPos(); // 回零点 + void msRpmChange(int chgram,int flag); // 速度改变 + void mainShaftJog();// 主轴点动 + +public: // 移动到XY坐标命令 + void moveFrameTo(int x, int y); + +public: // 文件传输命令 + int sendFileProc(int type, int idx, int id, DataDs16FileHead * pfileHead, u8 * pDatBuff); + int sendFileProc(int type, int idx, int id, DataDs16FileHead & fileHead, u8 * pDatBuff); + int sendAPPFileProc(int type, int idx, int id, AppFileHead &fileHead, u8 *pDatBuff); + +private: + void startFileTrans(FileTransCtrl & transCtrl); + void transFileData(FileTransCtrl & transCtrl, int pktidx); + +public: // 下位机系统升级命令 + void updateFirmware(); // 下位机升级 +}; + +#endif // MACHINE_H + diff --git a/machine/qbindtcpsocket.cpp b/machine/qbindtcpsocket.cpp new file mode 100644 index 0000000..740c43f --- /dev/null +++ b/machine/qbindtcpsocket.cpp @@ -0,0 +1,186 @@ +#include "qbindtcpsocket.h" + +#include + +QBindTcpSocket::QBindTcpSocket(QObject *parent): + QTcpSocket(parent) +{ + +} + +QBindTcpSocket::~QBindTcpSocket() +{ + +} + +int QBindTcpSocket::bindAddrAndPort(QString localAddr, quint16 localPort) +{ + QString str = localAddr; + QHostAddress addr(str); + setLocalAddress(addr); + setLocalPort(localPort); + return 0; +} + +//------------------------------- +TcpConnectDetect::TcpConnectDetect(QObject *parent) : + QObject(parent), + m_pDetectSocket(NULL), + m_localip(DEF_LOCAL_IP), + m_localport(DEF_LOCAL_PORT), + m_serverip(DEF_SERVER_IP), + m_serverport(DEF_SERVER_PORT) +{ +} + +TcpConnectDetect::~TcpConnectDetect() +{ + if (m_pDetectSocket == NULL) + { + m_pDetectSocket->disconnectFromHost(); + m_pDetectSocket->waitForDisconnected(); + m_pDetectSocket->close(); + delete m_pDetectSocket; + } +} + +void TcpConnectDetect::detectStart() +{ + qDebug("TcpConnectDetect start"); + if (m_pDetectSocket == NULL) + { + m_pDetectSocket = new QBindTcpSocket; + } +} + +int TcpConnectDetect::connectDetect() +{ + int connectsta = 0; + int rslt; + + // qDebug() << "TcpConnectDetect " << QThread::currentThread(); + + if (m_pDetectSocket == NULL) + { + return 0; + } + if (m_localip.isEmpty() == false) + { + m_pDetectSocket->bindAddrAndPort(m_localip, m_localport); + } + m_pDetectSocket->abort(); + m_pDetectSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); + m_pDetectSocket->connectToHost(m_serverip, m_serverport); + + do + { + rslt = m_pDetectSocket->waitForConnected(4000); // 等待连接 + + qDebug("bind Detect connect rslt=%d", rslt); + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + qDebug() << "serverip=" << m_serverip << "serverport=" << m_serverport; + + switch(m_pDetectSocket->state()) + { + case QAbstractSocket::ConnectedState: + { + // 如果连接上,说明 m_pClientSocket 连接已经无效, 需要断开重新连接 + // 先断开测试连接 + m_pDetectSocket->disconnectFromHost(); + m_pDetectSocket->waitForDisconnected(); + connectsta = 1; + // 发送断开主连接的信号 + qDebug() << "detect is Connected, disconnect all"; + + break; + } + case QAbstractSocket::UnconnectedState: + { + // qDebug() << "detect is Unconnected err=" << m_pDetectSocket->error() << ", info:" << m_pDetectSocket->errorString(); + + switch (m_pDetectSocket->error()) + { + case QAbstractSocket::SocketTimeoutError: // 连接超时,说明已经断开 + case QAbstractSocket::NetworkError: // 网络错误, 主机不可连接, 可能已经断开 + { + qDebug() << "detect is timout, disconnect all"; + connectsta = 1; + // 发送断开主连接的信号 + break; + } + case QAbstractSocket::ConnectionRefusedError: // 拒绝连接, 说明连接还在 + { + connectsta = 2; + // qDebug() << "Connection Refused, old connect is alive"; + break; + } + /* + case QAbstractSocket::RemoteHostClosedError: + case QAbstractSocket::HostNotFoundError: + case QAbstractSocket::SocketAccessError: + case QAbstractSocket::SocketResourceError: + case QAbstractSocket::SocketTimeoutError: + case QAbstractSocket::DatagramTooLargeError: + case QAbstractSocket::AddressInUseError: + case QAbstractSocket::SocketAddressNotAvailableError: + case QAbstractSocket::UnsupportedSocketOperationError: + case QAbstractSocket::UnfinishedSocketOperationError: + case QAbstractSocket::ProxyAuthenticationRequiredError: + case QAbstractSocket::SslHandshakeFailedError: + case QAbstractSocket::ProxyConnectionRefusedError: + case QAbstractSocket::ProxyConnectionClosedError: + case QAbstractSocket::ProxyConnectionTimeoutError: + case QAbstractSocket::ProxyNotFoundError: + case QAbstractSocket::ProxyProtocolError: + case QAbstractSocket::UnknownSocketError: + */ + default: + { + // 继续检测 + connectsta = 2; + qDebug() << " retry"; + break; + } + } // 错误处理结束 + } + case QAbstractSocket::ConnectingState: + { + // qDebug() << "detect is Connecting"; + // qDebug() << "localip=" << m_localip << "localport=" << m_localport; + // 继续等待 + break; + } + case QAbstractSocket::HostLookupState: + case QAbstractSocket::BoundState: + case QAbstractSocket::ListeningState: + case QAbstractSocket::ClosingState: + default: + { + // 继续等待 + qDebug("detect sta is %d\r\n", m_pDetectSocket->state()); + break; + } + } + + if (connectsta != 0) + { + break; + } + + }while(1); + + + m_pDetectSocket->close(); + + // 发送本次测试连接的状态信号 + emit(siConnectSta(connectsta)); + return connectsta; +} + +void TcpConnectDetect::setIpAndPort(QString localip, quint16 localport, QString serverip, quint16 serverport) +{ + m_localip = localip; + m_localport = localport; + m_serverip = serverip; + m_serverport = serverport; +} diff --git a/machine/qbindtcpsocket.h b/machine/qbindtcpsocket.h new file mode 100644 index 0000000..b433b66 --- /dev/null +++ b/machine/qbindtcpsocket.h @@ -0,0 +1,53 @@ +#ifndef QBINDTCPSOCKET_H +#define QBINDTCPSOCKET_H + +#define DEF_SERVER_IP "192.168.16.253" +#define DEF_SERVER_PORT 5000 +#define DEF_LOCAL_IP "" +#define DEF_LOCAL_PORT 5001 + + +#include + +class QBindTcpSocket : public QTcpSocket +{ + +public: + QBindTcpSocket(QObject *parent = 0); + virtual ~QBindTcpSocket(); + +public: + int bindAddrAndPort(QString localAddr, quint16 localPort); +}; + +#if(1) +class TcpConnectDetect : public QObject +{ + Q_OBJECT +public: + explicit TcpConnectDetect(QObject *parent = NULL); + virtual ~TcpConnectDetect(); + +signals: + void siConnectSta(int sta); // 网络连接信号 +public: + +public slots: + void detectStart(); + int connectDetect(); + +private: + QBindTcpSocket * m_pDetectSocket; + +public: + void setIpAndPort(QString localip, quint16 localport, QString serverip, quint16 serverport); + +private: + QString m_localip; + quint16 m_localport; + QString m_serverip; + quint16 m_serverport; +}; +#endif + +#endif // QBINDTCPSOCKET_H diff --git a/machine/qextserial/posix_qextserialport.cpp b/machine/qextserial/posix_qextserialport.cpp new file mode 100644 index 0000000..ce92fae --- /dev/null +++ b/machine/qextserial/posix_qextserialport.cpp @@ -0,0 +1,1117 @@ + +/*! +\class Posix_QextSerialPort +\version 1.0.0 +\author Stefan Sander + +A cross-platform serial port class. +This class encapsulates the POSIX portion of QextSerialPort. The user will be notified of errors +and possible portability conflicts at run-time by default - this behavior can be turned off by +defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off portability +warnings) in the project. Note that _TTY_NOWARN_ will also turn off portability warnings. +*/ + +#include +#include "posix_qextserialport.h" + +/*! +\fn Posix_QextSerialPort::Posix_QextSerialPort() +Default constructor. Note that the name of the device used by a QextSerialPort constructed with +this constructor will be determined by #defined constants, or lack thereof - the default behavior +is the same as _TTY_LINUX_. Possible naming conventions and their associated constants are: + +\verbatim + +Constant Used By Naming Convention +---------- ------------- ------------------------ +_TTY_WIN_ Windows COM1, COM2 +_TTY_IRIX_ SGI/IRIX /dev/ttyf1, /dev/ttyf2 +_TTY_HPUX_ HP-UX /dev/tty1p0, /dev/tty2p0 +_TTY_SUN_ SunOS/Solaris /dev/ttya, /dev/ttyb +_TTY_DIGITAL_ Digital UNIX /dev/tty01, /dev/tty02 +_TTY_FREEBSD_ FreeBSD /dev/ttyd0, /dev/ttyd1 +_TTY_LINUX_ Linux /dev/ttyS0, /dev/ttyS1 + Linux /dev/ttyS0, /dev/ttyS1 +\endverbatim + +This constructor assigns the device name to the name of the first port on the specified system. +See the other constructors if you need to open a different port. +*/ +Posix_QextSerialPort::Posix_QextSerialPort() +: QextSerialBase() +{ + Posix_File=new QFile(); +} + +/*! +\fn Posix_QextSerialPort::Posix_QextSerialPort(const Posix_QextSerialPort&) +Copy constructor. +*/ +Posix_QextSerialPort::Posix_QextSerialPort(const Posix_QextSerialPort& s) + : QextSerialBase(s.port) +{ + setOpenMode(s.openMode()); + port = s.port; + Settings.BaudRate=s.Settings.BaudRate; + Settings.DataBits=s.Settings.DataBits; + Settings.Parity=s.Settings.Parity; + Settings.StopBits=s.Settings.StopBits; + Settings.FlowControl=s.Settings.FlowControl; + lastErr=s.lastErr; + + Posix_File=new QFile(); + Posix_File=s.Posix_File; + memcpy(&Posix_Timeout, &s.Posix_Timeout, sizeof(struct timeval)); + memcpy(&Posix_Copy_Timeout, &s.Posix_Copy_Timeout, sizeof(struct timeval)); + memcpy(&Posix_CommConfig, &s.Posix_CommConfig, sizeof(struct termios)); +} + +/*! +\fn Posix_QextSerialPort::Posix_QextSerialPort(const QString & name) +Constructs a serial port attached to the port specified by name. +name is the name of the device, which is windowsystem-specific, +e.g."COM1" or "/dev/ttyS0". +*/ +Posix_QextSerialPort::Posix_QextSerialPort(const QString & name) + : QextSerialBase(name) +{ + Posix_File=new QFile(); +} + +/*! +\fn Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings) +Constructs a port with default name and specified settings. +*/ +Posix_QextSerialPort::Posix_QextSerialPort(const PortSettings& settings) + : QextSerialBase() +{ + setBaudRate(settings.BaudRate); + setDataBits(settings.DataBits); + setParity(settings.Parity); + setStopBits(settings.StopBits); + setFlowControl(settings.FlowControl); + + Posix_File=new QFile(); + setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec); +} + +/*! +\fn Posix_QextSerialPort::Posix_QextSerialPort(const QString & name, const PortSettings& settings) +Constructs a port with specified name and settings. +*/ +Posix_QextSerialPort::Posix_QextSerialPort(const QString & name, const PortSettings& settings) + : QextSerialBase(name) +{ + setBaudRate(settings.BaudRate); + setDataBits(settings.DataBits); + setParity(settings.Parity); + setStopBits(settings.StopBits); + setFlowControl(settings.FlowControl); + + Posix_File=new QFile(); + setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec); +} + +/*! +\fn Posix_QextSerialPort& Posix_QextSerialPort::operator=(const Posix_QextSerialPort& s) +Override the = operator. +*/ +Posix_QextSerialPort& Posix_QextSerialPort::operator=(const Posix_QextSerialPort& s) +{ + setOpenMode(s.openMode()); + port = s.port; + Settings.BaudRate=s.Settings.BaudRate; + Settings.DataBits=s.Settings.DataBits; + Settings.Parity=s.Settings.Parity; + Settings.StopBits=s.Settings.StopBits; + Settings.FlowControl=s.Settings.FlowControl; + lastErr=s.lastErr; + + Posix_File=s.Posix_File; + memcpy(&Posix_Timeout, &(s.Posix_Timeout), sizeof(struct timeval)); + memcpy(&Posix_Copy_Timeout, &(s.Posix_Copy_Timeout), sizeof(struct timeval)); + memcpy(&Posix_CommConfig, &(s.Posix_CommConfig), sizeof(struct termios)); + return *this; +} + +/*! +\fn Posix_QextSerialPort::~Posix_QextSerialPort() +Standard destructor. +*/ +Posix_QextSerialPort::~Posix_QextSerialPort() +{ + if (isOpen()) { + close(); + } + Posix_File->close(); + delete Posix_File; +} + +/*! +\fn void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate) +Sets the baud rate of the serial port. Note that not all rates are applicable on +all platforms. The following table shows translations of the various baud rate +constants on Windows(including NT/2000) and POSIX platforms. Speeds marked with an * +are speeds that are usable on both Windows and POSIX. + +\note +BAUD76800 may not be supported on all POSIX systems. SGI/IRIX systems do not support +BAUD1800. + +\verbatim + + RATE Windows Speed POSIX Speed + ----------- ------------- ----------- + BAUD50 110 50 + BAUD75 110 75 + *BAUD110 110 110 + BAUD134 110 134.5 + BAUD150 110 150 + BAUD200 110 200 + *BAUD300 300 300 + *BAUD600 600 600 + *BAUD1200 1200 1200 + BAUD1800 1200 1800 + *BAUD2400 2400 2400 + *BAUD4800 4800 4800 + *BAUD9600 9600 9600 + BAUD14400 14400 9600 + *BAUD19200 19200 19200 + *BAUD38400 38400 38400 + BAUD56000 56000 38400 + *BAUD57600 57600 57600 + BAUD76800 57600 76800 + *BAUD115200 115200 115200 + BAUD128000 128000 115200 + BAUD256000 256000 115200 +\endverbatim +*/ +void Posix_QextSerialPort::setBaudRate(BaudRateType baudRate) +{ + LOCK_MUTEX(); + if (Settings.BaudRate!=baudRate) { + switch (baudRate) { + case BAUD14400: + Settings.BaudRate=BAUD9600; + break; + + case BAUD56000: + Settings.BaudRate=BAUD38400; + break; + + case BAUD76800: + +#ifndef B76800 + Settings.BaudRate=BAUD57600; +#else + Settings.BaudRate=baudRate; +#endif + break; + + case BAUD128000: + case BAUD256000: + Settings.BaudRate=BAUD115200; + break; + + default: + Settings.BaudRate=baudRate; + break; + } + } + if (isOpen()) { + switch (baudRate) { + + /*50 baud*/ + case BAUD50: + TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 50 baud operation."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B50; +#else + cfsetispeed(&Posix_CommConfig, B50); + cfsetospeed(&Posix_CommConfig, B50); +#endif + break; + + /*75 baud*/ + case BAUD75: + TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 75 baud operation."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B75; +#else + cfsetispeed(&Posix_CommConfig, B75); + cfsetospeed(&Posix_CommConfig, B75); +#endif + break; + + /*110 baud*/ + case BAUD110: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B110; +#else + cfsetispeed(&Posix_CommConfig, B110); + cfsetospeed(&Posix_CommConfig, B110); +#endif + break; + + /*134.5 baud*/ + case BAUD134: + TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 134.5 baud operation."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B134; +#else + cfsetispeed(&Posix_CommConfig, B134); + cfsetospeed(&Posix_CommConfig, B134); +#endif + break; + + /*150 baud*/ + case BAUD150: + TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 150 baud operation."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B150; +#else + cfsetispeed(&Posix_CommConfig, B150); + cfsetospeed(&Posix_CommConfig, B150); +#endif + break; + + /*200 baud*/ + case BAUD200: + TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 200 baud operation."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B200; +#else + cfsetispeed(&Posix_CommConfig, B200); + cfsetospeed(&Posix_CommConfig, B200); +#endif + break; + + /*300 baud*/ + case BAUD300: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B300; +#else + cfsetispeed(&Posix_CommConfig, B300); + cfsetospeed(&Posix_CommConfig, B300); +#endif + break; + + /*600 baud*/ + case BAUD600: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B600; +#else + cfsetispeed(&Posix_CommConfig, B600); + cfsetospeed(&Posix_CommConfig, B600); +#endif + break; + + /*1200 baud*/ + case BAUD1200: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B1200; +#else + cfsetispeed(&Posix_CommConfig, B1200); + cfsetospeed(&Posix_CommConfig, B1200); +#endif + break; + + /*1800 baud*/ + case BAUD1800: + TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and IRIX do not support 1800 baud operation."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B1800; +#else + cfsetispeed(&Posix_CommConfig, B1800); + cfsetospeed(&Posix_CommConfig, B1800); +#endif + break; + + /*2400 baud*/ + case BAUD2400: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B2400; +#else + cfsetispeed(&Posix_CommConfig, B2400); + cfsetospeed(&Posix_CommConfig, B2400); +#endif + break; + + /*4800 baud*/ + case BAUD4800: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B4800; +#else + cfsetispeed(&Posix_CommConfig, B4800); + cfsetospeed(&Posix_CommConfig, B4800); +#endif + break; + + /*9600 baud*/ + case BAUD9600: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B9600; +#else + cfsetispeed(&Posix_CommConfig, B9600); + cfsetospeed(&Posix_CommConfig, B9600); +#endif + break; + + /*14400 baud*/ + case BAUD14400: + TTY_WARNING("Posix_QextSerialPort: POSIX does not support 14400 baud operation. Switching to 9600 baud."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B9600; +#else + cfsetispeed(&Posix_CommConfig, B9600); + cfsetospeed(&Posix_CommConfig, B9600); +#endif + break; + + /*19200 baud*/ + case BAUD19200: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B19200; +#else + cfsetispeed(&Posix_CommConfig, B19200); + cfsetospeed(&Posix_CommConfig, B19200); +#endif + break; + + /*38400 baud*/ + case BAUD38400: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B38400; +#else + cfsetispeed(&Posix_CommConfig, B38400); + cfsetospeed(&Posix_CommConfig, B38400); +#endif + break; + + /*56000 baud*/ + case BAUD56000: + TTY_WARNING("Posix_QextSerialPort: POSIX does not support 56000 baud operation. Switching to 38400 baud."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B38400; +#else + cfsetispeed(&Posix_CommConfig, B38400); + cfsetospeed(&Posix_CommConfig, B38400); +#endif + break; + + /*57600 baud*/ + case BAUD57600: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B57600; +#else + cfsetispeed(&Posix_CommConfig, B57600); + cfsetospeed(&Posix_CommConfig, B57600); +#endif + break; + + /*76800 baud*/ + case BAUD76800: + TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and some POSIX systems do not support 76800 baud operation."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + +#ifdef B76800 + Posix_CommConfig.c_cflag|=B76800; +#else + TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support. Switching to 57600 baud."); + Posix_CommConfig.c_cflag|=B57600; +#endif //B76800 +#else //CBAUD +#ifdef B76800 + cfsetispeed(&Posix_CommConfig, B76800); + cfsetospeed(&Posix_CommConfig, B76800); +#else + TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support. Switching to 57600 baud."); + cfsetispeed(&Posix_CommConfig, B57600); + cfsetospeed(&Posix_CommConfig, B57600); +#endif //B76800 +#endif //CBAUD + break; + + /*115200 baud*/ + case BAUD115200: +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B115200; +#else + cfsetispeed(&Posix_CommConfig, B115200); + cfsetospeed(&Posix_CommConfig, B115200); +#endif + break; + + /*128000 baud*/ + case BAUD128000: + TTY_WARNING("Posix_QextSerialPort: POSIX does not support 128000 baud operation. Switching to 115200 baud."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B115200; +#else + cfsetispeed(&Posix_CommConfig, B115200); + cfsetospeed(&Posix_CommConfig, B115200); +#endif + break; + + /*256000 baud*/ + case BAUD256000: + TTY_WARNING("Posix_QextSerialPort: POSIX does not support 256000 baud operation. Switching to 115200 baud."); +#ifdef CBAUD + Posix_CommConfig.c_cflag&=(~CBAUD); + Posix_CommConfig.c_cflag|=B115200; +#else + cfsetispeed(&Posix_CommConfig, B115200); + cfsetospeed(&Posix_CommConfig, B115200); +#endif + break; + } + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Posix_QextSerialPort::setDataBits(DataBitsType dataBits) +Sets the number of data bits used by the serial port. Possible values of dataBits are: +\verbatim + DATA_5 5 data bits + DATA_6 6 data bits + DATA_7 7 data bits + DATA_8 8 data bits +\endverbatim + +\note +This function is subject to the following restrictions: +\par + 5 data bits cannot be used with 2 stop bits. +\par + 8 data bits cannot be used with space parity on POSIX systems. + +*/ +void Posix_QextSerialPort::setDataBits(DataBitsType dataBits) +{ + LOCK_MUTEX(); + if (Settings.DataBits!=dataBits) { + if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) || + (Settings.StopBits==STOP_1_5 && dataBits!=DATA_5) || + (Settings.Parity==PAR_SPACE && dataBits==DATA_8)) { + } + else { + Settings.DataBits=dataBits; + } + } + if (isOpen()) { + switch(dataBits) { + + /*5 data bits*/ + case DATA_5: + if (Settings.StopBits==STOP_2) { + TTY_WARNING("Posix_QextSerialPort: 5 Data bits cannot be used with 2 stop bits."); + } + else { + Settings.DataBits=dataBits; + Posix_CommConfig.c_cflag&=(~CSIZE); + Posix_CommConfig.c_cflag|=CS5; + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + } + break; + + /*6 data bits*/ + case DATA_6: + if (Settings.StopBits==STOP_1_5) { + TTY_WARNING("Posix_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits."); + } + else { + Settings.DataBits=dataBits; + Posix_CommConfig.c_cflag&=(~CSIZE); + Posix_CommConfig.c_cflag|=CS6; + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + } + break; + + /*7 data bits*/ + case DATA_7: + if (Settings.StopBits==STOP_1_5) { + TTY_WARNING("Posix_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits."); + } + else { + Settings.DataBits=dataBits; + Posix_CommConfig.c_cflag&=(~CSIZE); + Posix_CommConfig.c_cflag|=CS7; + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + } + break; + + /*8 data bits*/ + case DATA_8: + if (Settings.StopBits==STOP_1_5) { + TTY_WARNING("Posix_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits."); + } + else { + Settings.DataBits=dataBits; + Posix_CommConfig.c_cflag&=(~CSIZE); + Posix_CommConfig.c_cflag|=CS8; + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + } + break; + } + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Posix_QextSerialPort::setParity(ParityType parity) +Sets the parity associated with the serial port. The possible values of parity are: +\verbatim + PAR_SPACE Space Parity + PAR_MARK Mark Parity + PAR_NONE No Parity + PAR_EVEN Even Parity + PAR_ODD Odd Parity +\endverbatim + +\note +This function is subject to the following limitations: +\par +POSIX systems do not support mark parity. +\par +POSIX systems support space parity only if tricked into doing so, and only with + fewer than 8 data bits. Use space parity very carefully with POSIX systems. + +*/ +void Posix_QextSerialPort::setParity(ParityType parity) +{ + LOCK_MUTEX(); + if (Settings.Parity!=parity) { + if (parity==PAR_MARK || (parity==PAR_SPACE && Settings.DataBits==DATA_8)) { + } + else { + Settings.Parity=parity; + } + } + if (isOpen()) { + switch (parity) { + + /*space parity*/ + case PAR_SPACE: + if (Settings.DataBits==DATA_8) { + TTY_PORTABILITY_WARNING("Posix_QextSerialPort: Space parity is only supported in POSIX with 7 or fewer data bits"); + } + else { + + /*space parity not directly supported - add an extra data bit to simulate it*/ + Posix_CommConfig.c_cflag&=~(PARENB|CSIZE); + switch(Settings.DataBits) { + case DATA_5: + Settings.DataBits=DATA_6; + Posix_CommConfig.c_cflag|=CS6; + break; + + case DATA_6: + Settings.DataBits=DATA_7; + Posix_CommConfig.c_cflag|=CS7; + break; + + case DATA_7: + Settings.DataBits=DATA_8; + Posix_CommConfig.c_cflag|=CS8; + break; + + case DATA_8: + break; + } + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + } + break; + + /*mark parity - WINDOWS ONLY*/ + case PAR_MARK: + TTY_WARNING("Posix_QextSerialPort: Mark parity is not supported by POSIX."); + break; + + /*no parity*/ + case PAR_NONE: + Posix_CommConfig.c_cflag&=(~PARENB); + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + break; + + /*even parity*/ + case PAR_EVEN: + Posix_CommConfig.c_cflag&=(~PARODD); + Posix_CommConfig.c_cflag|=PARENB; + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + break; + + /*odd parity*/ + case PAR_ODD: + Posix_CommConfig.c_cflag|=(PARENB|PARODD); + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + break; + } + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Posix_QextSerialPort::setStopBits(StopBitsType stopBits) +Sets the number of stop bits used by the serial port. Possible values of stopBits are: +\verbatim + STOP_1 1 stop bit + STOP_1_5 1.5 stop bits + STOP_2 2 stop bits +\endverbatim +\note +This function is subject to the following restrictions: +\par + 2 stop bits cannot be used with 5 data bits. +\par + POSIX does not support 1.5 stop bits. + +*/ +void Posix_QextSerialPort::setStopBits(StopBitsType stopBits) +{ + LOCK_MUTEX(); + if (Settings.StopBits!=stopBits) { + if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) || stopBits==STOP_1_5) {} + else { + Settings.StopBits=stopBits; + } + } + if (isOpen()) { + switch (stopBits) { + + /*one stop bit*/ + case STOP_1: + Settings.StopBits=stopBits; + Posix_CommConfig.c_cflag&=(~CSTOPB); + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + break; + + /*1.5 stop bits*/ + case STOP_1_5: + TTY_WARNING("Posix_QextSerialPort: 1.5 stop bit operation is not supported by POSIX."); + break; + + /*two stop bits*/ + case STOP_2: + if (Settings.DataBits==DATA_5) { + TTY_WARNING("Posix_QextSerialPort: 2 stop bits cannot be used with 5 data bits"); + } + else { + Settings.StopBits=stopBits; + Posix_CommConfig.c_cflag|=CSTOPB; + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + } + break; + } + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Posix_QextSerialPort::setFlowControl(FlowType flow) +Sets the flow control used by the port. Possible values of flow are: +\verbatim + FLOW_OFF No flow control + FLOW_HARDWARE Hardware (RTS/CTS) flow control + FLOW_XONXOFF Software (XON/XOFF) flow control +\endverbatim +\note +FLOW_HARDWARE may not be supported on all versions of UNIX. In cases where it is +unsupported, FLOW_HARDWARE is the same as FLOW_OFF. + +*/ +void Posix_QextSerialPort::setFlowControl(FlowType flow) +{ + LOCK_MUTEX(); + if (Settings.FlowControl!=flow) { + Settings.FlowControl=flow; + } + if (isOpen()) { + switch(flow) { + + /*no flow control*/ + case FLOW_OFF: + Posix_CommConfig.c_cflag&=(~CRTSCTS); + Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY)); + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + break; + + /*software (XON/XOFF) flow control*/ + case FLOW_XONXOFF: + Posix_CommConfig.c_cflag&=(~CRTSCTS); + Posix_CommConfig.c_iflag|=(IXON|IXOFF|IXANY); + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + break; + + case FLOW_HARDWARE: + Posix_CommConfig.c_cflag|=CRTSCTS; + Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY)); + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + break; + } + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Posix_QextSerialPort::setTimeout(ulong sec, ulong millisec); +Sets the read and write timeouts for the port to sec seconds and millisec milliseconds. +Note that this is a per-character timeout, i.e. the port will wait this long for each +individual character, not for the whole read operation. This timeout also applies to the +bytesWaiting() function. + +\note +POSIX does not support millisecond-level control for I/O timeout values. Any +timeout set using this function will be set to the next lowest tenth of a second for +the purposes of detecting read or write timeouts. For example a timeout of 550 milliseconds +will be seen by the class as a timeout of 500 milliseconds for the purposes of reading and +writing the port. However millisecond-level control is allowed by the select() system call, +so for example a 550-millisecond timeout will be seen as 550 milliseconds on POSIX systems for +the purpose of detecting available bytes in the read buffer. + +*/ +void Posix_QextSerialPort::setTimeout(ulong sec, ulong millisec) +{ + LOCK_MUTEX(); + Settings.Timeout_Sec=sec; + Settings.Timeout_Millisec=millisec; + Posix_Copy_Timeout.tv_sec=sec; + Posix_Copy_Timeout.tv_usec=millisec; + if (isOpen()) { + tcgetattr(Posix_File->handle(), &Posix_CommConfig); + Posix_CommConfig.c_cc[VTIME]=sec*10+millisec/100; + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + } + UNLOCK_MUTEX(); +} + +/*! +\fn bool Posix_QextSerialPort::open(OpenMode mode) +Opens the serial port associated to this class. +This function has no effect if the port associated with the class is already open. +The port is also configured to the current settings, as stored in the Settings structure. +*/ +bool Posix_QextSerialPort::open(OpenMode mode) +{ + LOCK_MUTEX(); + if (mode == QIODevice::NotOpen) + return isOpen(); + if (!isOpen()) { + /*open the port*/ + Posix_File->setFileName(port); + qDebug("Trying to open File"); + if (Posix_File->open(QIODevice::ReadWrite|QIODevice::Unbuffered)) { + qDebug("Opened File succesfully"); + /*set open mode*/ + QIODevice::open(mode); + + /*configure port settings*/ + tcgetattr(Posix_File->handle(), &Posix_CommConfig); + + /*set up other port settings*/ + Posix_CommConfig.c_cflag|=CREAD|CLOCAL; + Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG)); + Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY)); + Posix_CommConfig.c_oflag&=(~OPOST); + Posix_CommConfig.c_cc[VMIN]=0; + Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE; + Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE; + Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE; + Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE; + Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE; + setBaudRate(Settings.BaudRate); + setDataBits(Settings.DataBits); + setParity(Settings.Parity); + setStopBits(Settings.StopBits); + setFlowControl(Settings.FlowControl); + setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec); + tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig); + } else { + qDebug("Could not open File! Error code : %d", Posix_File->error()); + } + } + UNLOCK_MUTEX(); + return isOpen(); +} + +/*! +\fn void Posix_QextSerialPort::close() +Closes a serial port. This function has no effect if the serial port associated with the class +is not currently open. +*/ +void Posix_QextSerialPort::close() +{ + LOCK_MUTEX(); + Posix_File->close(); + QIODevice::close(); + UNLOCK_MUTEX(); +} + +/*! +\fn void Posix_QextSerialPort::flush() +Flushes all pending I/O to the serial port. This function has no effect if the serial port +associated with the class is not currently open. +*/ +void Posix_QextSerialPort::flush() +{ + LOCK_MUTEX(); + if (isOpen()) { + Posix_File->flush(); + } + UNLOCK_MUTEX(); +} + +/*! +\fn qint64 Posix_QextSerialPort::size() const +This function will return the number of bytes waiting in the receive queue of the serial port. +It is included primarily to provide a complete QIODevice interface, and will not record errors +in the lastErr member (because it is const). This function is also not thread-safe - in +multithreading situations, use Posix_QextSerialPort::bytesWaiting() instead. +*/ +qint64 Posix_QextSerialPort::size() const +{ + int numBytes; + if (ioctl(Posix_File->handle(), FIONREAD, &numBytes)<0) { + numBytes=0; + } + return (qint64)numBytes; +} + +/*! +\fn qint64 Posix_QextSerialPort::bytesAvailable() +Returns the number of bytes waiting in the port's receive queue. This function will return 0 if +the port is not currently open, or -1 on error. Error information can be retrieved by calling +Posix_QextSerialPort::getLastError(). +*/ +qint64 Posix_QextSerialPort::bytesAvailable() +{ + LOCK_MUTEX(); + if (isOpen()) { + int bytesQueued; + fd_set fileSet; + FD_ZERO(&fileSet); + FD_SET(Posix_File->handle(), &fileSet); + + /*on Linux systems the Posix_Timeout structure will be altered by the select() call. + Make sure we use the right timeout values*/ + //memcpy(&Posix_Timeout, &Posix_Copy_Timeout, sizeof(struct timeval)); + Posix_Timeout = Posix_Copy_Timeout; + int n=select(Posix_File->handle()+1, &fileSet, NULL, &fileSet, &Posix_Timeout); + if (!n) { + lastErr=E_PORT_TIMEOUT; + UNLOCK_MUTEX(); + return -1; + } + if (n==-1 || ioctl(Posix_File->handle(), FIONREAD, &bytesQueued)==-1) { + translateError(errno); + UNLOCK_MUTEX(); + return -1; + } + lastErr=E_NO_ERROR; + UNLOCK_MUTEX(); + return bytesQueued + QIODevice::bytesAvailable(); + } + UNLOCK_MUTEX(); + return 0; +} + +/*! +\fn void Posix_QextSerialPort::ungetChar(char) +This function is included to implement the full QIODevice interface, and currently has no +purpose within this class. This function is meaningless on an unbuffered device and currently +only prints a warning message to that effect. +*/ +void Posix_QextSerialPort::ungetChar(char) +{ + /*meaningless on unbuffered sequential device - return error and print a warning*/ + TTY_WARNING("Posix_QextSerialPort: ungetChar() called on an unbuffered sequential device - operation is meaningless"); +} + +/*! +\fn void Posix_QextSerialPort::translateError(ulong error) +Translates a system-specific error code to a QextSerialPort error code. Used internally. +*/ +void Posix_QextSerialPort::translateError(ulong error) +{ + switch (error) { + case EBADF: + case ENOTTY: + lastErr=E_INVALID_FD; + break; + + case EINTR: + lastErr=E_CAUGHT_NON_BLOCKED_SIGNAL; + break; + + case ENOMEM: + lastErr=E_NO_MEMORY; + break; + } +} + +/*! +\fn void Posix_QextSerialPort::setDtr(bool set) +Sets DTR line to the requested state (high by default). This function will have no effect if +the port associated with the class is not currently open. +*/ +void Posix_QextSerialPort::setDtr(bool set) +{ + LOCK_MUTEX(); + if (isOpen()) { + int status; + ioctl(Posix_File->handle(), TIOCMGET, &status); + if (set) { + status|=TIOCM_DTR; + } + else { + status&=~TIOCM_DTR; + } + ioctl(Posix_File->handle(), TIOCMSET, &status); + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Posix_QextSerialPort::setRts(bool set) +Sets RTS line to the requested state (high by default). This function will have no effect if +the port associated with the class is not currently open. +*/ +void Posix_QextSerialPort::setRts(bool set) +{ + LOCK_MUTEX(); + if (isOpen()) { + int status; + ioctl(Posix_File->handle(), TIOCMGET, &status); + if (set) { + status|=TIOCM_RTS; + } + else { + status&=~TIOCM_RTS; + } + ioctl(Posix_File->handle(), TIOCMSET, &status); + } + UNLOCK_MUTEX(); +} + +/*! +\fn unsigned long Posix_QextSerialPort::lineStatus() +returns the line status as stored by the port function. This function will retrieve the states +of the following lines: DCD, CTS, DSR, and RI. On POSIX systems, the following additional lines +can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD. The value returned is an unsigned +long with specific bits indicating which lines are high. The following constants should be used +to examine the states of individual lines: + +\verbatim +Mask Line +------ ---- +LS_CTS CTS +LS_DSR DSR +LS_DCD DCD +LS_RI RI +LS_RTS RTS (POSIX only) +LS_DTR DTR (POSIX only) +LS_ST Secondary TXD (POSIX only) +LS_SR Secondary RXD (POSIX only) +\endverbatim + +This function will return 0 if the port associated with the class is not currently open. +*/ +unsigned long Posix_QextSerialPort::lineStatus() +{ + unsigned long Status=0, Temp=0; + LOCK_MUTEX(); + if (isOpen()) { + ioctl(Posix_File->handle(), TIOCMGET, &Temp); + if (Temp&TIOCM_CTS) { + Status|=LS_CTS; + } + if (Temp&TIOCM_DSR) { + Status|=LS_DSR; + } + if (Temp&TIOCM_RI) { + Status|=LS_RI; + } + if (Temp&TIOCM_CD) { + Status|=LS_DCD; + } + if (Temp&TIOCM_DTR) { + Status|=LS_DTR; + } + if (Temp&TIOCM_RTS) { + Status|=LS_RTS; + } + if (Temp&TIOCM_ST) { + Status|=LS_ST; + } + if (Temp&TIOCM_SR) { + Status|=LS_SR; + } + } + UNLOCK_MUTEX(); + return Status; +} + +/*! +\fn qint64 Posix_QextSerialPort::readData(char * data, qint64 maxSize) +Reads a block of data from the serial port. This function will read at most maxSize bytes from +the serial port and place them in the buffer pointed to by data. Return value is the number of +bytes actually read, or -1 on error. + +\warning before calling this function ensure that serial port associated with this class +is currently open (use isOpen() function to check if port is open). +*/ +qint64 Posix_QextSerialPort::readData(char * data, qint64 maxSize) +{ + LOCK_MUTEX(); + int retVal=0; + retVal=Posix_File->read(data, maxSize); + if (retVal==-1) + lastErr=E_READ_FAILED; + UNLOCK_MUTEX(); + + return retVal; +} + +/*! +\fn qint64 Posix_QextSerialPort::writeData(const char * data, qint64 maxSize) +Writes a block of data to the serial port. This function will write maxSize bytes +from the buffer pointed to by data to the serial port. Return value is the number +of bytes actually written, or -1 on error. + +\warning before calling this function ensure that serial port associated with this class +is currently open (use isOpen() function to check if port is open). +*/ +qint64 Posix_QextSerialPort::writeData(const char * data, qint64 maxSize) +{ + LOCK_MUTEX(); + int retVal=0; + retVal=Posix_File->write(data, maxSize); + if (retVal==-1) + lastErr=E_WRITE_FAILED; + UNLOCK_MUTEX(); + + flush(); + return retVal; +} diff --git a/machine/qextserial/posix_qextserialport.h b/machine/qextserial/posix_qextserialport.h new file mode 100644 index 0000000..559d2f6 --- /dev/null +++ b/machine/qextserial/posix_qextserialport.h @@ -0,0 +1,57 @@ + +#ifndef _POSIX_QEXTSERIALPORT_H_ +#define _POSIX_QEXTSERIALPORT_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "qextserialbase.h" + +class Posix_QextSerialPort:public QextSerialBase { +public: + Posix_QextSerialPort(); + Posix_QextSerialPort(const Posix_QextSerialPort& s); + Posix_QextSerialPort(const QString & name); + Posix_QextSerialPort(const PortSettings& settings); + Posix_QextSerialPort(const QString & name, const PortSettings& settings); + Posix_QextSerialPort& operator=(const Posix_QextSerialPort& s); + virtual ~Posix_QextSerialPort(); + + virtual void setBaudRate(BaudRateType); + virtual void setDataBits(DataBitsType); + virtual void setParity(ParityType); + virtual void setStopBits(StopBitsType); + virtual void setFlowControl(FlowType); + virtual void setTimeout(ulong, ulong); + + virtual bool open(OpenMode mode=0); + virtual void close(); + virtual void flush(); + + virtual qint64 size() const; + virtual qint64 bytesAvailable(); + + virtual void ungetChar(char c); + + virtual void translateError(ulong error); + + virtual void setDtr(bool set=true); + virtual void setRts(bool set=true); + virtual ulong lineStatus(); + + QFile* Posix_File; +protected: + //QFile* Posix_File; + struct termios Posix_CommConfig; + struct timeval Posix_Timeout; + struct timeval Posix_Copy_Timeout; + + virtual qint64 readData(char * data, qint64 maxSize); + virtual qint64 writeData(const char * data, qint64 maxSize); +}; + +#endif diff --git a/machine/qextserial/qextserialbase.cpp b/machine/qextserial/qextserialbase.cpp new file mode 100644 index 0000000..027913d --- /dev/null +++ b/machine/qextserial/qextserialbase.cpp @@ -0,0 +1,250 @@ + +#include "qextserialbase.h" + +/*! +\class QextSerialBase +\version 1.0.0 +\author Stefan Sander + +A common base class for Win_QextSerialBase, Posix_QextSerialBase and QextSerialPort. +*/ +#ifdef QT_THREAD_SUPPORT +QMutex* QextSerialBase::mutex=NULL; +unsigned long QextSerialBase::refCount=0; +#endif + +/*! +\fn QextSerialBase::QextSerialBase() +Default constructor. +*/ +QextSerialBase::QextSerialBase() + : QIODevice() +{ + +#ifdef _TTY_WIN_ + setPortName("COM1"); + +#elif defined(_TTY_IRIX_) + setPortName("/dev/ttyf1"); + +#elif defined(_TTY_HPUX_) + setPortName("/dev/tty1p0"); + +#elif defined(_TTY_SUN_) + setPortName("/dev/ttya"); + +#elif defined(_TTY_DIGITAL_) + setPortName("/dev/tty01"); + +#elif defined(_TTY_FREEBSD_) + setPortName("/dev/ttyd1"); + +#else + setPortName("/dev/ttyS0"); +#endif + + construct(); +} + +/*! +\fn QextSerialBase::QextSerialBase(const QString & name) +Construct a port and assign it to the device specified by the name parameter. +*/ +QextSerialBase::QextSerialBase(const QString & name) + : QIODevice() +{ + setPortName(name); + construct(); +} + +/*! +\fn QextSerialBase::~QextSerialBase() +Standard destructor. +*/ +QextSerialBase::~QextSerialBase() +{ + +#ifdef QT_THREAD_SUPPORT + refCount--; + if (mutex && refCount==0) { + delete mutex; + mutex=NULL; + } +#endif + +} + +/*! +\fn void QextSerialBase::construct() +Common constructor function for setting up default port settings. +(115200 Baud, 8N1, Hardware flow control where supported, otherwise no flow control, and 500 ms timeout). +*/ +void QextSerialBase::construct() +{ + Settings.BaudRate=BAUD115200; + Settings.DataBits=DATA_8; + Settings.Parity=PAR_NONE; + Settings.StopBits=STOP_1; + Settings.FlowControl=FLOW_HARDWARE; + Settings.Timeout_Sec=0; + Settings.Timeout_Millisec=500; + +#ifdef QT_THREAD_SUPPORT + if (!mutex) { + mutex=new QMutex( QMutex::Recursive ); + } + refCount++; +#endif + + setOpenMode(QIODevice::NotOpen); +} + +/*! +\fn void QextSerialBase::setPortName(const QString & name) +Sets the name of the device associated with the object, e.g. "COM1", or "/dev/ttyS0". +*/ +void QextSerialBase::setPortName(const QString & name) +{ + port = name; +} + +/*! +\fn QString QextSerialBase::portName() const +Returns the name set by setPortName(). +*/ +QString QextSerialBase::portName() const +{ + return port; +} + +/*! +\fn BaudRateType QextSerialBase::baudRate(void) const +Returns the baud rate of the serial port. For a list of possible return values see +the definition of the enum BaudRateType. +*/ +BaudRateType QextSerialBase::baudRate(void) const +{ + return Settings.BaudRate; +} + +/*! +\fn DataBitsType QextSerialBase::dataBits() const +Returns the number of data bits used by the port. For a list of possible values returned by +this function, see the definition of the enum DataBitsType. +*/ +DataBitsType QextSerialBase::dataBits() const +{ + return Settings.DataBits; +} + +/*! +\fn ParityType QextSerialBase::parity() const +Returns the type of parity used by the port. For a list of possible values returned by +this function, see the definition of the enum ParityType. +*/ +ParityType QextSerialBase::parity() const +{ + return Settings.Parity; +} + +/*! +\fn StopBitsType QextSerialBase::stopBits() const +Returns the number of stop bits used by the port. For a list of possible return values, see +the definition of the enum StopBitsType. +*/ +StopBitsType QextSerialBase::stopBits() const +{ + return Settings.StopBits; +} + +/*! +\fn FlowType QextSerialBase::flowControl() const +Returns the type of flow control used by the port. For a list of possible values returned +by this function, see the definition of the enum FlowType. +*/ +FlowType QextSerialBase::flowControl() const +{ + return Settings.FlowControl; +} + +/*! +\fn bool QextSerialBase::isSequential() const +Returns true if device is sequential, otherwise returns false. Serial port is sequential device +so this function always returns true. Check QIODevice::isSequential() documentation for more +information. +*/ +bool QextSerialBase::isSequential() const +{ + return true; +} + +/*! +\fn bool QextSerialBase::atEnd() const +This function will return true if the input buffer is empty (or on error), and false otherwise. +Call QextSerialBase::lastError() for error information. +*/ +bool QextSerialBase::atEnd() const +{ + if (size()) { + return true; + } + return false; +} + +/*! +\fn qint64 QextSerialBase::readLine(char * data, qint64 maxSize) +This function will read a line of buffered input from the port, stopping when either maxSize bytes +have been read, the port has no more data available, or a newline is encountered. +The value returned is the length of the string that was read. +*/ +qint64 QextSerialBase::readLine(char * data, qint64 maxSize) +{ + qint64 numBytes = bytesAvailable(); + char* pData = data; + + if (maxSize < 2) //maxSize must be larger than 1 + return -1; + + /*read a byte at a time for MIN(bytesAvail, maxSize - 1) iterations, or until a newline*/ + while (pData<(data+numBytes) && --maxSize) { + readData(pData, 1); + if (*pData++ == '\n') { + break; + } + } + *pData='\0'; + + /*return size of data read*/ + return (pData-data); +} + +/*! +\fn ulong QextSerialBase::lastError() const +Returns the code for the last error encountered by the port, or E_NO_ERROR if the last port +operation was successful. Possible error codes are: + +\verbatim +Error Explanation +--------------------------- ------------------------------------------------------------- +E_NO_ERROR No Error has occured +E_INVALID_FD Invalid file descriptor (port was not opened correctly) +E_NO_MEMORY Unable to allocate memory tables (POSIX) +E_CAUGHT_NON_BLOCKED_SIGNAL Caught a non-blocked signal (POSIX) +E_PORT_TIMEOUT Operation timed out (POSIX) +E_INVALID_DEVICE The file opened by the port is not a character device (POSIX) +E_BREAK_CONDITION The port detected a break condition +E_FRAMING_ERROR The port detected a framing error + (usually caused by incorrect baud rate settings) +E_IO_ERROR There was an I/O error while communicating with the port +E_BUFFER_OVERRUN Character buffer overrun +E_RECEIVE_OVERFLOW Receive buffer overflow +E_RECEIVE_PARITY_ERROR The port detected a parity error in the received data +E_TRANSMIT_OVERFLOW Transmit buffer overflow +E_READ_FAILED General read operation failure +E_WRITE_FAILED General write operation failure +\endverbatim +*/ +ulong QextSerialBase::lastError() const +{ + return lastErr; +} diff --git a/machine/qextserial/qextserialbase.h b/machine/qextserial/qextserialbase.h new file mode 100644 index 0000000..cd8fcac --- /dev/null +++ b/machine/qextserial/qextserialbase.h @@ -0,0 +1,196 @@ + +#ifndef _QEXTSERIALBASE_H_ +#define _QEXTSERIALBASE_H_ + +#include +#include + +#ifdef QT_THREAD_SUPPORT +#include +#include +#endif + +/*if all warning messages are turned off, flag portability warnings to be turned off as well*/ +#ifdef _TTY_NOWARN_ +#define _TTY_NOWARN_PORT_ +#endif + +/*macros for thread support*/ +#ifdef QT_THREAD_SUPPORT +#define LOCK_MUTEX() mutex->lock() +#define UNLOCK_MUTEX() mutex->unlock() +#else +#define LOCK_MUTEX() +#define UNLOCK_MUTEX() +#endif + +/*macros for warning messages*/ +#ifdef _TTY_NOWARN_PORT_ +#define TTY_PORTABILITY_WARNING(s) +#else +#define TTY_PORTABILITY_WARNING(s) qWarning(s) +#endif +#ifdef _TTY_NOWARN_ +#define TTY_WARNING(s) +#else +#define TTY_WARNING(s) qWarning(s) +#endif + + +/*line status constants*/ +#define LS_CTS 0x01 +#define LS_DSR 0x02 +#define LS_DCD 0x04 +#define LS_RI 0x08 +#define LS_RTS 0x10 +#define LS_DTR 0x20 +#define LS_ST 0x40 +#define LS_SR 0x80 + +/*error constants*/ +#define E_NO_ERROR 0 +#define E_INVALID_FD 1 +#define E_NO_MEMORY 2 +#define E_CAUGHT_NON_BLOCKED_SIGNAL 3 +#define E_PORT_TIMEOUT 4 +#define E_INVALID_DEVICE 5 +#define E_BREAK_CONDITION 6 +#define E_FRAMING_ERROR 7 +#define E_IO_ERROR 8 +#define E_BUFFER_OVERRUN 9 +#define E_RECEIVE_OVERFLOW 10 +#define E_RECEIVE_PARITY_ERROR 11 +#define E_TRANSMIT_OVERFLOW 12 +#define E_READ_FAILED 13 +#define E_WRITE_FAILED 14 + +/*enums for port settings*/ +enum NamingConvention { + WIN_NAMES, + IRIX_NAMES, + HPUX_NAMES, + SUN_NAMES, + DIGITAL_NAMES, + FREEBSD_NAMES, + LINUX_NAMES +}; + +enum BaudRateType { + BAUD50, //POSIX ONLY + BAUD75, //POSIX ONLY + BAUD110, + BAUD134, //POSIX ONLY + BAUD150, //POSIX ONLY + BAUD200, //POSIX ONLY + BAUD300, + BAUD600, + BAUD1200, + BAUD1800, //POSIX ONLY + BAUD2400, + BAUD4800, + BAUD9600, + BAUD14400, //WINDOWS ONLY + BAUD19200, + BAUD38400, + BAUD56000, //WINDOWS ONLY + BAUD57600, + BAUD76800, //POSIX ONLY + BAUD115200, + BAUD128000, //WINDOWS ONLY + BAUD256000 //WINDOWS ONLY +}; + +enum DataBitsType { + DATA_5, + DATA_6, + DATA_7, + DATA_8 +}; + +enum ParityType { + PAR_NONE, + PAR_ODD, + PAR_EVEN, + PAR_MARK, //WINDOWS ONLY + PAR_SPACE +}; + +enum StopBitsType { + STOP_1, + STOP_1_5, //WINDOWS ONLY + STOP_2 +}; + +enum FlowType { + FLOW_OFF, + FLOW_HARDWARE, + FLOW_XONXOFF +}; + +/*structure to contain port settings*/ +struct PortSettings { + BaudRateType BaudRate; + DataBitsType DataBits; + ParityType Parity; + StopBitsType StopBits; + FlowType FlowControl; + ulong Timeout_Sec; + ulong Timeout_Millisec; +}; + +class QextSerialBase : public QIODevice { +public: + QextSerialBase(); + QextSerialBase(const QString & name); + virtual ~QextSerialBase(); + virtual void construct(); + virtual void setPortName(const QString & name); + virtual QString portName() const; + + virtual void setBaudRate(BaudRateType)=0; + virtual BaudRateType baudRate() const; + virtual void setDataBits(DataBitsType)=0; + virtual DataBitsType dataBits() const; + virtual void setParity(ParityType)=0; + virtual ParityType parity() const; + virtual void setStopBits(StopBitsType)=0; + virtual StopBitsType stopBits() const; + virtual void setFlowControl(FlowType)=0; + virtual FlowType flowControl() const; + virtual void setTimeout(ulong, ulong)=0; + + virtual bool open(OpenMode mode=0)=0; + virtual bool isSequential() const; + virtual void close()=0; + virtual void flush()=0; + + virtual qint64 size() const=0; + virtual qint64 bytesAvailable()=0; + virtual bool atEnd() const; + + virtual void ungetChar(char c)=0; + virtual qint64 readLine(char * data, qint64 maxSize); + + virtual ulong lastError() const; + virtual void translateError(ulong error)=0; + + virtual void setDtr(bool set=true)=0; + virtual void setRts(bool set=true)=0; + virtual ulong lineStatus()=0; + +protected: + QString port; + PortSettings Settings; + ulong lastErr; + +#ifdef QT_THREAD_SUPPORT + static QMutex* mutex; + static ulong refCount; +#endif + + virtual qint64 readData(char * data, qint64 maxSize)=0; + virtual qint64 writeData(const char * data, qint64 maxSize)=0; + +}; + +#endif diff --git a/machine/qextserial/qextserialport.cpp b/machine/qextserial/qextserialport.cpp new file mode 100644 index 0000000..1c0d9bf --- /dev/null +++ b/machine/qextserial/qextserialport.cpp @@ -0,0 +1,98 @@ + +/*! +\class QextSerialPort +\version 1.0.0 +\author Stefan Sander + +A cross-platform serial port class. +This class encapsulates a serial port on both POSIX and Windows systems. The user will be +notified of errors and possible portability conflicts at run-time by default - this behavior can +be turned off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn +off portability warnings) in the project. + +\note +On Windows NT/2000/XP this class uses Win32 serial port functions by default. The user may +select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can +make no guarantees as to the quality of POSIX support under NT/2000 however. + +*/ + +#include +#include "qextserialport.h" + +/*! +\fn QextSerialPort::QextSerialPort() +Default constructor. Note that the naming convention used by a QextSerialPort constructed with +this constructor will be determined by #defined constants, or lack thereof - the default behavior +is the same as _TTY_LINUX_. Possible naming conventions and their associated constants are: + +\verbatim + +Constant Used By Naming Convention +---------- ------------- ------------------------ +_TTY_WIN_ Windows COM1, COM2 +_TTY_IRIX_ SGI/IRIX /dev/ttyf1, /dev/ttyf2 +_TTY_HPUX_ HP-UX /dev/tty1p0, /dev/tty2p0 +_TTY_SUN_ SunOS/Solaris /dev/ttya, /dev/ttyb +_TTY_DIGITAL_ Digital UNIX /dev/tty01, /dev/tty02 +_TTY_FREEBSD_ FreeBSD /dev/ttyd0, /dev/ttyd1 +_TTY_LINUX_ Linux /dev/ttyS0, /dev/ttyS1 + Linux /dev/ttyS0, /dev/ttyS1 +\endverbatim + +The object will be associated with the first port in the system, e.g. COM1 on Windows systems. +See the other constructors if you need to use a port other than the first. +*/ +QextSerialPort::QextSerialPort() + : QextBaseType() +{} + +/*! +\fn QextSerialPort::QextSerialPort(const QString & name) +Constructs a serial port attached to the port specified by name. +name is the name of the device, which is windowsystem-specific, +e.g."COM1" or "/dev/ttyS0". +*/ +QextSerialPort::QextSerialPort(const QString & name) + : QextBaseType(name) +{} + +/*! +\fn QextSerialPort::QextSerialPort(PortSettings const& settings) +Constructs a port with default name and settings specified by the settings parameter. +*/ +QextSerialPort::QextSerialPort(PortSettings const& settings) + : QextBaseType(settings) +{} + +/*! +\fn QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings) +Constructs a port with the name and settings specified. +*/ +QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings) + : QextBaseType(name, settings) +{} + +/*! +\fn QextSerialPort::QextSerialPort(const QextSerialPort& s) +Copy constructor. +*/ +QextSerialPort::QextSerialPort(const QextSerialPort& s) + : QextBaseType(s) +{} + +/*! +\fn QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s) +Overrides the = operator. +*/ +QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s) +{ + return (QextSerialPort&)QextBaseType::operator=(s); +} + +/*! +\fn QextSerialPort::~QextSerialPort() +Standard destructor. +*/ +QextSerialPort::~QextSerialPort() +{} diff --git a/machine/qextserial/qextserialport.h b/machine/qextserial/qextserialport.h new file mode 100644 index 0000000..c1c296e --- /dev/null +++ b/machine/qextserial/qextserialport.h @@ -0,0 +1,27 @@ + +#ifndef _QEXTSERIALPORT_H_ +#define _QEXTSERIALPORT_H_ + +/*POSIX CODE*/ +#ifdef _TTY_POSIX_ +#include "posix_qextserialport.h" +#define QextBaseType Posix_QextSerialPort + +/*MS WINDOWS CODE*/ +#else +#include "win_qextserialport.h" +#define QextBaseType Win_QextSerialPort +#endif + +class QextSerialPort: public QextBaseType { +public: + QextSerialPort(); + QextSerialPort(const QString & name); + QextSerialPort(PortSettings const& s); + QextSerialPort(const QString & name, PortSettings const& s); + QextSerialPort(const QextSerialPort& s); + QextSerialPort& operator=(const QextSerialPort&); + virtual ~QextSerialPort(); +}; + +#endif diff --git a/machine/qextserial/win_qextserialport.cpp b/machine/qextserial/win_qextserialport.cpp new file mode 100644 index 0000000..9c2434d --- /dev/null +++ b/machine/qextserial/win_qextserialport.cpp @@ -0,0 +1,880 @@ +/*! +\class Win_QextSerialPort +\version 1.0.0 +\author Stefan Sander + +A cross-platform serial port class. +This class encapsulates the Windows portion of QextSerialPort. The user will be notified of +errors and possible portability conflicts at run-time by default - this behavior can be turned +off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off +portability warnings) in the project. Note that defining _TTY_NOWARN_ also defines +_TTY_NOWARN_PORT_. + +\note +On Windows NT/2000/XP this class uses Win32 serial port functions by default. The user may +select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can +make no guarantees as to the quality of POSIX support under NT/2000 however. + +*/ + +#include +#include "win_qextserialport.h" + +/*! +\fn Win_QextSerialPort::Win_QextSerialPort() +Default constructor. Note that the name of the device used by a Win_QextSerialPort constructed +with this constructor will be determined by #defined constants, or lack thereof - the default +behavior is the same as _TTY_LINUX_. Possible naming conventions and their associated constants +are: + +\verbatim + +Constant Used By Naming Convention +---------- ------------- ------------------------ +_TTY_WIN_ Windows COM1, COM2 +_TTY_IRIX_ SGI/IRIX /dev/ttyf1, /dev/ttyf2 +_TTY_HPUX_ HP-UX /dev/tty1p0, /dev/tty2p0 +_TTY_SUN_ SunOS/Solaris /dev/ttya, /dev/ttyb +_TTY_DIGITAL_ Digital UNIX /dev/tty01, /dev/tty02 +_TTY_FREEBSD_ FreeBSD /dev/ttyd0, /dev/ttyd1 +_TTY_LINUX_ Linux /dev/ttyS0, /dev/ttyS1 + Linux /dev/ttyS0, /dev/ttyS1 +\endverbatim + +This constructor associates the object with the first port on the system, e.g. COM1 for Windows +platforms. See the other constructor if you need a port other than the first. +*/ +Win_QextSerialPort::Win_QextSerialPort():QextSerialBase() { + Win_Handle=INVALID_HANDLE_VALUE; +} + +/*!Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort&) +Copy constructor. +*/ +Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort& s):QextSerialBase(s.port) { + Win_Handle=INVALID_HANDLE_VALUE; + setOpenMode(s.openMode()); + lastErr=s.lastErr; + port = s.port; + Settings.FlowControl=s.Settings.FlowControl; + Settings.Parity=s.Settings.Parity; + Settings.DataBits=s.Settings.DataBits; + Settings.StopBits=s.Settings.StopBits; + Settings.BaudRate=s.Settings.BaudRate; + Win_Handle=s.Win_Handle; + memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG)); + memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS)); +} + +/*! +\fn Win_QextSerialPort::Win_QextSerialPort(const QString & name) +Constructs a serial port attached to the port specified by devName. +devName is the name of the device, which is windowsystem-specific, +e.g."COM2" or "/dev/ttyS0". +*/ +Win_QextSerialPort::Win_QextSerialPort(const QString & name):QextSerialBase(name) { + Win_Handle=INVALID_HANDLE_VALUE; +} + +/*! +\fn Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings) +Constructs a port with default name and specified settings. +*/ +Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings) { + Win_Handle=INVALID_HANDLE_VALUE; + setBaudRate(settings.BaudRate); + setDataBits(settings.DataBits); + setStopBits(settings.StopBits); + setParity(settings.Parity); + setFlowControl(settings.FlowControl); + setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec); +} + +/*! +\fn Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings) +Constructs a port with specified name and settings. +*/ +Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings) { + Win_Handle=INVALID_HANDLE_VALUE; + setPortName(name); + setBaudRate(settings.BaudRate); + setDataBits(settings.DataBits); + setStopBits(settings.StopBits); + setParity(settings.Parity); + setFlowControl(settings.FlowControl); + setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec); +} + +/*! +\fn Win_QextSerialPort::~Win_QextSerialPort() +Standard destructor. +*/ +Win_QextSerialPort::~Win_QextSerialPort() { + if (isOpen()) { + close(); + } +} + +/*! +\fn Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s) +overrides the = operator +*/ +Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s) { + setOpenMode(s.openMode()); + lastErr=s.lastErr; + port = s.port; + Settings.FlowControl=s.Settings.FlowControl; + Settings.Parity=s.Settings.Parity; + Settings.DataBits=s.Settings.DataBits; + Settings.StopBits=s.Settings.StopBits; + Settings.BaudRate=s.Settings.BaudRate; + Win_Handle=s.Win_Handle; + memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG)); + memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS)); + return *this; +} + +/*! +\fn bool Win_QextSerialPort::open(OpenMode mode) +Opens a serial port. Note that this function does not specify which device to open. If you need +to open a device by name, see Win_QextSerialPort::open(const char*). This function has no effect +if the port associated with the class is already open. The port is also configured to the current +settings, as stored in the Settings structure. +*/ +bool Win_QextSerialPort::open(OpenMode mode) { + unsigned long confSize = sizeof(COMMCONFIG); + Win_CommConfig.dwSize = confSize; + + LOCK_MUTEX(); + if (mode == QIODevice::NotOpen) + return isOpen(); + if (!isOpen()) { + /*open the port*/ + Win_Handle=CreateFileA(port.toLatin1(), GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + if (Win_Handle!=INVALID_HANDLE_VALUE) { + /*set open mode*/ + QIODevice::open(mode); + + /*configure port settings*/ + GetCommConfig(Win_Handle, &Win_CommConfig, &confSize); + GetCommState(Win_Handle, &(Win_CommConfig.dcb)); + + /*set up parameters*/ + Win_CommConfig.dcb.fBinary=TRUE; + Win_CommConfig.dcb.fInX=FALSE; + Win_CommConfig.dcb.fOutX=FALSE; + Win_CommConfig.dcb.fAbortOnError=FALSE; + Win_CommConfig.dcb.fNull=FALSE; + setBaudRate(Settings.BaudRate); + setDataBits(Settings.DataBits); + setStopBits(Settings.StopBits); + setParity(Settings.Parity); + setFlowControl(Settings.FlowControl); + setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec); + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + } + } + UNLOCK_MUTEX(); + return isOpen(); +} + +/*! +\fn void Win_QextSerialPort::close() +Closes a serial port. This function has no effect if the serial port associated with the class +is not currently open. +*/ +void Win_QextSerialPort::close() { + LOCK_MUTEX(); + CloseHandle(Win_Handle); + QIODevice::close(); + UNLOCK_MUTEX(); +} + +/*! +\fn void Win_QextSerialPort::flush() +Flushes all pending I/O to the serial port. This function has no effect if the serial port +associated with the class is not currently open. +*/ +void Win_QextSerialPort::flush() { + LOCK_MUTEX(); + if (isOpen()) { + FlushFileBuffers(Win_Handle); + } + UNLOCK_MUTEX(); +} + +/*! +\fn qint64 Win_QextSerialPort::size() const +This function will return the number of bytes waiting in the receive queue of the serial port. +It is included primarily to provide a complete QIODevice interface, and will not record errors +in the lastErr member (because it is const). This function is also not thread-safe - in +multithreading situations, use Win_QextSerialPort::bytesAvailable() instead. +*/ +qint64 Win_QextSerialPort::size() const { + int availBytes; + COMSTAT Win_ComStat; + DWORD Win_ErrorMask=0; + ClearCommError(Win_Handle, &Win_ErrorMask, &Win_ComStat); + availBytes = Win_ComStat.cbInQue; + return (qint64)availBytes; +} + +/*! +\fn qint64 Win_QextSerialPort::bytesAvailable() +Returns the number of bytes waiting in the port's receive queue. This function will return 0 if +the port is not currently open, or -1 on error. Error information can be retrieved by calling +Win_QextSerialPort::getLastError(). +*/ +qint64 Win_QextSerialPort::bytesAvailable() { + LOCK_MUTEX(); + if (isOpen()) { + DWORD Errors; + COMSTAT Status; + bool success=ClearCommError(Win_Handle, &Errors, &Status); + translateError(Errors); + if (success) { + lastErr=E_NO_ERROR; + UNLOCK_MUTEX(); + return Status.cbInQue + QIODevice::bytesAvailable(); + } + UNLOCK_MUTEX(); + return (unsigned int)-1; + } + UNLOCK_MUTEX(); + return 0; +} + +/*! +\fn void Win_QextSerialPort::translateError(ulong error) +Translates a system-specific error code to a QextSerialPort error code. Used internally. +*/ +void Win_QextSerialPort::translateError(ulong error) { + if (error&CE_BREAK) { + lastErr=E_BREAK_CONDITION; + } + else if (error&CE_FRAME) { + lastErr=E_FRAMING_ERROR; + } + else if (error&CE_IOE) { + lastErr=E_IO_ERROR; + } + else if (error&CE_MODE) { + lastErr=E_INVALID_FD; + } + else if (error&CE_OVERRUN) { + lastErr=E_BUFFER_OVERRUN; + } + else if (error&CE_RXPARITY) { + lastErr=E_RECEIVE_PARITY_ERROR; + } + else if (error&CE_RXOVER) { + lastErr=E_RECEIVE_OVERFLOW; + } + else if (error&CE_TXFULL) { + lastErr=E_TRANSMIT_OVERFLOW; + } +} + +/*! +\fn qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize) +Reads a block of data from the serial port. This function will read at most maxlen bytes from +the serial port and place them in the buffer pointed to by data. Return value is the number of +bytes actually read, or -1 on error. + +\warning before calling this function ensure that serial port associated with this class +is currently open (use isOpen() function to check if port is open). +*/ +qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize) +{ + LOCK_MUTEX(); + int retVal=0; + COMSTAT Win_ComStat; + DWORD Win_BytesRead=0; + DWORD Win_ErrorMask=0; + ClearCommError(Win_Handle, &Win_ErrorMask, &Win_ComStat); + if (Win_ComStat.cbInQue && + (!ReadFile(Win_Handle, (void*)data, (DWORD)maxSize, &Win_BytesRead, NULL) + || Win_BytesRead==0)) { + lastErr=E_READ_FAILED; + retVal=-1; + } + else { + retVal=((int)Win_BytesRead); + } + UNLOCK_MUTEX(); + + return retVal; +} + +/*! +\fn qint64 Win_QextSerialPort::writeData(const char *data, qint64 maxSize) +Writes a block of data to the serial port. This function will write len bytes +from the buffer pointed to by data to the serial port. Return value is the number +of bytes actually written, or -1 on error. + +\warning before calling this function ensure that serial port associated with this class +is currently open (use isOpen() function to check if port is open). +*/ +qint64 Win_QextSerialPort::writeData(const char *data, qint64 maxSize) +{ + LOCK_MUTEX(); + int retVal=0; + DWORD Win_BytesWritten; + if (!WriteFile(Win_Handle, (void*)data, (DWORD)maxSize, &Win_BytesWritten, NULL)) { + lastErr=E_WRITE_FAILED; + retVal=-1; + } + else { + retVal=((int)Win_BytesWritten); + } + UNLOCK_MUTEX(); + + flush(); + return retVal; +} + +/*! +\fn void Win_QextSerialPort::ungetChar(char c) +This function is included to implement the full QIODevice interface, and currently has no +purpose within this class. This function is meaningless on an unbuffered device and currently +only prints a warning message to that effect. +*/ +void Win_QextSerialPort::ungetChar(char c) { + if (c == c) + { + + } + /*meaningless on unbuffered sequential device - return error and print a warning*/ + TTY_WARNING("Win_QextSerialPort: ungetChar() called on an unbuffered sequential device - operation is meaningless"); +} + +/*! +\fn void Win_QextSerialPort::setFlowControl(FlowType flow) +Sets the flow control used by the port. Possible values of flow are: +\verbatim + FLOW_OFF No flow control + FLOW_HARDWARE Hardware (RTS/CTS) flow control + FLOW_XONXOFF Software (XON/XOFF) flow control +\endverbatim +*/ +void Win_QextSerialPort::setFlowControl(FlowType flow) { + LOCK_MUTEX(); + if (Settings.FlowControl!=flow) { + Settings.FlowControl=flow; + } + if (isOpen()) { + switch(flow) { + + /*no flow control*/ + case FLOW_OFF: + Win_CommConfig.dcb.fOutxCtsFlow=FALSE; + Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE; + Win_CommConfig.dcb.fInX=FALSE; + Win_CommConfig.dcb.fOutX=FALSE; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + break; + + /*software (XON/XOFF) flow control*/ + case FLOW_XONXOFF: + Win_CommConfig.dcb.fOutxCtsFlow=FALSE; + Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_DISABLE; + Win_CommConfig.dcb.fInX=TRUE; + Win_CommConfig.dcb.fOutX=TRUE; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + break; + + case FLOW_HARDWARE: + Win_CommConfig.dcb.fOutxCtsFlow=TRUE; + Win_CommConfig.dcb.fRtsControl=RTS_CONTROL_HANDSHAKE; + Win_CommConfig.dcb.fInX=FALSE; + Win_CommConfig.dcb.fOutX=FALSE; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + break; + } + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Win_QextSerialPort::setParity(ParityType parity) +Sets the parity associated with the serial port. The possible values of parity are: +\verbatim + PAR_SPACE Space Parity + PAR_MARK Mark Parity + PAR_NONE No Parity + PAR_EVEN Even Parity + PAR_ODD Odd Parity +\endverbatim +*/ +void Win_QextSerialPort::setParity(ParityType parity) { + LOCK_MUTEX(); + if (Settings.Parity!=parity) { + Settings.Parity=parity; + } + if (isOpen()) { + Win_CommConfig.dcb.Parity=(unsigned char)parity; + switch (parity) { + + /*space parity*/ + case PAR_SPACE: + if (Settings.DataBits==DATA_8) { + TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: Space parity with 8 data bits is not supported by POSIX systems."); + } + Win_CommConfig.dcb.fParity=TRUE; + break; + + /*mark parity - WINDOWS ONLY*/ + case PAR_MARK: + TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: Mark parity is not supported by POSIX systems"); + Win_CommConfig.dcb.fParity=TRUE; + break; + + /*no parity*/ + case PAR_NONE: + Win_CommConfig.dcb.fParity=FALSE; + break; + + /*even parity*/ + case PAR_EVEN: + Win_CommConfig.dcb.fParity=TRUE; + break; + + /*odd parity*/ + case PAR_ODD: + Win_CommConfig.dcb.fParity=TRUE; + break; + } + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Win_QextSerialPort::setDataBits(DataBitsType dataBits) +Sets the number of data bits used by the serial port. Possible values of dataBits are: +\verbatim + DATA_5 5 data bits + DATA_6 6 data bits + DATA_7 7 data bits + DATA_8 8 data bits +\endverbatim + +\note +This function is subject to the following restrictions: +\par + 5 data bits cannot be used with 2 stop bits. +\par + 1.5 stop bits can only be used with 5 data bits. +\par + 8 data bits cannot be used with space parity on POSIX systems. + +*/ +void Win_QextSerialPort::setDataBits(DataBitsType dataBits) { + LOCK_MUTEX(); + if (Settings.DataBits!=dataBits) { + if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) || + (Settings.StopBits==STOP_1_5 && dataBits!=DATA_5)) { + } + else { + Settings.DataBits=dataBits; + } + } + if (isOpen()) { + switch(dataBits) { + + /*5 data bits*/ + case DATA_5: + if (Settings.StopBits==STOP_2) { + TTY_WARNING("Win_QextSerialPort: 5 Data bits cannot be used with 2 stop bits."); + } + else { + Win_CommConfig.dcb.ByteSize=5; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + } + break; + + /*6 data bits*/ + case DATA_6: + if (Settings.StopBits==STOP_1_5) { + TTY_WARNING("Win_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits."); + } + else { + Win_CommConfig.dcb.ByteSize=6; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + } + break; + + /*7 data bits*/ + case DATA_7: + if (Settings.StopBits==STOP_1_5) { + TTY_WARNING("Win_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits."); + } + else { + Win_CommConfig.dcb.ByteSize=7; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + } + break; + + /*8 data bits*/ + case DATA_8: + if (Settings.StopBits==STOP_1_5) { + TTY_WARNING("Win_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits."); + } + else { + Win_CommConfig.dcb.ByteSize=8; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + } + break; + } + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Win_QextSerialPort::setStopBits(StopBitsType stopBits) +Sets the number of stop bits used by the serial port. Possible values of stopBits are: +\verbatim + STOP_1 1 stop bit + STOP_1_5 1.5 stop bits + STOP_2 2 stop bits +\endverbatim + +\note +This function is subject to the following restrictions: +\par + 2 stop bits cannot be used with 5 data bits. +\par + 1.5 stop bits cannot be used with 6 or more data bits. +\par + POSIX does not support 1.5 stop bits. +*/ +void Win_QextSerialPort::setStopBits(StopBitsType stopBits) { + LOCK_MUTEX(); + if (Settings.StopBits!=stopBits) { + if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) || + (stopBits==STOP_1_5 && Settings.DataBits!=DATA_5)) { + } + else { + Settings.StopBits=stopBits; + } + } + if (isOpen()) { + switch (stopBits) { + + /*one stop bit*/ + case STOP_1: + Win_CommConfig.dcb.StopBits=ONESTOPBIT; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + break; + + /*1.5 stop bits*/ + case STOP_1_5: + TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: 1.5 stop bit operation is not supported by POSIX."); + if (Settings.DataBits!=DATA_5) { + TTY_WARNING("Win_QextSerialPort: 1.5 stop bits can only be used with 5 data bits"); + } + else { + Win_CommConfig.dcb.StopBits=ONE5STOPBITS; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + } + break; + + /*two stop bits*/ + case STOP_2: + if (Settings.DataBits==DATA_5) { + TTY_WARNING("Win_QextSerialPort: 2 stop bits cannot be used with 5 data bits"); + } + else { + Win_CommConfig.dcb.StopBits=TWOSTOPBITS; + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + } + break; + } + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Win_QextSerialPort::setBaudRate(BaudRateType baudRate) +Sets the baud rate of the serial port. Note that not all rates are applicable on +all platforms. The following table shows translations of the various baud rate +constants on Windows(including NT/2000) and POSIX platforms. Speeds marked with an * +are speeds that are usable on both Windows and POSIX. +\verbatim + + RATE Windows Speed POSIX Speed + ----------- ------------- ----------- + BAUD50 110 50 + BAUD75 110 75 + *BAUD110 110 110 + BAUD134 110 134.5 + BAUD150 110 150 + BAUD200 110 200 + *BAUD300 300 300 + *BAUD600 600 600 + *BAUD1200 1200 1200 + BAUD1800 1200 1800 + *BAUD2400 2400 2400 + *BAUD4800 4800 4800 + *BAUD9600 9600 9600 + BAUD14400 14400 9600 + *BAUD19200 19200 19200 + *BAUD38400 38400 38400 + BAUD56000 56000 38400 + *BAUD57600 57600 57600 + BAUD76800 57600 76800 + *BAUD115200 115200 115200 + BAUD128000 128000 115200 + BAUD256000 256000 115200 +\endverbatim +*/ +void Win_QextSerialPort::setBaudRate(BaudRateType baudRate) { + LOCK_MUTEX(); + if (Settings.BaudRate!=baudRate) { + switch (baudRate) { + case BAUD50: + case BAUD75: + case BAUD134: + case BAUD150: + case BAUD200: + Settings.BaudRate=BAUD110; + break; + + case BAUD1800: + Settings.BaudRate=BAUD1200; + break; + + case BAUD76800: + Settings.BaudRate=BAUD57600; + break; + + default: + Settings.BaudRate=baudRate; + break; + } + } + if (isOpen()) { + switch (baudRate) { + + /*50 baud*/ + case BAUD50: + TTY_WARNING("Win_QextSerialPort: Windows does not support 50 baud operation. Switching to 110 baud."); + Win_CommConfig.dcb.BaudRate=CBR_110; + break; + + /*75 baud*/ + case BAUD75: + TTY_WARNING("Win_QextSerialPort: Windows does not support 75 baud operation. Switching to 110 baud."); + Win_CommConfig.dcb.BaudRate=CBR_110; + break; + + /*110 baud*/ + case BAUD110: + Win_CommConfig.dcb.BaudRate=CBR_110; + break; + + /*134.5 baud*/ + case BAUD134: + TTY_WARNING("Win_QextSerialPort: Windows does not support 134.5 baud operation. Switching to 110 baud."); + Win_CommConfig.dcb.BaudRate=CBR_110; + break; + + /*150 baud*/ + case BAUD150: + TTY_WARNING("Win_QextSerialPort: Windows does not support 150 baud operation. Switching to 110 baud."); + Win_CommConfig.dcb.BaudRate=CBR_110; + break; + + /*200 baud*/ + case BAUD200: + TTY_WARNING("Win_QextSerialPort: Windows does not support 200 baud operation. Switching to 110 baud."); + Win_CommConfig.dcb.BaudRate=CBR_110; + break; + + /*300 baud*/ + case BAUD300: + Win_CommConfig.dcb.BaudRate=CBR_300; + break; + + /*600 baud*/ + case BAUD600: + Win_CommConfig.dcb.BaudRate=CBR_600; + break; + + /*1200 baud*/ + case BAUD1200: + Win_CommConfig.dcb.BaudRate=CBR_1200; + break; + + /*1800 baud*/ + case BAUD1800: + TTY_WARNING("Win_QextSerialPort: Windows does not support 1800 baud operation. Switching to 1200 baud."); + Win_CommConfig.dcb.BaudRate=CBR_1200; + break; + + /*2400 baud*/ + case BAUD2400: + Win_CommConfig.dcb.BaudRate=CBR_2400; + break; + + /*4800 baud*/ + case BAUD4800: + Win_CommConfig.dcb.BaudRate=CBR_4800; + break; + + /*9600 baud*/ + case BAUD9600: + Win_CommConfig.dcb.BaudRate=CBR_9600; + break; + + /*14400 baud*/ + case BAUD14400: + TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 14400 baud operation."); + Win_CommConfig.dcb.BaudRate=CBR_14400; + break; + + /*19200 baud*/ + case BAUD19200: + Win_CommConfig.dcb.BaudRate=CBR_19200; + break; + + /*38400 baud*/ + case BAUD38400: + Win_CommConfig.dcb.BaudRate=CBR_38400; + break; + + /*56000 baud*/ + case BAUD56000: + TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 56000 baud operation."); + Win_CommConfig.dcb.BaudRate=CBR_56000; + break; + + /*57600 baud*/ + case BAUD57600: + Win_CommConfig.dcb.BaudRate=CBR_57600; + break; + + /*76800 baud*/ + case BAUD76800: + TTY_WARNING("Win_QextSerialPort: Windows does not support 76800 baud operation. Switching to 57600 baud."); + Win_CommConfig.dcb.BaudRate=CBR_57600; + break; + + /*115200 baud*/ + case BAUD115200: + Win_CommConfig.dcb.BaudRate=CBR_115200; + break; + + /*128000 baud*/ + case BAUD128000: + TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 128000 baud operation."); + Win_CommConfig.dcb.BaudRate=CBR_128000; + break; + + /*256000 baud*/ + case BAUD256000: + TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: POSIX does not support 256000 baud operation."); + Win_CommConfig.dcb.BaudRate=CBR_256000; + break; + } + SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Win_QextSerialPort::setDtr(bool set) +Sets DTR line to the requested state (high by default). This function will have no effect if +the port associated with the class is not currently open. +*/ +void Win_QextSerialPort::setDtr(bool set) { + LOCK_MUTEX(); + if (isOpen()) { + if (set) { + EscapeCommFunction(Win_Handle, SETDTR); + } + else { + EscapeCommFunction(Win_Handle, CLRDTR); + } + } + UNLOCK_MUTEX(); +} + +/*! +\fn void Win_QextSerialPort::setRts(bool set) +Sets RTS line to the requested state (high by default). This function will have no effect if +the port associated with the class is not currently open. +*/ +void Win_QextSerialPort::setRts(bool set) { + LOCK_MUTEX(); + if (isOpen()) { + if (set) { + EscapeCommFunction(Win_Handle, SETRTS); + } + else { + EscapeCommFunction(Win_Handle, CLRRTS); + } + } + UNLOCK_MUTEX(); +} + +/*! +\fn ulong Win_QextSerialPort::lineStatus(void) +returns the line status as stored by the port function. This function will retrieve the states +of the following lines: DCD, CTS, DSR, and RI. On POSIX systems, the following additional lines +can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD. The value returned is an unsigned +long with specific bits indicating which lines are high. The following constants should be used +to examine the states of individual lines: + +\verbatim +Mask Line +------ ---- +LS_CTS CTS +LS_DSR DSR +LS_DCD DCD +LS_RI RI +\endverbatim + +This function will return 0 if the port associated with the class is not currently open. +*/ +ulong Win_QextSerialPort::lineStatus(void) { + unsigned long Status=0, Temp=0; + LOCK_MUTEX(); + if (isOpen()) { + GetCommModemStatus(Win_Handle, &Temp); + if (Temp&MS_CTS_ON) { + Status|=LS_CTS; + } + if (Temp&MS_DSR_ON) { + Status|=LS_DSR; + } + if (Temp&MS_RING_ON) { + Status|=LS_RI; + } + if (Temp&MS_RLSD_ON) { + Status|=LS_DCD; + } + } + UNLOCK_MUTEX(); + return Status; +} + +/*! +\fn void Win_QextSerialPort::setTimeout(ulong sec, ulong millisec); +Sets the read and write timeouts for the port to sec seconds and millisec milliseconds. +*/ +void Win_QextSerialPort::setTimeout(ulong sec, ulong millisec) { + LOCK_MUTEX(); + Settings.Timeout_Sec=sec; + Settings.Timeout_Millisec=millisec; + if(isOpen()) { + Win_CommTimeouts.ReadIntervalTimeout = sec*1000+millisec; + Win_CommTimeouts.ReadTotalTimeoutMultiplier = sec*1000+millisec; + Win_CommTimeouts.ReadTotalTimeoutConstant = 0; + Win_CommTimeouts.WriteTotalTimeoutMultiplier = sec*1000+millisec; + Win_CommTimeouts.WriteTotalTimeoutConstant = 0; + SetCommTimeouts(Win_Handle, &Win_CommTimeouts); + } + UNLOCK_MUTEX(); +} diff --git a/machine/qextserial/win_qextserialport.h b/machine/qextserial/win_qextserialport.h new file mode 100644 index 0000000..46efe80 --- /dev/null +++ b/machine/qextserial/win_qextserialport.h @@ -0,0 +1,48 @@ +#ifndef _WIN_QEXTSERIALPORT_H_ +#define _WIN_QEXTSERIALPORT_H_ + +#include "qextserialbase.h" + +/*if all warning messages are turned off, flag portability warnings to be turned off as well*/ +#ifdef _TTY_NOWARN_ +#define _TTY_NOWARN_PORT_ +#endif + +#include + +class Win_QextSerialPort:public QextSerialBase { +public: + Win_QextSerialPort(); + Win_QextSerialPort(Win_QextSerialPort const& s); + Win_QextSerialPort(const QString & name); + Win_QextSerialPort(const PortSettings& settings); + Win_QextSerialPort(const QString & name, const PortSettings& settings); + Win_QextSerialPort& operator=(const Win_QextSerialPort& s); + virtual ~Win_QextSerialPort(); + virtual bool open(OpenMode mode=0); + virtual void close(); + virtual void flush(); + virtual qint64 size() const; + virtual void ungetChar(char c); + virtual void setFlowControl(FlowType); + virtual void setParity(ParityType); + virtual void setDataBits(DataBitsType); + virtual void setStopBits(StopBitsType); + virtual void setBaudRate(BaudRateType); + virtual void setDtr(bool set=true); + virtual void setRts(bool set=true); + virtual ulong lineStatus(void); + virtual qint64 bytesAvailable(); + virtual void translateError(ulong); + virtual void setTimeout(ulong, ulong); + +protected: + HANDLE Win_Handle; + COMMCONFIG Win_CommConfig; + COMMTIMEOUTS Win_CommTimeouts; + + virtual qint64 readData(char *data, qint64 maxSize); + virtual qint64 writeData(const char *data, qint64 maxSize); +}; + +#endif diff --git a/machine/tcpclient.cpp b/machine/tcpclient.cpp new file mode 100644 index 0000000..5f20ccd --- /dev/null +++ b/machine/tcpclient.cpp @@ -0,0 +1,501 @@ +#include "tcpclient.h" + +#include +#include +#include + +TcpClient::TcpClient(QObject *parent) : + QObject(parent), + m_pClientSocket(NULL), + m_pConnectCheckTimer(NULL), + m_connected(0), + m_pConnectDetectThread(NULL), + m_pConnectDetect(NULL), + m_detect(0), + m_localip(DEF_LOCAL_IP), + m_localport(DEF_LOCAL_PORT), + m_serverip(DEF_SERVER_IP), + m_serverport(DEF_SERVER_PORT) +{ + m_pClientSocket = new QBindTcpSocket(this); + m_pClientSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); + connect(m_pClientSocket, SIGNAL(readyRead()), this, SLOT(receiveServerData())); + connect(m_pClientSocket, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(displaySocketError(QAbstractSocket::SocketError))); + // connect(m_pClientSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(netStateChanged(QAbstractSocket::SocketState))); + + m_pConnectCheckTimer = new QTimer(this); + connect(m_pConnectCheckTimer, SIGNAL(timeout()), this, SLOT(connectCheck())); + + + m_pConnectDetectThread = new QThread(); +} + +TcpClient::~TcpClient() +{ + m_pConnectCheckTimer->stop(); + delete m_pConnectCheckTimer; + + m_pClientSocket->disconnectFromHost(); + m_pClientSocket->waitForDisconnected(); + m_pClientSocket->close(); + delete m_pClientSocket; + + if (m_connected != 0) + { + m_pConnectDetectThread->quit(); + m_pConnectDetectThread->wait(); + } + + delete m_pConnectDetectThread; +} + +void TcpClient::setConfigFileName(QString configfilename) +{ + m_configFileName = configfilename; +} + +void TcpClient::connectToServer() +{ + if (m_pClientSocket == NULL) + { + qDebug() << "m_pClientSocket not alloc"; + return; + } + + if (m_connected == 0) + { + loadIpAndPort(); + if (m_pConnectDetect == NULL) + { + m_pConnectDetect = new TcpConnectDetect; + } + qDebug() << "ConnectToServer"; + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + qDebug() << "serverip=" << m_serverip << "serverport=" << m_serverport; + + m_pConnectDetect->setIpAndPort(m_localip, m_localport, m_serverip, m_serverport); + + m_pConnectDetect->moveToThread(m_pConnectDetectThread); + + connect(this, SIGNAL(siDetectHost()), m_pConnectDetect, SLOT(connectDetect()), Qt::QueuedConnection); + connect(m_pConnectDetect, SIGNAL(siConnectSta(int)), this, SLOT(detectStatus(int)), Qt::QueuedConnection); + + // 20191226由于检测线程会造成网络重连,所以将检测线程注释 lft +/* + connect(m_pConnectDetectThread, SIGNAL(started()), m_pConnectDetect, SLOT(detectStart()) ); + connect(m_pConnectDetectThread, SIGNAL(finished()), m_pConnectDetect, SLOT(deleteLater()) ); // 退出删除对象 + + m_pConnectDetectThread->start(); // 启动线程 +*/ + m_pConnectCheckTimer->start(1000); + m_connected = 1; + m_detect = 1; + } +} + +void TcpClient::disConnectFromServer() +{ + if (m_connected != 0) + { + m_pConnectCheckTimer->stop(); + + if (m_pClientSocket != NULL) + { + m_pClientSocket->disconnectFromHost(); + m_pClientSocket->waitForDisconnected(); + m_pClientSocket->close(); + } + + m_pConnectDetectThread->quit(); + m_pConnectDetectThread->wait(); + + m_connected = 0; + m_detect = 0; + } +} + +void TcpClient::loadIpAndPort() +{ + if (!m_configFileName.isEmpty()) + { + // 机器的IP和端口 和 连接机器的本地IP和端口 + QSettings configIni(m_configFileName, QSettings::IniFormat); + QString serverip, localip; + quint16 serverport, localport; + + serverip = configIni.value("server/ip", QVariant("192.168.16.253")).toString(); + serverport = configIni.value("server/port", QVariant(5000)).toInt(); + localip = configIni.value("local/ip", QVariant("192.168.16.41")).toString(); + localport = configIni.value("local/port", 5001).toInt(); + + // 回写参数 + configIni.setValue("server/ip", serverip); + configIni.setValue("server/port", serverport); + configIni.setValue("local/ip", localip); + configIni.setValue("local/port", localport); + + m_localip = localip; + m_localport = localport; + m_serverip = serverip; + m_serverport = serverport; + } +} + +// 发送数据的槽 +void TcpClient::slotSendData(QByteArray dat) +{ + if (m_pClientSocket != NULL) + { + m_pClientSocket->write(dat); + } +} + +// 自动检测连接 +void TcpClient::connectCheck() +{ + if (m_pClientSocket == NULL) + { + qDebug() << "Socket is not alloced"; + return; + } + +// qDebug() << "check client connect"; + if (m_connected == 1) + { + if (m_localip.isEmpty() == false) + { + m_pClientSocket->bindAddrAndPort(m_localip, m_localport); + } + m_pClientSocket->abort(); + m_pClientSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); + m_pClientSocket->connectToHost(m_serverip, m_serverport); + int rslt = m_pClientSocket->waitForConnected(2000); + if (rslt == 0) + { + + } + /* + qDebug("bind connect and waitForConnected 2000, rslt=%d", rslt); + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + qDebug() << "serverip=" << m_serverip << "serverport=" << m_serverport; + */ + m_connected = 2; + } + else if (m_connected != 0) + { + switch(m_pClientSocket->state()) + { + case QAbstractSocket::ConnectedState: + { + if (m_connected != 3) + { + /* + qDebug() << "net State is Connected"; + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + */ + m_connected = 3; // 检测连接状态 + } + + break; + } + case QAbstractSocket::ConnectingState: + { + if (m_connected != 2) + { + qDebug() << "net State is Connecting"; + // qDebug() << "localip=" << m_localip << "localport=" << m_localport; + } + m_connected = 2; + break; + } + case QAbstractSocket::UnconnectedState: + { + if (m_connected != 1) + { + // qDebug() << "net State is unconnected"; + // qDebug() << "localip=" << m_localip << "localport=" << m_localport; + } + m_connected = 1; + break; + } + default: + { + /* + QAbstractSocket::HostLookupState + QAbstractSocket::BoundState + QAbstractSocket::ListeningState + QAbstractSocket::ClosingState + */ + { + qDebug("net State is %d\r\n", m_pClientSocket->state()); + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + qDebug() << "serverip=" << m_serverip << "serverport=" << m_serverport; + } + m_connected = 1; + } + } + } + else + { + + } + + if (m_connected == 3) // 已连接 + { + if (m_detect == 1) + { + // qDebug() << "Machine " << QThread::currentThread(); + m_detect = 0; + emit(siDetectHost()); + // qDebug() << "after send SiDetectHost "; + } + } + + emit (siConnectSta(m_connected)); // 网络连接信号 +} + +void TcpClient::detectStatus(int sta) +{ + // qDebug("host detect sta=%d", sta); + + m_detect = 1; + if (sta == 1) // 网络已断开 + { + qDebug("disconnect ClientSocket by detect"); + m_pClientSocket->disconnectFromHost(); +// m_pClientSocket->waitForDisconnected(); + m_pClientSocket->close(); + m_connected = 1; + } + else if (sta == 2) // 网络连接还在 + { + + } + else + { + + } +} + +void TcpClient::receiveServerData() +{ + if (m_pClientSocket != NULL) + { + QByteArray tmpDat; + tmpDat = m_pClientSocket->readAll(); // 读取 +// qDebug("ReceiveServerData, size = %d", tmpDat.size()); +// PrintAsHex(&tmpDat); + + emit(siReceiveData(tmpDat)); // 发送收到数据信号 + } +} + +void TcpClient::displaySocketError(QAbstractSocket::SocketError err) +{ + QString errinfo; + + errinfo.sprintf("Err: code=%d, errorString=", err); + errinfo += m_pClientSocket->errorString(); + +// qDebug() << errinfo; + + emit(siConnectErr(errinfo)); // 网络错误信息 +} + +void TcpClient::netStateChanged(QAbstractSocket::SocketState sta) +{ + switch (sta) + { + /* + case UnconnectedState: + case HostLookupState: + case ConnectingState: + case ConnectedState: + case BoundState: + case ListeningState: + case ClosingStat: + */ + default: + break; + } + +} +void TcpClient::hostFound() +{ + qDebug("found host"); + + +} + + +#if(0) +//------------------------------------------------------- +TcpConnectDetect::TcpConnectDetect(QObject *parent) : + QObject(parent), + m_pDetectSocket(NULL), + m_localip(DEF_LOCAL_IP), + m_localport(DEF_LOCAL_PORT), + m_serverip(DEF_SERVER_IP), + m_serverport(DEF_SERVER_PORT) +{ +} + +TcpConnectDetect::~TcpConnectDetect() +{ + if (m_pDetectSocket == NULL) + { + m_pDetectSocket->disconnectFromHost(); + m_pDetectSocket->waitForDisconnected(); + m_pDetectSocket->close(); + delete m_pDetectSocket; + } +} + +void TcpConnectDetect::detectStart() +{ + qDebug("TcpConnectDetect start"); + if (m_pDetectSocket == NULL) + { + m_pDetectSocket = new QBindTcpSocket; + } +} + +int TcpConnectDetect::connectDetect() +{ + int connectsta = 0; + int rslt; + + // qDebug() << "TcpConnectDetect " << QThread::currentThread(); + + if (m_pDetectSocket == NULL) + { + return 0; + } + if (m_localip.isEmpty() == false) + { + m_pDetectSocket->bindAddrAndPort(m_localip, m_localport); + } + m_pDetectSocket->abort(); + m_pDetectSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); + m_pDetectSocket->connectToHost(m_serverip, m_serverport); + + do + { + rslt = m_pDetectSocket->waitForConnected(4000); // 等待连接 + + qDebug("bind Detect connect rslt=%d", rslt); + qDebug() << "localip=" << m_localip << "localport=" << m_localport; + qDebug() << "serverip=" << m_serverip << "serverport=" << m_serverport; + + switch(m_pDetectSocket->state()) + { + case QAbstractSocket::ConnectedState: + { + // 如果连接上,说明 m_pClientSocket 连接已经无效, 需要断开重新连接 + // 先断开测试连接 + m_pDetectSocket->disconnectFromHost(); + m_pDetectSocket->waitForDisconnected(); + connectsta = 1; + // 发送断开主连接的信号 + qDebug() << "detect is Connected, disconnect all"; + + break; + } + case QAbstractSocket::UnconnectedState: + { + // qDebug() << "detect is Unconnected err=" << m_pDetectSocket->error() << ", info:" << m_pDetectSocket->errorString(); + + switch (m_pDetectSocket->error()) + { + case QAbstractSocket::SocketTimeoutError: // 连接超时,说明已经断开 + case QAbstractSocket::NetworkError: // 网络错误, 主机不可连接, 可能已经断开 + { + qDebug() << "detect is timout, disconnect all"; + connectsta = 1; + // 发送断开主连接的信号 + break; + } + case QAbstractSocket::ConnectionRefusedError: // 拒绝连接, 说明连接还在 + { + connectsta = 2; + // qDebug() << "Connection Refused, old connect is alive"; + break; + } + /* + case QAbstractSocket::RemoteHostClosedError: + case QAbstractSocket::HostNotFoundError: + case QAbstractSocket::SocketAccessError: + case QAbstractSocket::SocketResourceError: + case QAbstractSocket::SocketTimeoutError: + case QAbstractSocket::DatagramTooLargeError: + case QAbstractSocket::AddressInUseError: + case QAbstractSocket::SocketAddressNotAvailableError: + case QAbstractSocket::UnsupportedSocketOperationError: + case QAbstractSocket::UnfinishedSocketOperationError: + case QAbstractSocket::ProxyAuthenticationRequiredError: + case QAbstractSocket::SslHandshakeFailedError: + case QAbstractSocket::ProxyConnectionRefusedError: + case QAbstractSocket::ProxyConnectionClosedError: + case QAbstractSocket::ProxyConnectionTimeoutError: + case QAbstractSocket::ProxyNotFoundError: + case QAbstractSocket::ProxyProtocolError: + case QAbstractSocket::UnknownSocketError: + */ + default: + { + // 继续检测 + connectsta = 2; + qDebug() << " retry"; + break; + } + } // 错误处理结束 + } + case QAbstractSocket::ConnectingState: + { + // qDebug() << "detect is Connecting"; + // qDebug() << "localip=" << m_localip << "localport=" << m_localport; + // 继续等待 + break; + } + case QAbstractSocket::HostLookupState: + case QAbstractSocket::BoundState: + case QAbstractSocket::ListeningState: + case QAbstractSocket::ClosingState: + default: + { + // 继续等待 + qDebug("detect sta is %d\r\n", m_pDetectSocket->state()); + break; + } + } + + if (connectsta != 0) + { + break; + } + + }while(1); + + + m_pDetectSocket->close(); + + // 发送本次测试连接的状态信号 + emit(siConnectSta(connectsta)); + return connectsta; +} + +void TcpConnectDetect::setIpAndPort(QString localip, quint16 localport, QString serverip, quint16 serverport) +{ + m_localip = localip; + m_localport = localport; + m_serverip = serverip; + m_serverport = serverport; +} +#endif + + + + + + diff --git a/machine/tcpclient.h b/machine/tcpclient.h new file mode 100644 index 0000000..1547255 --- /dev/null +++ b/machine/tcpclient.h @@ -0,0 +1,102 @@ +#ifndef TCPCLIENT_H +#define TCPCLIENT_H + +#include +#include +#include +#include +#include +#include +#include + +#include "qbindtcpsocket.h" + +class ConnectDetectThread; + + +class TcpClient : public QObject +{ + Q_OBJECT +public: + explicit TcpClient(QObject *parent = NULL); + virtual ~TcpClient(); + +public: + void setConfigFileName(QString configfilename); +signals: + void siConnectSta(int sta); // 网络连接信号 + void siConnectErr(QString errinfo); // 网络错误信息 + void siReceiveData(QByteArray dat); // 收到数据包信号 +signals: + void siDetectHost(void); +public: + + +public slots: + void slotSendData(QByteArray dat); // 发送数据的槽 + void connectToServer();//连接到服务器 + void disConnectFromServer(); + void detectStatus(int); +public: + +private slots: + void connectCheck(); + void receiveServerData(); + void displaySocketError(QAbstractSocket::SocketError err); + void netStateChanged(QAbstractSocket::SocketState sta); + void hostFound(); + +private: + void loadIpAndPort(); +private: + QBindTcpSocket * m_pClientSocket;//客户端 + + QTimer * m_pConnectCheckTimer; + +public: + int m_connected; // 连接状态; 0, 初始化; 1, 未连接; 2, 连接中; 3, 已连接 + +private: + QThread * m_pConnectDetectThread; + TcpConnectDetect * m_pConnectDetect; + int m_detect; // 连接测试状态 +private: + QString m_configFileName; +private: + QString m_localip; + quint16 m_localport; + QString m_serverip; + quint16 m_serverport; +}; + +#if(0) +class TcpConnectDetect : public QObject +{ + Q_OBJECT +public: + explicit TcpConnectDetect(QObject *parent = NULL); + virtual ~TcpConnectDetect(); + +signals: + void siConnectSta(int sta); // 网络连接信号 +public: + +public slots: + void detectStart(); + int connectDetect(); + +private: + QBindTcpSocket * m_pDetectSocket; + +public: + void setIpAndPort(QString localip, quint16 localport, QString serverip, quint16 serverport); + +private: + QString m_localip; + quint16 m_localport; + QString m_serverip; + quint16 m_serverport; +}; +#endif + +#endif // TCPCLIENT_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..7d0bc0c --- /dev/null +++ b/main.cpp @@ -0,0 +1,306 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define _IN_MAIN_CPP + +#include "main.h" +#include "mctype/patternsingleboard/mainUI/mainwidget.h" + +QString switchLanguage(int language,QDir appPath) +{ + QString sourcePath,targetPath; + targetPath = appPath.path() + appPath.separator() + "language.qm"; + switch (language) + { + case 0://中文 + sourcePath = appPath.path() + appPath.separator() + "chinese.qm"; + break; + case 1://英文 + sourcePath = appPath.path() + appPath.separator() + "english.qm"; + break; + case 2://西班牙文 + sourcePath = appPath.path() + appPath.separator() + "spanish.qm"; + break; + case 3://孟加拉文 + sourcePath = appPath.path() + appPath.separator() + "bengal.qm"; + break; + case 4://土耳其文 + sourcePath = appPath.path() + appPath.separator() + "turkey.qm"; + break; + case 5://丹麦文 + sourcePath = appPath.path() + appPath.separator() + "denmark.qm"; + break; + default://中文 + sourcePath = appPath.path() + appPath.separator() + "chinese.qm"; + break; + } + + QFile::remove(targetPath); + QFile::copy(sourcePath,targetPath); +#ifdef Q_OS_LINUX + system("sync"); +#endif + return targetPath; +} + +void setMcMainWindow(QApplication &app, QSplashScreen *splash, s16 HMIDecrypt, s16 connectMode) +{ + //创建主窗口 + MainWidget mainwindow; + //初始化主窗口 + mainwindow.initMcTypeWindows(); + mainwindow.initAllWindows(HMIDecrypt,connectMode); + mainwindow.show();//显示窗口 + //mainwindow.setWindowIcon(QIcon(":/images/1024x600/rp.png")); + splash->finish(NULL); + app.exec();//开始执行应用程序 +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv);//此处必须用QApplication,否则QSplashScreen不能使用 + QSharedMemory shared_memory; + shared_memory.setKey(QString("main_window"));//设置固定共享内存段的key值 + if(shared_memory.attach()) //尝试将进程附加到该共享内存段,避免windows下重开程序 + { + return 0; + } + +#ifdef Q_OS_LINUX + QApplication::setOverrideCursor(Qt::BlankCursor); +#endif + + //支持中文编码 + QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); + + //文件路径 + QDir apppath(qApp->applicationDirPath()); + + //配置文件路径 + QString configfile; + configfile = apppath.path() + apppath.separator() + "config.ini"; + + //读入配置 + g_pSettings = new Settings(); + g_pSettings->loadSetting(configfile); + QFile iniFile(configfile); + int language = 0; + int fontsize = 0; + s16 connectMode = 0; + s16 gatewayConnectMode = 0; + + if(!iniFile.exists())//配置文件不存在 + { + g_pSettings->writeToIniFile("Pattern/name",""); + g_pSettings->writeToIniFile("HMI/resolution",resolution1006); + g_pSettings->writeToIniFile("HMI/theme",theme1); + g_pSettings->writeToIniFile("HMI/language",chinese); + g_pSettings->writeToIniFile("HMI/fontsize",normal);//字体大小 + g_pSettings->writeToIniFile("HMI/machineType",MACHINE_HIGHSPEEDSINGLEQUI); + g_pSettings->writeToIniFile("HMI/productType",PRODUCT_NULL); + g_pSettings->writeToIniFile("HMI/debugMode",nodebugMode);//界面调试模式 + g_pSettings->writeToIniFile("HMI/waterMark",1);//0:主背景图不带水印 1:主背景图带水印 + g_pSettings->writeToIniFile("HMI/paraSort",0);//0:参数不分类显示 1:参数分类显示 + + g_pSettings->writeToIniFile("HMI/connectMode",0);//连接方式(通讯方式,网口或串口) + g_pSettings->writeToIniFile("HMI/passwordOne",g_passwordOne); + g_pSettings->writeToIniFile("IOT/gatewayConnectMode",0);//网关连接方式(连接方式,网口或串口) + g_pSettings->writeToIniFile("IOT/rackNumber",0);//机架号 + + g_pSettings->writeToIniFile("DateTime/second",0); + + //写入机头断线次数 + g_pSettings->writeToIniFile("HeadBreakLineNum",0); + + g_emResolut = resolution1006; + g_emTheme = theme1; + language = chinese; + fontsize = normal; + g_emDebugMode = nodebugMode; + g_emMacType = MACHINE_HIGHSPEEDSINGLEQUI; + g_emProductType = PRODUCT_NULL; + g_passwordOne = PASSWORD_ONE; + } + else + { + g_emResolut = (Resolution)(g_pSettings->readFromIniFile("HMI/resolution").toInt()); + g_emTheme = (Theme)(g_pSettings->readFromIniFile("HMI/theme").toInt()); + //这个情况是,存在配置文件的时候,很可能是只有DateTime/second,读不到主题,就是0(图片加载不出来),二级密码也会没有 + + //为了防止配置文件里没有debugMode时升级黑屏,因为界面调试模式是后来新加的,之前版本的配置文件里没有,兼容之前的版本 -rq + QString debugModeStr = "HMI/debugMode"; + if(g_pSettings->ifKeyExists(debugModeStr) == true) + { + g_emDebugMode =(DebugMode)(g_pSettings->readFromIniFile("HMI/debugMode").toInt());//如果存在配置文件,并且有这个key就读配置文件里的调试模式的值 + } + else + { + g_pSettings->writeToIniFile("HMI/debugMode",nodebugMode);//界面调试模式 + g_emDebugMode = nodebugMode; + } + language = g_pSettings->readFromIniFile("HMI/language").toInt(); + fontsize = g_pSettings->readFromIniFile("HMI/fontsize").toInt(); + g_emDebugMode =(DebugMode)(g_pSettings->readFromIniFile("HMI/debugMode").toInt());//如果存在配置文件,就读配置文件里的调试模式的值 + g_emMacType = (MachineType)(g_pSettings->readFromIniFile("HMI/machineType").toInt()); + g_emProductType = (ProductType)(g_pSettings->readFromIniFile("HMI/productType").toInt()); + connectMode = g_pSettings->readFromIniFile("HMI/connectMode").toInt(); + g_passwordOne = g_pSettings->readFromIniFile("HMI/passwordOne").toString(); + if(g_passwordOne.isEmpty()) + g_passwordOne = PASSWORD_ONE; + gatewayConnectMode = g_pSettings->readFromIniFile("IOT/gatewayConnectMode").toInt(); + } + + //自动获取屏幕分辨率 +#ifdef Q_OS_LINUX + QDesktopWidget * desktop = QApplication::desktop(); + QRect screenRect = desktop->screenGeometry(); + int width = screenRect.width(); + int height = screenRect.height(); + if(width == 1920 && height == 1080) + { + g_emResolut = resolution1910; + } + else if(width == 1024 && height == 600) + { + g_emResolut = resolution1006; + } +#endif + + + //多语言翻译 + QString languageFile = switchLanguage(language,apppath); + QTranslator translator; + translator.load(languageFile); + app.installTranslator(&translator); + + //资源文件 + QString resourcefile = apppath.path() + apppath.separator() + "nxcui.rcc"; + QResource::registerResource(resourcefile); + + //启动画面 + QSplashScreen *splash = new QSplashScreen; + if(g_emResolut == resolution1006) + { + splash->setPixmap(QPixmap(":/images/startlogo1006.png")); + } + else if(g_emResolut == resolution1910) + { + splash->setPixmap(QPixmap(":/images/startlogo1910.png")); + } + + QFont font; + font.setPixelSize(20); + splash->setFont(font); + splash->move(0,0); + int waterMark = g_pSettings->readFromIniFile("HMI/waterMark").toInt();//是否带水印 + if(waterMark==1)//带logo + { + splash->show();//显示启动画面 + } + + //检测界面解密的配置文件是否存在 + //界面解密配置文件路径 + s16 HMIDecrypt = 1;//1代表已授权解密过,0代表未授权解密过 + QString HMIDecryptConfigfile; + HMIDecryptConfigfile = apppath.path() + apppath.separator() + "HMIDecryptConfig.ini"; + QFile HMIDecryptIniFile(HMIDecryptConfigfile); + if(!HMIDecryptIniFile.exists())//不存在界面解密的文件(已发机器),可与主板建立连接 + { + HMIDecrypt = 1; + } + else//存在界面解密的文件,判断是否解密过来决定是否与主板建立连接 + { + QSettings iniSetting(HMIDecryptConfigfile, QSettings::IniFormat); + HMIDecrypt = iniSetting.value("HMIDecrypt/ifdecrypt").toInt(); + } + + g_pMachine = NULL; + QString mcConfigfile; + mcConfigfile = apppath.path() + apppath.separator() + "mcconfig.ini"; + + g_pMachine = new Machine(); //创建下位机通讯 + g_pMachine->initConnectMode(connectMode);//初始化通讯连接方式 + g_pMachine->setComportName(""); //名字为空 + g_pMachine->setConfigFileName(mcConfigfile);//配置文件 + if(HMIDecrypt != 0) + { + g_pMachine->startCommunication();//启动线程 + } + + //物联网客户端与mqtt网关服务器建立连接 + g_pLotMachine = NULL; + QString lotConfigfile; + lotConfigfile = apppath.path() + apppath.separator() + "lotconfig.ini"; + g_pLotMachine = new LotMachine(); //创建网关通讯 + g_pLotMachine->initConnectMode(gatewayConnectMode);//初始化通讯连接方式 + g_pLotMachine->setComportName(""); + g_pLotMachine->setConfigFileName(lotConfigfile); + g_pLotMachine->startCommunication(); + + g_pCurEmbData = new EmbData(); + + if (fontsize == 1)//如果是加大字体 + { + if(g_emResolut == resolution1006) + { + fontBold_1 = fontBold_4;//二级界面主标题字体 + fontNormal_1 = fontNormal_4;//1024x600常规字体加大 + fontNormal_2 = fontNormal_5;//800x480字体加大 + fontNormal_6 = fontNormal_7;//显示花样信息的字体 + fontNormal_10 = fontNormal_11;//断线机头字体 + fontNormal_12 = fontNormal_12;//1024x600分辨率 花样选择界面花样名称 + } + else + { + fontBold_1 = fontBold_1; + fontNormal_1 = fontNormal_9; + fontNormal_6 = fontNormal_9; //1920x1080分辨率 的所有字体 + fontNormal_10 = fontNormal_10; + fontNormal_12 = fontNormal_1; + } + } + else if (fontsize == 0)//如果是正常字体 + { + if(g_emResolut == resolution1006 ) + { + fontBold_1 = fontBold_5; + fontNormal_1 = fontNormal_8;//1024x600常规字体和显示花样字体一样大,都是fontNormal_8(正常) + fontNormal_2 = fontNormal_6;//800x480字体 + fontNormal_6 = fontNormal_8; + fontNormal_10 = fontNormal_11;//断线机头字体 + fontNormal_12 = fontNormal_12;//1024x600分辨率 花样选择界面花样名称 + } + else + { + fontBold_1 = fontBold_1; + fontNormal_1 = fontNormal_1; + fontNormal_6 = fontNormal_1; //1920x1080分辨率 的所有字体 + fontNormal_10 = fontNormal_10; + fontNormal_12 = fontNormal_1; + } + } + +#ifdef Q_OS_WIN + //win下防止多个程序打开 + if(shared_memory.create(1)) //创建1byte的共享内存段 + { + setMcMainWindow(app,splash,HMIDecrypt,connectMode); + } +#endif + +#ifdef Q_OS_LINUX + setMcMainWindow(app,splash,HMIDecrypt,connectMode); +#endif + + delete splash; + delete g_pSettings; + delete g_pMachine; + delete g_pCurEmbData; + return 0; +} diff --git a/main.h b/main.h new file mode 100644 index 0000000..fe8cfec --- /dev/null +++ b/main.h @@ -0,0 +1,244 @@ +#ifndef MAIN_H +#define MAIN_H + +#include +#include +#include "settings/settings.h" +#include "machine/machine.h" +#include "machine/lotmachine.h" +#include "datafile/embdata.h" + +#define NAMEMAXLENGTH 8 // 字体最大长度 +#define LINUXUSBPATH "/media/usb0/" +#define PATTERNPATH "datafiles" +#define IMAGE_TYPE (QImage::Format_ARGB32) +#define PEN_WIDTH 1 + +//透明背景色,白色前景色 +#define LABELWHITESTYLE "background-color: rgba(245, 245, 245, 0);color: rgb(255, 255, 255);" + +//透明背景色,白色前景色,带边框(色序设定针杆按钮) +#define BUTTONWHITESTYLE "QPushButton{outline: none;border:1px solid rgb(235,235,235);border-style:inset;border-radius:5px;color: rgb(255, 255, 255);} QPushButton:pressed{background-color: rgba(105, 105, 127);}" + +//白色背景色,黑色前景色,带边框(列表界面按钮-动框角度调节) +#define BUTTONSHEETSTYLE "QPushButton{background-color: rgba(245, 245, 245);border:0.5px solid rgb(120,120,120);color: rgb(10, 10, 10);} QPushButton:pressed{background-color: rgba(199, 226, 255);}" + +//透明背景色,灰色前景色 +#define LABELGREYSTYLE "background-color: rgba(245, 245, 245, 0);color: rgb(78, 78, 78);" + +//透明背景色,黑色前景色 +#define LABELBLACKSTYLE "background-color: rgba(245, 245, 245, 0);color: rgb(0, 0, 0);" + +//透明背景色,红色前景色 +#define LABELREDSTYLE "background-color: rgba(245, 245, 245, 0);color: rgb(220, 0, 0);" + +//透明背景色,黄色前景色 +#define LABELYELLOYSTYLE "background-color: rgba(245, 245, 245, 0);color: rgb(255, 239, 0);" + +//透明背景色,深蓝色前景色 +#define LABELNAVYBLUESTYLE "background-color: rgba(245, 245, 245, 0);color: rgb(57, 95, 140);" + +//透明色、无焦点、无边框 +#define TRANSPARENTSTYLE "outline:none;border:0px;background-color: rgba(255, 255, 255, 0);" + +//进度条样式表 +#define PROGRESSBARSTYLE "QProgressBar{border-radius: 5px;border:0px;}QProgressBar::chunk{background-color: rgb(255, 255, 255);}" + +//透明背景色,红色前景色 字体很大 font-size:700px; +#define LABELREDSTYLEBROKEN "background-color: rgba(245, 245, 245, 0);color: rgb(220, 0, 0);" + +//透明背景色,蓝色前景色 字体很大 +#define LABELREDSTYLEBROKENBLUE "background-color: rgba(245, 245, 245, 0);color: rgb(57, 95, 140);" + +#ifdef Q_OS_WIN +#define FONTSIZE1_1 18 //1920x1080分辨率 常规字体字体(正常) +#define FONTSIZE1_2 26 //暂时没用上 +#define FONTSIZE1_3 16 //1920x1080分辨率色序设定界面 +#define FONTSIZE1_4 11 //1024x600分辨率 常规字体字体(加大) +#define FONTSIZE1_5 16 // 800x480分辨率 的字体 +#define FONTSIZE1_6 18 //1920x1080分辨率 显示花样信息的字体(正常) +#define FONTSIZE1_7 10 //1024x600分辨率 显示花样信息的字体(加大) +#define FONTSIZE1_8 9 //1024x600分辨率 常规字体字体(正常) +#define FONTSIZE1_9 20 //1920x1080分辨率 的字体(加大) +#define FONTSIZE1_10 30 //1920x1080分辨率 机头断线字体 +#define FONTSIZE1_11 24 //1024x600分辨率 机头断线字体 +#define FONTSIZE1_12 8 //1024x600分辨率 花样选择界面花样名称 1920x1080的字体大小不变 +#endif + +#ifdef Q_OS_LINUX +#define FONTSIZE1_1 14 +#define FONTSIZE1_2 20 +#define FONTSIZE1_3 12 +#define FONTSIZE1_4 17 //1024x600分辨率 常规字体字体(加大) +#define FONTSIZE1_5 15 +#define FONTSIZE1_6 16 +#define FONTSIZE1_7 13 //LINUX 1024x600分辨率 显示花样信息的字体 +#define FONTSIZE1_8 11 //1024x600分辨率 常规字体字体(正常) +#define FONTSIZE1_9 18 //1920x1080分辨率 的字体(加大) +#define FONTSIZE1_10 28 //1920x1080分辨率 机头断线字体 +#define FONTSIZE1_11 22 //1024x600分辨率 机头断线字体 +#define FONTSIZE1_12 10 //1024x600分辨率 花样选择界面花样名称 +#endif + +#define BORDER_RADIUS1 "10" +#define BORDER_RADIUS2 "5" + +#define FONTTYPE "Microsoft YaHei" +#define FONTBOLD QFont::Bold //加粗 +#define FONTNORMAL QFont::Normal //正常 + +#define LINUX_APPNAME "OPRT_CP" +#define WIN_APPNAME "oprt_up.exe" +#define APPNAME "XPLATFORM" +#define PASSWORD_ONE "290810" //一级密码 +#define PASSWORD_TWO "262574" //二级密码 +#define PASSWORD_RESETPARA "123456" //重置参数密码 + +#define HMI_UPDATA 1 // 界面升级 +#define MC_UPDATA 2 // 主控升级 +#define PARA_IMPORT 3 // 参数导入 +#define PARA_EXPORT 4 // 参数导出 +#define PRODUCTSTATIS 5 // 生产统计 +#define JOURNAL 6 // 日志文件 + +enum ConnectState +{ + NoConnect = 1, //未连接 + Connectting = 2, //连接中 + Connected = 3 //已连接 +}; + +//用户权限 +enum UserRoles +{ + operate = 0, + repair = 1, + factory = 2, + root = 3, + resetpara = 4 +}; + +//分辨率 +enum Resolution +{ + resolution1910 = 0, //1920x1080 + resolution1006 = 1 //1024x600 +}; + +//主题 +enum Theme +{ + theme1 = 1, //主题1 + theme2 = 2, //主题2 + theme3 = 3 //主题3 +}; + +//语言 +enum Language +{ + chinese = 0, //中文 + english = 1 , //英文 + spanish = 2, //西班牙文 + bengal = 3, //孟加拉文 + turkey = 4, //土耳其文 + denmark =5 +}; + +//字体大小 +enum FontSize +{ + normal = 0, //标准 + larger = 1 //加大 +}; + +enum DebugMode +{ + debugMode = 0, //是调试模式 + nodebugMode = 1 //不是调试模式 +}; + +//机器类型 +enum MachineType +{ + MACHINE_HIGHSPEEDSINGLEQUI = 0, //高速单针绗缝机 + MACHINE_FIVEHEADPRECISIONSEWING = 1, //五头精密缝 + MACHINE_CLOTHINGMAC = 2, //服装机 + MACHINE_MULTINEEDLEROTARY = 3 //多针旋梭 +}; + +//产品类型 +enum ProductType +{ + PRODUCT_NULL //无产品类型 +}; + +#ifdef _IN_MAIN_CPP + +LotMachine * g_pLotMachine;//物联网Machine,作为客户端发送数据给mqtt网关 +Machine * g_pMachine; +EmbData * g_pCurEmbData = NULL; +UserRoles g_emUser = operate; +QString g_passwordOne = PASSWORD_ONE; +Settings * g_pSettings = NULL; +Resolution g_emResolut = resolution1910; +Theme g_emTheme = theme1; +MachineType g_emMacType = MACHINE_HIGHSPEEDSINGLEQUI; +ProductType g_emProductType = PRODUCT_NULL; +DebugMode g_emDebugMode = nodebugMode; + +QFont fontNormal_1(FONTTYPE,FONTSIZE1_1,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_2(FONTTYPE,FONTSIZE1_2,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_3(FONTTYPE,FONTSIZE1_3,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_4(FONTTYPE,FONTSIZE1_4,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_5(FONTTYPE,FONTSIZE1_5,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_6(FONTTYPE,FONTSIZE1_6,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_7(FONTTYPE,FONTSIZE1_7,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_8(FONTTYPE,FONTSIZE1_8,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_9(FONTTYPE,FONTSIZE1_9,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_10(FONTTYPE,FONTSIZE1_10,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_11(FONTTYPE,FONTSIZE1_11,FONTNORMAL);//微软雅黑常规 +QFont fontNormal_12(FONTTYPE,FONTSIZE1_12,FONTNORMAL);//微软雅黑常规 + +QFont fontBold_1(FONTTYPE,FONTSIZE1_2,FONTBOLD);//微软雅黑26加粗 +QFont fontBold_2(FONTTYPE,FONTSIZE1_3,FONTBOLD);//微软雅黑16加粗 +QFont fontBold_3(FONTTYPE,FONTSIZE1_1,FONTBOLD);//微软雅黑20加粗 +QFont fontBold_4(FONTTYPE,FONTSIZE1_4,FONTBOLD);//微软雅黑14加粗 +QFont fontBold_5(FONTTYPE,FONTSIZE1_8,FONTBOLD);//微软雅黑14加粗 +#else + +extern Machine * g_pMachine; +extern LotMachine * g_pLotMachine;//物联网Machine,作为客户端发送数据给mqtt网关 +extern EmbData * g_pCurEmbData;//绣花数据(库) +extern UserRoles g_emUser; +extern QString g_passwordOne;//一级密码 +extern Settings * g_pSettings; +extern Resolution g_emResolut; +extern Theme g_emTheme; +extern MachineType g_emMacType; +extern ProductType g_emProductType; +extern DebugMode g_emDebugMode; + +//1920x1080字体 +extern QFont fontNormal_1;//微软雅黑常规14 +extern QFont fontNormal_2;//微软雅黑常规22 +extern QFont fontNormal_3;//微软雅黑常规12 +extern QFont fontNormal_6;//微软雅黑常规16 +extern QFont fontNormal_9;//微软雅黑常规16 +extern QFont fontNormal_10;//微软雅黑常规35 +extern QFont fontNormal_11;//微软雅黑常规28 +extern QFont fontNormal_12;//微软雅黑常规28 + +extern QFont fontBold_1;//微软雅黑26加粗 +extern QFont fontBold_2;//微软雅黑18加粗 +extern QFont fontBold_3;//微软雅黑20加粗 +///1024x600字体 +extern QFont fontNormal_4;//微软雅黑常规9 +extern QFont fontNormal_5;//微软雅黑常规16 +extern QFont fontNormal_7;//微软雅黑常规16 +extern QFont fontNormal_8;//微软雅黑常规16 +extern QFont fontBold_4;//微软雅黑14加粗 +extern QFont fontBold_5;//微软雅黑8加粗 +#endif + + +#endif // MAIN_H diff --git a/mctype/machinetypefun.cpp b/mctype/machinetypefun.cpp new file mode 100644 index 0000000..a60704e --- /dev/null +++ b/mctype/machinetypefun.cpp @@ -0,0 +1,188 @@ +#include "machinetypefun.h" + +//(打开,关闭) +OutCtrlItem MachineTypeFun::creatOpenCloseItem(int macType, int showPriority, QString name, int def) +{ + return makeAOutCtrlItem(macType,showPriority,name,def, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1); +} + + //(归零,正转,反转) +OutCtrlItem MachineTypeFun::creatZeroForwardReverseItem(int macType, int showPriority, QString name, int def) +{ + return makeAOutCtrlItem(macType,showPriority,name,def, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + zeroStr,true,OUTCONTROL_ZERO,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP); +} + +//(上升,下降) +OutCtrlItem MachineTypeFun::creatAscendingDescendingItem(int macType, int showPriority, QString name, int def) +{ + return makeAOutCtrlItem(macType,showPriority,name,def, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + ascendStr,true,OUTCONTROL_UP,-1,-1, + descendStr,true,OUTCONTROL_DOWN,-1,-1); +} + +OutCtrlItem MachineTypeFun::creatEnableItem(int macType, int showPriority, QString name, int def, QString btnName) +{ + return makeAOutCtrlItem(macType,showPriority,name,def, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + btnName,true,OUTCONTROL_ENABLE,-1,-1); +} + +//归零命令 显示转动 +OutCtrlItem MachineTypeFun::creatZeroItem(int macType, int showPriority, QString name, int def) +{ + return makeAOutCtrlItem(macType,showPriority,name,def, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + turnStr,true,OUTCONTROL_ZERO,-1,-1); +} + +MachineTypeFun::MachineTypeFun(QObject *parent) : QObject(parent) +{ + m_allParasList.clear(); + m_allOutCtrlList.clear(); + m_allShortCutList.clear(); + m_allAssistList.clear(); + m_allPatternSetList.clear(); + m_allParaSetList.clear(); + m_allSensorList.clear(); + m_allErrorCodeAndStateList.clear(); + enableStr = QObject::tr("Enable"); //使能 + disableStr = QObject::tr("Disable"); //失能 + jogPStr = QObject::tr("JogP"); //正转 + jogNStr = QObject::tr("JogN"); //反转 + turnStr = QObject::tr("Turn"); //转动 + zeroStr = QObject::tr("Zero"); //归零 + openStr = QObject::tr("Open"); //打开 + closeStr = QObject::tr("Close");//关闭 + ascendStr = QObject::tr("Ascending");//上升 + descendStr = QObject::tr("descending");//下降 + trimStr = QObject::tr("Trim"); //剪线 + + initAllSensorList(); +} + +MachineTypeFun::~MachineTypeFun() +{ + m_allParasList.clear(); + m_allOutCtrlList.clear(); + m_allShortCutList.clear(); + m_allAssistList.clear(); + m_allPatternSetList.clear(); + m_allParaSetList.clear(); + m_allSensorList.clear(); + m_allErrorCodeAndStateList.clear(); +} + +//获取传感器列表 +QList MachineTypeFun::getSensorList() +{ + return m_allSensorList; +} + +//获取错误代码列表 +QList MachineTypeFun::getErrorCodeAndStateList() +{ + return m_allErrorCodeAndStateList; +} + +const QHash &MachineTypeFun::getNinebtn() +{ + return m_nineBtn; +} + +const QList &MachineTypeFun::getFileInfoMSG() +{ + return m_fileInfo; +} + +void MachineTypeFun::initFileInfoLabel() +{ + m_fileInfo.append(FileName); + m_fileInfo.append(Index); + m_fileInfo.append(BeginPoint); + m_fileInfo.append(LocalPoint); + m_fileInfo.append(Range); + m_fileInfo.append(Position); + m_fileInfo.append(Production); +} + +void MachineTypeFun::initAllSensorList() +{ + //所有传感器列表,字符为空 + m_allSensorList.clear(); + int addr, byteaddr, bitaddr; + + SensorItem item; + + for (addr = 0; addr < MAX_SENSOR_NUM; addr++) + { + byteaddr = addr / 8; + bitaddr = addr % 8; //(0-7) + item.setItemValue(byteaddr, bitaddr, ""); + m_allSensorList.append(item); + } +} + +QList MachineTypeFun::getParaSetListByFilter() +{ + return m_allParaSetList; +} + +QList MachineTypeFun::getPatternSetListByFilter() +{ + return m_allPatternSetList; +} + +QList MachineTypeFun::getAssistListByFilter() +{ + return m_allAssistList; +} + +QList MachineTypeFun::getShortCutListByFilter() +{ + return m_allShortCutList; +} + +QList MachineTypeFun::getOutCtrlListByFilter() +{ + return m_allOutCtrlList; +} + +QList MachineTypeFun::getParasListByMcSel() +{ + QList paralist; + int size = m_allParasList.size(); + + for (int i = 0; i < size; i++) + { + const ParaItem & item = m_allParasList.at(i); + paralist.append(item); +#if(0) + if ((item.mcenSel & mcensel) != 0) + { + paralist.append(item); + } +#endif + } + + qStableSort(paralist.begin(), paralist.end(), comparePriority); + return paralist; +} diff --git a/mctype/machinetypefun.h b/mctype/machinetypefun.h new file mode 100644 index 0000000..8c0139e --- /dev/null +++ b/mctype/machinetypefun.h @@ -0,0 +1,81 @@ +#ifndef MACHINETYPEFUN_H +#define MACHINETYPEFUN_H + +#include +#include +#include "items/itemsmanage.h" +#include "main.h" +#include + +enum PATTERNINFO{ + FileName,//文件名 + Index,//针数索引 + BeginPoint,//起始点 + LocalPoint,//定位点 + Range,//范围 + Position,//位置 + Production//产量 +}; + +class MachineTypeFun : public QObject +{ + Q_OBJECT +public: + explicit MachineTypeFun(QObject *parent = 0); + +public: + virtual ~MachineTypeFun(); + +public: + virtual QList getParasListByMcSel(); + virtual QList getOutCtrlListByFilter(); + virtual QList getShortCutListByFilter(); + virtual QList getAssistListByFilter(); + virtual QList getPatternSetListByFilter(); + virtual QList getParaSetListByFilter(); + virtual QList getSensorList(); + virtual QList getErrorCodeAndStateList(); + virtual const QHash& getNinebtn(); + virtual const QList& getFileInfoMSG(); + virtual void initNinebtn1234() = 0; + virtual void initFileInfoLabel(); + +protected: + OutCtrlItem creatOpenCloseItem(int macType, int showPriority, QString name, int def);//打开关闭(放松,夹紧) + OutCtrlItem creatZeroForwardReverseItem(int macType, int showPriority, QString name, int def);//(归零,正转,反转) + OutCtrlItem creatAscendingDescendingItem(int macType, int showPriority, QString name, int def);//(上升,下降) + OutCtrlItem creatEnableItem(int macType, int showPriority, QString name, int def, QString btnName);//(剪线) + OutCtrlItem creatZeroItem(int macType, int showPriority, QString name, int def);// (正转):转动 + +public: + QList m_allParasList; + QList m_allOutCtrlList; + + QList m_allShortCutList; + QList m_allAssistList; + QList m_allPatternSetList; + QList m_allParaSetList; + QList m_allSensorList; + QList m_allErrorCodeAndStateList; + +protected: + QHash m_nineBtn; //九宫格四角按钮的机型化配置 + QList m_fileInfo;//右上角花样信息显示 +private: + void initAllSensorList();//初始化全部传感器列表 + +protected: + QString enableStr; //使能 + QString disableStr; //失能 + QString jogPStr; //正转 + QString jogNStr; //反转 + QString turnStr; //转动 + QString zeroStr; //归零 + QString openStr; //打开 + QString closeStr;//关闭 + QString ascendStr;//上升 + QString descendStr;//下降 + QString trimStr;//剪线 +}; + +#endif // MACHINETYPEFUN_H diff --git a/mctype/mainwidgetfunction.cpp b/mctype/mainwidgetfunction.cpp new file mode 100644 index 0000000..acb17c0 --- /dev/null +++ b/mctype/mainwidgetfunction.cpp @@ -0,0 +1,4098 @@ +#include "mainwidgetfunction.h" + +MainWidgetFunction::MainWidgetFunction(QObject *parent) : + QObject(parent), + m_pPromptDlg(NULL), + m_pSystemManageDlg(NULL), + m_pBrokenLineDialog(NULL), + m_pDebugInfoDlg(NULL) +{ + initialize(); + initializeLotData();//初始化物联网数据 + + m_pPromptDlg = new PromptDialog(); + m_pPromptDlg->hide(); + + connect(m_pPromptDlg, SIGNAL(siSpindleAction(int)),this, SLOT(slotSpindleAction(int))); + connect(m_pPromptDlg, SIGNAL(siSpindleRotate(int)),this, SLOT(slotSpindleRotate(int))); + + connect(m_pPromptDlg, SIGNAL(siUpdataCancel()),g_pMachine, SLOT(breakFileTrans())); + connect(g_pMachine, SIGNAL(siTransProgress(u8,int,int)),this, SLOT(slotTransProgress(u8,int,int)));//升级主控进度条 + // connect(g_pLotMachine,SIGNAL(siConnectToMqtt()),this,SLOT(slotSendJsonToMqtt())); + connect(g_pLotMachine,SIGNAL(siRunLotDataAction(QString)),this,SLOT(slotRunLotDataAction(QString))); + + //机器信息改变 + connect(g_pMachine, SIGNAL(siMcInfoChange()), this, SLOT(slotMCInfoChange())); + //接收物联数据 + connect(g_pMachine, SIGNAL(siReceiveLotData()), this, SLOT(slotReceiveLotData())); + + m_pSystemManageDlg = new SystemManageDialog(); + connect(m_pSystemManageDlg,SIGNAL(siClearProductStatis()),this,SLOT(slotClearProductStatis())); + connect(m_pSystemManageDlg,SIGNAL(siCsvExport(int)),this,SLOT(slotCsvExport(int))); + connect(m_pSystemManageDlg,SIGNAL(siCsvChangeErro( )),this,SLOT(slotJournalError( ))); + connect(m_pSystemManageDlg,SIGNAL(siCsvChangeBrea( )),this,SLOT(slotJournalBreakage( ))); + connect(m_pSystemManageDlg,SIGNAL(siCsvChangeDebug( )),this,SLOT(slotCsvChangeDebug())); + connect(m_pSystemManageDlg,SIGNAL(siClearJournal()),this,SLOT(slotClearJournal())); + connect(m_pSystemManageDlg,SIGNAL(siRefreshWifiList()),this,SLOT(slotRefreshWifiList())); + + connect(m_pSystemManageDlg,SIGNAL(siSetDynamicIP(QString)),this,SLOT(slotSetDynamicIP(QString))); + connect(m_pSystemManageDlg,SIGNAL(siSetStaticIP(QString,QString,QString)),this,SLOT(slotSetStaticIP(QString,QString,QString))); + + m_pSystemManageDlg->hide(); + + m_pBrokenLineDialog = new BrokenLineDialog(); + m_pBrokenLineDialog->hide(); + + m_pDebugInfoDlg = new DebugInfoDialog(); + m_pDebugInfoDlg->hide(); + + m_pTipsTimer = new QTimer(this); + m_pTipsTimer->setInterval(14400000);//设置定时器时间间隔 4小时 + connect(m_pTipsTimer, SIGNAL(timeout()), this, SLOT(onTipsTimer())); + + // 测试物联网用 + // connect(&timer, SIGNAL(timeout()), this, SLOT(slotReceiveLotData())); + // timer.setInterval(1000); + // timer.start(); +} + +MainWidgetFunction::~MainWidgetFunction() +{ + if(m_pPromptDlg != NULL) + { + delete m_pPromptDlg; + } + if(m_pSystemManageDlg != NULL) + { + delete m_pSystemManageDlg; + } + if(m_pBrokenLineDialog != NULL) + { + delete m_pBrokenLineDialog; + } + if(m_pDebugInfoDlg != NULL) + { + delete m_pDebugInfoDlg; + } +} + +void MainWidgetFunction::initialize() +{ + memset(&m_mcStatus,0,sizeof(MCStatus)); + m_curFileID = 1;// 当前文件ID + m_filePath.clear(); + m_fileName.clear(); + m_getScore = 0; + m_totalScore = 0; + initializeLotInfo(); +} + +void MainWidgetFunction::initializeLotInfo() +{ + QDir apppath(qApp->applicationDirPath()); + QString iniPath = apppath.path() + apppath.separator() + "config.ini"; + QSettings setting(iniPath, QSettings::IniFormat); //QSettings能记录一些程序中的信息,下次再打开时可以读取出来 + m_getScore = setting.value("Progress/getScore").toInt(); + + QString path = apppath.path() + apppath.separator() + CSV_PROGRESS; + QFile file(path); + if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + qDebug() << "Open CSV file failed!"; + return; + } + + QStringList strlist; + strlist.clear(); + QTextStream out(&file); + out.setCodec("GB2312"); //支持读取中文信息 + + //遍历行 + for(int i = 0; !out.atEnd(); i++) + { + QString strLine = out.readLine(); + if(strLine.size() <= 0) + { + continue; + } + m_csvFileStrList.append(strLine); + strlist = strLine.split(",", QString::SkipEmptyParts); //根据","分隔开每行的列 + if(i > 0) //第一行不执行操作 + { + if (strlist.size() > COLUMN_SCORE) + { + QString code = strlist.at(COLUMN_CODE); + QStringList strlist1 = code.split("_", QString::SkipEmptyParts); //根据"_"分隔开每行的列 + int type = 0; + if(strlist1.size() > 0) + { + char *buf = strdup(strlist1[1].toLatin1().data()); + sscanf (buf, "%x", &type); + } + s16 score = 0; + score = strlist.at(COLUMN_SCORE).toInt(); + m_totalScore += score; + } + } + } + + file.close();//关闭文件 +} + +//初始化物联网数据 +void MainWidgetFunction::initializeLotData() +{ + memset(&m_mcLotData,0,sizeof(McLotData)); + memset(&m_HMILotData,0,sizeof(HMILotData)); + + QString verStr = getVersionStr(); + memcpy(m_HMILotData.HMIVerStr, verStr.data(), verStr.length()); // 版本号 + + u32 rackNum = g_pSettings->readFromIniFile("IOT/rackNumber").toInt();//机架号 + m_HMILotData.machineNumber = rackNum; // 机架号 + + u16 dProgress = g_pSettings->readFromIniFile("IOT/debugProgress").toInt();//调试进度 + m_HMILotData.debugProgress = dProgress; //调试进度 + + QString deliveryTime = g_pSettings->readFromIniFile("IOT/deliveryTime").toString();//工厂预计交货时间 + QByteArray arr = deliveryTime.toLocal8Bit(); + memcpy(m_HMILotData.deliveryTime, arr.data(), arr.size()); //交货日期 + + //电机总数-先固定写为4个,如果后续变动较大,可把电机个数写为全局变量或从其他cpp中传参 + m_HMILotData.motorNum = 4; + + QString fileName = m_fileName; + memcpy(m_HMILotData.fileName, fileName.data(), fileName.length()); // 文件名称 +} + +//优盘检测 +QString MainWidgetFunction::detectUsb() +{ + QString usbPath = ""; + +#ifdef Q_OS_LINUX + QDir dir(LINUXUSBPATH); + if(!dir.exists()) + { + usbPath = ""; + } + else + { + usbPath = LINUXUSBPATH; + } +#endif + +#ifdef Q_OS_WIN + QFileInfoList list = QDir::drives(); + + for(int i = 0; i= 2) + { + QString str1 = lineStr[0]; + //qDebug()<initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("USB flash drive is not detected!");//未检测到优盘! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + + QDir apppath(qApp->applicationDirPath()); + QString targetDir = apppath.absolutePath() + apppath.separator(); + + QDir dir (usbPath); + dir.setFilter(QDir::Files | QDir::NoSymLinks); // 设置类型过滤器,只为文件格式 + QFileInfoList fileList = dir.entryInfoList(); + + if(type == HMI_UPDATA)//界面升级 + { + qDebug()<<"update 1"; + //界面文件、语言文件、RCC资源文件、打包的AUT文件 + for (int var = 0; var < fileList.size(); var++) + { +#ifdef Q_OS_WIN + if((fileList.at(var).fileName().toUpper().indexOf(APPNAME) != -1 && + fileList.at(var).suffix().toUpper() == "EXE") || + fileList.at(var).fileName().toUpper().indexOf(".QM") != -1 || + fileList.at(var).fileName().toUpper().indexOf(".RCC") != -1 || + fileList.at(var).fileName().toUpper().indexOf(".AUT") != -1) + { + m_pSystemManageDlg->addItem(fileList.at(var).fileName()); + } +#endif + +#ifdef Q_OS_LINUX + if((fileList.at(var).fileName().toUpper().indexOf(APPNAME) != -1 && + fileList.at(var).suffix().toUpper().length() == 0) || + fileList.at(var).fileName().toUpper().indexOf(".QM") != -1 || + fileList.at(var).fileName().toUpper().indexOf(".RCC") != -1 || + fileList.at(var).fileName().toUpper().indexOf(".AUT") != -1) + { + m_pSystemManageDlg->addItem(fileList.at(var).fileName()); + } +#endif + } + qDebug()<<"update 2"; + } + else if(type == MC_UPDATA)//主控升级 + { + for (int var = 0; var < fileList.size(); var++) + { + if( fileList.at(var).suffix().toUpper() == "RNPU") + { + m_pSystemManageDlg->addItem(fileList.at(var).fileName()); + } + } + qDebug()<<"update 3"; + } + else if(type == PARA_IMPORT)//参数导入 + { + QString fileSuffix = "PARADAT"; + + for (int var = 0; var < fileList.size(); var++) + { + if( fileList.at(var).suffix().toUpper() == fileSuffix) + { + m_pSystemManageDlg->addItem(fileList.at(var).fileName()); + } + } + qDebug()<<"update 4"; + } + //点击了确认按钮 + if(m_pSystemManageDlg->exec(type) == 1) + { + QString fileName = m_pSystemManageDlg->getCurFile(); + + if(type == HMI_UPDATA)//界面升级 + { + QString sPath,tPath; +#ifdef Q_OS_WIN + if(fileName.toUpper().indexOf(APPNAME) != -1 && + fileName.toUpper().indexOf(".EXE") != -1) + { + sPath = usbPath + fileName; + tPath = targetDir + WIN_APPNAME; + + qDebug()<<"HMI Update"; + qDebug()<<"sPath"<exit(); + } +#endif + +#ifdef Q_OS_LINUX + if(fileName.toUpper().indexOf(APPNAME) != -1 && + fileName.toUpper().indexOf(".EXE") == -1 && + fileName.toUpper().indexOf(".AUT") == -1)//非aut打包文件 + { + sPath = usbPath + fileName; + tPath = targetDir + LINUX_APPNAME; + + qDebug()<<"HMI Update"; + qDebug()<<"sPath"<exit(); +#endif +#ifdef Q_OS_LINUX + system("sync"); + system("reboot"); +#endif + } + + else if(fileName.toUpper().indexOf(".RCC") != -1 ) + { + QString sPath = usbPath + fileName ; + QString tPath = targetDir + "nxcui.rcc"; + + qDebug()<<"RCC Update"; + qDebug()<<"sPath"<exit(); +#endif + +#ifdef Q_OS_LINUX + system("sync"); + system("reboot"); +#endif + } + + else if(fileName.toUpper().indexOf(".AUT") != -1)//界面打包文件(包括升级文件、语言包、RCC等) + { + QString strFile = usbPath + fileName; + QFile file(strFile); + file.open(QIODevice::ReadOnly); + + QByteArray AllData = file.readAll(); + HMIFileHead *fhead = (HMIFileHead*)(AllData.data()); + int filenum = fhead->fileNum; + + int bSize = 0; + for(int j = 0; j < filenum; j++) + { + int cSize = j*sizeof(HMIItemFileHead) + sizeof(HMIFileHead) + bSize; + HMIItemFileHead *ahead; + ahead = (HMIItemFileHead*)(AllData.data() + cSize); + QString fName = ahead->fileName; + + int fileSize = ahead->fileSize; + if(fileSize <= 0) + { + return; + } + int sDataCheck = ahead->dataCheck; + + cSize = cSize + sizeof(HMIItemFileHead); + QByteArray buf = AllData.mid(cSize,fileSize); + int tDataCheck = calcCheckSum32((u8*)buf.data(),fileSize); + + bSize = bSize + fileSize; + + //校验相同,查找相同的文件替换 + if(sDataCheck == tDataCheck) + { + QString uFileName = targetDir + fName; + QFile uFile(uFileName); + QString cName = fName; + + if(uFile.exists())//执行目录中存在U盘中的文件fileName + { + QString targetPath; + targetPath.clear(); + +#ifdef Q_OS_WIN + if(fName.toUpper().indexOf(APPNAME) != -1 && + fName.toUpper().indexOf(".EXE") != -1) + { + targetPath = targetDir + WIN_APPNAME; + } +#endif + +#ifdef Q_OS_LINUX + if(fName.toUpper().indexOf(APPNAME) != -1 && + fName.toUpper().indexOf(".EXE") == -1) + { + targetPath = targetDir + LINUX_APPNAME; + cName = LINUX_APPNAME; + } +#endif + +#if(0) + if(fName.toUpper().indexOf(APPNAME) != -1) + { +#ifdef Q_OS_WIN + targetPath = targetDir + WIN_APPNAME; +#endif +#ifdef Q_OS_LINUX + + targetPath = targetDir + LINUX_APPNAME; + cName = LINUX_APPNAME; +#endif + } +#endif + else//其他文件 + { + targetPath = uFileName; + } + + QFile::remove(targetPath); + QFile tFile(targetPath); + + if(tFile.open(QIODevice::WriteOnly) == false) + { + return; + } + tFile.write(buf); + + qDebug()<<"AUT Update"; + qDebug()<<"targetPath"<initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("The program is corrupted, please re-upgrade after replacing the program!")); //程序已损坏,请更换程序后重新升级! + m_pPromptDlg->exec(); + return; + } + } + file.close(); + +#ifdef Q_OS_LINUX + qDebug()<<"reboot before"; + system("sync"); + system("reboot"); + qDebug()<<"reboot end"; +#endif + + //需放在linux重启命令后面 +#ifdef Q_OS_WIN + qDebug()<<"qApp->exit()"; + qApp->exit(); +#endif + } + else + { + //所选文件非升级文件 + //文件格式错误,请重新选择! + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("The file format is wrong, please select again!");//文件格式错误,请重新选择! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + } + } + else if(type == MC_UPDATA)//主控升级 + { + if(fileName.toUpper().indexOf(".RNPU") != -1) + { + QString uPath = usbPath + fileName; + + qDebug()<<"RNPU update"; + qDebug()<<"uPath"<initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("File bytes are 0, please check the file!");//文件字节为0,请检查文件! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + + file.open(QIODevice::ReadOnly); + file.read( (char *)pBuff , file.size()) ; + file.close(); + + int nameSize = uPath.toUtf8().size() ; + if( nameSize > 32 ) + { + nameSize = 32; + } + memcpy(appHead.fileName , uPath.toUtf8().data() , nameSize); + appHead.dataSize = file.size(); + appHead.dataChecksum = calcCheckSum32(pBuff , file.size()); + + static int nID = 0; + if( g_pMachine->isConnected() == 3) + { + g_pMachine->sendAPPFileProc(FILE_TYPE_PGM, + 0, + nID++, + appHead , + pBuff + ); + } + free(pBuff); + } + } + else if(type == PARA_IMPORT)//参数导入 + { + QString uPath = usbPath + fileName; + + qDebug()<<"Para Import"; + qDebug()<<"uPath"<initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = (tr("File size not match, invalid file!"));//文件大小不匹配,无效的参数文件! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + + if( readSize != paraSize) + { + //文件大小不匹配,无效的参数文件 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = (tr("File size not match, invalid file!"));//文件大小不匹配,无效的参数文件! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + + // 参数被正确的读取 + if( + ( paraFileStruct.s_head[0] == 'P' ) + && ( paraFileStruct.s_head[1] == 'A' ) + && ( paraFileStruct.s_head[2] == 'R' ) + && ( paraFileStruct.s_head[3] == 'A' ) + && ( paraFileStruct.s_type == 0 ) + && ( paraFileStruct.s_len == 4096 ) + ) + { + unsigned short i_crc = calcCrc16( (unsigned char *) paraFileStruct.s_para_buff , paraFileStruct.s_len); + + if( paraFileStruct.s_crc != i_crc ) + { + //数据校验错误,无效的参数文件 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = (tr("Data check error, invalid file!"));//数据校验错误,无效的参数文件! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + //将 一个文件 拆分成两个 缓冲区 + unsigned char mac_config [1024] ; + unsigned char work_config [1024] ; + unsigned char pre_mac_config [1024] ; + unsigned char pre_work_config [1024] ; + + // 清空 + memset( mac_config , 0 , 1024 ) ; + memset( work_config , 0 , 1024 ) ; + memset( pre_mac_config , 0 , 1024 ) ; + memset( pre_work_config , 0 , 1024 ) ; + + memcpy( work_config , paraFileStruct.s_para_buff , 1024 ) ; + memcpy( mac_config , ((char*)paraFileStruct.s_para_buff) + 1024 , 1024 ) ; + memcpy( pre_mac_config , ((char*)paraFileStruct.s_para_buff) + 2048 , 1024 ) ; + memcpy( pre_work_config , ((char*)paraFileStruct.s_para_buff) + 3072 , 1024 ) ; + + g_pMachine->setMcPara((ParaStruct *) mac_config); + g_pMachine->setWkPara((ParaStruct *) work_config); + g_pMachine->setMcPrePara((ParaStruct *) pre_mac_config); + g_pMachine->setWkPrePara((ParaStruct *) pre_work_config); + + QString str; + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + str = (tr("Parameters imported successfully!"));//参数导入成功! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + else + { + //文件头不匹配,无效的参数文件! + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = (tr("File head not match, invalid file!"));//文件头不匹配,无效的参数文件! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + } + } + } +} + +s16 MainWidgetFunction::refreshWifiList(QStringList &wifiStrList,s16 scan) +{ + if(scan == 0){}//为了去掉编译警告 + wifiStrList.clear(); + + QProcess cmd; + QString cmdStr; + cmdStr.clear(); + QString strCmdOut; + strCmdOut.clear(); + QStringList lineStrList; + lineStrList.clear(); + + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + +#ifdef Q_OS_LINUX + cmdStr = "ifconfig";//查看wlan0初始化是否成功 + cmd.start(cmdStr); + cmd.waitForStarted(); + cmd.waitForFinished(); + strCmdOut=QString::fromLocal8Bit(cmd.readAllStandardOutput()); + lineStrList = strCmdOut.split("\n", QString::SkipEmptyParts); //换行符 + int initFlag = 0; + for(int i = 0; i < lineStrList.size(); i++) + { + QString lineStr = lineStrList[i]; + if(lineStr.indexOf("wlan0") != -1) + { + initFlag = 1; + break; + } + } + if(initFlag == 0) + { + m_pPromptDlg->setContentStr(tr("Failed to initialize wlan0!"));//初始化wlan0失败! + m_pPromptDlg->exec(); + return -1; + } + + if(scan != 0) + { + cmdStr = "wpa_cli -i wlan0 scan";//搜索可见wifi + cmd.start(cmdStr); + cmd.waitForStarted(); + cmd.waitForFinished(); + strCmdOut=QString::fromLocal8Bit(cmd.readAllStandardOutput()); + int flag = 0; + while(strCmdOut.toUpper().indexOf("OK") == -1) + { + cmdStr = "wpa_cli -i wlan0 scan";//搜索可见wifi + cmd.start(cmdStr); + cmd.waitForStarted(); + cmd.waitForFinished(); + strCmdOut=QString::fromLocal8Bit(cmd.readAllStandardOutput()); + flag++; + if(flag>=100){ + break; + } + } + } + + cmdStr = "wpa_cli -i wlan0 scan_result";//获取搜索结果 + cmd.start(cmdStr); + cmd.waitForStarted(); + cmd.waitForFinished(); + strCmdOut=QString::fromLocal8Bit(cmd.readAllStandardOutput()); + lineStrList = strCmdOut.split("\n", QString::SkipEmptyParts);//换行符 + for(int i = 0; i < lineStrList.size(); i++) + { + //qDebug()<= 2 && lineStr[lineStr.size()-1].indexOf("]") == -1) + { + QString str = lineStr[lineStr.size()-1].remove(QRegExp("^ +\\s*"));//正则表达式去掉空格 + s16 ifExist = 0; + for(s16 m = 0; m < wifiStrList.size(); m++) + { + if(wifiStrList[m] == str) + { + ifExist = 1; + break; + } + } + if(ifExist == 0) + { + wifiStrList.append(str); + } + } + } + if(wifiStrList.size() <= 0) + { + m_pPromptDlg->setContentStr(tr("Failed to search for WiFi list. Please try again later!"));//搜索wifi列表失败,请稍后重试! + m_pPromptDlg->exec(); + return -1; + } +#endif + return 1; +} + +QString MainWidgetFunction::getIpSegment(bool bl) +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString ipStr; + ipStr.clear(); + if(bl == true){}//为了去掉编译警告 + //linux下查询wifi连接状态 +#ifdef Q_OS_LINUX + s16 value = -1; + QProcess cmd; + QString cmdStr; + cmdStr.clear(); + + QString strCmdOut; + strCmdOut.clear(); + + QStringList lineStrList; + lineStrList.clear(); + + cmdStr = "wpa_cli -i wlan0 status";//查询wifi连接状态 + cmd.start(cmdStr); + cmd.waitForStarted(); + cmd.waitForFinished(); + strCmdOut=QString::fromLocal8Bit(cmd.readAllStandardOutput()); + //qDebug()<<"strCmdOut"<= 2) + { + QString str1 = lineStr[0]; + //qDebug()<= 0) + { + QString modeStr; + modeStr.clear(); + if(bl == false) + { + modeStr = tr("dynamic");//动态 + } + else if(bl == true) + { + modeStr = tr("static");//静态 + } + + ipStr = ipStr + "(" + modeStr + ")"; + } + else + { + if(bl == true) + { + m_pPromptDlg->setContentStr(tr("Failed to obtain IP. Please check the settings!"));//获取IP失败,请检查设置! + m_pPromptDlg->exec(); + } + } +#endif + return ipStr; +} + +//参数导入 +void MainWidgetFunction::funImportParameter(QString tStyle) +{ + m_pSystemManageDlg->setTypeLogo(tStyle); + m_pSystemManageDlg->setMainTitle(tr("Parameter Import")); + m_pSystemManageDlg->setSubTitle(tr("Auxiliary Function > Parameter Import")); + m_pSystemManageDlg->initDialog(); + systemUpgrade(PARA_IMPORT); +} + +//主控升级 +void MainWidgetFunction::funMCUpgrade(QString tStyle) +{ + m_pSystemManageDlg->setTypeLogo(tStyle); + m_pSystemManageDlg->setMainTitle(tr("MC Upgrade")); + m_pSystemManageDlg->setSubTitle(tr("Auxiliary Function > MC Upgrade")); + m_pSystemManageDlg->initDialog(); + systemUpgrade(MC_UPDATA); +} + +//界面升级 +void MainWidgetFunction::funHMIUpgrade(QString tStyle) +{ + m_pSystemManageDlg->setTypeLogo(tStyle); + m_pSystemManageDlg->setMainTitle(tr("HMI Upgrade")); + m_pSystemManageDlg->setSubTitle(tr("Auxiliary Function > HMI Upgrade")); + m_pSystemManageDlg->initDialog(); + + systemUpgrade(HMI_UPDATA); +} + +void MainWidgetFunction::funWIFI(QString tStyle) +{ + QStringList wifiStrList; + wifiStrList.clear(); + s16 rel = refreshWifiList(wifiStrList); + if(rel > 0) + { + m_pSystemManageDlg->setTypeLogo(tStyle); + m_pSystemManageDlg->setMainTitle(tr("WIFI")); + m_pSystemManageDlg->setSubTitle(tr("Auxiliary Function > WIFI")); + + bool mode = false;//动态获取IP方式 + QString iniPath = WIFIINIPATH; + QSettings setting(iniPath,QSettings::IniFormat); + QString wifiName = QByteArray::fromBase64(setting.value("WIFI/default_ssid").toByteArray()); + QString wifiPass = QByteArray::fromBase64(setting.value("WIFI/default_passwd").toByteArray()); + mode = setting.value("WIFI/static_mode").toBool(); + + QString ip = getIpSegment(mode); + if(ip.length() > 0)//已连接 + { + m_pSystemManageDlg->setWifiInfo(ip,wifiName,wifiPass,mode); + m_pSystemManageDlg->initDialog(1); + for(s16 i = 0; i < wifiStrList.size(); i++) + { + m_pSystemManageDlg->addItem(wifiStrList.at(i)); + } + emit siWifiState(true); + } + else//未连接 + { + m_pSystemManageDlg->initDialog(1); + for(s16 i = 0; i < wifiStrList.size(); i++) + { + m_pSystemManageDlg->addItem(wifiStrList.at(i)); + } + emit siWifiState(false); + } + m_pSystemManageDlg->exec(); + } +} + +//参数导出 +void MainWidgetFunction::funExportParameter() +{ + QString usbPath = detectUsb(); + if(usbPath.length() <= 0) + { + //优盘不存在 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("USB flash drive is not detected!");//未检测到优盘! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + + MCInfo info1 = g_pMachine->getMcInfo(); + QString software_ver; + software_ver.sprintf("%s",info1.softwareVerStr); + qDebug()<getMcPara())) , 1024 ); + memcpy(para_wk , (u8*) (&(g_pMachine->getWkPara())) , 1024 ); + + memcpy(pre_para_mc , (u8*) (&(g_pMachine->getPreMcPara())) , 1024 ); + memcpy(pre_para_wk , (u8*) (&(g_pMachine->getPreWkPara())) , 1024 ); + + //两个缓冲区,输出成一个参数文件 + // 转换结构体 开始 + ParaFile paraFileStruct ; + memset(¶FileStruct,0,sizeof(ParaFile)) ; + + paraFileStruct.s_head[0] = 'P'; + paraFileStruct.s_head[1] = 'A'; + paraFileStruct.s_head[2] = 'R'; + paraFileStruct.s_head[3] = 'A'; + + paraFileStruct.s_type = 0 ; + paraFileStruct.s_len = 4096 ; + + memcpy( paraFileStruct.s_para_buff , para_wk , 1024 ); + memcpy( (char *) (paraFileStruct.s_para_buff) + 1024 , para_mc , 1024 ); + memcpy( (char *) (paraFileStruct.s_para_buff) + 2048 , pre_para_mc , 1024 ); + memcpy( (char *) (paraFileStruct.s_para_buff) + 3072 , pre_para_wk , 1024 ); + + paraFileStruct.s_crc = calcCrc16( (u8 * ) paraFileStruct.s_para_buff , 4096 ) ; + // 转换结构体 结束 + + // 保存文件 开始 + QFile file(paraFileName); + file.open(QIODevice::ReadWrite | QIODevice::Truncate); + file.write((char*)¶FileStruct,sizeof(ParaFile)); + file.flush(); + file.close(); + // 保存文件 结束 + +#ifdef Q_OS_LINUX + system("sync"); +#endif + + //参数导出成功 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("Parameters exported successfully!");//参数导出成功! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; +} + +//全部归零 +void MainWidgetFunction::funAllToZero() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("All to zero"));//全部归零 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->allToZero(); + } + } +} + +//产量清零 +void MainWidgetFunction::funResetOutput() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("All to reset"));//产量清零 + + QString str; + str = tr("Whether to reset the output?");//是否重置产量? + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->resetOutput(); + } + } +} + +//流程复位 +void MainWidgetFunction::funAllToReset() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("All to reset"));//流程复位 + + QString str; + str = tr("If all process to reset?");//是否全部流程复位? + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->allToReset(); + } + } +} + +//主轴点动 +void MainWidgetFunction::funSpindleJog() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Spindle jog"));//主轴点动 + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->sewJog(); + } + } +} + +//主轴旋转 +void MainWidgetFunction::funSpindleRotate() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_SPINDLE_ROTATE); + m_pPromptDlg->setTitleStr(tr("Spindle rotate angle"));//主轴旋转角度 + m_pPromptDlg->exec(); + if (m_pPromptDlg->exec() == 1) + { + //s32 val = m_pPromptDlg->getSpindleRotateAngle(); + + if(g_pMachine != NULL) + { + } + } +} + +//回工作点 +void MainWidgetFunction::funBackWorkPoint() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Back work point"));//回工作点 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->gotoWorkPos(); + } + } +} + +//回原点 +void MainWidgetFunction::funBackToOrigin() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Back to origin"));//回原点 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->gotoZeroPos(); + } + } +} + +//定起始点 +void MainWidgetFunction::funSetStartPoint(QString filePath,int x,int y,int showFlag) +{ + if(filePath.length() <= 0) + { + return; + } + + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Set start point"));//定起始点 + QString str = tr("Whether to set the current point as the start point?");//是否将当前点设置为起始点? + m_pPromptDlg->setContentStr(str); + int setFlag = 1; + if(showFlag == 1) + { + setFlag = m_pPromptDlg->exec(); + } + + if(setFlag == 1) + { + int oldBeginX, oldBeginY; + oldBeginX = oldBeginY = 0; + if(g_pCurEmbData != NULL) + { + oldBeginX = g_pCurEmbData->getBeginX(); + oldBeginY = g_pCurEmbData->getBeginY(); + g_pCurEmbData->setStartPosition(x,y); + } + + sendPatternHead(filePath);//发送花样ds16头文件 + + //每次点击选择花样的时候才会生成ds16数据,其他时候就是给下位机发头文件 + //dsr,dst整个文件->中间数据->ds16 + int wx = x - oldBeginX - g_pCurEmbData->getAnchorX(); + int wy = y - oldBeginY - g_pCurEmbData->getAnchorY(); + writePonitToFile(filePath,wx,wy); //将新的起始点,机头,写回到(dst,dsr)源文件中 + + //流程复位 + g_pMachine->allToReset(); + slotCalMachineProgress(CSV_00_CODE_2); + } +} + +// 回起针点 +void MainWidgetFunction::funBackStartPoint() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + + //提示为起绣点设置,绣花机中定起绣点调用的是定定位点, + //所以提示回起绣点(回起绣点暂未使用) + m_pPromptDlg->setTitleStr(tr("Back embroidery point"));//回起绣点 + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->gotoStartPos(); + slotCalMachineProgress(CSV_00_CODE_3); + } + } +} + +//定偏移点 +void MainWidgetFunction::funSetOffsetPoint() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Set offset point"));//定偏移点 + + QString str; + str = tr("Whether to set the current point as the offset point?");//是否将当前点设置为偏移点? + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->setOffsetPos(); + } + } +} + +//回偏移点 +void MainWidgetFunction::funBackOffsetPoint() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Back offset point"));//回偏移点 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->gotoOffsetPos(); + } + } +} + +//边框检查 +void MainWidgetFunction::funBorderCheck() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Border check"));//边框检查 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if((m_mcStatus.workStatus & WORK_STA_BUSY) != 0) // 下位机在执行动作 + { + return; + } + + g_pMachine->checkFrame(); // 发给下位机,边框检查 + slotCalMachineProgress(CSV_00_CODE_4); + } +} + +//手动剪线 +void MainWidgetFunction::funManualTrim() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Trim"));//剪线 + QString str; + str = tr("The machine is about to cut the thread, please pay attention to safety!");//机器即将剪线,请注意安全! + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + //g_pMachine->sewCutThread(); + } + } +} + +//设置可工作区域 +void MainWidgetFunction::funSetWorkArea() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_WORK_AREA); + m_pPromptDlg->setTitleStr(tr("Setting workable area"));//设置可工作区域 + //int areaValue = m_pPromptDlg->getArea(); + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + } + } +} + +//剪刀开合 +void MainWidgetFunction::funCutterOpenAndClose() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Lower cutter"));//下剪线 + QString str; + str = tr("The scissors are about to move, please pay attention to safety!");//剪刀即将动作,请注意安全! + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + } + } +} + +//空走边框 +void MainWidgetFunction::funSimulateFrame() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Simulate frame"));//空走边框 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if((m_mcStatus.workStatus & WORK_STA_BUSY) != 0) // 下位机在执行动作 + { + return; + } + + g_pMachine->simulateFrame(); // 发给下位机,空走边框 + } +} + +//流程复位 +void MainWidgetFunction::funProcessReset() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Process reset"));//流程复位 + + QString str; + str = tr("The machine is about to reset, please pay attention to safety!");//机器即将流程复位,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->allToReset(); + } + } +} + +//手动加油 +void MainWidgetFunction::funManualOil() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Manual oil"));//手动加油 + + QString str; + str = tr("The machine is about to oil!");//机器即将加油! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->manualOil(1); + } + slotCalMachineProgress(CSV_00_CODE_6); + } +} + +//梭盘计数复位 +void MainWidgetFunction::funShuttleChange() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Shuttle count reset"));//梭盘计数复位 + + QString str; + str = tr("The machine is about to change the shuttle automatically!");//机器即将自动换梭! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->shuttleCounter(); + } + } +} + +//框架归零 +void MainWidgetFunction::funGotoZeroPos() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Goto zero pos"));//框架归零 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->gotoZeroPos(); + } + } +} + +//定工作范围 +void MainWidgetFunction::funSetWorkRange() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Set work range"));//定工作范围 + + QString str; + str = tr("If automatically set work range?");//是否自动定工作范围? + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + } + } +} + +void MainWidgetFunction::sendPatternHead(QString filePath) +{ + if(DATA_FORMATE == DATA_DS16) + { + //获取文件头并重新发送文件头 + DataDs16FileHead *pDs16Head = g_pCurEmbData->getDsDatHead(); + g_pMachine->setFilePara(0, m_curFileID, (DataFilePara&)*pDs16Head); + } + else if(DATA_FORMATE == DATA_DS8) + { + QString ds8FilePath = filePath + ".ds8"; + QFile file(ds8FilePath); + + if(file.exists())//存在ds8文件 + { + if(!file.open(QIODevice::ReadOnly)) + { + qDebug() << "open file fail when read"; + return; + } + + QByteArray ary = file.readAll(); + DataDs16FileHead *pDs8Head = (DataDs16FileHead *)(ary.data()); + + DataDs16FileHead *pDs16Head = g_pCurEmbData->getDsDatHead(); + pDs8Head->anchorX = pDs16Head->anchorX; + pDs8Head->anchorY = pDs16Head->anchorY; + pDs8Head->beginX = pDs16Head->beginX; + pDs8Head->beginY = pDs16Head->beginY; + pDs8Head->beginR = pDs16Head->beginR; + //pDs8Head->combineMode = pDs16Head->combineMode; + pDs8Head->maxX = pDs16Head->maxX; + pDs8Head->maxY = pDs16Head->maxY; + pDs8Head->minX = pDs16Head->minX; + pDs8Head->minY = pDs16Head->minY; + + g_pMachine->setFilePara(0, m_curFileID, (DataFilePara&)*pDs8Head); + + file.close(); + } + else + { + QByteArray ds16dat = g_pCurEmbData->getDsDat();//获得ds16数据 + + QByteArray ds8dat; + ds8dat.clear(); + + // ds16数据 + int size = ds16dat.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("data less then head size"); + return; + } + DataDs16FileHead * pDs16Head = (DataDs16FileHead *)(ds16dat.data()); + ds8dat.append((char*)pDs16Head,sizeof(DataDs16FileHead)); + + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("ds16 dataBegin err"); + return; + } + int stepsize = datasize/sizeof(Ds16Item); + if (stepsize <= 0) + { + qDebug("ds16 data size err"); + return; + } + Ds16Item *pData = (Ds16Item *)(ds16dat.data() + sizeof(DataDs16FileHead)); + Ds16Item * dataPtr = pData; + + u8 ctrl,attr; + s16 dx,dy,dr; + Ds8Item ds8Item; + + for (int i = 0; i < stepsize; i++) + { + ctrl = dataPtr->ctrl; + attr = dataPtr->attr; + dx = dataPtr->dx; + dy = dataPtr->dy; + dr = dataPtr->dr; + + ds8Item.ctrl = ctrl; + ds8Item.attr = attr; + ds8Item.dx = dx; + ds8Item.dy = dy; + ds8Item.dr = dr; + + ds8dat.append((char*)&ds8Item,sizeof(Ds8Item)); + + dataPtr++; + } + + //发送ds8数据 + DataDs16FileHead * pDs8Head = (DataDs16FileHead *)(ds8dat.data()); + Ds8Item *tData = (Ds8Item *)(ds8dat.data() + sizeof(DataDs16FileHead)); + + //重新生成文件头 + pDs8Head->dataSize = pDs8Head->itemNums*sizeof(Ds8Item); // 数据字节数 + pDs8Head->bytesPerItem = sizeof(Ds8Item); // 每项占的字节数 + pDs8Head->dataChecksum = calcCheckSum32((u8 *)(tData) , pDs8Head->dataSize);; // 数据累加校验和 + pDs8Head->checkCrc = calcCrc16((u8 *)(pDs8Head), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + + g_pMachine->setFilePara(0, m_curFileID, (DataFilePara&)*pDs8Head); + } + } +} + +//选择花样后发送数据并显示大图 +void MainWidgetFunction::sendPatternData(QString filePath,int type) +{ + m_filePath = filePath; + + //保存最后一次绣作的花样路径到配置文件中 + if(g_pSettings != NULL) + { + g_pSettings->writeToIniFile("Pattern/name",filePath); + } + + if(DATA_FORMATE == DATA_DS16) + { + sendDs16PatternData(type);//发送ds16数据 + } + else if(DATA_FORMATE == DATA_DS8) + { + convertDs16ToDs8AndSend(filePath,type);//将ds16数据转换为ds8数据并发送 + } +} + +void MainWidgetFunction::funBottomDetect() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_BOTTOM); + m_pPromptDlg->setTitleStr(tr("Bottom line detection")); + m_pPromptDlg->exec(); +} + +void MainWidgetFunction::funFaceDetect() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_FACE); + m_pPromptDlg->setTitleStr(tr("Face line detection")); + m_pPromptDlg->exec(); +} + +void MainWidgetFunction::funExitRoot() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + g_emUser = operate; + m_pPromptDlg->setContentStr(tr("Exit successfully!"));//成功退出! + m_pPromptDlg->exec(); +} + +void MainWidgetFunction::funGetMCVersionInfo() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("System info")); + m_pPromptDlg->setContentInfoShow(); + + m_pPromptDlg->exec(); +} + +void MainWidgetFunction::funProductStatistics(QString tStyle,QString filePath,int patternBreakLineNum) +{ + m_pSystemManageDlg->setTypeLogo(tStyle); + m_pSystemManageDlg->setMainTitle(tr("Production statistics"));//生产统计 + m_pSystemManageDlg->setSubTitle(tr("Auxiliary Function > Production statistics"));//辅助功能 > 生产统计 + m_pSystemManageDlg->initDialog(); + + m_filePath = filePath; + QFileInfo file(m_filePath); + QString fileName = file.fileName(); + m_fileName = fileName; + addProductStatisInfo(patternBreakLineNum); + m_pSystemManageDlg->exec(PRODUCTSTATIS); +} + +//错误日志 +void MainWidgetFunction::slotJournalError() +{ + //m_pSystemManageDlg->setTypeLogo(tStyle); + m_pSystemManageDlg->setMainTitle(tr("Error Log"));//错误日志 + m_pSystemManageDlg->setSubTitle(tr("Auxiliary Function > Error Log"));//辅助功能 > 错误日志 + m_pSystemManageDlg->initDialog(); + addJournalInfoError(); + //m_pSystemManageDlg->exec(JOURNALERROR);//显示窗体 +} + +//断线日志 +void MainWidgetFunction::slotJournalBreakage() +{ + //m_pSystemManageDlg->setTypeLogo(tStyle); + m_pSystemManageDlg->setMainTitle(tr("Breakage Log"));//断线日志 + m_pSystemManageDlg->setSubTitle(tr("Auxiliary Function > Breakage Log"));//辅助功能 > 断线日志 + m_pSystemManageDlg->initDialog(); + addJournalInfoBreakage(); + //m_pSystemManageDlg->exec(JOURNALBREAKAGE);//显示窗体 +} + +void MainWidgetFunction::slotCsvChangeDebug() +{ + //m_pSystemManageDlg->setTypeLogo(tStyle); + m_pSystemManageDlg->setMainTitle(tr("Debug Info"));//调试信息 + m_pSystemManageDlg->setSubTitle(tr("Auxiliary Function >Debug Info"));//辅助功能 > 调试信息 + m_pSystemManageDlg->initDialog(); + addJournalInfoDebug(); + //m_pSystemManageDlg->exec(JOURNALBREAKAGE);//显示窗体 +} + +//错误日志 +void MainWidgetFunction::funJournalError(QString tStyle) +{ + m_pSystemManageDlg->setTypeLogo(tStyle); + m_pSystemManageDlg->setMainTitle(tr("ErrorLog"));//错误日志 + m_pSystemManageDlg->setSubTitle(tr("Auxiliary Function > ErrorLog"));//辅助功能 > 错误日志 + m_pSystemManageDlg->initDialog(); + addJournalInfoError(); + m_pSystemManageDlg->exec(JOURNAL);//显示窗体 +} + +void MainWidgetFunction::funDebugInfo() +{ + m_pDebugInfoDlg->initDialog(); + m_pDebugInfoDlg->addListInfo(); + m_pDebugInfoDlg->exec();//显示窗体 +} + +void MainWidgetFunction::funSoftwareAuthor() +{ + if (g_pMachine != NULL) + { + if(g_pMachine->isConnected() == 3) + { + g_pMachine->getInfoFromMachine(); + } + else + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("No connection")); + m_pPromptDlg->exec(); + return; + } + } + + // 设置板卡ID值的显示 + m_pPromptDlg->initDialog(PromptDialog::BTN_WARRANT); + m_pPromptDlg->setTitleStr(tr("Warrant")); + m_pPromptDlg->setContentWarrantShow(); + m_pPromptDlg->exec(); +} + +//报错信息 +int MainWidgetFunction::funErrorPrompt(QString info) +{ + int ret = 0; + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + //QString errInfo= errcode+info; + m_pPromptDlg->setContentStr(info); + if(m_pPromptDlg->exec() == 1) + { + g_pMachine->cleanError(); + } + return ret; +} + +int MainWidgetFunction::funDetectBreakLineStatus() +{ + //断线状态 + QString allStr; + allStr.clear(); + QString headStr; + headStr.clear(); + + QString infoStr;//记录到csv的内容 + infoStr.clear(); + + int ret = 0; + if(g_pMachine != NULL) + { + ParaStruct mcParaValues; + mcParaValues = g_pMachine->getMcPara(); + } + g_pSettings->writeToCsv(infoStr,TYPE_BREAK);//保存到csv + + return ret; +} + +void MainWidgetFunction::funSetPromptDlgVisibleFalse() +{ + if(m_pPromptDlg->isVisible()) + { + m_pPromptDlg->done(1); + } + if(m_pBrokenLineDialog->isVisible())//断线检测弹窗消失 + { + m_pBrokenLineDialog->hide(); + } +} + +//底线计数复位 +void MainWidgetFunction::funBottomLineCountReset() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("Is the bottom line count reset?")); //是否底线计数复位? + if(m_pPromptDlg->exec() == 1) + { + g_pMachine->resetBobbinCounter(); // 底线计数复位 + } +} + +//手自动工作状态切换 0:手动 1:自动 +void MainWidgetFunction::funManualOrAutoSwitch(s16 val) +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt")); + if(val == 0) + { + m_pPromptDlg->setContentStr(tr("Are you sure to ManualSwitch?")); //是否手动工作状态切换? + if(m_pPromptDlg->exec() == 1) + { + g_pMachine->setToManualWork(); + } + } + else if( val ==1) + { + m_pPromptDlg->setContentStr(tr("Are you sure to AutoSwitch?")); //是否自动工作状态切换? + if(m_pPromptDlg->exec() == 1) + { + g_pMachine->setToAutoWork(); + } + } +} + +void MainWidgetFunction::slotCalMachineProgress(s16 csvCode,s16 type) +{ + int per = 0; + int ifPress = 0; + + for(int i = 1; i < m_csvFileStrList.size(); i++) + { + QStringList strlist = m_csvFileStrList[i].split(",", QString::SkipEmptyParts); //根据","分隔开每行的列 + if(strlist.size() > 0) + { + QString code = strlist.at(COLUMN_CODE); + QStringList strlist1 = code.split("_", QString::SkipEmptyParts); //根据"_"分隔开每行的列 + int infoCode = 0; + int csvType = 0; + if(strlist1.size() >= 2) + { + char *bufCode = strdup(strlist1[2].toLatin1().data()); + sscanf (bufCode, "%x", &infoCode); + + char *bufType = strdup(strlist1[1].toLatin1().data()); + sscanf (bufType, "%x", &csvType); + } + + if(infoCode == csvCode && type == csvType) + { + QStringList strlist2 = m_csvFileStrList[i].split(",", QString::SkipEmptyParts); //根据","分隔开每行的列 + if(COLUMN_PRESSNUM < strlist2.size()) + { + ifPress = strlist2.at(COLUMN_PRESSNUM).toInt()+1; + strlist2[COLUMN_PRESSNUM] = QString::number(ifPress); + QString str; + for(int m = 0; m < strlist2.size(); m++) + { + str.append(strlist2[m]); + if(m != strlist2.size() - 1) + { + str.append(","); + } + } + m_csvFileStrList[i] = str; + + //如果按钮没被点击过就加入百分比的计算 + if(ifPress == 1) + { + per += strlist2.at(COLUMN_SCORE).toInt(); + } + } + + m_getScore += per; + + if(per != 0) + { + if(m_totalScore == 0) + { + m_totalScore = 1; + } + + sendDataToGateway(csvCode,type); + } + + break; + } + } + } + + if(ifPress == 1) + { + QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); + + QByteArray array; + array.clear(); + for(int j = 0; j < m_csvFileStrList.size(); j++) + { + QString str = m_csvFileStrList[j]; + array.append(str.toLocal8Bit()); + if(j != m_csvFileStrList.size() - 1) + { + array.append('\n'); + } + } + + QDir apppath(qApp->applicationDirPath()); + QString path = apppath.path() + apppath.separator() + CSV_PROGRESS; + QFile file(path); + if (file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) + { + file.write(array); +#ifdef Q_OS_LINUX + system("sync"); +#endif + } + file.close(); + + QString iniPath = apppath.path() + apppath.separator() + "config.ini"; + QSettings setting(iniPath, QSettings::IniFormat); //QSettings能记录一些程序中的信息,下次再打开时可以读取出来 + setting.setValue("Progress/getScore",m_getScore); //记录路径到QSetting中保存 + + QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); + } +} + +//发送ds16花样数据 +void MainWidgetFunction::sendDs16PatternData(int type) +{ + QByteArray & ds16dat = g_pCurEmbData->getDsDat(); + + // ds16数据(转换的) + int size = ds16dat.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("data less then head size"); + return; + } + DataDs16FileHead * pDs16Head = (DataDs16FileHead *)(ds16dat.data()); + + qDebug()<<"fileid 2"<fileid; + + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("ds16 dataBegin err"); + return; + } + int stepsize = datasize/sizeof(Ds16Item); + if (stepsize <= 0) + { + qDebug("ds16 data size err"); + return; + } + Ds16Item *pData = (Ds16Item *)(ds16dat.data() + sizeof(DataDs16FileHead)); + +#if(0) + Ds16Item item; + item.dx = pData->dx; + item.dy = pData->dy; + item.dr = pData->dr; + if(item.dx == 0 && item.dy == 0) + { + ds16dat.remove(0,sizeof(Ds16Item)); + pData = (Ds16Item *)(ds16dat.data() + sizeof(DataDs16FileHead)); + } +#endif + + //发送ds16数据 + m_curFileID++; + if ((m_curFileID & 0xffff) == 0) + { + m_curFileID = 1; + } + if(g_pMachine != NULL) + { + g_pMachine->sendFileProc(type, 0, m_curFileID, pDs16Head, (u8*)pData); + } +} + +//将ds16数据转换为ds8数据并发送 +void MainWidgetFunction::convertDs16ToDs8AndSend(QString filePath,int type) +{ + QByteArray ds16dat = g_pCurEmbData->getDsDat();//获得ds16数据 + + QByteArray ds8dat; + ds8dat.clear(); + + // ds16数据 + int size = ds16dat.size(); + if (size <= (int)sizeof(DataDs16FileHead)) + { + qDebug("data less then head size"); + return; + } + DataDs16FileHead * pDs16Head = (DataDs16FileHead *)(ds16dat.data()); + ds8dat.append((char*)pDs16Head,sizeof(DataDs16FileHead)); + + int datasize = size - sizeof(DataDs16FileHead); + if (datasize <= 0) + { + qDebug("ds16 dataBegin err"); + return; + } + int stepsize = datasize/sizeof(Ds16Item); + if (stepsize <= 0) + { + qDebug("ds16 data size err"); + return; + } + Ds16Item *pData = (Ds16Item *)(ds16dat.data() + sizeof(DataDs16FileHead)); + Ds16Item * dataPtr = pData; + + u8 ctrl,attr; + s16 dx,dy,dr; + Ds8Item ds8Item; + + for (int i = 0; i < stepsize; i++) + { + ctrl = dataPtr->ctrl; + attr = dataPtr->attr; + dx = dataPtr->dx; + dy = dataPtr->dy; + dr = dataPtr->dr; + + ds8Item.ctrl = ctrl; + ds8Item.attr = attr; + ds8Item.dx = dx; + ds8Item.dy = dy; + ds8Item.dr = dr; + + ds8dat.append((char*)&ds8Item,sizeof(Ds8Item)); + + dataPtr++; + } + +#if(1) + //保存成ds8文件 + QString ds8FilePath = filePath + ".ds8"; + QFile file(ds8FilePath); + if(file.exists())//存在ds8文件 + { + QFile::remove(ds8FilePath); + } +#endif + + //发送ds8数据 + DataDs16FileHead * pDs8Head = (DataDs16FileHead *)(ds8dat.data()); + Ds8Item *tData = (Ds8Item *)(ds8dat.data() + sizeof(DataDs16FileHead)); + + //重新生成文件头 + pDs8Head->dataSize = pDs8Head->itemNums*sizeof(Ds8Item); // 数据字节数 + pDs8Head->bytesPerItem = sizeof(Ds8Item); // 每项占的字节数 + pDs8Head->dataChecksum = calcCheckSum32((u8 *)(tData) , pDs8Head->dataSize);; // 数据累加校验和 + pDs8Head->checkCrc = calcCrc16((u8 *)(pDs8Head), HEAD_FIX_INFO_LEN); // 前面6个字段的CRC校验,(6个字段分别为:文件名称,字节数,项个数,每项字节数,每块字节数,数据累加和的CRC校验值) + + m_curFileID++; + if ((m_curFileID & 0xffff) == 0) + { + m_curFileID = 1; + } + g_pMachine->sendFileProc(type, 0, m_curFileID, pDs8Head, (u8*)tData); + + if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) + { + qDebug() << "open file fail when wirte, path =" << filePath; + return; + } + else + { + file.write(ds8dat); + file.close(); + } +} + +void MainWidgetFunction::addProductStatisInfo(int patternBreakLineNum) +{ + //刷新生产统计信息 + m_pSystemManageDlg->initDialog(); + + QString itemStr = tr("Total number of patterns processed: ") + QString::number(m_mcStatus.outCounter);//总共加工花样数量: + m_pSystemManageDlg->addItem(itemStr); + itemStr = tr("Total number of embroidery: ") + QString::number(m_mcStatus.needleNum);//总刺绣针数: + m_pSystemManageDlg->addItem(itemStr); + + itemStr = tr("Pattern name: ") + m_fileName;//花样名称: + m_pSystemManageDlg->addItem(itemStr); + + itemStr = tr("Pattern break line num: ") + QString::number(patternBreakLineNum);//花样断线次数: + m_pSystemManageDlg->addItem(itemStr); + + ParaStruct mcParaValues; + mcParaValues = g_pMachine->getMcPara(); + int needleBreakNum = 0; + //机头断线次数: + itemStr = tr("Head ") + QString::number(1) + tr(" break line num: ") + QString::number(needleBreakNum);// 机头断线次数: + m_pSystemManageDlg->addItem(itemStr); +} + +void MainWidgetFunction::addJournalInfoError() +{ + //刷新信息 + m_pSystemManageDlg->initDialog(); + m_pSystemManageDlg->addListError();//读取csv列表 +} + +void MainWidgetFunction::addJournalInfoBreakage() +{ + //刷新信息 + m_pSystemManageDlg->initDialog(); + m_pSystemManageDlg->addListBreakage();//读取csv列表 +} + +void MainWidgetFunction::addJournalInfoDebug() +{ + //刷新信息 + m_pSystemManageDlg->initDialog(); + m_pSystemManageDlg->addListDebug();//读取csv列表 +} + +QString MainWidgetFunction::getCompileDateTime() +{ + const char *pMonth[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + const char date[12] = __DATE__; // 取编译日期 + + int i; + int month, year, day; + month = year = day = 0; + for(i = 0; i < 12; i++) + { + if(memcmp(date, pMonth[i], 3) == 0) + { + month = i + 1; + break; + } + } + year = (unsigned char)atoi(date + 9); // date[9]为2位年份, date[7]为完整年份 + day = (unsigned char)atoi(date + 4); // 日期 + + QString str; + str.sprintf("%02d%02d%02d", year, month, day); + return str; +} + +//组成json键值对 +QString MainWidgetFunction::compositionJson(QString key, QString value) +{ + QString mStr="\"";//引号的字符串 + QString str = mStr + key + mStr + ":" + mStr + value + mStr + ","; + return str; +} + +HMILotData MainWidgetFunction::getHMILotData() +{ + HMILotData lotFata; + memset(&lotFata, 0, sizeof(HMILotData)); + + memcpy(lotFata.HMIVerStr, getVersionStr().data(), getVersionStr().length()); // 版本信息 + memcpy(lotFata.fileName, m_fileName.data(), m_fileName.length()); // 文件名称 + + u32 rackNum = g_pSettings->readFromIniFile("IOT/rackNumber").toInt();//机架号 + lotFata.machineNumber = rackNum; // 机架号 + + QString deliveryTime = g_pSettings->readFromIniFile("IOT/deliveryTime").toString();//工厂预计交货时间 + QByteArray arr = deliveryTime.toLocal8Bit(); + memcpy(lotFata.deliveryTime, arr.data(), arr.size()); //交货日期 + + u16 debugProgress = g_pSettings->readFromIniFile("IOT/debugProgress").toInt();//调试进度 + lotFata.debugProgress = debugProgress; //调试进度 + + //电机总数-先固定写为4个,如果后续变动较大,可把电机个数写为全局变量或从其他cpp中传参 + lotFata.motorNum = 4; + + return lotFata; +} + +//发送数据到物联网 +void MainWidgetFunction::sendDataToGateway(s16 code,s16 type) +{ + QString mStr="\"";//引号的字符串 + + QString mcType = mStr+U00016+mStr+":"+mStr+"Emb"+mStr+","; + + QString mcStr1; + mcStr1.clear(); + QString mcStr2; + mcStr2.clear(); + mcStr1 = mStr+"Towel"+mStr+":0,"; + mcStr2 = mStr+"Coil"+mStr+":0,"; + s16 towel = g_pSettings->readFromIniFile("HMI/towel").toInt();//是否有毛巾功能 + s16 coil = g_pSettings->readFromIniFile("HMI/coil").toInt();//是否有缠绕功能 + if(towel == 1) + { + mcStr1 = mStr+"Towel"+mStr+":1,"; + } + if(coil == 1) + { + mcStr2 = mStr+"Coil"+mStr+":1,"; + } + + QString sensorMotorStr; + sensorMotorStr.clear(); + + sensorMotorStr = mStr+S00000+mStr+":1,"+mStr+S00010+mStr+":1,"+mStr+S00070+mStr+":1,"+mStr+S01000+mStr+":1,"; + + if(type == 0) + { + switch (code) + { + case CSV_00_CODE_1: + sensorMotorStr += mStr+S00020+mStr+":1,"; + sensorMotorStr += mStr+M0003+mStr+":1,"; + break; + case CSV_00_CODE_4://边框检查 + case CSV_00_CODE_8://自动定软限位 + sensorMotorStr += mStr+S00200+mStr+":1,"; + sensorMotorStr += mStr+S00201+mStr+":1,"; + sensorMotorStr += mStr+S00220+mStr+":1,"; + sensorMotorStr += mStr+S00221+mStr+":1,"; + sensorMotorStr += mStr+S00230+mStr+":1,"; + sensorMotorStr += mStr+S00231+mStr+":1,"; + sensorMotorStr += mStr+M0001+mStr+":1,"; + sensorMotorStr += mStr+M0002+mStr+":1,"; + break; + case CSV_00_CODE_5: + sensorMotorStr += mStr+M0004+mStr+":1,"; + break; + default: + break; + } + } + else if(type == CSV_MC_TYPE_02) + { + switch (code) + { + case CSV_02_CODE_1://毛巾M轴零位 + sensorMotorStr += mStr+S01020+mStr+":1,"; + sensorMotorStr += mStr+M0005+mStr+":1,"; + sensorMotorStr += mStr+M0006+mStr+":1,"; + break; + case CSV_02_CODE_2://毛巾打环轴归零 + sensorMotorStr += mStr+S01021+mStr+":1,"; + sensorMotorStr += mStr+M0007+mStr+":1,"; + break; + default: + break; + } + } + else if(type == CSV_MC_TYPE_03) + { + switch (code) + { + case CSV_03_CODE_1://缠绕压脚电机归零 + sensorMotorStr += mStr+M0008+mStr+":1,"; + sensorMotorStr += mStr+M0009+mStr+":1,"; + sensorMotorStr += mStr+M0010+mStr+":1,"; + break; + case CSV_03_CODE_2://缠绕锯齿电机归零 + sensorMotorStr += mStr+M0011+mStr+":1,"; + break; + default: + break; + } + } + + int val = ((double)m_getScore / (double)m_totalScore) * 100; + //emit siShowPercentage(val);//测试物联网用 + + QString timeStr; + timeStr.clear(); + +#ifdef Q_OS_LINUX + timeStr = QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch() - 28800000);//mcgs下时间差8个小时 +#endif + +#ifdef Q_OS_WIN + timeStr = QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch()); +#endif + + QString lotStr; + lotStr.clear(); + lotStr = "{" + mStr + QString::number(m_HMILotData.machineNumber) + "#" + mStr + ":[{" + + mStr + "ts" + mStr + ":" + timeStr + "," + + mStr + "values" + mStr + ":{\"timestamp" + mStr + ":" + timeStr + ",\"RackNumber\":\"" + QString::number(m_HMILotData.machineNumber) + "#\"" + "," + + mcType + mcStr1 + mcStr2 + sensorMotorStr; + + QString keyStr = compositionJson(U00001, QString::number(val)); + lotStr += keyStr; + lotStr.chop(1); + + lotStr += "}}]}"; + //qDebug()<sendLotDataToGateway(lotStr); +} + +void MainWidgetFunction::setErrorCodeAndStateList(QList list) +{ + m_errorCodeAndStateItemList.clear(); + m_errorCodeAndStateItemList.append(list); +} + +//上电计算 关机时间 并发送给主控 +void MainWidgetFunction::setShutDownTime() +{ + int oldSecond = g_pSettings->readFromIniFile("DateTime/second").toInt();//上次上电的系统时间 + + QDateTime dateTime = QDateTime::currentDateTime(); //当前时间 + int curSecond = dateTime.toTime_t();//单位为秒 //新的时间 + int diff = curSecond - oldSecond;//关机秒数 + if (diff >= 0) + { + } + else//小于0 + { + diff = 5000*3600; + } + qDebug()<<"shutdown second"<setShutDownTime(0, diff);//可能这个diff太大了 + } +} +//设置机器状态 +void MainWidgetFunction::setMcStates(MCStatus mcStatus) +{ + memset((char*)&m_mcStatus,0,sizeof(MCStatus)); + memcpy((char*)&m_mcStatus,(char*)&mcStatus,sizeof(MCStatus)); +} + +QString MainWidgetFunction::getVersionStr() +{ + QString str; + str.sprintf("RSAPL EMB-V"); + str += getCompileDateTime(); + return str; +} + +//将定位点或起绣点写回到文件中 +void MainWidgetFunction::writePonitToFile(QString filePath,int x, int y, int flag) +{ + QFileInfo fileInfo(filePath); + QString suffix = fileInfo.suffix().toUpper();//后缀大写 + + if(suffix == "DST") + { + DataFileDst dst; + dst.initFile(filePath); + dst.loadFile(); + dst.writePointToFile(x,y,flag); + } + else if(suffix == "DSR") + { + DataFileDsr dsr; + dsr.initFile(filePath); + dsr.loadFile(); + dsr.writePointToFile(x,y,flag); + } + else if(suffix == "QUI") + { + } + else if(suffix == "QUIX") + { + } + else if(suffix == "PLT") + { + } + else if(suffix == "DXF") + { + } +} + +//机器信息改变 +void MainWidgetFunction::slotMCInfoChange() +{ + static int fID = 0; + m_mcStatus = g_pMachine->getMcStatus(); + + //可使用时长 + int workTime = m_mcStatus.workableTimer; + if( workTime > 0 && workTime < INT_MAX ) + { + QString strTime; + QString strDay; + QString strHour; + QString strSec; + + int day = workTime/(60 *24); + + //使用时长不足5天就主动提示用户 + if(day < 5 && fID == 0) + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + + strDay = QString::number(workTime/(60 *24) , 10); + strHour = QString::number((workTime%(60 *24))/60 , 10) ; + strSec = QString::number(workTime%60 , 10); + + strTime = strDay + " " + tr("Day") + " " + strHour + " " + tr("Hour") + " " + strSec + " " + tr("Minutes") ; // 天 小时 分钟 + + //机器剩余可用时间为 + str = tr("The remaining available time of the machine is ") + strTime; + + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + //开启一个定时器,隔4个小时就发一次查询机器状态 + m_pTipsTimer->start(); + fID++; + } + } +} + +//给主控发查询机器信息 +void MainWidgetFunction::onTipsTimer() +{ + if (g_pMachine != NULL) + { + g_pMachine->getInfoFromMachine(); + } + m_pTipsTimer->stop(); //关定时器 +} + +void MainWidgetFunction::slotSetDynamicIP(QString ssid) +{ + if(ssid.length() <= 0) + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("ssid is empty!"));//ssid为空! + m_pPromptDlg->exec(); + return; + } + + WordsInputDialog wordInputDlg; + wordInputDlg.wifiClean(); + wordInputDlg.setTitleStr(tr("Password input"));//密码输入 + wordInputDlg.setOldWordsStr(""); + if(wordInputDlg.exec() == 1) + { +#ifdef Q_OS_LINUX + QString psd = wordInputDlg.getInputStr(); + //base64解密 + //向配置文件写入加密结果,设置动态IP + QString iniPath = WIFIINIPATH; + QSettings setting(iniPath,QSettings::IniFormat); + setting.beginGroup("WIFI"); + setting.setValue("default_passwd",psd.toLatin1().toBase64()); + setting.setValue("default_ssid",ssid.toLatin1().toBase64()); + setting.setValue("static_ip",""); + setting.setValue("static_mask",""); + setting.setValue("static_mode","false"); + setting.endGroup(); + + system("sync"); + + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("Settings require screen restart to take effect!");//设置需要重启屏幕才生效! + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + system("reboot"); + } +#endif + } +} + +void MainWidgetFunction::slotSetStaticIP(QString ssid, QString psd,QString dnip) +{ + if(ssid.length() <= 0) + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("ssid is empty!"));//ssid为空! + m_pPromptDlg->exec(); + return; + } + if(psd.length() <= 0){}//为了去掉编译警告 + + PassWordDialog passWordDlg; + QString ip; + ip.clear(); + passWordDlg.setTitleStr(tr("IP input"),-1);//IP输入 + passWordDlg.setShowIfVisible(true); + passWordDlg.setIpStr(dnip); + int rslt = passWordDlg.exec(); + if(rslt == 1) + { + ip = passWordDlg.getInputStr(); + } + +#ifdef Q_OS_LINUX + if(ip.length() <= 0) + { + return; + } + + //base64解密 + //向配置文件写入加密结果,设置静态IP + QString iniPath = WIFIINIPATH; + QSettings setting(iniPath,QSettings::IniFormat); + setting.beginGroup("WIFI"); + setting.setValue("default_passwd",psd.toLatin1().toBase64()); + setting.setValue("default_ssid",ssid.toLatin1().toBase64()); + setting.setValue("static_ip",ip); + setting.setValue("static_mask","255.255.255.0"); + setting.setValue("static_mode","true"); + setting.endGroup(); + + system("sync"); + + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("Settings require screen restart to take effect!");//设置需要重启屏幕才生效! + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + system("reboot"); + } + return; + +#endif +} + +void MainWidgetFunction::slotSpindleAction(int action) +{ + if(g_pMachine != NULL) + { + g_pMachine->motoMove(MT_LM, action, 0); + } +} + +void MainWidgetFunction::slotSpindleRotate(int angle) +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(MT_LM,angle); + } +} + +//接收到主板的物联网数据 +void MainWidgetFunction::slotReceiveLotData() +{ + static int nID = 0; + + //因为串口模式打开串口成功在连接的信号和槽之前,所以写以下代码表示刚建立连接就向网关发送连接符 + //网口连接方式不会有此问题,串口转wifi又不能检测wifi断开,所以每次都发送连接符 + QString mStr="\"";//引号的字符串 + QString lotStr; + lotStr.clear(); + if(nID % 2 == 0)//为了让两条间隔分开,用取余做判断,否则网关收到键值对错误 + { + lotStr += "{" + mStr + "device" + mStr + ":" + mStr + QString::number(m_HMILotData.machineNumber) + "#" + mStr + "}"; + //如果物联网Machine 不是空 + if(g_pLotMachine != NULL) + { + //相当于Machine给主板发数据 + g_pLotMachine->sendLotDataToGateway(lotStr);//发送物联数据(机器编号)到网关 + } + nID++; + return; + } + + //emit siReceiveLotDat(); //测试物联网用 + //qDebug()<<"slotReceiveLotData"; //测试物联网用 + + McLotData nMcLotData = g_pMachine->getMcLotData();//得到下位机的物联网数据 + HMILotData nHMILotData = getHMILotData(); //得到界面要发给网关的物联网数据 + + QString timeStr; + timeStr.clear(); + +#ifdef Q_OS_LINUX + timeStr = QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch() - 28800000);//mcgs下时间差8个小时 +#endif + +#ifdef Q_OS_WIN + timeStr = QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch()); +#endif + + lotStr.clear(); + lotStr = "{" + mStr + QString::number(m_HMILotData.machineNumber) + "#" + mStr + ":[{" + + mStr + "ts" + mStr + ":" + timeStr + "," + + mStr + "values" + mStr + ":{\"timestamp" + mStr + ":" + timeStr + ",\"RackNumber\":\"" + QString::number(m_HMILotData.machineNumber) + "#\"" + ","; + + QString keyStr; + keyStr.clear(); + + if(g_pLotMachine != NULL) + { + if(nID == 0) + { + keyStr = compositionJson(U00033, S0504); + } + else + { + if ((m_mcStatus.workStatus & WORK_STA_BUSY) != 0) // 下位机在执行动作 + { + keyStr = compositionJson(U00033, S0505); + } + else + { + keyStr = compositionJson(U00033, S0504); + } + } + lotStr += keyStr; + + //机器版本 + // 界面上存的下位机数据 下位机里的数据 + if(memcmp(&m_mcLotData.mBoardVerStr, &nMcLotData.mBoardVerStr, sizeof(nMcLotData.mBoardVerStr)) != 0) + { + keyStr = compositionJson(U00022, QString::fromLocal8Bit(nMcLotData.mBoardVerStr)); + lotStr += keyStr; + } + + //报警信息 + // 界面上存的下位机数据 不等于 下位机里的数据 + //这种情况应该就是主控里的数据和界面上存的不一样了 + if(m_mcLotData.errorCode != nMcLotData.errorCode) + { + if ((nMcLotData.errorCode > 0 && nMcLotData.errorCode < 0x100) || nMcLotData.errorCode > 0x200) + { + QString info; + info.clear(); + info = getErrStr(nMcLotData.errorCode); + //如果不是通用错误(即info为空),就从机型cpp中的错误代码查找 + if(info.length() <= 0) + { + for(int i = 0; i < m_errorCodeAndStateItemList.size(); i++) + { + if(nMcLotData.errorCode == m_errorCodeAndStateItemList[i].m_code) + { + info = m_errorCodeAndStateItemList[i].m_name; + break; + } + } + } + //如果不是通用错误也不是机型cpp中的错误代码,就显示未定义错误 + if(info.length() <= 0) + { + QString errorCode; + errorCode.sprintf("CODE 0x%x", nMcLotData.errorCode); + info.append(tr("Undefined error,") + errorCode);//未定义错误, + } + + keyStr = compositionJson(U00023, QString::number(nMcLotData.errorCode));// 原来为info,lxs修改 + lotStr += keyStr; + } + } + + //授权剩余时间(min) + if(m_mcLotData.workableTimer != nMcLotData.workableTimer) + { + keyStr = compositionJson(U00025, QString::number(nMcLotData.workableTimer)); + lotStr += keyStr; + } + + //开机时间(min) + if(m_mcLotData.bootTimer != nMcLotData.bootTimer) + { + keyStr = compositionJson(U00026, QString::number(nMcLotData.bootTimer)); + lotStr += keyStr; + } + + //工作时间(min) + if(m_mcLotData.workTimer != nMcLotData.workTimer) + { + keyStr = compositionJson(U00027, QString::number(nMcLotData.workTimer)); + lotStr += keyStr; + } + + //工作转速 + if(m_mcLotData.workRpm != nMcLotData.workRpm) + { + keyStr = compositionJson(U00004, QString::number(nMcLotData.workRpm)); + lotStr += keyStr; + } + + //当前产量 + if(m_mcLotData.curOutCounter != nMcLotData.curOutCounter) + { + keyStr = compositionJson(U00028, QString::number(nMcLotData.curOutCounter)); + lotStr += keyStr; + } + + //累计产量 + if(m_mcLotData.totalOutCounter != nMcLotData.totalOutCounter) + { + keyStr = compositionJson(U00014, QString::number(nMcLotData.totalOutCounter)); + lotStr += keyStr; + } + + //产量设定 + if(m_mcLotData.expectedOutput != nMcLotData.expectedOutput) + { + keyStr = compositionJson(U00029, QString::number(nMcLotData.expectedOutput)); + lotStr += keyStr; + } + + //设备(机器)ID + if(memcmp(&m_mcLotData.boardId, &nMcLotData.boardId, sizeof(nMcLotData.boardId)) != 0) + { + keyStr = compositionJson(U00017, QString::fromLocal8Bit(nMcLotData.boardId)); + lotStr += keyStr; + } + + //主轴零位 + if(m_mcLotData.spindleZeroSta != nMcLotData.spindleZeroSta) + { + keyStr = compositionJson(U00034, QString::number(nMcLotData.spindleZeroSta)); + lotStr += keyStr; + } + + //主轴角度 + if(m_mcLotData.spindleAngle != nMcLotData.spindleAngle) + { + keyStr = compositionJson(U00035, QString::number(nMcLotData.spindleAngle)); + lotStr += keyStr; + } + + //电机1坐标(绣框X坐标) + if(m_mcLotData.motosPos[1] != nMcLotData.motosPos[1]) + { + keyStr = compositionJson(U00036, QString::number(nMcLotData.motosPos[1])); + lotStr += keyStr; + } + + //电机2坐标(绣框Y坐标) + if(m_mcLotData.motosPos[2] != nMcLotData.motosPos[2]) + { + keyStr = compositionJson(U00037, QString::number(nMcLotData.motosPos[2])); + lotStr += keyStr; + } + + //8对应m_mcLotData.sensorSignal的数量 + s16 sensorNum = 0; + for(int i = 0; i < 8; i++) + { + for(int j = 0; j < 32; j++)//一个u32是32位 + { + if(((m_mcLotData.sensorSignal[i] >> j) & 1) != ((nMcLotData.sensorSignal[i] >> j) & 1)) + { + QString sensorName; + sensorName.clear(); + switch (i*32+j) + { + case 0:sensorName = U00038;break;//启动按钮1 + case 1:sensorName = U00039;break;//暂停按钮1 + case 2:sensorName = U00040;break;//点动按钮1 + case 3:sensorName = U00041;break;//主框架X零位 + case 4:sensorName = U00042;break;//主框架Y零位 + case 5:sensorName = U00043;break;//主框架X负限位 + case 6:sensorName = U00044;break;//主框架Y负限位 + case 7:sensorName = U00045;break;//主框架X正限位 + case 8:sensorName = U00046;break;//主框架Y正限位 + case 9:sensorName = U00047;break;//剪刀回位 + default:sensorName.clear();break; + } + + if(sensorName.length() > 0) + { + keyStr = compositionJson(sensorName, QString::number((nMcLotData.sensorSignal[i] >> j) & 1)); + lotStr += keyStr; + sensorNum++; + } + } + } + } + //传感器总数 + keyStr = compositionJson(U000103, QString::number(nMcLotData.sensonNumbers));//原为Qstring::number(sensorNum) + lotStr += keyStr; + + // 机器配置 + // if(m_mcLotData.machinecfg != nMcLotData.machinecfg) + // { + + // keyStr = compositionJson(U000120, QString::number((nMcLotData.machinecfg >> 0) & 1)+ "#");//勾线模式 + // lotStr += keyStr; + + // keyStr = compositionJson(U000121, QString::number((nMcLotData.machinecfg >>1) & 1)+ "#");//锁头模式 + // lotStr += keyStr; + + // } + + // 缝纫机头个数 + if(m_mcLotData.sewHeadNumbers != nMcLotData.sewHeadNumbers) + { + keyStr = compositionJson(U000122, QString::number(nMcLotData.sewHeadNumbers)+ "#"); + lotStr += keyStr; + } + + // 绣花机头个数 + if(m_mcLotData.embHeadNumbers != nMcLotData.embHeadNumbers) + { + keyStr = compositionJson(U000123, QString::number(nMcLotData.embHeadNumbers)); + lotStr += keyStr; + } + + //绣花机针个数 + if(m_mcLotData.embneedleNumbers != nMcLotData.embneedleNumbers) + { + keyStr = compositionJson(U000124, QString::number(nMcLotData.embneedleNumbers)); + lotStr += keyStr; + } + //冲孔机头个数 + if(m_mcLotData.punchHeadNumbers != nMcLotData.punchHeadNumbers) + { + keyStr = compositionJson(U000125, QString::number(nMcLotData.punchHeadNumbers)); + lotStr += keyStr; + } + //冲孔机针个数 + if(m_mcLotData.punchneedleNumbers != nMcLotData.punchneedleNumbers) + { + keyStr = compositionJson(U000126, QString::number(nMcLotData.punchneedleNumbers)); + lotStr += keyStr; + } + + //界面版本 + //memcmp(s1,s2,n)就是比较s1和s2的前n个字节的ascII码值 + if(memcmp(&m_HMILotData.HMIVerStr, &nHMILotData.HMIVerStr, sizeof(nHMILotData.HMIVerStr)) != 0) + { + keyStr = compositionJson(U00030, QString::fromLocal8Bit(nHMILotData.HMIVerStr)); + lotStr += keyStr; + } + + //机架号 + if(m_HMILotData.machineNumber != nHMILotData.machineNumber) + { + keyStr = compositionJson(U00018, QString::number(nHMILotData.machineNumber) + "#"); + lotStr += keyStr; + } + + //电机总数 + //界面上存的电机数 不等于 界面上存的电机数 的时候就往下发数据 + if(m_HMILotData.motorNum != nHMILotData.motorNum) + { + keyStr = compositionJson(U000102, QString::number(nHMILotData.motorNum)); + lotStr += keyStr; + } + //调试进度 + if(m_HMILotData.debugProgress != nHMILotData.debugProgress) + { + keyStr = compositionJson(U000119, QString::number(nHMILotData.debugProgress)); + lotStr += keyStr; + } + //交付日期 + if(memcmp(&m_HMILotData.deliveryTime, &nHMILotData.deliveryTime, sizeof(nHMILotData.deliveryTime)) != 0) + { + keyStr = compositionJson(U000118, QString::fromLocal8Bit(nHMILotData.deliveryTime)); + lotStr += keyStr; + } + // workProgress = ; + // //机器工作进度 -rq + // if(m_HMILotData.workProgress != nHMILotData.workProgress) + // { + // keyStr = compositionJson(U000118, QString::numbert(nHMILotData.workProgress)); + // lotStr += keyStr; + // } +#if(0) + //当前加工文件名称 + if(memcmp(&m_HMILotData.fileName, &nHMILotData.fileName, sizeof(nHMILotData.fileName)) != 0) + { + keyStr = compositionJson(U00031, QString::fromLocal8Bit(nHMILotData.fileName)); + lotStr += keyStr; + } +#endif + + if(lotStr.at(lotStr.length()-1) == ',')//去除最后一个逗号 + { + lotStr.chop(1); //删除字符串右边n个字符 + } + lotStr += "}}]}"; + //qDebug()<sendLotDataToGateway(lotStr); + } + + m_mcLotData = nMcLotData; + m_HMILotData = nHMILotData; + nID++; + qDebug()<getTotalSendNum(); + ctotal += g_pMachine->getTotalPacketNum(); + + if (csend < 0 && ctotal < 0) + { + // 失败 + m_pPromptDlg->initDialog(PromptDialog::BTN_UCANCEL); + m_pPromptDlg->setTitleStr(tr("MC Upgrade"));//主控升级 + //m_pPromptDlg->setButtonUCancelStr(tr("Close"));//关闭 + m_pPromptDlg->setContentProcessStr(tr("Failed to upgrade the main control system!")); //主控系统升级失败! + } + else if (csend == 0 && ctotal == 0) + { + // 成功 + m_pPromptDlg->initDialog(PromptDialog::BTN_RESTART); + m_pPromptDlg->setTitleStr(tr("MC Upgrade"));//主控升级 + m_pPromptDlg->setContentProcessStr(tr("The main control system has been successed, waiting until machine restart")); + int seconds = 10;//界面重启时间改成10秒 + for(int i = 0; i < seconds; i++) + { + QString str = QString(tr("System will restart %1 s later")).arg(seconds-i);//系统将在 %1 秒后重启 + m_pPromptDlg->setContentProcessStr(str); + g_pMachine->sleep(1); + } + +#ifdef Q_OS_WIN + qApp->exit(); +#endif + +#ifdef Q_OS_LINUX + system("reboot"); +#endif + + m_pPromptDlg->hide(); + } + else if(csend >= 0 && csend <= ctotal) + { + m_pPromptDlg->initDialog(PromptDialog::BTN_UCANCEL); + m_pPromptDlg->setTitleStr(tr("MC Upgrade"));//主控升级 + m_pPromptDlg->setContentProcessStr(tr("Main control system is being upgraded...")); //主控系统升级中... + //m_pPromptDlg->setButtonUCancelStr(tr("Cancel"));//取消 + m_pPromptDlg->setRange(0, total); + m_pPromptDlg->setValue(send); + m_pPromptDlg->show(); + QCoreApplication::processEvents(QEventLoop::AllEvents); + } + else + { + m_pPromptDlg->hide(); + } + } + else + { + if (send < 0 && total < 0) + { + // 失败 + m_pPromptDlg->initDialog(PromptDialog::BTN_UCANCEL); + + if(fileType == FILE_TYPE_DAT)//花样数据文件(边框刺绣文件) + { + m_pPromptDlg->setTitleStr(tr("Prompt")); + //m_pPromptDlg->setButtonUCancelStr(tr("Close"));//关闭 + m_pPromptDlg->setContentStr(tr("Failed to send data file!")); //发送数据文件失败! + } + } + else if (send == 0 && total == 0) + { + if(fileType == FILE_TYPE_DAT)//花样数据文件 + { + // 成功 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt"));//主控升级 + m_pPromptDlg->setContentProcessStr(tr("The data file is send successfully!")); //数据文件发送成功! + } + m_pPromptDlg->hide(); + } + else if(send >= 0 && send <= total) + { + m_pPromptDlg->initDialog(PromptDialog::BTN_UCANCEL); + if(fileType == FILE_TYPE_DAT)//花样数据文件 + { + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentProcessStr(tr("Data file sending...")); //数据文件发送中... + } + //m_pPromptDlg->setButtonUCancelStr(tr("Cancel"));//取消 + m_pPromptDlg->setRange(0, total); + m_pPromptDlg->setValue(send); + m_pPromptDlg->show(); + QCoreApplication::processEvents(QEventLoop::AllEvents); + } + else + { + m_pPromptDlg->hide(); + } + } +} + +//导出csv文件到U盘 +void MainWidgetFunction::slotCsvExport(int logType) +{ + QString usbPath = detectUsb();//U盘路径 + if(usbPath.length() <= 0) + { + //优盘不存在 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("USB flash drive is not detected!");//未检测到优盘! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + + QDir apppath(qApp->applicationDirPath());//D:/work/workQT/XPlatform/Windows/debug + QString newName = usbPath + apppath.separator();//G + QString timeStr = QDateTime::currentDateTime().toString("_yyMMdd_hhmmss");//时间日期 _230215_144121 + + QString astr; + if(logType == TYPE_ERROR) + { + astr = "error"; + } + else if(logType == TYPE_BREAK) + { + astr = "break"; + } + else if(logType == TYPE_DEBUGINFO) + { + astr = "debuginfo"; + } + + QString newFileName = newName+astr+timeStr+".csv"; + + //csv文件路径 + QString csvfile; + if(logType == TYPE_ERROR) + { + csvfile = apppath.path() + apppath.separator() + CSV_ERROR; + } + else if(logType == TYPE_BREAK) + { + csvfile = apppath.path() + apppath.separator() + CSV_BREAK; + } + else if(logType == TYPE_DEBUGINFO) + { + csvfile = apppath.path() + apppath.separator() + CSV_DEBUGINFO; + } + QString csvfilePath = QDir(csvfile).absolutePath();//为了将"\"变为"/" + bool bl = QFile::copy(csvfilePath,newFileName); + + //强制写入 + //linux下写入文件或者拷贝、删除文件的情况 +#ifdef Q_OS_LINUX + system("sync"); +#endif + + QString str; + if(bl == true) + { + str = tr("Journal exported successfully!");//文件日志导出成功! + } + else + { + str = tr("Journal exported failed!");//文件日志导出失败! + } + + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; +} + +void MainWidgetFunction::slotClearJournal() +{ + QDir apppath(qApp->applicationDirPath()); + QString csvfile = apppath.path() + apppath.separator(); + g_pSettings->fileClear(csvfile+CSV_ERROR);//清空文件日志内容,但文件还在 + g_pSettings->fileClear(csvfile+CSV_BREAK);//清空文件日志内容,但文件还在 + + // 刷新文件日志界面信息 + m_pSystemManageDlg->initDialog(); + m_pSystemManageDlg->exec(JOURNAL);//显示窗体 +} + +void MainWidgetFunction::slotRefreshWifiList() +{ + QStringList wifiStrList; + wifiStrList.clear(); + s16 rel = refreshWifiList(wifiStrList,1); + if(rel > 0) + { + m_pSystemManageDlg->setItemList(wifiStrList); + } +} + +//清空产量统计 +void MainWidgetFunction::slotClearProductStatis() +{ + if(g_pMachine != NULL) + { + g_pMachine->resetOutput();//清除产量统计(主控计数) + } + + emit siClearPatternBreakLineNum(); + + addProductStatisInfo(0);//花版断线次数清零 + m_pSystemManageDlg->refreshUi(); +} + +//用户登录 +void MainWidgetFunction::slotUserLogin(s16 user) +{ + // QTextCodec *cod = QTextCodec::codecForLocale(); + PassWordDialog passWordDlg; + QString str(""); + if(user == repair) + { + passWordDlg.setTitleStr(tr("Password input *"));//密码输入 + } + else if(user == factory) + { + passWordDlg.setTitleStr(tr("Password input **"));//密码输入 + } + else if(user == resetpara) + { + passWordDlg.setTitleStr(tr("Password input ****"));//密码输入 + } + int rslt = passWordDlg.exec(); + if(rslt == 1) + { + str = passWordDlg.getInputStr(); + + if(user == repair) + { + if (str == g_passwordOne) + { + g_emUser = repair; + emit siSetButtonUserLogo(1); + } + else + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("The password is wrong,please re-enter!"));//密码错误,请重新输入密码! + m_pPromptDlg->exec(); + return; + } + } + else if(user == factory) + { + if (str == PASSWORD_TWO) + { + g_emUser = root; + emit siSetButtonUserLogo(2); + } + else + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("The password is wrong,please re-enter!"));//密码错误,请重新输入密码! + m_pPromptDlg->exec(); + return; + } + } + else if(user == resetpara) + { + if (str == PASSWORD_RESETPARA) + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + g_emUser = resetpara; + m_pPromptDlg->setContentStr(tr("reset parameters password successfully logged in!"));//重置参数密码成功登入! + m_pPromptDlg->exec(); + emit siSetButtonUserLogo(2); + } + else + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("The password is wrong,please re-enter!"));//密码错误,请重新输入密码! + m_pPromptDlg->exec(); + return; + } + + + } + } +} + +//界面解密 +void MainWidgetFunction::slotHMIDecrypt(QString id) +{ + // 获取网卡号并输入序列号 + m_pPromptDlg->initDialog(PromptDialog::BTN_HMI_DECRYPT); + m_pPromptDlg->setTitleStr(tr("HMI decrypt")); + m_pPromptDlg->setContentHMIDecryptShow(id); + if(m_pPromptDlg->exec() == 1) + { + QString inputStr = m_pPromptDlg->getInputPassword(); + QByteArray inputAry = inputStr.toLatin1(); + + QString idStr = m_pPromptDlg->getNetworkCardID(); + QByteArray idAry = idStr.toLatin1(); + + char inputBuf[20]; //输入的注册码 + u8 idBuf[12]; //id号16进制字符串 + memset(inputBuf,0,sizeof(inputBuf)); + memset(idBuf,0,sizeof(idBuf)); + memcpy(inputBuf,inputAry.data(),inputStr.toLatin1().length()); + memcpy(idBuf,idAry.data(),idStr.toLatin1().length()); + + char outputBuf[20]; //生成的注册码 + int num,i; + u8 anBuf[16],chanBuf[16]; + memset(anBuf,0,sizeof(anBuf)); + memset(chanBuf,0,sizeof(chanBuf)); + memset(outputBuf,0,sizeof(outputBuf)); + for(i = 0; i < 4; i++) + { + if((inputBuf[i] >= '0') && (inputBuf[i] <= '9')) + anBuf[i]=inputBuf[i] - '0'; + else if((inputBuf[i] >= 'a') && (inputBuf[i] <= 'f')) + anBuf[i]=inputBuf[i] - 'a' + 10; + else if((inputBuf[i] >= 'A') && (inputBuf[i] <= 'F')) + anBuf[i]=inputBuf[i] - 'A' + 10; + else + break; + } + + for(u16 i = 0; i < sizeof(idBuf);) + { + if((idBuf[i] >= '0') && (idBuf[i] <= '9')) + idBuf[i]=idBuf[i] - '0'; + else if((idBuf[i] >= 'a') && (idBuf[i] <= 'f')) + idBuf[i]=idBuf[i] - 'a' + 10; + else if((idBuf[i] >= 'A') && (idBuf[i] <= 'F')) + idBuf[i]=idBuf[i] - 'A' + 10; + + if((idBuf[i+1] >= '0') && (idBuf[i+1] <= '9')) + idBuf[i+1]=idBuf[i+1] - '0'; + else if((idBuf[i+1] >= 'a') && (idBuf[i+1] <= 'f')) + idBuf[i+1]=idBuf[i+1] - 'a' + 10; + else if((idBuf[i+1] >= 'A') && (idBuf[i+1] <= 'F')) + idBuf[i+1]=idBuf[i+1] - 'A' + 10; + + i += 2; + } + + num=((u8)(anBuf[0]*16 + anBuf[1]))*256 + (u8)(anBuf[2]*16 + anBuf[3]); + anBuf[4]=(u8)(((idBuf[0] << 4) | idBuf[1]) + num) >> 4; + anBuf[5]=(u8)(((idBuf[0] << 4) | idBuf[1]) + num) & 0x0f; + anBuf[6]=(u8)(((idBuf[2] << 4) | idBuf[3]) + num) >> 4; + anBuf[7]=(u8)(((idBuf[2] << 4) | idBuf[3]) + num) & 0x0f; + anBuf[8]=(u8)(((idBuf[4] << 4) | idBuf[5]) + num) >> 4; + anBuf[9]=(u8)(((idBuf[4] << 4) | idBuf[5]) + num) & 0x0f; + anBuf[10]=(u8)(((idBuf[6] << 4) | idBuf[7]) + num) >> 4; + anBuf[11]=(u8)(((idBuf[6] << 4) | idBuf[7]) + num) & 0x0f; + anBuf[12]=(u8)(((idBuf[8] << 4) | idBuf[9]) + num) >> 4; + anBuf[13]=(u8)(((idBuf[8] << 4) | idBuf[9]) + num) & 0x0f; + anBuf[14]=(u8)(((idBuf[10] << 4) | idBuf[11]) + num) >> 4; + anBuf[15]=(u8)(((idBuf[10] << 4) | idBuf[11]) + num) & 0x0f; + + chanBuf[0]=(u8)(anBuf[0]*16 + anBuf[1]); + chanBuf[1]=(u8)(anBuf[2]*16 + anBuf[3]); + chanBuf[2]=(u8)(anBuf[7]*16 + anBuf[9]); + chanBuf[3]=(u8)(anBuf[6]*16 + anBuf[8]); + chanBuf[4]=(u8)(anBuf[10]*16 + anBuf[15]); + chanBuf[5]=(u8)(anBuf[5]*16 + anBuf[11]); + chanBuf[6]=(u8)(anBuf[13]*16 + anBuf[4]); + chanBuf[7]=(u8)(anBuf[14]*16 + anBuf[12]); + + //id号长度大于12,以此类推 + //chanbuf[8]=(u8)(anbuf[17]*16 + anbuf[16]); + //chanbuf[9]=(u8)(anbuf[19]*16 + anbuf[18]); + //chanbuf[10]=(u8)(anbuf[21]*16 + anbuf[20]); + sprintf(outputBuf,"%02x%02x%02x%02x%02x%02x%02x%02x",chanBuf[0], + chanBuf[1],chanBuf[2],chanBuf[3],chanBuf[4],chanBuf[5],chanBuf[6],chanBuf[7]); + + QDir apppath(qApp->applicationDirPath()); + QString HMIDecryptConfigfile; + HMIDecryptConfigfile = apppath.path() + apppath.separator() + "HMIDecryptConfig.ini"; + QSettings iniSetting(HMIDecryptConfigfile, QSettings::IniFormat); + + if( 0 == memcmp(inputBuf, outputBuf, sizeof(inputBuf)) ) // 比较两个缓存区内容是否相同(等于0相等) + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("The interface program is licensed, and then take effect after restarting, please restart manually!");//界面程序授权成功,重启后生效,请手动重启! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + + iniSetting.setValue("HMIDecrypt/ifdecrypt",1); + + return; + } + else + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("Password error, interface program authorization failed!");//密码错误,界面程序授权失败! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + + //iniSetting.setValue("HMIDecrypt/ifdecrypt",0); + + return; + } + } +} + +//超级用户退出程序 +void MainWidgetFunction::slotExitApp() +{ + //是否退出程序 + + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt"));//提示 + + QString str; + str = tr("Whether to exit the program?");//是否退出程序? + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + QApplication* app; + app->exit(0); + } +} + +//超级用户版本恢复 +void MainWidgetFunction::slotVerRecovery() +{ + //是否版本恢复 + + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt"));//提示 + + QString str; + str = tr("Is the version restored?");//是否版本恢复? + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + } +} + +//超级用户修改一级密码 +void MainWidgetFunction::slotChangePassword() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_CHANGE_PASSWORD);//修改一级密码界面 + m_pPromptDlg->setTitleStr(tr("Modify the first level password")); + m_pPromptDlg->setContentChangePasswordShow(); + if(m_pPromptDlg->exec() == 1)//点击确认按钮,确认修改密码 + { + /*点击确定,首先检查编辑框中是否为空,然后检查两次输入的密码是否一致, + 一致就将原密码和新密码*/ + QString n_pwd = m_pPromptDlg->getInputNewPassword();//新密码 + QString rn_pwd = m_pPromptDlg->getInputConfirmPassword();//确认新密码 + if(n_pwd != rn_pwd) + { + //新密码和确认密码不一致 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + QString str; + str = tr("The two passwords are inconsistent!");//新密码和确认密码不一致! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + } + else + { + g_passwordOne = n_pwd;//新的密码变成一级密码 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + QString str; + str = tr("Password reset complete!");//密码修改成功! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + g_pSettings->writeToIniFile("HMI/passwordOne",g_passwordOne); + } + } +} + +//删除执行目录下的config.ini +void MainWidgetFunction::slotDeleteIni() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt"));//提示 + + QString str; + str = tr("Do you delete the configuration file?");//是否删除配置文件? + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + QDir apppath(qApp->applicationDirPath()); + + //配置文件路径 + QString configfile; + configfile = apppath.path() + apppath.separator() + "config.ini"; + QFile::remove(configfile); + + QString HMIConfigfile; + HMIConfigfile = apppath.path() + apppath.separator() + "HMIConfig.ini"; + QFile::remove(HMIConfigfile); + + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("The settings take effect after restarting the interface!");//重启界面后设置生效! + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + +#ifdef Q_OS_WIN + qApp->exit(); +#endif + +#ifdef Q_OS_LINUX + system("reboot"); +#endif + } + } +} + +//导入csv文件 +void MainWidgetFunction::slotImportCSV() +{ + QString usbPath = detectUsb(); + if(usbPath.length() <= 0) + { + //优盘不存在 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("USB flash drive is not detected!");//未检测到优盘! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); + return; + } + + QString sPath = usbPath + CSV_PROGRESS; + QDir apppath(qApp->applicationDirPath()); + QString tPath= apppath.absolutePath() + apppath.separator() + CSV_PROGRESS; + QFile::remove(tPath); + QFile::copy(sPath,tPath); + +#ifdef Q_OS_LINUX + system("sync"); +#endif + + //成功导入csv文件! + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("Import csv file successful!");//成功导入csv文件! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); +} +//删除csv文件 +void MainWidgetFunction::slotDeleteCSV() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt"));//提示 + + QString str; + str = tr("Do you delete the csv file?");//是否删除csv文件? + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + QDir apppath(qApp->applicationDirPath()); + + //配置文件路径 + QString csvfile; + csvfile = apppath.path() + apppath.separator() + CSV_PROGRESS; + QFile::remove(csvfile); + +#ifdef Q_OS_LINUX + system("sync"); +#endif + } +} + +//重置csv文件 +void MainWidgetFunction::slotResetCSV() +{ + m_csvFileStrList.clear(); + + QDir apppath(qApp->applicationDirPath()); + QString path = apppath.path() + apppath.separator() + CSV_PROGRESS; + QFile file(path); + if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + qDebug() << "Open file failed!"; + return; + } + + QTextStream out(&file); + out.setCodec("GB2312"); //支持读取中文信息 + + //遍历行 + for(int i = 0; !out.atEnd(); i++) + { + QString strLine = out.readLine(); + if(strLine.size() <= 0) + { + continue; + } + + QStringList strlist = strLine.split(",", QString::SkipEmptyParts); //根据","分隔开每行的列 + if(COLUMN_PRESSNUM < strlist.size()) + { + if(i != 0) + { + strlist[COLUMN_PRESSNUM] = "0"; + } + QString str; + for(int m = 0; m < strlist.size(); m++) + { + str.append(strlist[m]); + if(m != strlist.size() - 1) + { + str.append(","); + } + } + m_csvFileStrList.append(str); + } + } + file.close(); + + QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); + + QByteArray array; + array.clear(); + for(int j = 0; j < m_csvFileStrList.size(); j++) + { + QString str = m_csvFileStrList[j]; + array.append(str.toLocal8Bit()); + if(j != m_csvFileStrList.size() - 1) + { + array.append('\n'); + } + } + + QFile wfile(path); + if (wfile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) + { + wfile.write(array); +#ifdef Q_OS_LINUX + system("sync"); +#endif + } + wfile.close(); + + QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); + + QString iniPath = apppath.path() + apppath.separator() + "config.ini"; + QSettings setting(iniPath, QSettings::IniFormat); + setting.setValue("Progress/getScore",0); + m_getScore = 0; + + //成功导入csv文件! + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + + QString str; + str = tr("Reset succeeded!");//重置成功! + m_pPromptDlg->setContentStr(str); + m_pPromptDlg->exec(); +} + +//界面调试模式,调试模式时不需要密码 -rq +void MainWidgetFunction::slotDebugMode() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt"));//提示 + + QString str; + if (g_emDebugMode == nodebugMode) + { + str = tr("Whether to enter debug mode?");//是否进入调试模式? + } + else + { + str = tr("whether to exit debug mode?");//是否退出调试模式? + } + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + if (g_emDebugMode == nodebugMode) + { + g_emDebugMode = debugMode; + } + else //退出了调试模式 + { + g_emDebugMode = nodebugMode;//全局的 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt"));//提示 + QString str2; + str2 = tr("Please log in to super user again!");//请重新登录超级用户! + m_pPromptDlg->setContentStr(str2); + if(m_pPromptDlg->exec() == 1) //退出超级用户界面 + { + emit siCloseRootPara();//关闭超级用户参数界面 + } + } + g_pSettings->writeToIniFile("HMI/debugMode",g_emDebugMode);//写入配置文件 + emit siDebugState();//主界面接收信号,调试模式时,界面不需要密码,界面标题变红 + } +} + +//超级用户花样总清 +void MainWidgetFunction::slotPatternClear() +{ + //是否花样总清 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt"));//提示 + QString str; + str = tr("Is the pattern clear?");//是否花样总清? + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { //删除文件 + QDir apppath(qApp->applicationDirPath()); + QString targetDir = apppath.absolutePath() + apppath.separator(); + QString tPath = targetDir + PATTERNPATH; + deleteDir(tPath); + } +} + +void MainWidgetFunction:: deleteDir(QString tPath) +{ + QDir dir(tPath);//项目中所保存的路径 + dir.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);//设置过滤 + QFileInfoList fileList = dir.entryInfoList();// 获取所有的文件信息 + foreach (QFileInfo file,fileList)//遍历文件信息 + { + if (file.isFile()) //是文件,删除,文件夹也要删除 + { + file.dir().remove(file.fileName()); + } + else //递归删除 + { + deleteDir(file.absoluteFilePath()); + } + } + dir.rmpath(dir.absolutePath()); + //检测是否删除 + QDir dir1(tPath); + dir1.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);//设置过滤 + QFileInfoList fileList_1 = dir1.entryInfoList();//获取所有的文件信息 + if(fileList_1.size() == 0) + { + m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("Delete complete!"));//删除完成! + m_pPromptDlg->exec(); + emit siClearPattern();//清空当前选择的花样 + return; + } + else + { + deleteDir(tPath); + // m_pPromptDlg->initDialog(PromptDialog::BTN_OK); + // m_pPromptDlg->setTitleStr(tr("Prompt")); + // m_pPromptDlg->setContentStr(tr("Not cleaned up!"));//未清理完成! + // m_pPromptDlg->exec(); + // return; + } +} + +void MainWidgetFunction::funSimulatedSewing() +{ + if(g_pMachine == NULL) + { + return; + } + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Simulated sewing"));//模拟缝纫 + QString str = tr("Whether to switch working status");//是否切换工作状态 + m_pPromptDlg->setContentStr(str); + + u32 workStatus = g_pMachine->getMcStatus().workStatus; + + if ((workStatus & WORK_STA_SIMULATE) == WORK_STA_SIMULATE) //模拟工作 + { + if(m_pPromptDlg->exec() == 1) + { + g_pMachine->setNormalWork(); + } + } + else + { + if(m_pPromptDlg->exec() == 1) + { + g_pMachine->setSimulateWork(); + } + } +} + +void MainWidgetFunction::manualThreadCutting() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Manual thread cutting"));//手动剪线 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->cutThreadByhand(); + } + } +} + +void MainWidgetFunction::makeup(int mode) +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("makeup sewing"));//补缝 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->makeup(mode); + } + } +} + +void MainWidgetFunction::headLiftUpDown() +{ + PromptDialog promptDialog; + promptDialog.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDialog.setTitleStr(tr("Head lifting and lowering"));//机头升降 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + promptDialog.setContentStr(str); + + if(promptDialog.exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->sewHeadLiftUpDown(); + } + } +} + +void MainWidgetFunction::headLifting() +{ + PromptDialog promptDialog; + promptDialog.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDialog.setTitleStr(tr("Head lifting"));//机头上升 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + promptDialog.setContentStr(str); + + if(promptDialog.exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->sewHeadLiftUp(); + } + } +} + +void MainWidgetFunction::funSetAnchorPoint(QString filePath,int x,int y,int showFlag) +{ + if(filePath.length() <= 0) + { + return; + } + + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Set anchor point"));//定定位点 + QString str = tr("Whether to set the current point as the start point?");//是否将当前点设置为定位点? + m_pPromptDlg->setContentStr(str); + + int setFlag = 1; + if(showFlag == 1) + { + setFlag = m_pPromptDlg->exec(); + } + + if(setFlag == 1) + { + if(g_pCurEmbData != NULL) + { + g_pCurEmbData->setAnchorPosition(x,y);//将主控当前机头存在ds16头文件里 + //改变中间数据(ds16)的头文件 + } + sendPatternHead(filePath);//发送花样ds16头文件 + + //每次点击选择花样的时候才会生成ds16数据,其他时候就是给下位机发头文件 + //dsr,dst整个文件->中间数据->ds16 + writePonitToFile(filePath,x,y,1); //将新的起始点,机头,写回到(dst,dsr)源文件中 + + //流程复位 + g_pMachine->allToReset(); + slotCalMachineProgress(CSV_00_CODE_2); + } +} + +void MainWidgetFunction::funBackAnchorPoint() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Back anchor point"));//回定位点 + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->gotoAnchor(); + slotCalMachineProgress(CSV_00_CODE_3); + } + } +} + +void MainWidgetFunction::funBackShuttlePos() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Back shuttle pos"));//回换梭位 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->gotoShuttlePos(); + } + } +} + +void MainWidgetFunction::funNeedleShuttleReset() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Needle shuttle adjust"));//针梭校对 + + QString str; + str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->msAdjust(0); + } + } +} + +//win下关机按钮 +void MainWidgetFunction::funShutDown() +{ + //是否关闭计算机 + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt"));//提示 + + QString str; + str = tr("Whether to shut down the computer?");//是否关闭计算机? + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + system("shutdown -s -t 00");//电脑关机 + } +} + +//自动换一个梭 +void MainWidgetFunction::funChangeOneShuttle() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("Prompt"));//提示 + QString str; + str = tr("Whether to set to change a shuttle automatically?");//是否设置自动换一个梭? + m_pPromptDlg->setContentStr(str); + if(m_pPromptDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + g_pMachine->changeOneShuttle(); + } + } +} + +void MainWidgetFunction::funAllMtZero() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("AllSpindleZeroPositions"));//所有主轴零位 + QString str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + if((m_pPromptDlg->exec() == 1) && (g_pMachine != NULL)) + { + g_pMachine->motoToZero(MT_ALLZ); + } +} + +void MainWidgetFunction::funAllMtG() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("AllSpindleHookLines"));//所有主轴勾线 + QString str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + if((m_pPromptDlg->exec() == 1) && (g_pMachine != NULL)) + { + g_pMachine->motoToZero(MT_ALLG); + } +} + +void MainWidgetFunction::funAllMtM() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("AllSpindleJogs"));//所有主轴点动 + QString str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + if((m_pPromptDlg->exec() == 1) && (g_pMachine != NULL)) + { + g_pMachine->motoToZero(MT_ALLM); + } +} + +void MainWidgetFunction::funMainshaftAdjust() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("NeedleShuttleProofreading")); // 针梭校对 + QString str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + if((m_pPromptDlg->exec() == 1) && (g_pMachine != NULL)) + { + g_pMachine->motoToZero(MAINSHAFT_ADJUST); + } +} + +void MainWidgetFunction::funAllMainShaftRun() +{ + m_pPromptDlg->initDialog(PromptDialog::BTN_OK_CANCEL); + m_pPromptDlg->setTitleStr(tr("AllMainShaftRun")); // 所有主轴研车 + QString str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + m_pPromptDlg->setContentStr(str); + if((m_pPromptDlg->exec() == 1) && (g_pMachine != NULL)) + { + g_pMachine->manualAction(ALL_MS_RUN); + } +} + diff --git a/mctype/mainwidgetfunction.h b/mctype/mainwidgetfunction.h new file mode 100644 index 0000000..097844d --- /dev/null +++ b/mctype/mainwidgetfunction.h @@ -0,0 +1,230 @@ +#ifndef MAINWIDGETFUNCTION_H +#define MAINWIDGETFUNCTION_H + +#include +#include +#include +#include +#include +#include +#include "main.h" +#include "machine/error.h" +#include "sharedviews/promptdialog.h" +#include "sharedviews/passworddialog.h" +#include "sharedviews/systemmanagedialog.h" +#include "sharedviews/brokenlinedialog.h" +#include "datafile/datafiledst.h" +#include "datafile/datafiledsr.h" +#include "settings/lotsettings.h" +#include "items/errorcodestateitem.h" +#include "Lot/csvcode.h" +#include "items/paraitem.h" +#include "sharedviews/debuginfodialog.h" + +#ifdef Q_OS_WIN +#include +#endif + +#define DATA_DS8 1 +#define DATA_DS16 2 +#define DATA_FORMATE DATA_DS16 + +#define COLUMN_CODE 0 //信息代码(第一列) +#define COLUMN_INFO 1 //映射信息(第二列) +#define COLUMN_SCORE 2 //分值(第三列) +#define COLUMN_PRESSNUM 3 //是否被点击过(第四列) + +#define HEADNUM 32 +#define NEEDLENUM 15 + +#define WIFIINIPATH "/etc/iot_cfg/mcgs_box_conf.ini" + +struct HMIFileHead +{ + int fileNum; +}; + +struct HMIItemFileHead +{ + char filePath[64]; + char fileName[64]; + int dataCheck; + int fileSize; +}; + +class MainWidgetFunction : public QObject +{ + Q_OBJECT +public: + explicit MainWidgetFunction(QObject *parent = 0); + ~MainWidgetFunction(); + +private: + PromptDialog *m_pPromptDlg; + SystemManageDialog *m_pSystemManageDlg; + BrokenLineDialog *m_pBrokenLineDialog; + DebugInfoDialog *m_pDebugInfoDlg; + MCStatus m_mcStatus; + int m_curFileID; + QString m_filePath; + QString m_fileName; + McLotData m_mcLotData;//下位机物联数据 + HMILotData m_HMILotData;//上位机物联数据 + int m_sensorBitmapNum;//传感器位图个数 + QList m_errorCodeAndStateItemList;//错误代码和状态列表 + QTimer * m_pTipsTimer; //4小时定时器提示用户使用时长不足5天 + //QTimer timer; //测试物联网用 + int m_getScore;//安装进度调试得分 + int m_totalScore;//总分值 + QStringList m_csvFileStrList; + +private: + void initialize();//初始化 + void initializeLotInfo();//初始化物联网所需要的机器信息 + void initializeLotData();//初始化物联网数据 + void systemUpgrade(int type); + s16 refreshWifiList(QStringList &wifiStrList,s16 scan = 0);//刷新wifi列表 + QString getIpSegment(bool bl);//获取已连接wifi分配的IP + void writePonitToFile(QString filePath,int x, int y, int flag = 0);//将定位点或起绣点写回到文件中(以及工作机头) + void sendDs16PatternData(int type = FILE_TYPE_DAT);//发送ds16花样数据 + void convertDs16ToDs8AndSend(QString filePath,int type = FILE_TYPE_DAT);//将ds16数据转换为ds8数据并发送 + void addProductStatisInfo(int patternBreakLineNum);//添加生产统计信息 + + void addJournalInfoError();//添加错误日志信息 + void addJournalInfoBreakage();//添加断线日志信息 + void addJournalInfoDebug();//添加调试信息 + + QString getCompileDateTime(); + QString compositionJson(QString key,QString value);//组成json键值对 + HMILotData getHMILotData();//获取界面物联数据 + void sendDataToGateway(s16 code,s16 type = 0);//发送数据到物联网 + +public: + void setErrorCodeAndStateList(QList list);//设置错误代码和状态的列表 + void setShutDownTime();//上电计算关机时间并发送给主控 + void setMcStates(MCStatus mcStatus);//设置机器状态 + QString getVersionStr(); + QString detectUsb();//优盘检测 + s16 detectWifiConnect(); + void funImportParameter(QString tStyle);//参数导入 + void funExportParameter();//参数导出 + void funMCUpgrade(QString tStyle);//主控升级 + void funHMIUpgrade(QString tStyle);//界面升级 + void funWIFI(QString tStyle);//WIFI管理 + void funAllToZero();//全部归零 + void funResetOutput();//产量清零 + void funAllToReset();//流程复位 + void funFlatEmbHook();//平绣勾线 + void funSpindleJog();//主轴点动 + + void funSpindleRotate();//主轴旋转 + void funBackWorkPoint();//回工作点 + void funBackToOrigin();//回原点 + void funSetStartPoint(QString filePath,int x,int y,int showFlag = 0);//设置起始点 + void funBackStartPoint();// 回起针点 + void funSetOffsetPoint();//设置偏移点 + void funBackOffsetPoint();//回偏移点 + void funBorderCheck();//边框检查 + void funManualTrim();//手动剪线 + void funCutterOpenAndClose();//剪刀开合 + void funSetWorkArea();// 设置可工作区域 + void funSimulateFrame();//空走边框 + void funProcessReset();//流程复位 + void funSetFeedPoint();//定上料点 + void funBackFeedPoint();//回上料点 + void funManualOil();//手动加油 + void funResetRepeatNum();//重置反复次数 + void funShuttleChange();//梭盘计数复位 + void funGotoZeroPos();//框架归零 + void funSetWorkRange();//定工作范围 + void sendPatternHead(QString filePath);//发送花样文件头 + void sendPatternData(QString filePath,int type = FILE_TYPE_DAT);//发送花样数据 + void funBottomDetect();//底线检测 + void funFaceDetect();//面线检测 + void funExitRoot();//退出登录 + void funAgingTest();//老化测试 + void funGetMCVersionInfo();//获取主控主板版本信息 + void funProductStatistics(QString tStyle,QString filePath,int patternBreakLineNum);//生产统计 +// void funJournal(QString bStyle,QString tStyle);//文件日志 + void funJournalError(QString tStyle);//错误日志 +// void funJournalBreakage(QString bStyle,QString tStyle);//断线日志 + void funDebugInfo(); + void funSoftwareAuthor();//软件授权 + void funChangeOneShuttle();//自动换一个梭 + void funAllMtZero();//所有主轴零位 + void funAllMtG();//所有主轴勾线 + void funAllMtM();//所有主轴点动 + void funMainshaftAdjust();// 针梭校对 + void funAllMainShaftRun(); // 主轴研车 + void funShutDown();//win下关闭计算机 + int funErrorPrompt(QString info);//错误信息提示 + int funDetectBreakLineStatus();//检测断线状态 + void funSetPromptDlgVisibleFalse();//错误信息提示窗体隐藏 + void funBottomLineCountReset();//底线计数复位 + void funManualOrAutoSwitch(s16 val = 0);//手自动工作状态切换 0:手动 1:自动 + void deleteDir(QString path);//删除文件夹 + void funSimulatedSewing();//模拟工作 + void manualThreadCutting(); //手动剪线 + void makeup(int mode); //补缝 + void headLiftUpDown();//机头升降 + void headLifting();//机头上升 + void funSetAnchorPoint(QString filePath,int x,int y,int showFlag = 0);//设置定位点 + void funBackAnchorPoint();//回定位点 + void funBackShuttlePos();//回换梭位 + void funNeedleShuttleReset();//针梭校对 + +private slots: + void slotMCInfoChange();//机器信息改变 + void slotReceiveLotData();//接收物联数据 + void slotRunLotDataAction(QString str);//执行网关数据动作 + //void slotSendJsonToMqtt();//当界面与网关建立连接时需要向网关发送固定的键值对 + void slotTransProgress(u8 fileType, int send, int total); // 发送文件进度条 + void slotClearProductStatis();//清空产量统计 + void slotCsvExport(int logType);//导出csv文件 + void slotClearJournal();//清空文件日志 + void slotRefreshWifiList();//刷新wifi列表 + void onTipsTimer();//4小时定时器 + void slotSetDynamicIP(QString ssid);//设置动态IP + void slotSetStaticIP(QString ssid,QString psd,QString dnip);//设置静态IP + void slotSpindleAction(int action);//主轴动作 + void slotSpindleRotate(int angle);//主轴旋转 + +signals: + void siSetButtonUserLogo(int level); + void siHeadBuf(u8* buf); + void siClearPatternBreakLineNum(); + void siDebugState(); + void siCloseRootPara(); + void siClearPattern(); + void siClearPatternFcg(); + void siShowPercentage(int val); + //void siReceiveLotDat(); //测试物联网用 + + void siAfterDeleteFileid();//xcy 0314 删掉影响fileid的数据后需要将m_fileHead置为0 + void siWifiState(bool bl);//wifi连接状态 + void siHeadParaImportFinish(int type); + +public slots: + void slotUserLogin(s16 user);//用户登录 + void slotHMIDecrypt(QString id);//界面解密 + void slotExitApp();//超级用户退出程序 + void slotVerRecovery();//超级用户下版本恢复 + void slotChangePassword();//超级用户下修改一级密码 + void slotDeleteIni();//删除执行目录下的config.ini + void slotImportCSV();//导入csv文件 + void slotDeleteCSV();//删除csv文件 + void slotResetCSV();//重置安装调试进度 + void slotDebugMode();//界面调试模式 + void slotPatternClear();//超级用户下花样总清 + void slotCalMachineProgress(s16 csvCode,s16 type = 0);//计算安装调试进度 + void slotJournalError();//错误日志 + void slotJournalBreakage();//断线日志 + void slotCsvChangeDebug();//调试信息 + //以下为测试记录断线次数精准到针位 + //void testBreakLineNeedle(); +public: + //QTimer *m_testNeedle; + +}; + +#endif // MAINWIDGETFUNCTION_H diff --git a/mctype/patternsingleboard/function/clothingmac.cpp b/mctype/patternsingleboard/function/clothingmac.cpp new file mode 100644 index 0000000..f0ee320 --- /dev/null +++ b/mctype/patternsingleboard/function/clothingmac.cpp @@ -0,0 +1,1454 @@ +#include "clothingmac.h" + +ClothingMac::ClothingMac() +{ + //添加各种参数到列表中 + initRootParasList(); + initRootHMIConfigurationList(m_allParasList);//超级用户界面配置 + initPatternsParasList(); + initSoftwareParasList(m_allParasList); + initTimeParasList(m_allParasList); + initMcParasList(); + initWkParasList(); + + //初始化控制动作列表 + initOutCtrlList(); + + //初始化快捷功能列表 + initShortCutList(); + + //初始化辅助功能列表 + initAssistList(); + + //初始化花样设置功能列表 + initPatternSetList(); + + //参数分类功能 + initParaSetList(); + + //初始化传感器列表 + initSensorList(); + + //初始化错误代码和状态列表 + initErrorCodeAndStateList(); + + //初始化九宫格 + initNinebtn1234(); + + //加载右上角信息 + initFileInfoLabel(); +} + +ClothingMac::~ClothingMac() +{ + +} + +void ClothingMac::initNinebtn1234() +{ + m_nineBtn.insert(1,NineItem(FUN_HEAD_LIFTING,"buttonHeadLifting")); + m_nineBtn.insert(2,NineItem(FUN_MANUAL_THREAD_CUTTING,"buttonMunualThreadCutting")); + m_nineBtn.insert(3,NineItem(FUN_PROCESSRESET,"buttonProcessReset")); + m_nineBtn.insert(4,NineItem(FUN_SIMULATED_STATUS,"buttonSimulatedStatus")); +} + +void ClothingMac::initRootParasList() +{ + //超级用户参数--------------------------- + //超级用户参数-界面配置;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_HMICONFIGURATION, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("HMI Configuration"),//界面配置 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0000 , factory)); + + //超级用户参数-界面进入调试模式;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_DEBUGMODE, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Interface debug mode"),//界面进入调试模式 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001 , root)); + + //超级用户参数-删除config.ini配置文件;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_DELETEINI, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Delete configure file"),//删除配置文件 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001 , root)); + + //超级用户参数-机器参数;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_MACHINEPARA, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Machine parameters"),//机器参数 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0002, factory)); + + //超级用户参数-工作参数;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_WORKPARA, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Work parameters"),//工作参数 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0003, factory)); +} + +void ClothingMac::initPatternsParasList() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + + //花样参数-花样设置参数-定位点x;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR, + SET_ANCHORX, 0, 0, PARA_VALUE_TYPE_INT, + tr("AnchorX"),//定位点X + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0001, operate)); + + //花样参数-花样设置参数-定位点y;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR , + SET_ANCHORY, 0, 0, PARA_VALUE_TYPE_INT, + tr("AnchorY"),//定位点Y + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0002, operate)); + + //花样参数-花样设置参数-起始点x;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR , + SET_STARTX, 0, 0, PARA_VALUE_TYPE_INT, + tr("startX"),//起始点X + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0003, operate)); + + //花样参数-花样设置参数-起始点y;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR , + SET_STARTY, 0, 0, PARA_VALUE_TYPE_INT, + tr("startrY"),//起始点Y + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0004, operate)); + + //花样参数-花样设置参数-翻转式样;单位:无 ,范围0-7,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR, + SET_ROTATESTYLE, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Flip style"),//翻转式样 + 0, 0, 7, 0, 0, tr(""), tr(""), + tr("normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7"), + 0, 0, 0x0005, operate)); + + //花样参数-花样设置参数-旋转角度;单位:° ,范围0-90,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR, + SET_ROTATEANGLE, 0, 0, PARA_VALUE_TYPE_INT, + tr("Rotation angle"),//旋转角度 + 0, 0, 90, 0, 0, cod->toUnicode("°"), tr(""),//度 + tr(""), 0, 0,0x0006, operate)); + + //花样参数--------------------------- +} + +void ClothingMac::initMcParasList() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + + //模版识别装置, 范围0-3,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 29, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Template recognition device"),//模版识别装置 + 0, 0, 3, 0, 0, tr(""), tr(""), + //无装置: 0;条形码:1;编码孔:2;多文件选择:3 + tr("No device:0;Bar code:1;Coding hole:2;Multiple files:3"), + 0, 0, 0x0001, factory)); + + //X框传感器坐标, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 50, 0, 0, PARA_VALUE_TYPE_INT, + tr("X frame sensor coordinates"),//X框传感器坐标 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //Y框传感器坐标, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 51, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y frame sensor coordinates"),//Y框传感器坐标 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴停车传感器角度, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 52, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle parking sensor angle"),//主轴停车传感器角度 + 0, S32_MIN, S32_MAX, 0, 2, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //升降传感器坐标, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 53, 0, 0, PARA_VALUE_TYPE_INT, + tr("Lift sensor coordinates"),//升降传感器坐标 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴勾线传感器角度, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 56, 0, 0, PARA_VALUE_TYPE_INT, + tr("Angle of spindle hook sensor"),//主轴勾线传感器角度 + 0, S32_MIN, S32_MAX, 0, 2, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴点动停车角度, 范围:-36000-36000,默认8500 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 62, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle jog parking angle"),//主轴点动停车角度 + 8500, -36000, 36000, 8500, 2, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //X可移动区域负边界, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 70, 0, 0, PARA_VALUE_TYPE_INT, + tr("X movable area negative boundary"),//X可移动区域负边界 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //X可移动区域正边界, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 71, 0, 0, PARA_VALUE_TYPE_INT, + tr("X movable area positive boundary"),//X可移动区域正边界 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //Y可移动区域负边界, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 72, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y movable area negative boundary"),//Y可移动区域负边界 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //Y可移动区域正边界, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 73, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y movable area positive boundary"),//Y可移动区域正边界 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //X可缝纫区域负边界, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 84, 0, 0, PARA_VALUE_TYPE_INT, + tr("X Sewing area negative boundary"),//X可缝纫区域负边界 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //X可缝纫区域正边界, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 85, 0, 0, PARA_VALUE_TYPE_INT, + tr("X Sewing area positive boundary"),//X可缝纫区域正边界 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //Y可缝纫区域负边界, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 86, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y Sewing area negative boundary"),//Y可缝纫区域负边界 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //Y可缝纫区域正边界, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_POSITION, + 87, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y Sewing area positive boundary"),//Y可缝纫区域正边界 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //xy启动停止速度, 范围1-100,默认10 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 100, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY start stop speed"),//xy启动停止速度 + 10, 1, 100, 10, 0, tr("mm/s"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //xy归零运行速度, 范围1-500,默认100 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 101, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY zero running speed"),//xy归零运行速度 + 100, 1, 500, 100, 0, tr("mm/s"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //xy空走运行速度, 范围1-1700,默认300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 102, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY simulate running speed"),//xy空走运行速度 + 300, 1, 1700, 300, 0, tr("mm/s"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //xy行走加速度, 范围1-10000,默认1000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 103, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY movement acceleration"),//xy行走加速度 + 1000, 1, 10000, 1000, 0, tr("mm/s2"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //xy刹车加速度, 范围1-10000,默认10000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 104, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY brake acceleration"),//xy刹车加速度 + 10000, 1, 10000, 10000, 0, tr("mm/s2"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //xy手动移动速度1, 范围1-1000,默认10 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 105, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY manual movement speed 1"),//xy手动移动速度1 + 10, 1, 1000, 10, 0, tr("mm/s"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //xy手动移动速度2, 范围1-1000,默认100 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 106, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY manual movement speed 2"),//xy手动移动速度2 + 100, 1, 1000, 100, 0, tr("mm/s"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //xy手动移动速度3, 范围1-1000,默认300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 107, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY manual movement speed 3"),//xy手动移动速度3 + 300, 1, 1000, 300, 0, tr("mm/s"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //xy最高移动速度, 范围1-1700,默认300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 108, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY maximum moving speed"),//xy最高移动速度 + 300, 1, 1700, 300, 0, tr("mm/s"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴启动停止转速, 范围1-1000,默认100 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 109, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle start stop speed"),//主轴启动停止转速 + 100, 1, 1000, 100, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴归零转速, 范围1-3000,默认120 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 110, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle zero reset speed"),//主轴归零转速 + 120, 1, 3000, 120, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴运转转速, 范围1-3000,默认300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 111, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle running speed"),//主轴运转转速 + 300, 1, 3000, 300, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴运转加速度, 范围1-100,默认50 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 112, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle running acceleration"),//主轴运转加速度 + 50, 1, 100, 50, 0, tr("r/ss"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴刹车加速度, 范围1-100,默认100 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 113, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle brake acceleration"),//主轴刹车加速度 + 100, 1, 100, 100, 0, tr("r/ss"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴缝纫最高转速, 范围1-3000,默认1200 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SPEED, + 114, 0, 0, PARA_VALUE_TYPE_INT, + tr("sewing maximum speed"),//主轴缝纫最高转速 + 1200, 1, 3000, 1200, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0089, factory)); + + + //主轴归零补偿角度, 范围:-1000-1000,默认200 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 146, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle zeroing compensation angle"),//主轴归零补偿角度 + 200, -1000, 1000, 200, 2, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //X间隙补偿, 范围-200-200,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 175, 0, 0, PARA_VALUE_TYPE_INT, + tr("X gap compensation"),//X间隙补偿 + 0, -200, 200, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, repair)); + + //Y间隙补偿, 范围-200-200,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 177, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y gap compensation"),//Y间隙补偿 + 0, -200, 200, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, repair)); + +} + +void ClothingMac::initWkParasList() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + + //主轴缝纫工作转速, 范围1-3600,默认2000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 0, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing main shaft working speed"),//主轴缝纫工作转速 + 2000, 1, 3600, 2000, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //主轴剪线转速, 范围1-500,默认120 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 1, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle cutting speed"),//主轴剪线转速 + 120, 1, 500, 120, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴回针转速, 范围1-1000,默认200 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 2, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle needle return speed"),//主轴回针转速 + 200, 1, 1000, 200, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //主轴启动慢动转速, 范围1-1000,默认200 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 3, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle start slow speed"),//主轴启动慢动转速 + 200, 1, 1000, 200, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //倒车等效主轴转速, 范围1-3000,默认1000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 4, 0, 0, PARA_VALUE_TYPE_INT, + tr("Reverse equivalent spindle speed"),//倒车等效主轴转速 + 1000, 1, 3000, 1000, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //缝纫动框方式, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 4, 0, PARA_VALUE_TYPE_LIST, + tr("Sewing frame movement mode"),//缝纫动框方式 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("XY continuous:0;XY intermittent:1"),//XY连续动框:0;XY间歇动框:1 + 0, 0, 0x0001, operate)); + + //缝纫动框起始角度, 范围0-36000,默认24000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 6, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing frame start angle"),//缝纫动框起始角度 + 24000, 0, 36000, 24000, 2, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, root)); + + //缝纫动框持续角度, 范围0-36000,默认24000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 7, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing frame steadiness angle"),//缝纫动框持续角度 + 24000, 0, 36000, 24000, 2, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, root)); + + //起针慢动针数, 范围0-10,默认3 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 8, 0, 0, PARA_VALUE_TYPE_INT, + tr("Slow stitch at beginning"),//起针慢动针数 + 3, 0, 10, 3, 0, tr("Needle"), tr(""),//针 + tr(""), + 0, 0, 0x0001, operate)); + + //起针动作松线允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 9, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Needle action, thread loosen allowed"),//起针动作松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //起针动作顶线允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 9, 2, 0, PARA_VALUE_TYPE_LIST, + tr("Needle action,tight bobbin spring allowed"),//起针动作顶线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //起针动作夹线允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 9, 3, 0, PARA_VALUE_TYPE_LIST, + tr("Needle action, catch upper thread allowed"),//起针动作夹线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //剪线允许, 范围0-3,默认1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 10, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Cut thread allowed"),//剪线允许 + 1, 0, 3, 1, 0, tr(""), tr(""), + //不剪线:0;自动剪线:1;最后剪线:2;数据剪线:3 + tr("Do not trim:0;Automatic:1;Last trimming:2;Data trimming:3"), + 0, 0, 0x0001, operate)); + + //剪线分线角度, 范围0-36000,默认20000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 11, 0, 0, PARA_VALUE_TYPE_INT, + tr("Trimmer cutting angle"),//剪线分线角度 + 20000, 0, 36000, 20000, 2, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //剪线完成角度, 范围0-36000,默认6000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 12, 0, 0, PARA_VALUE_TYPE_INT, + tr("Trimming completion angle"),//剪线完成角度 + 6000, 0, 36000, 6000, 2, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //剪线时动作松线允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 13, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Thread cut, upper thread loosen allowed"),//剪线时动作松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //剪线时动作拉线允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 13, 2, 0, PARA_VALUE_TYPE_LIST, + tr("Thread cut, tensile thread allowed"),//剪线时动作拉线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //剪线时动作夹线允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 13, 3, 0, PARA_VALUE_TYPE_LIST, + tr("Thread cut, catch upper thread allowed"),//剪线时动作夹线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //剪线时动作提升压脚允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 13, 4, 0, PARA_VALUE_TYPE_LIST, + tr("Thread cut, presser foot lift allowed"),//剪线时动作提升压脚允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //断线检测针数, 范围0-10,默认3 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 14, 0, 0, PARA_VALUE_TYPE_INT, + tr("Stitch detect if thread broken"),//断线检测针数 + 3, 0, 10, 3, 0, tr("Needle"), tr(""),//针 + tr(""), + 0, 0, 0x0001, operate)); + + //断线检测主轴角度, 范围0-36000,默认3000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 14, 0, 0, PARA_VALUE_TYPE_INT, + tr("Thread brake detection, main shaft angle"),//断线检测主轴角度 + 3000, 0, 36000, 3000, 2, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, factory)); + + //换梭芯提醒功能, 范围0-3,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 16, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Bobbin change reminder function"),//换梭芯提醒功能 + 0, 0, 3, 0, 0, tr(""), tr(""), + //不提醒: 0;按长度延时提醒:1;按片数提醒:2;按长度立刻提醒:3 + tr("Not enabled: 0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3"), + 0, 0, 0x0001, operate)); + + //底线长度, 范围0-最大,默认10000000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 17, 0, 0, PARA_VALUE_TYPE_INT, + tr("Bobbin thread length"),//底线长度 + 3, 0, S32_MAX, 3, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //每针底线修正量, 范围 最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 18, 0, 0, PARA_VALUE_TYPE_INT, + tr("Bobbin thread correction per stitch"),//每针底线修正量 + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //换梭片数计数, 范围0-10,默认3 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 19, 0, 0, PARA_VALUE_TYPE_INT, + tr("Bobbin change as per sewed pieces"),//换梭片数计数 + 3, 0, 10, 3, 0, tr("times"), tr(""),//次 + tr(""), + 0, 0, 0x0001, operate)); + + //加油方式选择, 范围0-3,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 20, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Oiling mode selection"),//加油方式选择 + 0, 0, 3, 0, 0, tr(""), tr(""), + //不加油: 0;按时间加油:1;按针数加油:2;持续加油:3 + tr("No oil:0;Oiling by time:1;Oiling by stitches:2;Oiling continously:3"), + 0, 0, 0x0001, operate)); + + //加油针数间隔, 范围0-最大,默认10000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 21, 0, 0, PARA_VALUE_TYPE_INT, + tr("Oiling interval by needle stitch"),//加油针数间隔 + 10000, 0, S32_MAX, 10000, 0, tr("Needle"), tr(""),//针 + tr(""), + 0, 0, 0x0001, operate)); + + //加油时间间隔, 范围1-最大,默认1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 22, 0, 0, PARA_VALUE_TYPE_INT, + tr("Oiling interval by working time"),//加油时间间隔 + 1, 1, S32_MAX, 1, 0, tr("s"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //针加油持续时长, 范围1-最大,默认1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 23, 0, 0, PARA_VALUE_TYPE_INT, + tr("Needle Oiling sustained time"),//针加油持续时长 + 1, 1, S32_MAX, 1, 0, tr("s"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //完成后停车位置选择, 范围0-4,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 24, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Stop position selection after work complete"),//完成后停车位置选择 + 0, 0, 4, 0, 0, tr(""), tr(""), + //当前位置:0;起始点:1;定位点:2;上料点:3;偏移点:4 + tr("Current:0;Start:1;Anchor:2;Feeding:3;Offset:4"), + 0, 0, 0x0001, operate)); + + //偏移点坐标有效标志, 范围0-3,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 25, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Valid flag for offset point coordinates"),//偏移点坐标有效标志 + 0, 0, 3, 0, 0, tr(""), tr(""), + //无效:0;X有效:1;Y有效:2;XY同时有效:3 + tr("invalid:0;X is valid:1;Y is valid:2;XY is valid:3"), + 0, 0, 0x0001, operate)); + + //偏移点坐标X, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 26, 0, 0, PARA_VALUE_TYPE_INT, + tr("Offset point coordinate X"),//偏移点坐标X + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //偏移点坐标Y, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 27, 0, 0, PARA_VALUE_TYPE_INT, + tr("Offset point coordinate Y"),//偏移点坐标Y + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //穿线点坐标有效标志, 范围0-3,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 28, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Threading point coordinate valid symbol"),//穿线点坐标有效标志 + 0, 0, 3, 0, 0, tr(""), tr(""), + //无效:0;X有效:1;Y有效:2;XY同时有效:3 + tr("invalid:0;X is valid:1;Y is valid:2;XY is valid:3"), + 0, 0, 0x0001, operate)); + + //穿线点坐标X, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 29, 0, 0, PARA_VALUE_TYPE_INT, + tr("Threading point coordinates X"),//穿线点坐标X + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //穿线点坐标Y, 范围:最小-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 30, 0, 0, PARA_VALUE_TYPE_INT, + tr("Threading point coordinates Y"),//穿线点坐标Y + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //产量预设, 范围0-S32_MAX,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 33, 0, 0, PARA_VALUE_TYPE_INT, + tr("Production preset"),//产量预设 + 0, 0, S32_MAX, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //气框关闭后延时, 范围0-2000,默认500 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 35, 0, 0, PARA_VALUE_TYPE_INT, + tr("Delay after pneumatic frame off"),//气框关闭后延时 + 500, 0, 2000, 500, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //缝纫加速度, 范围1-100,默认5 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 36, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing acceleration"),//缝纫加速度 + 5, 1, 100, 5, 0, tr("r/ss"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //剪线动框位移, 范围1-5000,默认500 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 37, 0, 0, PARA_VALUE_TYPE_INT, + tr("Trimming frame displacement"),//剪线动框位移 + 500, 1, 5000, 500, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0001, root)); + + //自动回穿线点允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 38, 3, 0, PARA_VALUE_TYPE_LIST, + tr("Automatic move to threading point allowed"),//自动回穿线点允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, operate)); + + //大压脚动作允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 38, 7, 0, PARA_VALUE_TYPE_LIST, + tr("Large presser foot action allowed"),//大压脚动作允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //缝纫间越框机头升降, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 46, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Sewing move head up down"),//缝纫间越框机头升降 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //移框松线允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 48, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Moving basket Loose line"),//移框松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //移框夹线允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 48, 2, 0, PARA_VALUE_TYPE_LIST, + tr("Moving basket Clamp line"),//移框夹线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //软件限位XY移动允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 49, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Software limit XY move allowed"),//软件限位XY移动允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //面线勾线针数, 范围0-5,默认1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 52, 0, 0, PARA_VALUE_TYPE_INT, + tr("Number of Needle hooks"),//面线勾线针数 + 1, 0, 5, 1, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //剪线动框方向, 范围0-4,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 57, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Trimming frame direction"),//剪线动框方向 + 0, 0, 4, 0, 0, tr(""), tr(""), + tr("No:0;left:1;Forward:2;Right:3;Backward:4"),//不移动:0;向左:1;向前:2;向右:3;向后:4 + 0, 0, 0x0001, root)); + + //主轴拐角转速, 范围1-3000,默认1000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 59, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle corner speed"),//主轴拐角转速 + 1000, 1, 3000, 1000, 0, tr("r/min"), tr(""), + tr(""), + 0, 0, 0x0001, root)); + + //降速最小偏差角度, 范围0-180,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 60, 0, 0, PARA_VALUE_TYPE_INT, + tr("Minimum speed deviation angle"),//降速最小偏差角度 + 0, 0, 180, 0, 0, cod->toUnicode("°"), tr(""), + tr(""), + 0, 0, 0x0001, root)); + + //提前降速针步, 范围0-20,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 61, 0, 0, PARA_VALUE_TYPE_INT, + tr("Early speed reduction"),//提前降速针步 + 0, 0, 20, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001, root)); + + //延迟提速针步, 范围0-20,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 62, 0, 0, PARA_VALUE_TYPE_INT, + tr("Delayed speed step"),//延迟提速针步 + 0, 0, 20, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001, root)); + + //安全输入光幕允许, 范围0-1,默认1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 101, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Secure input light curtain allows"),//安全输入光幕允许 + 1, 0, 1, 1, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //安全输入气压允许, 范围0-1,默认1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 101, 2, 0, PARA_VALUE_TYPE_LIST, + tr("Safety input pressure allowed"),//安全输入气压允许 + 1, 0, 1, 1, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, root)); + + //自动气框关闭允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 102, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Pneumatic frame off"),//自动气框关闭允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, operate)); + + //自动气框打开允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 102, 2, 0, PARA_VALUE_TYPE_LIST, + tr("Penumatic frame on"),//自动气框打开允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, operate)); + + //自动气框闭合延时, 范围0-5000,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 103, 0, 0, PARA_VALUE_TYPE_INT, + tr("Penumatic frame on"),//自动气框闭合延时 + 0, 0, 5000, 0, 0, tr("ms"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //循环工作允许, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 105, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Loop work allowed"),//循环工作允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"),//不允许:0;允许:1 + 0, 0, 0x0001, operate)); + + //梭加油持续时长, 范围0-最大,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 110, 0, 0, PARA_VALUE_TYPE_INT, + tr("Shuttle Oiling sustained time"),//梭加油持续时长 + 0, 0, S32_MAX, 0, 0, tr("s"), tr(""), + tr(""), + 0, 0, 0x0001, operate)); + + //缝纫运行速度1, 范围1-5000,默认500 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 170, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing operation speed 1"),//缝纫运行速度1 + 500, 1, 5000, 500, 0, tr("r/min"), tr(""),//次 + tr(""), + 0, 0, 0x0001, root)); + + //缝纫运行速度2, 范围1-5000,默认1000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 171, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing operation speed 2"),//缝纫运行速度2 + 1000, 1, 5000, 1000, 0, tr("r/min"), tr(""),//次 + tr(""), + 0, 0, 0x0001, root)); + + //缝纫运行速度3, 范围1-5000,默认1000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 172, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing operation speed 3"),//缝纫运行速度3 + 1500, 1, 5000, 1500, 0, tr("r/min"), tr(""),//次 + tr(""), + 0, 0, 0x0001, root)); + + //更换缝纫针计数值, 范围0-S32_MAX,默认500000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 190, 0, 0, PARA_VALUE_TYPE_INT, + tr("Change the sewing needle count value"),//更换缝纫针计数值 + 500000, 0, S32_MAX, 500000, 0, tr("times"), tr(""),//次 + tr(""), + 0, 0, 0x0001, root)); +} + +void ClothingMac::initOutCtrlList() +{ + m_allOutCtrlList.clear(); + + QString enableStr = tr("Enable"); //使能 + QString disableStr = tr("Disable"); //失能 + QString jogPStr = tr("JogP"); //正转 + QString jogNStr = tr("JogN"); //反转 + QString zeroStr = tr("Zero"); //归零 + QString openStr = tr("Open"); //打开 + QString closeStr = tr("Close");//关闭 + QString upStr = tr("Up"); //上升 + QString downStr = tr("Down");//下降 + QString extStr = tr("Extend"); //伸出 + QString backStr = tr("Back");//收回 + QString comStr = tr("Combine"); //结合 + QString sepStr = tr("Separate");//分离 + //QString testStr = tr("Test");//测试 + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0001,tr("X to move motor"),MT_LX,// X向移动电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0002,tr("Y to move motor"),MT_LY,// Y向移动电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0003,tr("Spindle motor"),MT_LM,// 主轴电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0004,tr("Needle motor"),MT_LN,// 针电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0005,tr("Shuttle motor"),MT_LH,// 梭电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0006,tr("Lifting motor"),MT_LU,// 升降电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0007,tr("Frame"),OT_FRAME,// 气框 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0008,tr("Big foot"),OT_BIT_FOOT,// 大压脚 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + upStr,true,OUTCONTROL_OPEN,-1,-1, + downStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0009,tr("Middle foot"),OT_MID_FOOT,// 中压脚 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + upStr,true,OUTCONTROL_OPEN,-1,-1, + downStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000A,tr("Buckle the bottom line"),OT_PUSH_BTRD,// 扣底线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000B,tr("Top and bottom lines"),OT_STAND_BTRD,// 顶底线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000C,tr("Lower scissors to cut thread"),OT_DCUT_THREAD,// 下剪刀剪线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000D,tr("Sandwich line"),OT_CLIP_UTRD,// 夹面线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000E,tr("Elastic thread"),OT_LOOSE_THREAD,// 松紧线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000F,tr("Elastic thread 2"),OT_LOOSE_UTRD2,// 第二松紧线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0010,tr("Laser control"),OT_LASER_CTRL,// 激光控制 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0011,tr("Laser blow"),OT_LASER_BLOW,// 激光控制 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0012,tr("Oil"),OT_OIL,// 加油 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0013,tr("Headlamp"),OT_LIGHT,// 照明灯 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0014,tr("Sewing Blow"),OT_SEW_BLOW,// 缝纫吹气 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0015,tr("Hookline ext"),OT_CLIP_EXTEND,// 勾线伸出 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + extStr,true,OUTCONTROL_OPEN,-1,-1, + backStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0016,tr("Hookline open and close"),OT_CLIP_EXTEND,// 勾线开合 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + +// m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0016,tr("Scan code test"),OT_CLIP_EXTEND,// 扫码测试 +// "",false,-1,-1,-1, +// "",false,-1,-1,-1, +// "",false,-1,-1,-1, +// "",false,-1,-1,-1, +// testStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0016,tr("Sewing machine head lifting"),OT_SEW_LIFT,// 缝纫机头升降 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + upStr,true,OUTCONTROL_OPEN,-1,-1, + downStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0017,tr("Spindle clutch"),OT_HEAD_L_CLUTH,// 主轴离合 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + comStr,true,OUTCONTROL_OPEN,-1,-1, + sepStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0018,tr("Pen"),OT_PEN_DOWN,// 画笔 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + upStr,true,OUTCONTROL_OPEN,-1,-1, + downStr,true,OUTCONTROL_CLOSE,-1,-1)); +} + +void ClothingMac::initShortCutList() +{ + m_allShortCutList.clear(); + int index = 1; + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("All to zero"),"buttonAllToZero",FUN_ALLTOZERO));//全部归零 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Needle shuttle reset"),"buttonNeedleShuttleReset",FUN_NEEDLESHUTTLERESET));//针梭校对 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Back thread"),"buttonBackThread",FUN_BACKTHREADPOINT));//回穿线点 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Back offset"),"buttonBackOffsetPoint",FUN_BACKOFFSETPOINT));//回偏移点 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Back shuttle"),"buttonBackShuttle",FUN_BACKSHUTTLE));//回换梭位 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Back work"),"buttonBackWorkPoint",FUN_BACKWORKPOINT));//回工作点 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Set anchor"),"buttonSetAnchorPoint",FUN_SETANCHORPOINT));//定定位点 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Back anchor"),"buttonBackAnchorPoint",FUN_BACKANCHORPOINT));//回定位点 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Back start"),"buttonSetEmbPoint",FUN_SETSTARTPOINT));//定起始点 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Back start"),"buttonBackEmbPoint",FUN_BACKSTARTPOINT));//回起始点 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Forwrak or back"),"buttonForwardOrBack",FUN_FORWARDORBACK));//前进回退 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Bottom count reset"),"buttonShutCount",FUN_COUNTRESET));//底线计数清零 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("HeadLifting"),"buttonHeadLifting",FUN_HEAD_LIFTING)); + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("ThreadCut"),"buttonMunualThreadCutting",FUN_MANUAL_THREAD_CUTTING)); + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("ProcessReset"),"buttonProcessReset",FUN_PROCESSRESET)); + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Simulated"),"buttonSimulatedStatus",FUN_SIMULATED_STATUS)); +} + +void ClothingMac::initAssistList() +{ + m_allAssistList.clear(); + + m_allAssistList.append(makeAAssistItem(0,0x0001,tr("Signal"),"buttonSensor",ASSIST_SENSOR));//传感器信号 + m_allAssistList.append(makeAAssistItem(0,0x0002,tr("Action"),"buttonControlAction",ASSIST_CONTROLACTION));//控制动作 + m_allAssistList.append(makeAAssistItem(0,0x0003,tr("HMIUpgrade"),"buttonHMIUpgrade",ASSIST_HMIUPGRADE));//界面升级 + m_allAssistList.append(makeAAssistItem(0,0x0004,tr("MCUpgrade"),"buttonMCUpgrade",ASSIST_MCUPGRADE));//主控升级 + m_allAssistList.append(makeAAssistItem(0,0x0006,tr("ParaImport"),"buttonParaImport",ASSIST_PARAIMPORT));//参数导入 + m_allAssistList.append(makeAAssistItem(0,0x0007,tr("ParaExport"),"buttonParaExport",ASSIST_PARAEXPORT));//参数导出 + m_allAssistList.append(makeAAssistItem(0,0x0008,tr("SoftwareSet"),"buttonSoftwareSet",ASSIST_SOFTWARESET));//软件设置 + m_allAssistList.append(makeAAssistItem(0,0x0009,tr("Authorization"),"buttonSoftwareAuthor",ASSIST_AUTHORIZATION));//软件授权 + m_allAssistList.append(makeAAssistItem(0,0x000A,tr("Network"),"buttonNetworkManage",ASSIST_NETWORK));//网络管理 + m_allAssistList.append(makeAAssistItem(0,0x000C,tr("Time"),"buttonTimeSet",ASSIST_TIMESET));//时间设置 + m_allAssistList.append(makeAAssistItem(0,0x000F,tr("Version"),"buttonVersionInfo",ASSIST_MCVERSION));//版本信息 + m_allAssistList.append(makeAAssistItem(0,0x0014,tr("Root"),"buttonRoot",ASSIST_ROOT));//超级用户 +} + +void ClothingMac::initPatternSetList() +{ + m_allPatternSetList.clear(); + + m_allPatternSetList.append(makeAPatternSetItem(0,0x0001,tr("Select"),"buttonPatternSelect",PATTERNSET_PATTERNSELECT));//花样选择 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0002,tr("Para"),"buttonPatternPara",PATTERNSET_PATTERNPARA));//花样参数 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0004,tr("Import"),"buttonPatternImport",PATTERNSET_PATTERNIMPORT));//花样导入 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0005,tr("Export"),"buttonPatternExport",PATTERNSET_PATTERNEXPORT));//花样导出 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0006,tr("Delete"),"buttonPatternDelete",PATTERNSET_PATTERNDELETE));//花样删除 +} + +void ClothingMac::initParaSetList() +{ + m_allParaSetList.clear(); + + m_allParaSetList.append(makeAParaSetItem(0,0x0001,tr("OperatPara"),"buttonPositionParas",PARASET_SETTING));//设置参数 //操作参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0002,tr("ActionSet"),"buttonSpeedParas",PARASET_ACTION));//动作参数 //动作设定 + m_allParaSetList.append(makeAParaSetItem(0,0x0003,tr("SpeedPara"),"buttonActionParas",PARASET_SPEED));//速度参数 //速度控制参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0004,tr("LimitPara"),"buttonDetectParas",PARASET_POSITION));// 位置参数 //限位参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0005,tr("MCPara"),"buttonSettingParas",PARASET_DETECT));//设置参数 //机器参数 +} + +void ClothingMac::initSensorList() +{ + QList sensorList; + + sensorList.append(makeASensorItem(0x0000, 0, tr("Start button 1")));//启动按钮1 + sensorList.append(makeASensorItem(0x0001, 0, tr("Pause button 1")));//暂停按钮1 + sensorList.append(makeASensorItem(0x0007, 0, tr("Air pressure detection 1")));//气压检测1 + sensorList.append(makeASensorItem(0x0008, 0, tr("Security input 1")));//安全输入1 + sensorList.append(makeASensorItem(0x0020, 0, tr("X zero position")));//X零位 + sensorList.append(makeASensorItem(0x0021, 1, tr("Y deceleration")));//Y降速 + sensorList.append(makeASensorItem(0x0023, 0, tr("X positive limit")));//X正限位 + sensorList.append(makeASensorItem(0x0023, 1, tr("Y positive limit")));//Y正限位 + + sensorList.append(makeASensorItem(0x0040, 0, tr("Sewing machine head 1 lifting upper limit")));//缝纫机头1升降上限位 + sensorList.append(makeASensorItem(0x0042, 0, tr("Lower lifting limit of sewing machine head 1")));//缝纫机头1升降下限位 + sensorList.append(makeASensorItem(0x0080, 0, tr("Sewing spindle 1 needle - parking space")));//缝纫主轴1针-停车位 + sensorList.append(makeASensorItem(0x0088, 0, tr("Sewing shuttle 1- parking space")));//缝纫旋梭1-停车位 + sensorList.append(makeASensorItem(0x0170, 0, tr("Sewing machine head 1 - surface thread breakage inspection")));//缝纫机头1-面线断检 + + //将机型所需的传感器列表替换到传感器整体列表中 + for(int i = 0; i < sensorList.size(); i++) + { + int byteaddr = sensorList[i].m_byte_offset; + int bitaddr = sensorList[i].m_bit_offset; + QString str = sensorList[i].m_name; + int type = sensorList[i].m_type; + + int idx = byteaddr*8+bitaddr; + if(idx < m_allSensorList.size()) + { + m_allSensorList[idx].m_name = str; + m_allSensorList[idx].m_type = type; + } + } +} + +void ClothingMac::initErrorCodeAndStateList() +{ + //暂时无专用的错误代码,都为通用的 + m_allErrorCodeAndStateList.clear(); +} diff --git a/mctype/patternsingleboard/function/clothingmac.h b/mctype/patternsingleboard/function/clothingmac.h new file mode 100644 index 0000000..70765a5 --- /dev/null +++ b/mctype/patternsingleboard/function/clothingmac.h @@ -0,0 +1,39 @@ +#ifndef CLOTHINGMAC_H +#define CLOTHINGMAC_H + +#include +#include "mctype/machinetypefun.h" + +//服装机 +class ClothingMac : public MachineTypeFun +{ + Q_OBJECT +public: + ClothingMac(); + ~ClothingMac(); +public: + void initNinebtn1234(); + +private: + void initRootParasList();//超级用户参数(包括机器参数、工作参数) + void initPatternsParasList();//花样参数 + void initMcParasList();//主控机器参数 + void initWkParasList();//主控工作参数 + +private: + void initOutCtrlList();//控制动作 + void initShortCutList();//快捷动作 + void initAssistList();//辅助功能 + void initPatternSetList();//花样设置 + void initParaSetList();//参数设置 + +private: + void initSensorList();//初始化传感器列表 + void initErrorCodeAndStateList();//初始化错误代码和状态列表 + +signals: + +public slots: +}; + +#endif // CLOTHINGMAC_H diff --git a/mctype/patternsingleboard/function/fiveheadprecisionsewing.cpp b/mctype/patternsingleboard/function/fiveheadprecisionsewing.cpp new file mode 100644 index 0000000..5e03622 --- /dev/null +++ b/mctype/patternsingleboard/function/fiveheadprecisionsewing.cpp @@ -0,0 +1,967 @@ +#include "fiveheadprecisionsewing.h" + +FiveHeadPrecisionSewing::FiveHeadPrecisionSewing() +{ + + + //添加各种参数到列表中 + initRootParasList(); + initRootHMIConfigurationList(m_allParasList);//超级用户界面配置 + initPatternsParasList(); + initSoftwareParasList(m_allParasList); + initTimeParasList(m_allParasList); + initMcParasList(); + initWkParasList(); + + //初始化控制动作列表 + initOutCtrlList(); + + //初始化快捷功能列表 + initShortCutList(); + + //初始化辅助功能列表 + initAssistList(); + + //初始化花样设置功能列表 + initPatternSetList(); + + //参数分类功能 + initParaSetList(); + + //初始化传感器列表 + initSensorList(); + + //初始化错误代码和状态列表 + initErrorCodeAndStateList(); + + //初始化九宫格 + initNinebtn1234(); + + //加载右上角信息 + initFileInfoLabel(); +} + +FiveHeadPrecisionSewing::~FiveHeadPrecisionSewing() +{ + +} + +void FiveHeadPrecisionSewing::initNinebtn1234() +{ + m_nineBtn.insert(1,NineItem(FUN_HEAD_LIFTING,"buttonHeadLifting")); + m_nineBtn.insert(2,NineItem(FUN_FORWARDORBACK,"buttonForwardOrBack")); + m_nineBtn.insert(3,NineItem(FUN_PROCESSRESET,"buttonProcessReset")); + m_nineBtn.insert(4,NineItem(FUN_SIMULATED_STATUS,"buttonSimulatedStatus")); +} + +void FiveHeadPrecisionSewing::initFileInfoLabel() +{ + m_fileInfo.append(FileName); + m_fileInfo.append(Index); + m_fileInfo.append(BeginPoint); + m_fileInfo.append(Range); + m_fileInfo.append(Position); + m_fileInfo.append(Production); +} + +//超级用户参数(包括机器参数、工作参数) //五头未更改 +void FiveHeadPrecisionSewing::initRootParasList() +{ + //超级用户参数--------------------------- + //超级用户参数-界面配置;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_HMICONFIGURATION, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("HMI Configuration"),//界面配置 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0000 , factory)); + + //超级用户参数-界面进入调试模式;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_DEBUGMODE, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Interface debug mode"),//界面进入调试模式 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001 , root)); + + //超级用户参数-删除config.ini配置文件;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_DELETEINI, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Delete configure file"),//删除配置文件 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001 , root)); + + //超级用户参数-机器参数;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_MACHINEPARA, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Machine parameters"),//机器参数 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0002, factory)); + + //超级用户参数-工作参数;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_WORKPARA, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Work parameters"),//工作参数 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0003, factory)); +} + +//花样参数 +void FiveHeadPrecisionSewing::initPatternsParasList() +{ + //QTextCodec *cod = QTextCodec::codecForLocale(); + + //花样参数-花样设置参数-起始点x;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR , + SET_STARTX, 0, 0, PARA_VALUE_TYPE_INT, + tr("startX"),//起始点X + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0003, operate)); + + //花样参数-花样设置参数-起始点y;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR , + SET_STARTY, 0, 0, PARA_VALUE_TYPE_INT, + tr("startrY"),//起始点Y + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0004, operate)); + + +#if 0 + + //花样参数-花样设置参数-定位点x;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR, + SET_ANCHORX, 0, 0, PARA_VALUE_TYPE_INT, + tr("AnchorX"),//定位点X + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0001, operate)); + + //花样参数-花样设置参数-定位点y;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR , + SET_ANCHORY, 0, 0, PARA_VALUE_TYPE_INT, + tr("AnchorY"),//定位点Y + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0002, operate)); + + //花样参数-花样设置参数-左边;单位:毫米 ,范围0-10000,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_SETLEFT, 0, 0, PARA_VALUE_TYPE_INT, + tr("Left"),//左边 + 0, 0, 10000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0010, operate)); + + //花样参数-花样设置参数-前边;单位:毫米 ,范围0-10000,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_SETFRONT, 0, 0, PARA_VALUE_TYPE_INT, + tr("Front"),//前边 + 0, 0, 10000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0011, operate)); + +#endif + +} + +//机器参数 +void FiveHeadPrecisionSewing::initMcParasList() +{ + // QTextCodec *cod = QTextCodec::codecForLocale(); + + //x可移动区域正边界(X+), 范围 -10000.00--10000.00,单位0.01mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 2, 0, 0, PARA_VALUE_TYPE_INT, + tr("X movable area positive boundary"),//x可移动区域正边界(X+) + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0028, operate)); + + // y可移动区域正边界(Y+), 范围 -10000.00--10000.00,单位0.01mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 3, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y movable area positive boundary"),//y可移动区域正边界(Y+) + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0029, operate)); + + // x可缝纫区域负边界(X-), 范围 -10000.00--10000.00,单位0.01mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 4, 0, 0, PARA_VALUE_TYPE_INT, + tr("X Sewing area Negative boundary"),//x可缝纫区域负边界(X-) + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0030, operate)); + + // x可缝纫区域正边界(X+), 范围 -10000.00--10000.00,单位0.01mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 5, 0, 0, PARA_VALUE_TYPE_INT, + tr("X Sewing area positive boundary"),//x可缝纫区域正边界(X+) + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0031, operate)); + + // y可缝纫区域负边界(Y-), 范围 -10000.00--10000.00,单位0.01mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 6, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y Sewing area Negative boundary"),//y可缝纫区域负边界(Y-) + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0032, operate)); + + + // y可缝纫区域正边界(Y+), 范围 -10000.00--10000.00,单位0.01mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 7, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y Sewing area positive boundary"),// y可缝纫区域正边界(Y+) + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0033, operate)); + + // 机头2零位坐标,范围 0--4000.0,单位0.1mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 8, 0, 0, PARA_VALUE_TYPE_INT, + tr("Zero position coordinate of head 2"),// 机头2零位坐标 + 0, 0, 40000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0023, operate)); + + // 机头3零位坐标,范围 0--4000.0,单位0.1mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 9, 0, 0, PARA_VALUE_TYPE_INT, + tr("Zero position coordinate of head 3"),// 机头3零位坐标 + 0, 0, 40000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0024, operate)); + + // 机头4零位坐标,范围 0--4000.0,单位0.1mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 10, 0, 0, PARA_VALUE_TYPE_INT, + tr("Zero position coordinate of head 4"),// 机头4零位坐标 + 0, 0, 40000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0025, operate)); + + // 机头5零位坐标,范围 0--4000.0,单位0.1mm + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 11, 0, 0, PARA_VALUE_TYPE_INT, + tr("Zero position coordinate of head 5"),// 机头5零位坐标 + 0, 0, 40000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0026, operate)); + +} + +//工作参数 +void FiveHeadPrecisionSewing::initWkParasList() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + // 主轴缝纫工作转速, 范围 1--500,单位r/min,默认 300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 0, 0, 0, PARA_VALUE_TYPE_INT, + tr("sewing work speed"),// 主轴缝纫工作转速 + 300, 1, 500, 300, 0, tr("r/min"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + // 主轴剪线转速, 范围 1--500,单位r/min,默认 120 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 1, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle thread cutting speed"),// 主轴剪线转速 + 120, 1, 500, 120, 0, tr("r/min"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // 缝纫动框方式, 位图 + // bit0 = 0, xy连续动框; bit = 1, xy间歇式动框; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 2, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Sewing motion frame method"),// 缝纫动框方式 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Xy continuous moving box:0;Xy intermittent moving frame:1"), 0, 0, 0x0007, operate));// bit0 = 0, xy连续动框; bit = 1, xy间歇式动框; + + // 起针动作允许; 位图选择, 0, 不允许; 1, 允许; + // bit0, 松线允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 3, 1, 0, PARA_VALUE_TYPE_SW, + tr("Allow for needle starting and thread loosening"),// 起针松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0008, operate)); + + // 剪线允许; 0, 不剪线; 1, 剪线 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 4, 0, 0, PARA_VALUE_TYPE_SW, + tr("Thread cutting allowed"),// 剪线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0003, operate));// 0, 不剪线; 1, 剪线 + + // 剪线时动作允许, 位图选择, + // bit0, 松线允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 1, 0, PARA_VALUE_TYPE_SW, + tr("Allow for loose thread during thread cutting"),// 剪线时松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0009, operate)); + // bit2, 夹线允许; 0, 不允许; 1, 允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 3, 0, PARA_VALUE_TYPE_SW, + tr("Allowing for wire clamping during wire cutting"),// 剪线时夹线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0009, operate)); + // bit7, 退针允许;0:允许 1:不允许 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 8, 0, PARA_VALUE_TYPE_SW, + tr("Allow needle withdrawal during thread cutting"),// 剪线时退针允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0009, operate)); + + // 断线检测针数; 0, 不检测断线; 其他, 断线信号连续针数, 默认3 断线检测0~10 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 6, 0, 0, PARA_VALUE_TYPE_INT, + tr("No. of stitch detect if thread broken"),// 断线检测针数 + 3, 0, 10, 3, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0002, operate)); + + // 换梭芯提醒功能, 0, 不启用该功能; 1, 按长度计数延迟提醒; 2, 按片数计数; 3, 按长度立刻提醒; 默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 7, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Bobbin change reminder function"),// 换梭芯提醒功能 + 0, 0, 3, 0, 0, tr(""), tr(""), + //0, 不启用该功能; 1, 按长度计数延迟提醒; 2, 按片数计数; 3, 按长度立刻提醒; 默认0 + tr("Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3"), 0, 0, 0x0012, operate)); + + // 底线长度, 单位 0.01mm,默认 10000000 底线长度1~100000.00 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 8, 0, 0, PARA_VALUE_TYPE_INT, + tr("Bobbin thread length"),// 底线长度 + 10000000, 1, 10000000, 10000000, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0013, operate)); + + // 换梭片数计数, 单位 次,默认 0 片数1~1000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 9, 0, 0, PARA_VALUE_TYPE_INT, + tr("Count of shuttle change pieces"),// 换梭片数计数 + 0, 1, 1000, 0, 0, tr("Times"), tr(""), + tr(""), + 0, 0, 0x0014, operate)); + + // 加油方式选择, 0, 不加油; 1, 按工作时间间歇加油; 2, 按工作针数间歇加油; 3, 持续不停加油,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 10, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Refueling method selection"),// 加油方式选择 + 0, 1, 3, 0, 0, tr(""), tr(""), + // 0, 不加油; 1, 按工作时间间歇加油; 2, 按工作针数间歇加油; 3, 持续不停加油, + tr("not refueling:0;Intermittent refueling according to worktime:1;Intermittent refueling according to the number of working stitches:2;Continuously refueling:3"),0, 0, 0x0016, operate)); + + // 加油针数间隔, 单位针, 加油方式为按针数加油时有用,默认 10000 加油间隔0~10000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 11, 0, 0, PARA_VALUE_TYPE_INT, + tr("Interval between refueling stitches"),// 加油针数间隔 + 10000, 0, 10000, 10000, 0, tr(""), tr(""), + tr(""),0, 0, 0x0017, operate)); + + // 加油持续时长, 单位秒, 加油时长0~60秒 默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 13, 0, 0, PARA_VALUE_TYPE_INT, + tr("Refueling duration"),// 加油持续时长 + 0, 0, 60, 0, 0, tr("second"), tr(""), //秒 + tr(""),0, 0, 0x0018, operate)); + + // 剪线分线角度,0--36000, 单位 0.01度,默认 20000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 15, 0, 0, PARA_VALUE_TYPE_INT, + tr("Cutting and parting angle"),// 剪线分线角度 + 20000, 0, 36000, 20000, 2, cod->toUnicode("°"), tr(""), //度 + tr(""),0, 0, 0x0018, operate)); + + // 剪线完成角度,0--36000, 单位 0.01度,默认 6000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 16, 0, 0, PARA_VALUE_TYPE_INT, + tr("Thread trimming completion angle"),// 剪线完成角度 + 6000, 0, 36000, 6000, 2, cod->toUnicode("°"), tr(""), //度 + tr(""),0, 0, 0x0018, operate)); + // 面线夹线针数,0--5,单位 针,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 17, 0, 0, PARA_VALUE_TYPE_INT, + tr("Number of stitches for surface thread clamping"),// 面线夹线针数 + 0, 0, 5, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0019, operate)); + + /////////////////////////////////////////////////////////////////////////////////////// + + // 产量预设 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 21, 0, 0, PARA_VALUE_TYPE_INT, + tr("Production preset"),// 产量预设 + 0, 0, S32_MAX, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0004, operate)); + + // 缝纫时动作允许, 0, 不允许; 1, 允许; + // bit1 自动回穿线点允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 23, 1, 0, PARA_VALUE_TYPE_SW, + tr("Automatically thread back points during sewing"),// 缝纫时自动回穿线点 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0010, operate)); + + // 移框时动作选择; 位图选择, 0, 不允许; 1, 允许; + // bit0, 松线允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 25, 1, 0, PARA_VALUE_TYPE_SW, + tr("Allow for loose lines when moving boxes"),//移框时松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x011, operate)); + + // 软件限位; 位图选择, 0, 不允许; 1, 允许; + // bit0, xy移动; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 26, 1, 0, PARA_VALUE_TYPE_SW, + tr("Software limit: xy movement"),// 软件限位:xy移动 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0027, operate)); + + // 缝纫降速: 0 不降速 1 降速 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 31, 0, 0, PARA_VALUE_TYPE_SW, + tr("Automatic sewing speed regulation"),// 缝纫降速 + 0, 0, 2, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0006, operate));// 1降速,2不降速 + + // 循环工作功能,0, 不允许; 1, 允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 34, 1, 0, PARA_VALUE_TYPE_SW, + tr("Circular working function"),// 循环工作功能 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0005, operate)); + + // 梭加油持续时长, 单位秒, (针梭独立加油时有效) + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 35, 0, 0, PARA_VALUE_TYPE_INT, + tr("Duration of shuttle refueling"),// 梭加油持续时长 + 0, 0, 60, 0, 0, tr("second"), tr(""), //秒 + tr(""),0, 0, 0x0019, operate)); + + // 缝纫吹气时间,范围0-10,单位s,默认0(0为持续吹气) + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 36, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing and blowing time"),// 缝纫吹气时间 + 0, 0, 10, 0, 0, tr("second"), tr(""), //秒 + tr(""),0, 0, 0x0015, operate)); + + // 缝纫动框起始角度, 0--36000, 单位 0.01度,默认 28000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 37, 0, 0, PARA_VALUE_TYPE_INT, + tr("Starting angle of sewing frame"),// 缝纫动框起始角度 + 28000, 0, 36000, 28000, 2, cod->toUnicode("°"), tr(""), //度 + tr(""),0, 0, 0x0021, operate)); + + // 缝纫勾线角度, 0--36000, 单位 0.01度,默认 20200 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 38, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing hook angle"),// 缝纫勾线角度 + 20200, 0, 36000, 20200, 2, cod->toUnicode("°"), tr(""), //度 + tr(""),0, 0, 0x0021, operate)); + + // 缝纫动框持续角度, 0--36000, 单位 0.01度,默认 15000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 39, 0, 0, PARA_VALUE_TYPE_INT, + tr("Continuous angle of sewing frame"),// 缝纫动框持续角度 + 15000, 0, 36000, 15000, 2, cod->toUnicode("°"), tr(""), //度 + tr(""),0, 0, 0x0021, operate)); + + // // 穿线点坐标X 0--400000 单位0.01mm 默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 40, 0, 0, PARA_VALUE_TYPE_INT, + tr("Coordinate of threading point X"),// 穿线点坐标X + 0, 0, 400000, 0, 2, tr("mm"), tr(""), //毫米 + tr(""),0, 0, 0x0021, operate)); + + // 穿线点坐标Y 0--400000 单位0.01mm 默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 41, 0, 0, PARA_VALUE_TYPE_INT, + tr("Coordinate of threading point Y"),// 穿线点坐标Y + 0, 0, 400000, 0, 2, tr("mm"), tr(""), //毫米 + tr(""),0, 0, 0x0021, operate)); + +} + +//电机和控制动作 +void FiveHeadPrecisionSewing::initOutCtrlList() +{ + m_allOutCtrlList.clear(); + int showPriority = 1; + + m_allOutCtrlList.append(makeAOutCtrlItem(0,showPriority++,tr("Zero All"),MT_HX,// 全部归零 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + zeroStr,true,ALLTO_ZERO,-1,-1)); + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("X to move motor"),MT_LX));// X向移动电机(归零,正转,反转) + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Y to move motor"),MT_LY));// Y向移动电机(归零,正转,反转) + m_allOutCtrlList.append(makeAOutCtrlItem(0,showPriority++,tr("Head moving motor"),MT_HX,// 机头移动电机(归零) + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(creatZeroItem(0,showPriority++,tr("All spindle zero positions"),MT_ALLZ)); // 所有主轴 零位 (归零) + m_allOutCtrlList.append(creatZeroItem(0,showPriority++,tr("All Spindle Hook Lines positions"),MT_ALLG)); // 所有主轴 勾线 (归零) + m_allOutCtrlList.append(creatZeroItem(0,showPriority++,tr("All spindle jogs positions"),MT_ALLM)); // 所有主轴 点动 (归零) + + + //同样的按钮组封装为一个方法 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Spindle 1 motor"),MT_LM1));// 主轴1电机 (归零,正转,反转) + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Pin 1 motor"),MT_LN1));// 针1电机 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Shuttle 1 motor"),MT_LH1));// 梭1电机 + + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Spindle 2 motor"),MT_LM2));// 主轴2电机 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Pin 2 motor"),MT_LN2));// 针2电机 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Shuttle 2 motor"),MT_LH2));// 梭2电机 + + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Spindle 3 motor"),MT_LM3));// 主轴3电机 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Pin 3 motor"),MT_LN3));// 针3电机 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Shuttle 3 motor"),MT_LH3));// 梭3电机 + + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Spindle 4 motor"),MT_LM4));// 主轴4电机 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Pin 4 motor"),MT_LN4));// 针4电机 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Shuttle 4 motor"),MT_LH4));// 梭4电机 + + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Spindle 5 motor"),MT_LM5));// 主轴5电机 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Pin 5 motor"),MT_LN5));// 针5电机 + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Shuttle 5 motor"),MT_LH5));// 梭5电机 + + + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 1 Elastic thread"),OT_LOOSE_THREAD1));//机头1 松紧线 (放松,夹紧) + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 2 Elastic thread"),OT_LOOSE_THREAD2));//机头2 松紧线 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 3 Elastic thread"),OT_LOOSE_THREAD3));//机头3 松紧线 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 4 Elastic thread"),OT_LOOSE_THREAD4));//机头4 松紧线 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 5 Elastic thread"),OT_LOOSE_THREAD5));//机头5 松紧线 + + m_allOutCtrlList.append(creatEnableItem(0,showPriority++,tr("Head 1 ThreadCuttingAction"), ThreadCuttingAction1,trimStr)); // 机头1 剪线动作 + m_allOutCtrlList.append(creatEnableItem(0,showPriority++,tr("Head 2 ThreadCuttingAction"), ThreadCuttingAction2,trimStr)); // 机头2 剪线动作 + m_allOutCtrlList.append(creatEnableItem(0,showPriority++,tr("Head 3 ThreadCuttingAction"), ThreadCuttingAction3,trimStr)); // 机头3 剪线动作 + m_allOutCtrlList.append(creatEnableItem(0,showPriority++,tr("Head 4 ThreadCuttingAction"), ThreadCuttingAction4,trimStr)); // 机头4 剪线动作 + m_allOutCtrlList.append(creatEnableItem(0,showPriority++,tr("Head 5 ThreadCuttingAction"), ThreadCuttingAction5,trimStr)); // 机头5 剪线动作 + + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 1 blow"), OT_BLOW1)); // 机头1 吹气 (打开,关闭) + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 2 blow"), OT_BLOW2)); // 机头2 吹气 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 3 blow"), OT_BLOW3)); // 机头3 吹气 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 4 blow"), OT_BLOW4)); // 机头4 吹气 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 5 blow"), OT_BLOW5)); // 机头5 吹气 + + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 1 trim"), OT_DCUT_THREAD1)); //机头1 剪线 (打开,关闭) + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 2 trim"), OT_DCUT_THREAD2)); //机头2 剪线 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 3 trim"), OT_DCUT_THREAD3)); //机头3 剪线 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 4 trim"), OT_DCUT_THREAD4)); //机头4 剪线 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 5 trim"), OT_DCUT_THREAD5)); //机头5 剪线 + + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 1 needle refueling"), OT_ADD_NOIL1)); //机头1 针加油 (打开,关闭) + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 2 needle refueling"), OT_ADD_NOIL2)); //机头2 针加油 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 3 needle refueling"), OT_ADD_NOIL3)); //机头3 针加油 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 4 needle refueling"), OT_ADD_NOIL4)); //机头4 针加油 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 5 needle refueling"), OT_ADD_NOIL5)); //机头5 针加油 + + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 1 shuttle refueling"), OT_ADD_HOIL1)); // 机头1 梭加油 (打开,关闭) + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 2 shuttle refueling"), OT_ADD_HOIL2)); // 机头2 梭加油 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 3 shuttle refueling"), OT_ADD_HOIL3)); // 机头3 梭加油 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 4 shuttle refueling"), OT_ADD_HOIL4)); // 机头4 梭加油 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 5 shuttle refueling"), OT_ADD_HOIL5)); // 机头5 梭加油 + + m_allOutCtrlList.append(creatAscendingDescendingItem(0,showPriority++,tr("Head 1 lifting"), OT_LIFT_UP1)); // 机头1 升降 (上升,下降) + m_allOutCtrlList.append(creatAscendingDescendingItem(0,showPriority++,tr("Head 2 lifting"), OT_LIFT_UP2)); // 机头2 升降 + m_allOutCtrlList.append(creatAscendingDescendingItem(0,showPriority++,tr("Head 3 lifting"), OT_LIFT_UP3)); // 机头3 升降 + m_allOutCtrlList.append(creatAscendingDescendingItem(0,showPriority++,tr("Head 4 lifting"), OT_LIFT_UP4)); // 机头4 升降 + m_allOutCtrlList.append(creatAscendingDescendingItem(0,showPriority++,tr("Head 5 lifting"), OT_LIFT_UP5)); // 机头5 升降 + + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Lock frame cylinder"), OT_LOCK_FRM_CTRL)); // 锁框气缸 (打开,关闭) + m_allOutCtrlList.append(creatAscendingDescendingItem(0,showPriority++,tr("Flap control"), OT_FLAP_UP)); // 翻板控制 (上升,下降) + m_allOutCtrlList.append(makeAOutCtrlItem(0,showPriority++,tr("Barcode testing"),OT_SCAN_CODE, // 条码测试 (打开) + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1)); + + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 1 Clamp wire"), OT_CLIP1)); // 机头1 夹线 (打开,关闭) + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 2 Clamp wire"), OT_CLIP2)); // 机头2 夹线 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 3 Clamp wire"), OT_CLIP3)); // 机头3 夹线 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 4 Clamp wire"), OT_CLIP4)); // 机头4 夹线 + m_allOutCtrlList.append(creatOpenCloseItem(0,showPriority++,tr("Head 5 Clamp wire"), OT_CLIP5)); // 机头5 夹线 +} + + +//快捷功能 +void FiveHeadPrecisionSewing::initShortCutList() +{ + m_allShortCutList.clear(); + int index = 1;; + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("All_Zero"),"buttonFrameZero",FUN_ALLTOZERO));//全部归零 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Front_Back"),"buttonForwardOrBack",FUN_FORWARDORBACK));// 快进快退 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("AllSpleZero"),"buttonAllToZero",FUN_MT_ALLZ));//所有主轴零位 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("AllSpleHook"),"buttonFlatEmbHook",FUN_MT_ALLG));//所有主轴勾线 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("AllSpleJogs"),"buttonSpindleRotate",FUN_MT_ALLM));//所有主轴点动 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("N/S_Proof"),"buttonAutoParas",FUN_MAINSHAFT_ADJUST));//针梭校对 + + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("MU_Canl"),"MakeupCancel",FUN_MAKEUP_NOHEAD));// 取消补缝 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Makeup1"),"Makeup1",FUN_MAKEUP_HEAD1));// 机头1补缝 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Makeup2"),"Makeup2",FUN_MAKEUP_HEAD2));// 机头2补缝 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Makeup3"),"Makeup3",FUN_MAKEUP_HEAD3));// 机头3补缝 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Makeup4"),"Makeup4",FUN_MAKEUP_HEAD4));// 机头4补缝 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Makeup5"),"Makeup5",FUN_MAKEUP_HEAD5));// 机头5补缝 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ThCutAct1"),"ThCutAct1",ASSIST_ThCutAct1));//机头1 剪线动作 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ThCutAct2"),"ThCutAct2",ASSIST_ThCutAct2));//机头2 剪线动作 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ThCutAct3"),"ThCutAct3",ASSIST_ThCutAct3));//机头3 剪线动作 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ThCutAct4"),"ThCutAct4",ASSIST_ThCutAct4));//机头4 剪线动作 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ThCutAct5"),"ThCutAct5",ASSIST_ThCutAct5));//机头5 剪线动作 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("SetStart"),"buttonSetEmbPoint",FUN_SETSTARTPOINT));//定起始点 + + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("AMShaftRun"),"buttonSetAnchorPoint",FUN_SPINDLETEST));// 所有主轴研车 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ProcReset"),"buttonProcessReset",FUN_PROCESSRESET));//流程复位 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Simulate"),"buttonSimulatedStatus",FUN_SIMULATED_STATUS));//模拟缝纫 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("HeadLifting"),"buttonHeadLifting",FUN_HEAD_LIFTING));//机头上升 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("GoFeedt"),"buttonEmbParas",FUN_GOTO_FEEDT));//回穿线点 + m_allShortCutList.append(makeAShortCutItem(0, index++, tr("Back start"),"buttonBackEmbPoint",FUN_BACKSTARTPOINT));//回起针点 + +} + +//辅助功能 +void FiveHeadPrecisionSewing::initAssistList() +{ + m_allAssistList.clear(); + + m_allAssistList.append(makeAAssistItem(0,0x0001,tr("Signal"),"buttonSensor",ASSIST_SENSOR));//传感器信号 + m_allAssistList.append(makeAAssistItem(0,0x0002,tr("Action"),"buttonControlAction",ASSIST_CONTROLACTION));//控制动作 + m_allAssistList.append(makeAAssistItem(0,0x0003,tr("HMIUpgrade"),"buttonHMIUpgrade",ASSIST_HMIUPGRADE));//界面升级 + m_allAssistList.append(makeAAssistItem(0,0x0004,tr("MCUpgrade"),"buttonMCUpgrade",ASSIST_MCUPGRADE));//主控升级 + m_allAssistList.append(makeAAssistItem(0,0x0006,tr("ParaImport"),"buttonParaImport",ASSIST_PARAIMPORT));//参数导入 + m_allAssistList.append(makeAAssistItem(0,0x0007,tr("ParaExport"),"buttonParaExport",ASSIST_PARAEXPORT));//参数导出 + m_allAssistList.append(makeAAssistItem(0,0x0008,tr("Setting"),"buttonSoftwareSet",ASSIST_SOFTWARESET));//软件设置 + m_allAssistList.append(makeAAssistItem(0,0x0009,tr("Authorize"),"buttonSoftwareAuthor",ASSIST_AUTHORIZATION));//软件授权 + m_allAssistList.append(makeAAssistItem(0,0x000A,tr("Network"),"buttonNetworkManage",ASSIST_NETWORK));//网络管理 + m_allAssistList.append(makeAAssistItem(0,0x000C,tr("Time"),"buttonTimeSet",ASSIST_TIMESET));//时间设置 + m_allAssistList.append(makeAAssistItem(0,0x000F,tr("Version"),"buttonVersionInfo",ASSIST_MCVERSION));//版本信息 + m_allAssistList.append(makeAAssistItem(0,0x0014,tr("Root"),"buttonRoot",ASSIST_ROOT));//超级用户 +// m_allAssistList.append(makeAAssistItem(0,0x001A,tr("ScanTest"),"ScanTest",ASSIST_ScanTest));//扫码测试 +} + +//花样设置 +void FiveHeadPrecisionSewing::initPatternSetList() +{ + m_allPatternSetList.clear(); + + m_allPatternSetList.append(makeAPatternSetItem(0,0x0001,tr("Para"),"buttonPatternPara",PATTERNSET_PATTERNPARA));//花样参数 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0002,tr("Select"),"buttonPatternSelect",PATTERNSET_PATTERNSELECT));//花样选择 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0004,tr("Import"),"buttonPatternImport",PATTERNSET_PATTERNIMPORT));//花样导入 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0005,tr("Export"),"buttonPatternExport",PATTERNSET_PATTERNEXPORT));//花样导出 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0006,tr("Delete"),"buttonPatternDelete",PATTERNSET_PATTERNDELETE));//花样删除 +} + + +//参数分类(参数分组功能) +void FiveHeadPrecisionSewing::initParaSetList() +{ + m_allParaSetList.clear(); + + m_allParaSetList.append(makeAParaSetItem(0,0x0001,tr("OperatPara"),"buttonPositionParas",PARASET_SETTING));//设置参数 //操作参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0002,tr("ActionSet"),"buttonSpeedParas",PARASET_ACTION));//动作参数 //动作设定 + m_allParaSetList.append(makeAParaSetItem(0,0x0003,tr("SpeedPara"),"buttonActionParas",PARASET_SPEED));//速度参数 //速度控制参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0004,tr("LimitPara"),"buttonDetectParas",PARASET_POSITION));// 位置参数 //限位参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0005,tr("MCPara"),"buttonSettingParas",PARASET_DETECT));//设置参数 //机器参数 +} + + +//初始化传感器列表 +void FiveHeadPrecisionSewing::initSensorList() +{ + QList sensorList; + + sensorList.append(makeASensorItem(0x0000, 0, tr("Start button 1")));//启动按钮1 + sensorList.append(makeASensorItem(0x0001, 0, tr("Pause button 1")));//暂停按钮1 + sensorList.append(makeASensorItem(0x0002, 0, tr("Jog button 1")));//点动按钮1 + sensorList.append(makeASensorItem(0x0003, 0, tr("Open frame button 1")));//开框按钮1 + sensorList.append(makeASensorItem(0x0004, 0, tr("Manual operation button 1")));//手动按钮1 + sensorList.append(makeASensorItem(0x0005, 0, tr("Be ready button 1")));//就绪按钮1 + sensorList.append(makeASensorItem(0x0006, 0, tr("Key button 1")));//钥匙按钮1 + sensorList.append(makeASensorItem(0x0007, 0, tr("Air pressure detection 1")));//气压检测1 + sensorList.append(makeASensorItem(0x0008, 0, tr("Security input 1")));//安全输入1 + sensorList.append(makeASensorItem(0x0009, 0, tr("Template in position 1")));//模板到位1 + sensorList.append(makeASensorItem(0x0009, 1, tr("Template in position 2")));//模板到位2 + sensorList.append(makeASensorItem(0x000A, 0, tr("MOTOR_ALM1")));//电机报警1 + sensorList.append(makeASensorItem(0x000B, 0, tr("MOTOR_ALM9")));//电机报警9 + sensorList.append(makeASensorItem(0x000C, 0, tr("MOTOR_ALM17")));//电机报警17 + sensorList.append(makeASensorItem(0x000D, 0, tr("MOTOR_ALM25")));//电机报警25 + sensorList.append(makeASensorItem(0x000E, 0, tr("MOTOR_ALM33")));//电机报警33 + sensorList.append(makeASensorItem(0x000F, 0, tr("MOTOR_ALM41")));//电机报警41 + + sensorList.append(makeASensorItem(0x0020, 0, tr("X zero position")));//X零位 + sensorList.append(makeASensorItem(0x0020, 1, tr("Y zero position")));//Y零位 + sensorList.append(makeASensorItem(0x0021, 0, tr("X deceleration")));//X降速 + sensorList.append(makeASensorItem(0x0021, 1, tr("Y deceleration")));//Y降速 + sensorList.append(makeASensorItem(0x0022, 0, tr("X negative limit")));//X负限位 + sensorList.append(makeASensorItem(0x0022, 1, tr("Y negative limit")));//Y负限位 + + sensorList.append(makeASensorItem(0x0023, 0, tr("X positive limit")));//X正限位 + sensorList.append(makeASensorItem(0x0023, 1, tr("Y positive limit")));//Y正限位 + + sensorList.append(makeASensorItem(0x0040, 0, tr("Sewing machine head 1 lifting upper limit")));//缝纫机头1升降上限位 + sensorList.append(makeASensorItem(0x0041, 1, tr("Sewing machine head 2 lifting upper limit")));//缝纫机头2升降上限位 + sensorList.append(makeASensorItem(0x0041, 2, tr("Sewing machine head 3 lifting upper limit")));//缝纫机头3升降上限位 + sensorList.append(makeASensorItem(0x0041, 3, tr("Sewing machine head 4 lifting upper limit")));//缝纫机头4升降上限位 + sensorList.append(makeASensorItem(0x0042, 0, tr("Lower lifting limit of sewing machine head 0")));//缝纫机头0升降下限位 + sensorList.append(makeASensorItem(0x0042, 1, tr("Lower lifting limit of sewing machine head 1")));//缝纫机头1升降下限位 + sensorList.append(makeASensorItem(0x0042, 2, tr("Lower lifting limit of sewing machine head 2")));//缝纫机头2升降下限位 + sensorList.append(makeASensorItem(0x0042, 3, tr("Lower lifting limit of sewing machine head 3")));//缝纫机头3升降下限位 + + sensorList.append(makeASensorItem(0x0063, 0, tr("Moving up motor limit on head 1")));//机头1上移动电机 限位+ + sensorList.append(makeASensorItem(0x0063, 1, tr("Moving down motor limit on head 1")));//机头1下移动电机 限位+ + + sensorList.append(makeASensorItem(0x0080, 0, tr("Sewing needle parking space 1")));//缝纫针停车位1 + sensorList.append(makeASensorItem(0x0080, 1, tr("Sewing needle parking space 2")));//缝纫针停车位2 + sensorList.append(makeASensorItem(0x0080, 2, tr("Sewing needle parking space 3")));//缝纫针停车位3 + + sensorList.append(makeASensorItem(0x0099, 0, tr("Embroidery spindle zero position 9")));//绣花主轴零位9 + sensorList.append(makeASensorItem(0x0099, 1, tr("Embroidery spindle zero position 10")));//绣花主轴零位10 + sensorList.append(makeASensorItem(0x0080, 0, tr("Sewing spindle 1 needle - parking space")));//缝纫主轴1针-停车位 + sensorList.append(makeASensorItem(0x0088, 0, tr("Sewing shuttle 1- parking space")));//缝纫旋梭1-停车位 + sensorList.append(makeASensorItem(0x0088, 1, tr("Sewing shuttle 2- parking space")));//缝纫旋梭2-停车位 + sensorList.append(makeASensorItem(0x0088, 2, tr("Sewing shuttle 3- parking space")));//缝纫旋梭3-停车位 + sensorList.append(makeASensorItem(0x0088, 3, tr("Sewing shuttle 4- parking space")));//缝纫旋梭4-停车位 + sensorList.append(makeASensorItem(0x0170, 0, tr("Sewing machine head 1 - surface thread breakage inspection")));//缝纫机头1-面线断检 + sensorList.append(makeASensorItem(0x0170, 1, tr("Sewing machine head 2 - surface thread breakage inspection")));//缝纫机头2-面线断检 + sensorList.append(makeASensorItem(0x0170, 2, tr("Sewing machine head 3 - surface thread breakage inspection")));//缝纫机头3-面线断检 + sensorList.append(makeASensorItem(0x0170, 3, tr("Sewing machine head 4 - surface thread breakage inspection")));//缝纫机头4-面线断检 + sensorList.append(makeASensorItem(0x0174, 0, tr("Sewing thread trimming return 1")));//缝纫下剪线回位1 + sensorList.append(makeASensorItem(0x0174, 1, tr("Sewing thread trimming return 2")));//缝纫下剪线回位2 + sensorList.append(makeASensorItem(0x0174, 2, tr("Sewing thread trimming return 3")));//缝纫下剪线回位3 + sensorList.append(makeASensorItem(0x0174, 3, tr("Sewing thread trimming return 4")));//缝纫下剪线回位4 + + //将机型所需的传感器列表替换到传感器整体列表中 + for(int i = 0; i < sensorList.size(); i++) + { + int byteaddr = sensorList[i].m_byte_offset; + int bitaddr = sensorList[i].m_bit_offset; + QString str = sensorList[i].m_name; + int type = sensorList[i].m_type; + + int idx = byteaddr*8+bitaddr; + if(idx < m_allSensorList.size()) + { + m_allSensorList[idx].m_name = str; + m_allSensorList[idx].m_type = type; + } + } +} + +//初始化错误代码和状态列表 //五头未更改 +void FiveHeadPrecisionSewing::initErrorCodeAndStateList() +{ + m_allErrorCodeAndStateList.clear(); + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_NONE,tr("freedom from error"))); // 没有错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_NO_POWER,tr("Not powered on"))); // 没有上电 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_NO_AIR,tr("Insufficient air pressure"))); // 气压不足 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_NOT_SAFE,tr("Safe Area Intervention"))); // 安全区域介入 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_EXPIRATION,tr("The usage deadline has expired"))); // 使用时限已到 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_FILL_DATA,tr("Filling data error"))); // 填充数据错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_NOT_ALLOWED,tr("Working status not allowed"))); // 不允许工作状态 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_CTRL_ERR,tr("control error"))); // 控制错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_FPGA_ERR,tr("Motion control chip version error"))); // 运动控制芯片版本错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_BUTTON_NOUP,tr("Waiting for button to lift timeout"))); // 等待按钮抬起超时 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_FPGA_RESET,tr("FPGA reset error"))); // FPGA复位错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_NO_READY,tr("Peripheral not ready"))); // 外设未就绪 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_NO_SEND_ERR,tr("Transmission data error"))); // 传输数据错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_EDTION_ERR,tr("Program version error"))); // 程序版本错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_WORK_DONE,tr("Production completed"))); // 完成产量 + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_LMT_POSITIVE,tr("forward limit"))); // 正向限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_LMT_NEGATIVE,tr("Reverse limit"))); // 反向限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_RUN_ALM,tr("Motion alarm"))); // 运动报警 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_RUN_LIMIT,tr("Motion limit"))); // 运动限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_RUN_EMS,tr("Exercise emergency stop"))); // 运动急停 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MV_PARA,tr("Motion parameter error"))); // 运动参数错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MC_PARA,tr("Machine parameter error"))); // 机器参数错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_IN_PARA,tr("Input parameter error"))); // 输入参数错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_CUTTER_NORMAL,tr("The file is correct"))); // 文件正确 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_CUTTER_WAIT,tr("Waiting for files"))); // 等待文件 + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MTZ_RIGHT,tr("Zero successfully"))); // 归零成功 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MTZ_ERROR,tr("Zero error"))); // 归零错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_COOR_SYSTM,tr("Coordinate system error"))); // 坐标系统错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_OUT_RANGE,tr("Target position out of range"))); // 目标位置越界 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_X_LIT_POSI,tr("X forward limit"))); // X正向限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_X_LIT_NEGA,tr("X reverse limit"))); // X反向限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_Y_LIT_POSI,tr("Y forward limit"))); // Y正向限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_Y_LIT_NEGA,tr("Y reverse limit"))); // Y反向限位 + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_NO_DATA,tr("No Data"))); // 无数据 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_DATA_ERROR,tr("data error"))); // 数据错误 + + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MS_NOT_ZERO,tr("Spindle not in zero position"))); // 主轴不在零位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_HK_NOT_ZERO,tr("Rotary shuttle not in zero position"))); // 旋梭不在零位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MS_NOT_SYNC,tr("Needle shuttle out of sync"))); // 针梭不同步 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_RO_NOT_SYNC,tr("Rotation out of sync"))); // 旋转不同步 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_CUTTER_NOT_POS,tr("The scissors are not returning to their original position"))); // 剪刀不在回位(注:该报错码是缝纫剪刀) + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_HEAD_NOT_HIGH,tr("Machine head not in high position"))); // 机头不在高位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_HEAD_NOT_LOW,tr("Machine head not in low position"))); // 机头不在低位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_LIGHTCURTAINS,tr("Light curtain intervention"))); // 光幕介入 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_UPER_TBREAK,tr("Broken surface thread"))); // 面线断线 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_BOBBIN_TBREAK,tr("Bottom line disconnection"))); // 底线断线 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_LIFT_TIMEOUT,tr("Head lifting timeout"))); // 机头升降超时 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_CHANGE_BOBBIN,tr("Replacing the shuttle core"))); // 更换梭芯 + + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_FEED_ROLLER,tr("Abnormal feeding pressure roller"))); // 进料压辊 异常 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_DIS_ROLLER,tr("Abnormal discharge pressure roller"))); // 出料压辊 异常 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_DIS_MATERIAL,tr("Abnormal discharge and pressing"))); // 出料压料 异常 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_TENS_DEVICE,tr("Tensioning device abnormal"))); // 张紧装置 异常 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_CLOTH_DEVICE,tr("Abnormal cloth clamping device"))); // 夹布装置 异常 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_EDGE_MOTOR,tr("Edge cutting motor blocked"))); // 边切电机 阻塞 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_CROSS_MOTOR,tr("Cross cutting motor abnormality"))); // 横切电机 异常 + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_INSTALLMENT_OK,tr("Password set successfully"))); // 密码设置成功 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_INSTALLMENT_FAIL,tr("Password setting failed"))); // 密码设置失败 + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MOTO_N_ALM,tr("Needle motor alarm"))); // 针电机报警 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MOTO_H_ALM,tr("Shuttle motor alarm"))); // 梭电机报警 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MOTO_X_ALM,tr("X motor alarm"))); // X电机报警 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MOTO_Y_ALM,tr("Y motor alarm"))); // Y电机报警 + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MOTO_N_FZ,tr("Needle motor reset failed"))); // 针电机归零失败 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MOTO_H_FZ,tr("Shuttle motor reset failed"))); // 梭电机归零失败 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MOTO_X_FZ,tr("X motor reset failed"))); // X电机归零失败 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MOTO_Y_FZ,tr("Y motor reset failed"))); // Y电机归零失败 + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_CS_TIMEOUT,tr("Slave board communication timeout"))); // 从板通讯超时 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERRQUI_MOTO_X_ZERO,tr("X motor not in zero position"))); // X电机不在零位 + + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_HEAD_NOT_HIGH,tr("Machine head not in high position"))); // 机头不在高位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_X_LIT_POSI,tr("X forward limit"))); // X正向限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_X_LIT_NEGA,tr("X reverse limit"))); // X反向限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_Y_LIT_POSI,tr("Y forward limit"))); // Y正向限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_Y_LIT_NEGA,tr("Y reverse limit"))); // Y反向限位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_COOR_SYSTM,tr("Coordinate system error"))); // 坐标系统错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_OUT_RANGE,tr("Target position out of range"))); // 目标位置越界 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_NOT_SAFE,tr("Safe Area Intervention"))); // 安全区域介入 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_AIR_POWER,tr("Insufficient air pressure"))); // 气压不足 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_GUARDRAIL_OPEN,tr("The safety door is not closed"))); // 安全门未关闭 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_UPER_TBREAK,tr("Broken surface thread"))); // 面线断线 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_CHANGE_BOBBIN,tr("Replacing the shuttle core"))); // 更换梭芯 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_MS_NOT_ZERO,tr("Spindle not in zero position"))); // 主轴不在零位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_HK_NOT_ZERO,tr("Rotary shuttle not in zero position"))); // 旋梭不在零位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_NO_DATA,tr("No Data"))); // 无数据 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_MC_PARA,tr("Machine parameter error"))); // 机器参数错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_MV_PARA,tr("Motion parameter error"))); // 运动参数错误 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_HEAD_NOT_SAFE,tr("The machine head is not in a safe area"))); // 机头不在安全区域 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_NOT_ALLOWED,tr("Working status not allowed"))); // 不允许工作状态 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_LIFT_TIMEOUT,tr("Head lifting timeout"))); // 机头升降超时 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_NOT_AT_POS,tr("Template not in place"))); // 模版不到位 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_EXPIRATION,tr("The usage deadline has expired"))); // 使用时限已到 + m_allErrorCodeAndStateList.append(makeAErrorStateItem(ERR_IN_PARA,tr("Input parameter error"))); // 输入参数错误 + +} diff --git a/mctype/patternsingleboard/function/fiveheadprecisionsewing.h b/mctype/patternsingleboard/function/fiveheadprecisionsewing.h new file mode 100644 index 0000000..0847a9b --- /dev/null +++ b/mctype/patternsingleboard/function/fiveheadprecisionsewing.h @@ -0,0 +1,227 @@ +#ifndef FIVEHEADPRECISIONSEWING_H +#define FIVEHEADPRECISIONSEWING_H + +#include "mctype/machinetypefun.h" + +//-------------------------------------------------------------------------------- +// 通讯命令定义 + +//-------------------------------------------------- +// 归零和手动移动和电机使能的 控制参数 定义 + +// A板 +#define MT_HX 0x0003 // 机头移动电机 (归零) + +#define MT_LM1 0x0010 // 主轴1电机 (归零,正转,反转) +#define MT_LN1 0x0011 // 针1电机 (归零,正转,反转) +#define MT_LH1 0x0012 // 梭1电机 (归零,正转,反转) + +#define MT_LM2 0x0020 // 主轴2电机 (归零,正转,反转) +#define MT_LN2 0x0021 // 针2电机 (归零,正转,反转) +#define MT_LH2 0x0022 // 梭2电机 (归零,正转,反转) + +#define MT_LM3 0x0030 // 主轴3电机 (归零,正转,反转) +#define MT_LN3 0x0031 // 针3电机 (归零,正转,反转) +#define MT_LH3 0x0032 // 梭3电机 (归零,正转,反转) + +#define MT_LM4 0x0040 // 主轴4电机 (归零,正转,反转) +#define MT_LN4 0x0041 // 针4电机 (归零,正转,反转) +#define MT_LH4 0x0042 // 梭4电机 (归零,正转,反转) + +#define MT_LM5 0x0050 // 主轴5电机 (归零,正转,反转) +#define MT_LN5 0x0051 // 针5电机 (归零,正转,反转) +#define MT_LH5 0x0052 // 梭5电机 (归零,正转,反转) + +//-------------------------------------------------- + +// 输出控制的 控制参数1 定义 + +#define OT_LOOSE_THREAD1 0x0001 // 机头1 松紧线 (放松,夹紧) +#define OT_LOOSE_THREAD2 0x0002 // 机头2 松紧线 +#define OT_LOOSE_THREAD3 0x0003 // 机头3 松紧线 +#define OT_LOOSE_THREAD4 0x0004 // 机头4 松紧线 +#define OT_LOOSE_THREAD5 0x0005 // 机头5 松紧线 + +#define ThreadCuttingAction1 0x0011 // 机头1 剪线动作 (使能) +#define ThreadCuttingAction2 0x0012 // 机头2 剪线动作 +#define ThreadCuttingAction3 0x0013 // 机头3 剪线动作 +#define ThreadCuttingAction4 0x0014 // 机头4 剪线动作 +#define ThreadCuttingAction5 0x0015 // 机头5 剪线动作 + +#define OT_BLOW1 0x0021 // 机头1 吹气 (打开,关闭) +#define OT_BLOW2 0x0022 // 机头2 吹气 +#define OT_BLOW3 0x0023 // 机头3 吹气 +#define OT_BLOW4 0x0024 // 机头4 吹气 +#define OT_BLOW5 0x0025 // 机头5 吹气 + +#define OT_DCUT_THREAD1 0x0031 // 机头1 剪线 (打开,关闭) +#define OT_DCUT_THREAD2 0x0032 // 机头2 剪线 +#define OT_DCUT_THREAD3 0x0033 // 机头3 剪线 +#define OT_DCUT_THREAD4 0x0034 // 机头4 剪线 +#define OT_DCUT_THREAD5 0x0035 // 机头5 剪线 + +#define OT_ADD_NOIL1 0x0041 // 机头1 针加油 (打开,关闭) +#define OT_ADD_NOIL2 0x0042 // 机头2 针加油 +#define OT_ADD_NOIL3 0x0043 // 机头3 针加油 +#define OT_ADD_NOIL4 0x0044 // 机头4 针加油 +#define OT_ADD_NOIL5 0x0045 // 机头5 针加油 + +#define OT_ADD_HOIL1 0x0051 // 机头1 梭加油 (打开,关闭) +#define OT_ADD_HOIL2 0x0052 // 机头2 梭加油 +#define OT_ADD_HOIL3 0x0053 // 机头3 梭加油 +#define OT_ADD_HOIL4 0x0054 // 机头4 梭加油 +#define OT_ADD_HOIL5 0x0055 // 机头5 梭加油 + +#define OT_LIFT_UP1 0x0061 // 机头1 升降 (上升,下降) +#define OT_LIFT_UP2 0x0062 // 机头2 升降 +#define OT_LIFT_UP3 0x0063 // 机头3 升降 +#define OT_LIFT_UP4 0x0064 // 机头4 升降 +#define OT_LIFT_UP5 0x0065 // 机头5 升降 + +#define OT_LOCK_FRM_CTRL 0x0070 // 锁框气缸 (打开,关闭) +#define OT_FLAP_UP 0x0071 // 翻板控制 (上升,下降) +#define OT_SCAN_CODE 0x0073 // 条码测试 (打开) + +#define OT_CLIP1 0x0081 // 机头1 夹线 (打开,关闭) +#define OT_CLIP2 0x0082 // 机头2 夹线 +#define OT_CLIP3 0x0083 // 机头3 夹线 +#define OT_CLIP4 0x0084 // 机头4 夹线 +#define OT_CLIP5 0x0085 // 机头5 夹线 + +// 标准绗缝机型专用报警 +#define ERRQUI_NONE 0x00010000 // 没有错误 +#define ERRQUI_NO_POWER 0x00010001 // 没有上电 +#define ERRQUI_NO_AIR 0x00010002 // 气压不足 +#define ERRQUI_NOT_SAFE 0x00010003 // 安全区域介入 +#define ERRQUI_EXPIRATION 0x00010004 // 使用时限已到 +#define ERRQUI_DRIVER 0x00010005 // 驱动器报警 +#define ERRQUI_FILL_DATA 0x00010006 // 填充数据错误 +#define ERRQUI_NOT_ALLOWED 0x00010007 // 不允许工作状态 +#define ERRQUI_CTRL_ERR 0x00010008 // 控制错误 +#define ERRQUI_FPGA_ERR 0x00010009 // 运动控制芯片版本错误 +#define ERRQUI_BUTTON_NOUP 0x0001000A // 等待按钮抬起超时 +#define ERRQUI_FPGA_RESET 0x0001000B // FPGA复位错误 +#define ERRQUI_NO_READY 0x0001000C // 外设未就绪 +#define ERRQUI_NO_SEND_ERR 0x0001000D // 传输数据错误 +#define ERRQUI_EDTION_ERR 0x0001000E // 程序版本错误 +#define ERRQUI_WORK_DONE 0x0001000F // 完成产量 + +#define ERRQUI_LMT_POSITIVE 0x00010010 // 正向限位 +#define ERRQUI_LMT_NEGATIVE 0x00010011 // 反向限位 +#define ERRQUI_RUN_ALM 0x00010012 // 运动报警 +#define ERRQUI_RUN_LIMIT 0x00010013 // 运动限位 +#define ERRQUI_RUN_EMS 0x00010014 // 运动急停 +#define ERRQUI_MV_PARA 0x00010015 // 运动参数错误 +#define ERRQUI_MC_PARA 0x00010016 // 机器参数错误 +#define ERRQUI_IN_PARA 0x00010017 // 输入参数错误 +#define ERRQUI_CUTTER_NORMAL 0x00010018 // 文件正确 +#define ERRQUI_CUTTER_WAIT 0x00010019 // 等待文件 + + +#define ERRQUI_MTZ_RIGHT 0x0001001F // 归零成功 +#define ERRQUI_MTZ_ERROR 0x00010020 // 归零错误 +#define ERRQUI_COOR_SYSTM 0x00010021 // 坐标系统错误 +#define ERRQUI_OUT_RANGE 0x00010022 // 目标位置越界 +#define ERRQUI_X_LIT_POSI 0x00010023 // X正向限位 +#define ERRQUI_X_LIT_NEGA 0x00010024 // X反向限位 +#define ERRQUI_Y_LIT_POSI 0x00010025 // Y正向限位 +#define ERRQUI_Y_LIT_NEGA 0x00010026 // Y反向限位 + +#define ERRQUI_NO_DATA 0x00010040 // 无数据 +#define ERRQUI_DATA_ERROR 0x00010041 // 数据错误 + + +#define ERRQUI_MS_NOT_ZERO 0x00010050 // 主轴不在零位 +#define ERRQUI_HK_NOT_ZERO 0x00010051 // 旋梭不在零位 +#define ERRQUI_MS_NOT_SYNC 0x00010052 // 针梭不同步 +#define ERRQUI_RO_NOT_SYNC 0x00010053 // 旋转不同步 +#define ERRQUI_CUTTER_NOT_POS 0x00010054 // 剪刀不在回位(注:该报错码是缝纫剪刀) +#define ERRQUI_HEAD_NOT_HIGH 0x00010055 // 机头不在高位 +#define ERRQUI_HEAD_NOT_LOW 0x00010056 // 机头不在低位 +#define ERRQUI_LIGHTCURTAINS 0x00010057 // 光幕介入 +#define ERRQUI_UPER_TBREAK 0x00010058 // 面线断线 +#define ERRQUI_BOBBIN_TBREAK 0x00010059 // 底线断线 +#define ERRQUI_LIFT_TIMEOUT 0x0001005F // 机头升降超时 +#define ERRQUI_CHANGE_BOBBIN 0x000100F0 // 更换梭芯 + +#define ERRQUI_FEED_ROLLER 0x00010200 // 进料压辊 异常 +#define ERRQUI_DIS_ROLLER 0x00010201 // 出料压辊 异常 +#define ERRQUI_DIS_MATERIAL 0x00010202 // 出料压料 异常 +#define ERRQUI_TENS_DEVICE 0x00010203 // 张紧装置 异常 +#define ERRQUI_CLOTH_DEVICE 0x00010204 // 夹布装置 异常 +#define ERRQUI_EDGE_MOTOR 0x00010205 // 边切电机 阻塞 +#define ERRQUI_CROSS_MOTOR 0x00010206 // 横切电机 异常 + + +#define ERRQUI_INSTALLMENT_OK 0x00010300 // 密码设置成功 +#define ERRQUI_INSTALLMENT_FAIL 0x00010301 // 密码设置失败 + +#define ERRQUI_MOTO_N_ALM 0x00011001 // 针电机报警 +#define ERRQUI_MOTO_H_ALM 0x00011002 // 梭电机报警 +#define ERRQUI_MOTO_X_ALM 0x00011003 // X电机报警 +#define ERRQUI_MOTO_Y_ALM 0x00011004 // Y电机报警 + +#define ERRQUI_MOTO_N_FZ 0x00011011 // 针电机归零失败 +#define ERRQUI_MOTO_H_FZ 0x00011012 // 梭电机归零失败 +#define ERRQUI_MOTO_X_FZ 0x00011013 // X电机归零失败 +#define ERRQUI_MOTO_Y_FZ 0x00011014 // Y电机归零失败 + +#define ERRQUI_CS_TIMEOUT 0x00012000 // 从板通讯超时 +#define ERRQUI_MOTO_X_ZERO 0x00012001 // X电机不在零位 + +#define ERR_HEAD_NOT_HIGH 0x0055 // 机头不在高位 +#define ERR_X_LIT_POSI 0x0023 // X正向限位 +#define ERR_X_LIT_NEGA 0x0024 // X反向限位 +#define ERR_Y_LIT_POSI 0x0025 // Y正向限位 +#define ERR_Y_LIT_NEGA 0x0026 // Y反向限位 +#define ERR_COOR_SYSTM 0x0021 // 坐标系统错误 +#define ERR_OUT_RANGE 0x0022 // 目标位置越界 +#define ERR_NOT_SAFE 0x0003 // 安全区域介入 +#define ERR_AIR_POWER 0x002E // 气压不足 +#define ERR_GUARDRAIL_OPEN 0x0039 // 安全门未关闭 +#define ERR_UPER_TBREAK 0x0058 // 面线断线 +#define ERR_CHANGE_BOBBIN 0x00F0 // 更换梭芯 +#define ERR_MS_NOT_ZERO 0x0050 // 主轴不在零位 +#define ERR_HK_NOT_ZERO 0x0051 // 旋梭不在零位 +#define ERR_NO_DATA 0x0040 // 无数据 +#define ERR_MC_PARA 0x0016 // 机器参数错误 +#define ERR_MV_PARA 0x0015 // 运动参数错误 +#define ERR_HEAD_NOT_SAFE 0x0060 // 机头不在安全区域 +#define ERR_NOT_ALLOWED 0x0007 // 不允许工作状态 +#define ERR_LIFT_TIMEOUT 0x005F // 机头升降超时 +#define ERR_NOT_AT_POS 0x005E // 模版不到位 +#define ERR_EXPIRATION 0x0004 // 使用时限已到 +#define ERR_IN_PARA 0x0017 // 输入参数错误 + + +//五头精密缝 +class FiveHeadPrecisionSewing : public MachineTypeFun +{ + Q_OBJECT +public: + FiveHeadPrecisionSewing(); + ~FiveHeadPrecisionSewing(); +public: + void initNinebtn1234(); + void initFileInfoLabel(); + +private: + void initRootParasList();//超级用户参数(包括机器参数、工作参数) + void initPatternsParasList();//花样参数 + void initMcParasList();//主控机器参数 + void initWkParasList();//主控工作参数 + +private: + void initOutCtrlList();//控制动作 + void initShortCutList();//快捷动作 + void initAssistList();//辅助功能 + void initPatternSetList();//花样设置 + void initParaSetList();//参数设置 + +private: + void initSensorList();//初始化传感器列表 + void initErrorCodeAndStateList();//初始化错误代码和状态列表 + +}; + +#endif // FIVEHEADPRECISIONSEWING_H diff --git a/mctype/patternsingleboard/function/highsinglequilting.cpp b/mctype/patternsingleboard/function/highsinglequilting.cpp new file mode 100644 index 0000000..e8a9c6e --- /dev/null +++ b/mctype/patternsingleboard/function/highsinglequilting.cpp @@ -0,0 +1,1375 @@ +#include "highsinglequilting.h" + +// 高速单针绗缝机 +HighSingleQui::HighSingleQui() +{ + //添加各种参数到列表中 + initRootParasList(); + initRootHMIConfigurationList(m_allParasList);//超级用户界面配置 + initPatternsParasList(); + initSoftwareParasList(m_allParasList); + initTimeParasList(m_allParasList); + initMcParasList(); + initWkParasList(); + + //初始化控制动作列表 + initOutCtrlList(); + + //初始化快捷功能列表 + initShortCutList(); + + //初始化辅助功能列表 + initAssistList(); + + //初始化花样设置功能列表 + initPatternSetList(); + + //参数分类功能 + initParaSetList(); + + //初始化传感器列表 + initSensorList(); + + //初始化错误代码和状态列表 + initErrorCodeAndStateList(); + + //初始化九宫格 + initNinebtn1234(); + + //加载右上角信息 + initFileInfoLabel(); +} + +HighSingleQui::~HighSingleQui() +{ + +} + +//初始化九宫格功能按键 +void HighSingleQui::initNinebtn1234() +{ + m_nineBtn.insert(1,NineItem(FUN_HEAD_LIFTING,"buttonHeadLifting")); + m_nineBtn.insert(2,NineItem(FUN_MANUAL_THREAD_CUTTING,"buttonMunualThreadCutting")); + m_nineBtn.insert(3,NineItem(FUN_PROCESSRESET,"buttonProcessReset")); + m_nineBtn.insert(4,NineItem(FUN_SIMULATED_STATUS,"buttonSimulatedStatus")); + +} + +void HighSingleQui::initFileInfoLabel() +{ + m_fileInfo.append(FileName); + m_fileInfo.append(Index); + m_fileInfo.append(BeginPoint); + m_fileInfo.append(Range); + m_fileInfo.append(Position); + m_fileInfo.append(Production); +} + +//超级用户参数(包括机器参数、工作参数) +void HighSingleQui::initRootParasList() +{ + //超级用户参数--------------------------- + //超级用户参数-界面配置;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_HMICONFIGURATION, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("HMI Configuration"),//界面配置 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0000 , factory)); + + //超级用户参数-界面进入调试模式;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_DEBUGMODE, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Interface debug mode"),//界面进入调试模式 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001 , root)); + + //超级用户参数-删除config.ini配置文件;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_DELETEINI, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Delete configure file"),//删除配置文件 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001 , root)); + + //超级用户参数-机器参数;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_MACHINEPARA, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Machine parameters"),//机器参数 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0002, factory)); + + //超级用户参数-工作参数;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_WORKPARA, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Work parameters"),//工作参数 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0003, factory)); +} + +//花样参数 +void HighSingleQui::initPatternsParasList() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + int index = 0; //按顺序排列,想要更改顺序只需要修改代码位置 + //花样参数-花样设置参数-左边;单位:毫米 ,范围0-10000,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_SETLEFT, 0, 0, PARA_VALUE_TYPE_INT, + tr("Left"),//左边 + 0, 0, 10000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); + + //花样参数-花样设置参数-前边;单位:毫米 ,范围0-10000,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_SETFRONT, 0, 0, PARA_VALUE_TYPE_INT, + tr("Front"),//前边 + 0, 0, 10000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); + + //花样参数-花样设置参数-缩放x;单位:毫米 ,范围0-20000,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_SCANX, 0, 0, PARA_VALUE_TYPE_INT, + tr("Width"),//宽度 + 5000, 0, 20000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); + + //花样参数-花样设置参数-缩放y;单位:毫米 ,范围0-20000,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_SCANY, 0, 0, PARA_VALUE_TYPE_INT, + tr("Height"),//高度 + 5000, 0, 20000, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); + + //花样参数-花样设置参数-等比缩放 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_QUI, + SET_EQUAL, 0, 0, PARA_VALUE_TYPE_SW, + tr("Equal ratio"),//等比缩放 + 1, 0, 1, 1, 0, tr(""), tr(""), + tr(""), + 0, 0, index++, operate)); + + //花样参数-花样设置参数-翻转式样;单位:无 ,范围0-7,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_ROTATESTYLE, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Flip style"),//翻转式样 + 0, 0, 7, 0, 0, tr(""), tr(""), + tr("normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7"), + 0, 0, index++, operate)); + + //花样参数-花样设置参数-旋转角度;单位:° ,范围0-90,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_ROTATEANGLE, 0, 0, PARA_VALUE_TYPE_INT, + tr("Rotation angle"),//旋转角度 + 0, 0, 90, 0, 0, cod->toUnicode("°"), tr(""),//度 + tr(""), 0, 0,index++, operate)); + + //花样参数-花样设置参数-针步大小;单位:毫米 ,范围20-80,默认20 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_SETSTEPSIZE, 0, 0, PARA_VALUE_TYPE_INT, + tr("Step size"),//针步大小 + 20, 20, 80, 20, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); + + //绣花机-花样参数-花样设置参数-加固方式;单位:无 ,范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_REINMODE, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Reinforcement method"),//加固方式 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Tight locking:0;Reinforced locking:1"),//密针锁针:0;加固锁针:1 + 0, 0,index++, operate)); + + //绣花机-花样参数-花样设置参数-加固针数;单位:针 ,范围0-10,默认2 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_REINNEEDLE, 0, 0, PARA_VALUE_TYPE_INT, + tr("Reinforcement needles"),//加固针数 + 2, 0, 10, 2, 0, tr("pin"), tr(""),//针 + tr(""), 0, 0,index++, operate)); + + //绣花机-花样参数-花样设置参数-加固次数;单位:次 ,范围0-10,默认2 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_REINNUM, 0, 0, PARA_VALUE_TYPE_INT, + tr("Reinforcement frequency"),//加固次数 + 2, 0, 10, 2, 0, tr(""), tr(""), + tr(""), 0, 0,index++, operate)); + +#if(0) + //花样参数-花样设置参数-角度修正量;单位:毫米 ,范围0-200,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_ANGLECORROFFSET, 0, 0, PARA_VALUE_TYPE_INT, + tr("Angle correction offset"),//角度修正量 + 0, 0, 200, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); +#else + //花样参数-花样设置参数-角度修正x正;单位:毫米 ,范围0-200,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_ANGLECORRPOSX, 0, 0, PARA_VALUE_TYPE_INT, + tr("Angle correction x positive"),//角度修正x正 + 0, 0, 200, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); + + //花样参数-花样设置参数-角度修正x负;单位:毫米 ,范围0-200,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_ANGLECORRNEGX, 0, 0, PARA_VALUE_TYPE_INT, + tr("Angle correction x negative"),//角度修正x负 + 0, 0, 200, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); + + //花样参数-花样设置参数-角度修正y正;单位:毫米 ,范围0-200,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_ANGLECORRPOSY, 0, 0, PARA_VALUE_TYPE_INT, + tr("Angle correction y positive"),//角度修正y正 + 0, 0, 200, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); + + //花样参数-花样设置参数-角度修正y负;单位:毫米 ,范围0-200,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR | PATTERNPARA_SORT_QUI, + SET_ANGLECORRNEGY, 0, 0, PARA_VALUE_TYPE_INT, + tr("Angle correction y negative"),//角度修正y负 + 0, 0, 200, 0, 1, tr("mm"), tr(""), + tr(""), + 0, 0, index++, operate)); +#endif + + + //花样参数--------------------------- +} + +//机器参数 +void HighSingleQui::initMcParasList() +{ + // QTextCodec *cod = QTextCodec::codecForLocale(); + + + //自动换梭装置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 0, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Automatic shuttle changing device"),//自动换梭装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("No:0;Have:1"), + 0, 0, 0x0001, operate)); + + //安全装置配置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 1, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Infrared device"),//红外装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Normally closed:0;Normally open:1"), + 0, 0, 0x0002, operate)); + + //气压装置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 1, 2, 0, PARA_VALUE_TYPE_LIST, + tr("Pneumatic device"),//气压装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Normally closed:0;Normally open:1"), + 0, 0, 0x0002, operate)); + + //上电装置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 1, 3, 0, PARA_VALUE_TYPE_LIST, + tr("Power-on device"),//上电装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Normally closed:0;Normally open:1"), + 0, 0, 0x0002, operate)); + + //安全门装置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 1, 5, 0, PARA_VALUE_TYPE_LIST, + tr("Safety door device"),//安全门装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Normally closed:0;Normally open:1"), + 0, 0, 0x0002, operate)); + + //手自动按钮装置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 1, 6, 0, PARA_VALUE_TYPE_LIST, + tr("Manual and automatic button device"),//手自动按钮装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Normally closed:0;Normally open:1"), + 0, 0, 0x0002, operate)); + + //X可移动区域正边界, 范围S32_MIN--S32_MAX,默认207500 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 2, 0, 0, PARA_VALUE_TYPE_INT, + tr("X movable area positive boundary"),//X可移动区域正边界 + 207500, S32_MIN, S32_MAX, 207500, 2, tr("mm"), tr(""), + tr(""), + 207500, 207500, 0x0004, operate)); + + //Y可移动区域正边界, 范围S32_MIN--S32_MAX,默认99300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 3, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y movable area positive boundary"),//Y可移动区域正边界 + 99300, S32_MIN, S32_MAX, 99300, 2, tr("mm"), tr(""), + tr(""), + 99300, 99300, 0x0006, operate)); + + //x可缝纫区域负边界, 范围S32_MIN--S32_MAX,默认6800 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 4, 0, 0, PARA_VALUE_TYPE_INT, + tr("X Sewing area Negative boundary"),//x可缝纫区域负边界 + 6800, S32_MIN, S32_MAX, 6800, 2, tr("mm"), tr(""), + tr(""), + 6800, 6800, 0x0007, operate)); + + //x可缝纫区域正边界, 范围S32_MIN--S32_MAX,默认128800 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 5, 0, 0, PARA_VALUE_TYPE_INT, + tr("X Sewing area Positive margin"),//x可缝纫区域正边界 + 128800, S32_MIN, S32_MAX, 128800, 2, tr("mm"), tr(""), + tr(""), + 128800, 128800, 0x0008, operate)); + + //y可缝纫区域负边界, 范围S32_MIN--S32_MAX,默认20300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 6, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y Sewing area Negative boundary"),//y可缝纫区域负边界 + 20300, S32_MIN, S32_MAX, 20300, 2, tr("mm"), tr(""), + tr(""), + 20300, 20300, 0x0009, operate)); + + //y可缝纫区域正边界, 范围S32_MIN--S32_MAX,默认99300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 7, 0, 0, PARA_VALUE_TYPE_INT, + tr("Y Sewing area Positive margin"),//y可缝纫区域正边界 + 99300, S32_MIN, S32_MAX, 99300, 2, tr("mm"), tr(""), + tr(""), + 99300, 99300, 0x0010, operate)); + + + //进料编码器系数分子, 范围S32_MIN--S32_MAX,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 8, 0, 0, PARA_VALUE_TYPE_INT, + tr("Encoder coefficient molecule"),//进料编码器系数分子 + 0, S32_MIN, S32_MAX, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0011, operate)); + + // //进料编码器系数分母, 范围S32_MIN--S32_MAX,默认0 + // m_allParasList.append(makeAParaItem(0, + // PARA_TYPE_MACH, + // MC_SORT_SETTING, + // 205, 0, 0, PARA_VALUE_TYPE_INT, + // tr("Encoder coefficient denominator"),//进料编码器系数分母 + // 0, S32_MIN, S32_MAX, 0, 0, tr(""), tr(""), + // tr(""), + // 0, 0, 0x00C3, operate)); + + + + //零切距离, 范围S32_MIN--S32_MAX,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 9, 0, 0, PARA_VALUE_TYPE_INT, + tr("Zero tangent distance"),//零切距离 + 0, S32_MIN, S32_MAX, 0, 0, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0012, operate)); + //切料箱装置选择, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 10, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Feeding device"),//进料装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("No:0;Have:1"), + 0, 0, 0x0013, operate)); + + //横切装置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 10, 2, 0, PARA_VALUE_TYPE_LIST, + tr("Crosscutting device"),//横切装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("No:0;Have:1"), + 0, 0, 0x0013, operate)); + + //夹布装置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 10, 3, 0, PARA_VALUE_TYPE_LIST, + tr("Cloth clamping device"),//夹布装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("No:0;Have:1"), + 0, 0, 0x0013, operate)); + + //张紧装置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 10, 4, 0, PARA_VALUE_TYPE_LIST, + tr("Tensioning device"),//张紧装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("No:0;Have:1"), + 0, 0, 0x0013, operate)); + + //边切装置, 范围0-1,默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_MACH, + MC_SORT_SETTING, + 10, 5, 0, PARA_VALUE_TYPE_LIST, + tr("Edge cutting device"),//边切装置 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("No:0;Have:1"), + 0, 0, 0x0013, operate)); + +} + +//工作参数 +void HighSingleQui::initWkParasList() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + + // 主轴缝纫工作转速, 范围 1--3000,单位r/min,默认2000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 0, 0, 0, PARA_VALUE_TYPE_INT, + tr("sewing work speed"),// 主轴缝纫工作转速 + 2000, 1, 3000, 2000, 0, tr("r/min"), tr(""), + tr(""), 0, 0, 0x0100, operate)); + + // 主轴回针转速, 范围 1--500,单位r/min,默认 200 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 1, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle Back needle speed"),// 主轴回针转速 + 200, 1, 500, 200, 0, tr("r/min"), tr(""), + tr(""), 0, 0, 0x0101, operate)); + + // 缝纫动框方式, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 2, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Sewing moving frame"),// 缝纫动框方式 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Continuous:0;Intermittent:1"), 0, 0, 0x0102, operate));//连续:0;间歇式:1 + + // 缝纫加减速方式, 范围 0--1,默认 1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 2, 2, 0, PARA_VALUE_TYPE_LIST, + tr("Sewing acceleration and deceleration mode"),// 缝纫加减速方式 + 1, 0, 1, 1, 0, tr(""), tr(""), + tr("No acceleration or deceleration:0;Xy sine acceleration and deceleration:1"), //无加速或减速:0;Xy正弦加速度和减速度:1 + 1, 1, 0x0102, operate)); + + // 缝纫机头旋转方式, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 2, 3, 0, PARA_VALUE_TYPE_LIST, + tr("Sewing machine head rotating manner"),// 缝纫机头旋转方式 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Continuous rotation:0;Xy intermittent rotation:1"),//连续旋转:0;Xy间歇旋转:1 + 0, 0, 0x0102, operate)); + + // 缝纫机头加减速方式, 范围 0--1,默认 1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 2, 4, 0, PARA_VALUE_TYPE_LIST, + tr("Sewing head deceleration mode"),// 缝纫机头加减速方式 + 1, 0, 1, 1, 0, tr(""), tr(""), + tr("No acceleration or deceleration:0;Intermittent acceleration and deceleration:1"), //无加速或减速:0;间歇加减速:1 + 1, 1, 0x0102, operate));//无加速或减速:0;间歇加减速:1 + + // 起针动作允许; 位图选择, 0, 不允许; 1, 允许; + // bit0, 松线允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 3, 1, 0, PARA_VALUE_TYPE_SW, + tr("Allow for needle starting and thread loosening"),// 起针松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0102, operate)); + // bit1, 夹线允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 3, 2, 0, PARA_VALUE_TYPE_SW, + tr("Needle and thread clamping allowed"),// 起针夹线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0102, operate)); + + // 剪线允许, 范围 0--3,默认 1 + // 剪线允许; 0, 不剪线; 1, 自动剪线; 2, 最后剪线;3,数据剪线;默认1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 4, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Cut lines allow"),// 剪线允许 + 1, 0, 3, 1, 0, tr(""), tr(""), + tr("Do not trim:0;Automatic thread trim:1;Finally trim:2;Data trim:3"),//不剪线:0;自动剪线:1;最后剪线:2;数据剪线:3 + 1, 1, 0x0104, operate)); + // bit0, 松线允许; + // 剪线时松线允许, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 1, 0, PARA_VALUE_TYPE_SW, + tr("Thread loosening is allowed during thread cutting"),// 剪线时松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0105, operate)); + // bit1, 拉线允许; + // 剪线时拉线允许, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 2, 0, PARA_VALUE_TYPE_SW, + tr("During thread cutting, the stay wire is allowed"),// 剪线时拉线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0105, operate)); + // bit2, 夹线允许; + // 剪线时夹线允许, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 3, 0, PARA_VALUE_TYPE_SW, + tr("Thread clamping is allowed during thread cutting"),// 剪线时夹线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0105, operate)); + // bit3, 提升压脚允许; + // 剪线时提升压脚允许, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 4, 0, PARA_VALUE_TYPE_SW, + tr("It is allowed to lift the presser foot during thread trimming"),// 剪线时提升压脚允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0105, operate)); + // bit4, 提升机头剪线; + // 剪线时提升机头剪线允许, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 5, 0, PARA_VALUE_TYPE_SW, + tr("Lifting machine head thread cutting is allowed during thread cutting"),// 剪线时提升机头剪线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0105, operate)); + // bit5, 提升机头夹线;0:允许 1:不允许 + // 剪线时提升机头夹线允许, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 6, 0, PARA_VALUE_TYPE_SW, + tr("The thread clamping of the lifting head is allowed during thread cutting"),// 剪线时提升机头夹线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0105, operate)); + // bit6, 在压脚下勾线;0:允许 1:不允许 + // 剪线时在压脚下勾线允许, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 7, 0, PARA_VALUE_TYPE_SW, + tr("It is allowed to hook the thread at the foot of the presser during thread cutting"),// 剪线时在压脚下勾线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0105, operate)); + + // bit7, 退针允许;0:允许 1:不允许 + // 剪线时退针允许, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 8, 0, PARA_VALUE_TYPE_LIST, + tr("Needle withdrawal allowed during thread trimming"),// 剪线时退针允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0105, operate)); + // bit8, 扣线允许;0:允许 1:不允许 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 5, 9, 0, PARA_VALUE_TYPE_LIST, + tr("Buckle the thread allowed during thread trimming"),// 剪线时扣线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0105, operate)); + + + // 断线检测针数, 范围 0--10,默认 3 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 6, 0, 0, PARA_VALUE_TYPE_INT, + tr("Number of broken wires"),// 断线检测针数 + 3, 0, 10, 3, 0, tr("Needles"), tr(""),//针 + tr(""), 0, 0, 0x0106, operate)); + + // 换梭芯提醒功能, 范围 0--3,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 7, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Change bobbin Reminder function"),// 换梭芯提醒功能 + 0, 0, 3, 0, 0, tr(""), tr(""), //未启用:0;按长度划分的延迟提醒:1;按切片数计数:2;按长度立即提醒:3 + tr("Not:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3"), 0, 0, 0x0107, operate)); + + // 底线长度, 范围 0--S32_MAX,默认 10000000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 8, 0, 0, PARA_VALUE_TYPE_INT, + tr("Bottom line length"),// 底线长度 + 10000000, 0, S32_MAX, 10000000, 2, tr("mm"), tr(""), + tr(""), 0, 0, 0x0108, operate)); + + // 换梭片数计数, 范围 0--1000,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 9, 0, 0, PARA_VALUE_TYPE_INT, + tr("Number of shuttles"),// 换梭片数计数 + 0, 0, 1000, 0, 0, tr("times"), tr(""), + tr(""), 0, 0, 0x0109, operate)); + + // 加油方式选择, 范围 0--3,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 10, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Refueling method selection"),// 加油方式选择 + 0, 0, 3, 0, 0, tr(""), tr(""),//不加油:0;按工作时间间断加油:1;按工作针数间歇加油:2;持续加油:3 + tr("No:0; According to working hours:1; According to the number of working stitches:2; Persistent refueling:3"), 0, 0, 0x010A, operate)); + + // 加油针数间隔, 范围 S32_MIN--S32_MAX,默认 10000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 11, 0, 0, PARA_VALUE_TYPE_INT, + tr("Refueling needles interval"),// 加油针数间隔 + 10000, S32_MIN, S32_MAX, 10000, 0, tr("Needles"), tr(""), + tr(""), 0, 0, 0x010B, operate)); + + // // 加油时间间隔, 范围 1--S32_MAX,默认 1 + // m_allParasList.append(makeAParaItem(0, + // PARA_TYPE_WORK, + // MC_SORT_ACTION, + // 12, 0, 0, PARA_VALUE_TYPE_INT, + // tr("Refueling time interval"),// 加油时间间隔 + // 1, 1, S32_MAX, 1, 0, tr("s"), tr(""), + // tr(""), 0, 0, 0x010C, operate)); + + // 加油持续时长, 范围 1--S32_MAX,默认 1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 13, 0, 0, PARA_VALUE_TYPE_INT, + tr("Refueling duration"),// 加油持续时长 + 1, 1, S32_MAX, 1, 0, tr("s"), tr(""), + tr(""), 1, 1, 0x010D, operate)); + + // 完成后停车位置选择, 范围 0--4,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 14, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Parking position selection after completion"),// 完成后停车位置选择 + 0, 0, 4, 0, 0, tr(""), tr(""), + tr("Current:0;Starting:1;Anchor:2;Feeding:3;Offset:4"),//当前点:0;起始点:1;定位点:2;上料点:3;偏移点:4 + 0, 0, 0x010E, operate)); + + // 偏移点坐标有效标志, 范围 0--3,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 15, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Offset point coordinate valid flag"),// 偏移点坐标有效标志 + 0, 0, 3, 0, 0, tr(""), tr(""), + tr("Invalid:0;X is valid:1;Y is valid:2;XY is valid:3"),//无效:0;X有效:1;Y有效:2;XY同时有效:3 + 0, 0, 0x010F, operate)); + + // 偏移点坐标X, 范围 S32_MIN--S32_MAX,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 16, 0, 0, PARA_VALUE_TYPE_INT, + tr("Offset point coordinate X"),// 偏移点坐标X + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), 0, 0, 0x0110, operate)); + + // 偏移点坐标Y, 范围 S32_MIN--S32_MAX,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 17, 0, 0, PARA_VALUE_TYPE_INT, + tr("Offset point coordinate Y"),// 偏移点坐标Y + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), 0, 0, 0x0111, operate)); + + // 穿线点坐标有效标志, 范围 0--3,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 18, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Threading point coordinate effective mark"),// 穿线点坐标有效标志 + 0, 0, 3, 0, 0, tr(""), tr(""), + tr("Invalid:0;X is valid:1;Y is valid:2;XY is valid:3"),//无效:0;X有效:1;Y有效:2;XY同时有效:3 + 0, 0, 0x0112, operate)); + + // 穿线点坐标X, 范围 S32_MIN--S32_MAX,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 19, 0, 0, PARA_VALUE_TYPE_INT, + tr("Threading point coordinates X"),// 穿线点坐标X + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), 0, 0, 0x0113, operate)); + + // 穿线点坐标 Y, 范围 S32_MIN--S32_MAX,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_POSITION, + 20, 0, 0, PARA_VALUE_TYPE_INT, + tr("Threading point coordinates Y"),// 穿线点坐标Y + 0, S32_MIN, S32_MAX, 0, 2, tr("mm"), tr(""), + tr(""), 0, 0, 0x0114, operate)); + + // 产量预设, 范围 0--S32_MAX,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 21, 0, 0, PARA_VALUE_TYPE_INT, + tr("Production preset"),// 产量预设 + 0, 0, S32_MAX, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0115, operate)); + + // 剪线动框位移, 范围 1--1000,默认 500 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 22, 0, 0, PARA_VALUE_TYPE_INT, + tr("Trimming frame displacement"),// 剪线动框位移 + 500, 1, 1000, 500, 2, tr("mm"), tr(""), + tr(""), 0, 0, 0x0116, operate)); + + // 缝纫时自动回穿线点允许, 范围 0--1,默认 0 + // bit1 自动回穿线点允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 23, 2, 0, PARA_VALUE_TYPE_SW, + tr("Automatic threading back point is allowed during sewing"),// 缝纫时自动回穿线点允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0117, operate)); + + // 缝纫间越框机头升降, 范围 0--max,默认 0 + // bit1, 缝纫间越框机头升降; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 24, 2, 0, PARA_VALUE_TYPE_SW, + tr("Lifting and lowering of frame crossing machine head in sewing room"),// 缝纫间越框机头升降 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0117, operate)); + + // 移框时动作选择, 范围 0--1,默认 0 + // bit0, 松线允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 25, 1, 0, PARA_VALUE_TYPE_SW, + tr("Moving basket Loose line"),// 移框松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0117, operate)); + + // 移框夹线允许, 范围 0--1,默认 0 + // bit1, 夹线允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 25, 2, 0, PARA_VALUE_TYPE_SW, + tr("Moving basket Clamp line"),// 移框夹线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0117, operate)); + + // 移框自动压框允许, 范围 0--1,默认 0 + // bit2, 开框允许 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 25, 3, 0, PARA_VALUE_TYPE_SW, + tr("Frame moving and automatic frame pressing allowed"),// 移框自动压框允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0117, operate)); + + // 移框扣线允许, 范围 0--1,默认 0 + // bit4. 叩线允许 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 25, 5, 0, PARA_VALUE_TYPE_SW, + tr("Allowed to move frame and thread"),// 移框扣线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0117, operate)); + + // 软件限位XY移动允许, 范围 0--1,默认 0 + // bit0, xy移动; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 26, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Software limit XY move allowed"),// 软件限位XY移动允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;Allowed:1"), 0, 0, 0x011C, operate)); + + // 剪线动框方向, 0, 不动框; 1, 向左; 2, 向前; 3, 向右; 4, 向后 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 27, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Thread trimming moving frame direction"),// 剪线动框方向 + 0, 0, 4, 0, 0, tr(""), tr(""), + tr("Fixed frame:0;Left:1;Forward:2;Right:3;Backward:4"), 0, 0, 0x0122, operate)); + + + // 主轴拐角转速, 范围 1--3000,单位r/min,默认 1000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 28, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle corner speed"),// 主轴拐角转速 + 1000, 1, 3000, 1000, 0, tr("r/min"), tr(""), + tr(""), 0, 0, 0x0123, operate)); + + // 降速最小偏差角度, 范围 0--180,默认 180 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 29, 0, 0, PARA_VALUE_TYPE_INT, + tr("Minimum speed deviation angle"),// 降速最小偏差角度 + 180, 0, 180, 180, 0, cod->toUnicode("°"), tr(""), + tr(""), 0, 0, 0x0124, operate)); + + // 开机自动找零, 范围 0--1,默认 1 + //BIT0:1:开机自动找零, 0:开机不自动找零 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 30, 1, 0, PARA_VALUE_TYPE_SW, + tr("Auto Zero after power on"),// 开机自动归零 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0125, operate)); + + // 缝纫降速模式:0:自动降速,1参数降速,2不降速 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 31, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Sewing speed reduction mode"),// 缝纫降速模式 + 0, 0, 2, 0, 0, tr(""), tr(""), + tr("Auto:0;Param:1;Not:2"), 0, 0, 0x0126, operate));//0:自动降速,1参数降速,2不降速 + + // 机器动作配置, 范围 0--1 + // bit0 自动拉料允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 32, 1, 0, PARA_VALUE_TYPE_SW, + tr("Automatic drawing is allowed"),// 自动拉料允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0126, operate)); + + // 进料时对边允许, 范围 0--1 + // bit1 进料时对边允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 32, 2, 0, PARA_VALUE_TYPE_SW, + tr("The opposite side is allowed when feeding"),// 进料时对边允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0126, operate)); + + // 进料时展布允许, 范围 0--1,默认 1 + // bit2 进料时展布允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 32, 3, 0, PARA_VALUE_TYPE_SW, + tr("Allowing distribution during feeding"),// 进料时展布允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0126, operate)); + + // 进料时中切允许, 范围 0--1,默认 1 + // bit3 进料时中切允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 32, 4, 0, PARA_VALUE_TYPE_SW, + tr("Medium cutting is allowed during feeding"),// 进料时中切允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0126, operate)); + + // 进料时中切对边允许, 范围 0--1,默认 1 + // bit4 进料时中切对边允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 32, 5, 0, PARA_VALUE_TYPE_SW, + tr("During feeding, it is allowed to cut across the edge"),// 进料时中切对边允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0126, operate)); + + // 机头升降时松线允许, 范围 0--1,默认 1 + // bit5 机头升降时松线允许; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 32, 6, 0, PARA_VALUE_TYPE_SW, + tr("The thread loosening is allowed when the head is lifting"),// 机头升降时松线允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0126, operate)); + + // 安全输入光幕允许, 范围 0--1,默认 0 + // bit0, 光幕; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 33, 1, 0, PARA_VALUE_TYPE_LIST, + tr("Secure input light curtain allows"),// 安全输入光幕允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;Allowed:1"), 0, 0, 0x0127, operate)); + + // 安全输入气压允许, 范围 0--1,默认 1 + // bit1, 气压; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 33, 2, 0, PARA_VALUE_TYPE_LIST, + tr("Safety input pressure allowed"),// 安全输入气压允许 + 1, 0, 1, 1, 0, tr(""), tr(""), + tr("Not allow:0;Allowed:1"), 1, 1, 0x0127, operate)); + + // 安全输入上电信号允许, 范围 0--1,默认 0 + // bit2, 上电信号; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 33, 3, 0, PARA_VALUE_TYPE_LIST, + tr("Safe input power-on signal allowed"),// 安全输入上电信号允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;Allowed:1"), 0, 0, 0x0127, operate)); + + // 安全输入安全门允许, 范围 0--1,默认 0 + // bit4, 安全门 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 33, 5, 0, PARA_VALUE_TYPE_LIST, + tr("Safe input emergency door allowed"),// 安全输入安全门允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;Allowed:1"), 0, 0, 0x0127, operate)); + + // 安全输入手自动允许, 范围 0--1,默认 0 + // bit5 手自动按钮 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 33, 6, 0, PARA_VALUE_TYPE_LIST, + tr("Manual and automatic safe input"),// 安全输入手自动允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;Allowed:1"), 0, 0, 0x0127, operate)); + + // 循环工作允许, 范围 0--1,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 34, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Loop work allowed"),// 循环工作允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr("Not allow:0;Allowed:1"), 0, 0, 0x0128, factory)); + + // 梭加油持续时长, 范围 0--S32_MAX,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 35, 0, 0, PARA_VALUE_TYPE_INT, + tr("Shuttle refueling duration"),// 梭加油持续时长 + 0, 0, S32_MAX, 0, 0, tr("s"), tr(""), + tr(""), 0, 0, 0x0129, factory)); + + + // 缝纫吹气时间,范围0-10,单位 s,默认0(0为持续吹气) + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 36, 0, 0, PARA_VALUE_TYPE_INT, + tr("Replace the punch count value"),// 缝纫吹气时间 + 0, 0, 10, 0, 0, tr("s"), tr(""), + tr(""), 0, 0, 0x0130, operate)); + + // 缝纫动框起始角度, 0--36000, 单位 0.01度,默认 28000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 37, 0, 0, PARA_VALUE_TYPE_INT, + tr("Starting angle of sewing frame"),// 缝纫动框起始角度 + 28000, 0, 36000, 36000, 2, cod->toUnicode("°"), tr(""), + tr(""), 0, 0, 0x0130, operate)); + + // 剪线分线角度,0--36000, 单位 0.01度,默认 20000 // beifen1; // 备用1 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 38, 0, 0, PARA_VALUE_TYPE_INT, + tr("Replace the punch count value"),// 缝纫吹气时间 + 20000, 0, 36000, 36000, 2, cod->toUnicode("°"), tr(""), + tr(""), 0, 0, 0x0130, operate)); + + // 剪线完成角度,0--36000, 单位 0.01度,默认 6000 // beifen2; // 备用2 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 39, 0, 0, PARA_VALUE_TYPE_INT, + tr("Trimming completion angle"),// 剪线完成角度 + 6000, 0, 36000, 36000, 2, cod->toUnicode("°"), tr(""), + tr(""), 0, 0, 0x0130, operate)); + // 主轴停车传感器角度,0--36000, 单位 0.01度,默认 6000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 40, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle parking sensor angle"),// 主轴停车传感器角度 + 6000, 0, 36000, 36000, 2, cod->toUnicode("°"), tr(""), + tr(""), 0, 0, 0x0130, operate)); + // 主轴剪线转速, 范围 1--500,单位r/min,默认 120u32 // beifen4; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 41, 0, 0, PARA_VALUE_TYPE_INT, + tr("Spindle thread cutting speed"),//主轴剪线转速 + 120, 1, 500, 36000, 0, tr("r/min"), tr(""), + tr(""), 0, 0, 0x0130, operate)); + + +} + +//电机和控制动作 +void HighSingleQui::initOutCtrlList() +{ + m_allOutCtrlList.clear(); + + QString enableStr = tr("Enable"); //使能 + QString disableStr = tr("Disable"); //失能 + QString jogPStr = tr("JogP"); //正转 + QString jogNStr = tr("JogN"); //反转 + QString zeroStr = tr("Zero"); //归零 + QString openStr = tr("Open"); //打开 + QString closeStr = tr("Close");//关闭 + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0001,tr("X to move motor"),MT_LX,// X向移动电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0002,tr("Y to move motor"),MT_LY,// Y向移动电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0003,tr("Spindle motor"),MT_LM,// 主轴电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0004,tr("Needle motor"),MT_LN,// 针电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0005,tr("Shuttle motor"),MT_LH,// 梭电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0006,tr("Lifting motor"),MT_LU,// 升降电机 + enableStr,true,OUTCONTROL_ENABLE,-1,-1, + disableStr,true,OUTCONTROL_DISABLE,-1,-1, + jogPStr,true,-1,OUTCONTROL_JOGP,OUTCONTROL_STOP, + jogNStr,true,-1,OUTCONTROL_JOGN,OUTCONTROL_STOP, + zeroStr,true,OUTCONTROL_ZERO,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0007,tr("Lower scissors to cut thread"),OT_DCUT_THREAD,// 下剪刀剪线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0008,tr("Buckle the bottom line"),OT_PUSH_BTRD,// 扣底线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0009,tr("Elastic thread"),OT_LOOSE_THREAD,// 松紧线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000A,tr("oil"),OT_OIL,// 加油 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000B,tr("headlamp"),OT_LIGHT,// 照明灯 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000C,tr("Sewing machine head lifting"),OT_SEW_LIFT,// 缝纫机头升降 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000D,tr("Sandwich line"),OT_CLIP_UTRD,// 夹面线 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000E,tr("Shuttle changing device grabbing"),OT_CHBOB_GRAB_OPEN,// 换梭装置抓取 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x000F,tr("Shuttle changer swing"),OT_CHBOB_SWAY_PUSH,// 换梭装置摆动 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0010,tr("Shuttle changer rotation"),OT_CHBOB_SPIN,// 换梭装置旋转 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); + + m_allOutCtrlList.append(makeAOutCtrlItem(0,0x0011,tr("Sewing Blow"),OT_SEW_BLOW,// 缝纫吹气 + "",false,-1,-1,-1, + "",false,-1,-1,-1, + "",false,-1,-1,-1, + openStr,true,OUTCONTROL_OPEN,-1,-1, + closeStr,true,OUTCONTROL_CLOSE,-1,-1)); +} + +//快捷功能 +void HighSingleQui::initShortCutList() +{ + m_allShortCutList.clear(); + int index = 1; + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("AllToZero"),"buttonFrameZero",FUN_ALLTOZERO));//全部归零 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Front_Back"),"buttonForwardOrBack",FUN_FORWARDORBACK));// 快进快退 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("BackThread"),"buttonSetAnchorPoint",FUN_BACKTHREADPOINT));//回穿线点 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("N/S_Proof"),"buttonAutoParas",FUN_MAINSHAFT_ADJUST));//针梭校对 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("BackOffset"),"buttonQuantityMoveFrame",FUN_BACKOFFSETPOINT));//回偏移点 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("BackZero"),"buttonSetAnchorPoint",FUN_BACKZEROPOINT));//回零点 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("CountReset"),"buttonCommonFunction",FUN_COUNTRESET));//底线计数清零 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("OutputReset"),"buttonSetAnchorPoint",FUN_OUTPUTRESET));//产量清零 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("NeedZeroPos"),"buttonSetStartPoint",FUN_NEDDLEZEROPOS));//对针零位 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ShutZeroPos"),"buttonSetAnchorPoint",FUN_SHUTTLEZEROPOS));//对梭零位 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("HeadLifting"),"buttonHeadLifting",FUN_HEAD_LIFTUPDOWN));//机头升降 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ThreadCut"),"buttonMunualThreadCutting",FUN_MANUAL_THREAD_CUTTING));//手动剪线 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("ProcessReset"),"buttonProcessReset",FUN_PROCESSRESET));//流程复位 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Simulated"),"buttonSimulatedStatus",FUN_SIMULATED_STATUS));// 模拟缝纫 +} + +//辅助功能 +void HighSingleQui::initAssistList() +{ + m_allAssistList.clear(); + + m_allAssistList.append(makeAAssistItem(0,0x0001,tr("Signal"),"buttonSensor",ASSIST_SENSOR));//传感器信号 + m_allAssistList.append(makeAAssistItem(0,0x0002,tr("Action"),"buttonControlAction",ASSIST_CONTROLACTION));//控制动作 + m_allAssistList.append(makeAAssistItem(0,0x0003,tr("HMIUpgrade"),"buttonHMIUpgrade",ASSIST_HMIUPGRADE));//界面升级 + m_allAssistList.append(makeAAssistItem(0,0x0004,tr("MCUpgrade"),"buttonMCUpgrade",ASSIST_MCUPGRADE));//主控升级 + m_allAssistList.append(makeAAssistItem(0,0x0006,tr("ParaImport"),"buttonParaImport",ASSIST_PARAIMPORT));//参数导入 + m_allAssistList.append(makeAAssistItem(0,0x0007,tr("ParaExport"),"buttonParaExport",ASSIST_PARAEXPORT));//参数导出 + m_allAssistList.append(makeAAssistItem(0,0x0008,tr("SoftwareSet"),"buttonSoftwareSet",ASSIST_SOFTWARESET));//软件设置 + m_allAssistList.append(makeAAssistItem(0,0x0009,tr("Authorization"),"buttonSoftwareAuthor",ASSIST_AUTHORIZATION));//软件授权 + m_allAssistList.append(makeAAssistItem(0,0x000A,tr("Network"),"buttonNetworkManage",ASSIST_NETWORK));//网络管理 + m_allAssistList.append(makeAAssistItem(0,0x000C,tr("Time"),"buttonTimeSet",ASSIST_TIMESET));//时间设置 + m_allAssistList.append(makeAAssistItem(0,0x000F,tr("Version"),"buttonVersionInfo",ASSIST_MCVERSION));//版本信息 + m_allAssistList.append(makeAAssistItem(0,0x0014,tr("Root"),"buttonRoot",ASSIST_ROOT));//超级用户 +// m_allAssistList.append(makeAAssistItem(0,0x0015,tr("DebugInfo"),"buttonSpindleTest",ASSIST_DEBUGINFO));//调试信息 +} + +//花样设置 +void HighSingleQui::initPatternSetList() +{ + m_allPatternSetList.clear(); + + m_allPatternSetList.append(makeAPatternSetItem(0,0x0001,tr("Para"),"buttonPatternPara",PATTERNSET_PATTERNPARA));//花样参数 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0002,tr("Select"),"buttonPatternSelect",PATTERNSET_PATTERNSELECT));//花样选择 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0004,tr("Import"),"buttonPatternImport",PATTERNSET_PATTERNIMPORT));//花样导入 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0005,tr("Export"),"buttonPatternExport",PATTERNSET_PATTERNEXPORT));//花样导出 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0006,tr("Delete"),"buttonPatternDelete",PATTERNSET_PATTERNDELETE));//花样删除 +} + +//参数分类(参数分组功能) +void HighSingleQui::initParaSetList() +{ + m_allParaSetList.clear(); + + m_allParaSetList.append(makeAParaSetItem(0,0x0001,tr("OperatPara"),"buttonPositionParas",PARASET_SETTING));//设置参数 //操作参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0002,tr("ActionSet"),"buttonSpeedParas",PARASET_ACTION));//动作参数 //动作设定 + m_allParaSetList.append(makeAParaSetItem(0,0x0003,tr("SpeedPara"),"buttonActionParas",PARASET_SPEED));//速度参数 //速度控制参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0004,tr("LimitPara"),"buttonDetectParas",PARASET_POSITION));// 位置参数 //限位参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0005,tr("MCPara"),"buttonSettingParas",PARASET_DETECT));//设置参数 //机器参数 +} + +//初始化传感器列表 +void HighSingleQui::initSensorList() +{ + QList sensorList; + + sensorList.append(makeASensorItem(0x0000, 0, tr("Start button 1")));//启动按钮1 + sensorList.append(makeASensorItem(0x0001, 0, tr("Pause button 1")));//暂停按钮1 + sensorList.append(makeASensorItem(0x0007, 0, tr("Air pressure detection 1")));//气压检测1 + sensorList.append(makeASensorItem(0x0008, 0, tr("Security input 1")));//安全输入1 + sensorList.append(makeASensorItem(0x0020, 0, tr("X zero position")));//X零位 + // sensorList.append(makeASensorItem(0x0020, 1, tr("Y zero position")));//Y零位 + // sensorList.append(makeASensorItem(0x0021, 0, tr("X deceleration")));//X降速 + sensorList.append(makeASensorItem(0x0021, 1, tr("Y deceleration")));//Y降速 + // sensorList.append(makeASensorItem(0x0022, 0, tr("X negative limit")));//X负限位 + // sensorList.append(makeASensorItem(0x0022, 1, tr("Y negative limit")));//Y负限位 + sensorList.append(makeASensorItem(0x0023, 0, tr("X positive limit")));//X正限位 + sensorList.append(makeASensorItem(0x0023, 1, tr("Y positive limit")));//Y正限位 + + sensorList.append(makeASensorItem(0x0040, 0, tr("Sewing machine head 1 lifting upper limit")));//缝纫机头1升降上限位 + sensorList.append(makeASensorItem(0x0042, 0, tr("Lower lifting limit of sewing machine head 1")));//缝纫机头1升降下限位 + sensorList.append(makeASensorItem(0x0080, 0, tr("Sewing spindle 1 needle - parking space")));//缝纫主轴1针-停车位 + sensorList.append(makeASensorItem(0x0088, 0, tr("Sewing shuttle 1- parking space")));//缝纫旋梭1-停车位 + sensorList.append(makeASensorItem(0x0170, 0, tr("Sewing machine head 1 - surface thread breakage inspection")));//缝纫机头1-面线断检 + + //将机型所需的传感器列表替换到传感器整体列表中 + for(int i = 0; i < sensorList.size(); i++) + { + int byteaddr = sensorList[i].m_byte_offset; + int bitaddr = sensorList[i].m_bit_offset; + QString str = sensorList[i].m_name; + int type = sensorList[i].m_type; + + int idx = byteaddr*8+bitaddr; + if(idx < m_allSensorList.size()) + { + m_allSensorList[idx].m_name = str; + m_allSensorList[idx].m_type = type; + } + } +} + +//初始化错误代码和状态列表 +void HighSingleQui::initErrorCodeAndStateList() +{ + m_allErrorCodeAndStateList.clear(); +} + diff --git a/mctype/patternsingleboard/function/highsinglequilting.h b/mctype/patternsingleboard/function/highsinglequilting.h new file mode 100644 index 0000000..61094b9 --- /dev/null +++ b/mctype/patternsingleboard/function/highsinglequilting.h @@ -0,0 +1,35 @@ +#ifndef HIGHSINGLEQUI +#define HIGHSINGLEQUI + +#include "mctype/machinetypefun.h" + +//高速单针绗缝机 +class HighSingleQui : public MachineTypeFun +{ + Q_OBJECT +public: + HighSingleQui(); + ~HighSingleQui(); + +public: + void initNinebtn1234(); + void initFileInfoLabel(); + +private: + void initRootParasList();//超级用户参数(包括机器参数、工作参数) + void initPatternsParasList();//花样参数 + void initMcParasList();//主控机器参数 + void initWkParasList();//主控工作参数 + +private: + void initOutCtrlList();//控制动作 + void initShortCutList();//快捷动作 + void initAssistList();//辅助功能 + void initPatternSetList();//花样设置 + void initParaSetList();//参数设置 + +private: + void initSensorList();//初始化传感器列表 + void initErrorCodeAndStateList();//初始化错误代码和状态列表 +}; +#endif // HIGHSINGLEQUI diff --git a/mctype/patternsingleboard/function/multineedlerotary.cpp b/mctype/patternsingleboard/function/multineedlerotary.cpp new file mode 100644 index 0000000..294c30a --- /dev/null +++ b/mctype/patternsingleboard/function/multineedlerotary.cpp @@ -0,0 +1,412 @@ +#include "multineedlerotary.h" + +MultiNeedleRotary::MultiNeedleRotary() +{ + //添加各种参数到列表中 + initRootParasList(); + initRootHMIConfigurationList(m_allParasList);//超级用户界面配置 + initPatternsParasList(); + initSoftwareParasList(m_allParasList); + initTimeParasList(m_allParasList); + initMcParasList(); + initWkParasList(); + + //初始化控制动作列表 + initOutCtrlList(); + + //初始化快捷功能列表 + initShortCutList(); + + //初始化辅助功能列表 + initAssistList(); + + //初始化花样设置功能列表 + initPatternSetList(); + + //参数分类功能 + initParaSetList(); + + //初始化传感器列表 + initSensorList(); + + //初始化错误代码和状态列表 + initErrorCodeAndStateList(); + + //初始化九宫格 + initNinebtn1234(); + + //加载右上角信息 + initFileInfoLabel(); +} + +MultiNeedleRotary::~MultiNeedleRotary() +{ + +} + +void MultiNeedleRotary::initNinebtn1234() +{ + m_nineBtn.insert(1,NineItem(FUN_HEAD_LIFTING,"buttonHeadLifting")); + m_nineBtn.insert(2,NineItem(FUN_FORWARDORBACK,"buttonForwardOrBack")); + m_nineBtn.insert(3,NineItem(FUN_PROCESSRESET,"buttonProcessReset")); + m_nineBtn.insert(4,NineItem(FUN_SIMULATED_STATUS,"buttonSimulatedStatus")); +} + +void MultiNeedleRotary::initRootParasList() +{ + //超级用户参数--------------------------- + //超级用户参数-界面配置;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_HMICONFIGURATION, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("HMI Configuration"),//界面配置 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0000 , factory)); + + //超级用户参数-界面进入调试模式;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_DEBUGMODE, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Interface debug mode"),//界面进入调试模式 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001 , root)); + + //超级用户参数-删除config.ini配置文件;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_DELETEINI, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Delete configure file"),//删除配置文件 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0001 , root)); + + //超级用户参数-机器参数;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_MACHINEPARA, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Machine parameters"),//机器参数 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0002, factory)); + + //超级用户参数-工作参数;单位:无 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_ROOT, + 0 , + ROOT_WORKPARA, 0, 0, PARA_VALUE_TYPE_CLICK, + tr("Work parameters"),//工作参数 + 0, 0, 0, 0, 0, tr(""), tr(""), + tr(""), + 0, 0, 0x0003, factory)); +} + +void MultiNeedleRotary::initPatternsParasList() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + + //花样参数-花样设置参数-起始点x;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR , + SET_STARTX, 0, 0, PARA_VALUE_TYPE_INT, + tr("startX"),//起始点X + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0003, operate)); + + //花样参数-花样设置参数-起始点y;范围-1000000--1000000,单位0.01mm,默认 0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_PATTERN, + PATTERNPARA_SORT_DSTR , + SET_STARTY, 0, 0, PARA_VALUE_TYPE_INT, + tr("startrY"),//起始点Y + 0, -1000000, 1000000, 0, 2, tr("mm"), tr(""),//mm + tr(""), 0, 0,0x0004, operate)); +} + +void MultiNeedleRotary::initMcParasList() +{ + // QTextCodec *cod = QTextCodec::codecForLocale(); + + +} + +void MultiNeedleRotary::initWkParasList() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + + // 主轴缝纫工作转速, 范围 1--500,单位r/min,默认 300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 0, 0, 0, PARA_VALUE_TYPE_INT, + tr("Sewing main shaft working speed"),// 主轴缝纫工作转速 + 2000, 1, 3600, 2000, 0, tr("r/min"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // 主轴归零转速, 范围 1--3000,单位r/min,默认 120 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 110, 0, 0, PARA_VALUE_TYPE_INT, + tr("Main shaft zero reset speed"),//主轴归零转速 + 120, 1, 3000, 120, 0, tr("r/min"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // 主轴运转转速, 范围 1--3000,单位r/min,默认 300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 111, 0, 0, PARA_VALUE_TYPE_INT, + tr("Main shaft running speed"),//主轴运转转速 + 120, 1, 3000, 120, 0, tr("r/min"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // xy归零运行速度, 范围 1--500,单位mm/s,默认 100 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 101, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY zero reset speed"),//xy归零运行速度 + 100, 1, 500, 100, 0, tr("mm/s"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // xy空走运行速度, 范围 1--1700,单位mm/s,默认 300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 102, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY zero reset speed"),//xy空走运行速度 + 300, 1, 1700, 300, 0, tr("mm/s"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // xy手动移动速度1, 范围 1--1000,单位mm/s,默认 10 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 105, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY manual movement speed 1"),//xy手动移动速度1 + 10, 1, 1000, 10, 0, tr("mm/s"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // xy手动移动速度2, 范围 1--1000,单位mm/s,默认 100 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 106, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY manual movement speed 2"),//xy手动移动速度2 + 100, 1, 1000, 100, 0, tr("mm/s"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // xy手动移动速度3, 范围 1--1000,单位mm/s,默认 300 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SPEED, + 107, 0, 0, PARA_VALUE_TYPE_INT, + tr("XY manual movement speed 3"),//xy手动移动速度3 + 300, 1, 1000, 300, 0, tr("mm/s"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // 工作机头选择 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 100, 1, 0, PARA_VALUE_TYPE_INT, + tr("Work head selection 1"),//工作头选择1 + 1, 0, 1, 1, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"), 0, 0, 0x0001, operate)); + + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 100, 2, 0, PARA_VALUE_TYPE_INT, + tr("Work head selection 2"),//工作头选择2 + 1, 0, 1, 1, 0, tr(""), tr(""), + tr("Not allow:0;allowed:1"), 0, 0, 0x0001, operate)); + + // 产量预设 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 33, 0, 0, PARA_VALUE_TYPE_INT, + tr("Production preset"),// 产量预设 + 0, 0, S32_MAX, 0, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // 断线检测针数; 0, 不检测断线; 其他, 断线信号连续针数,默认3 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 14, 0, 0, PARA_VALUE_TYPE_INT, + tr("No. of stitch detect if thread broken"),// 断线检测针数 + 3, 0, 10, 3, 0, tr("Needle"), tr(""),//针 + tr(""), 0, 0, 0x0001, operate)); + + // 底线长度, 单位 0.01mm,默认 10000000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 17, 0, 0, PARA_VALUE_TYPE_INT, + tr("Bobbin thread length"),// 底线长度 + 10000000, 0, S32_MAX, 10000000, 2, tr("mm"), tr(""), + tr(""), 0, 0, 0x0001, operate)); + + // 断线检测针数; 0, 不检测断线; 其他, 断线信号连续针数,默认3 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_DETECT, + 14, 0, 0, PARA_VALUE_TYPE_INT, + tr("No. of stitch detect if thread broken"),// 断线检测针数 + 3, 0, 10, 3, 0, tr(""), tr(""), + tr(""), 0, 0, 0x0002, operate)); + + // 换梭芯提醒功能, 0, 不启用该功能; 1, 按长度计数延迟提醒; 2, 按片数计数; 3, 按长度立刻提醒; 默认0 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_ACTION, + 16, 0, 0, PARA_VALUE_TYPE_LIST, + tr("Bobbin change reminder function"),//换梭芯提醒功能 + 0, 0, 3, 0, 0, tr(""), tr(""), + //0, 不启用该功能; 1, 按长度计数延迟提醒; 2, 按片数计数; 3, 按长度立刻提醒; 默认0 + tr("Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3"), 0, 0, 0x0012, operate)); + + // 底线长度, 单位 0.01mm,默认 10000000 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 17, 0, 0, PARA_VALUE_TYPE_INT, + tr("Bobbin thread length"),// 底线长度 + 10000000, 1, 10000000, 10000000, 2, tr("mm"), tr(""), + tr(""), + 0, 0, 0x0013, operate)); + + // 安全输入允许,位图选择,0, 不允许; 1, 允许; + // bit0, 光幕; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 101, 1, 0, PARA_VALUE_TYPE_SW, + tr("Secure input light curtain allows"),//安全输入光幕允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0010, operate)); + + // bit1, 气压; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 101, 2, 0, PARA_VALUE_TYPE_SW, + tr("Safety input pressure allowed"),//安全输入气压允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0010, operate)); + + // bit2, 上电信号; + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 101, 3, 0, PARA_VALUE_TYPE_SW, + tr("Safe input power-on signal allowed"),//安全输入上电信号允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0010, operate)); + + // bit4, 安全门 + m_allParasList.append(makeAParaItem(0, + PARA_TYPE_WORK, + MC_SORT_SETTING, + 101, 4, 0, PARA_VALUE_TYPE_SW, + tr("Safe door allowed"),//安全门允许 + 0, 0, 1, 0, 0, tr(""), tr(""), + tr(""),0, 0, 0x0010, operate)); + +} + +void MultiNeedleRotary::initOutCtrlList() +{ + m_allOutCtrlList.clear(); + int showPriority = 1; + + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("X to move motor"),MT_LX));// X向移动电机(归零,正转,反转) + m_allOutCtrlList.append(creatZeroForwardReverseItem(0,showPriority++,tr("Y to move motor"),MT_LY));// Y向移动电机(归零,正转,反转) + + + m_allOutCtrlList.append(creatZeroItem(0,showPriority++,tr("All spindle zero positions"),MT_ALLZ)); // 所有主轴 零位 (归零) + m_allOutCtrlList.append(creatZeroItem(0,showPriority++,tr("All Spindle Hook Lines positions"),MT_ALLG)); // 所有主轴 勾线 (归零) + m_allOutCtrlList.append(creatZeroItem(0,showPriority++,tr("All spindle jogs positions"),MT_ALLM)); // 所有主轴 点动 (归零) + + +} + +void MultiNeedleRotary::initShortCutList() +{ + m_allShortCutList.clear(); + int index = 1;; + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("All_Zero"),"buttonFrameZero",FUN_ALLTOZERO));//全部归零 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("Front_Back"),"buttonForwardOrBack",FUN_FORWARDORBACK));// 快进快退 + m_allShortCutList.append(makeAShortCutItem(0,index++,tr("AllSpleZero"),"buttonAllToZero",FUN_MT_ALLZ));//所有主轴零位 + +} + +void MultiNeedleRotary::initAssistList() +{ + m_allAssistList.clear(); + + m_allAssistList.append(makeAAssistItem(0,0x0001,tr("Signal"),"buttonSensor",ASSIST_SENSOR));//传感器信号 + m_allAssistList.append(makeAAssistItem(0,0x0002,tr("Action"),"buttonControlAction",ASSIST_CONTROLACTION));//控制动作 + m_allAssistList.append(makeAAssistItem(0,0x0003,tr("HMIUpgrade"),"buttonHMIUpgrade",ASSIST_HMIUPGRADE));//界面升级 + m_allAssistList.append(makeAAssistItem(0,0x0004,tr("MCUpgrade"),"buttonMCUpgrade",ASSIST_MCUPGRADE));//主控升级 + m_allAssistList.append(makeAAssistItem(0,0x0006,tr("ParaImport"),"buttonParaImport",ASSIST_PARAIMPORT));//参数导入 + m_allAssistList.append(makeAAssistItem(0,0x0007,tr("ParaExport"),"buttonParaExport",ASSIST_PARAEXPORT));//参数导出 + m_allAssistList.append(makeAAssistItem(0,0x0008,tr("Setting"),"buttonSoftwareSet",ASSIST_SOFTWARESET));//软件设置 + m_allAssistList.append(makeAAssistItem(0,0x0009,tr("Authorize"),"buttonSoftwareAuthor",ASSIST_AUTHORIZATION));//软件授权 + m_allAssistList.append(makeAAssistItem(0,0x000A,tr("Network"),"buttonNetworkManage",ASSIST_NETWORK));//网络管理 + m_allAssistList.append(makeAAssistItem(0,0x000C,tr("Time"),"buttonTimeSet",ASSIST_TIMESET));//时间设置 + m_allAssistList.append(makeAAssistItem(0,0x000F,tr("Version"),"buttonVersionInfo",ASSIST_MCVERSION));//版本信息 + m_allAssistList.append(makeAAssistItem(0,0x0014,tr("Root"),"buttonRoot",ASSIST_ROOT));//超级用户 +} + +void MultiNeedleRotary::initPatternSetList() +{ + m_allPatternSetList.clear(); + + m_allPatternSetList.append(makeAPatternSetItem(0,0x0001,tr("Para"),"buttonPatternPara",PATTERNSET_PATTERNPARA));//花样参数 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0002,tr("Select"),"buttonPatternSelect",PATTERNSET_PATTERNSELECT));//花样选择 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0004,tr("Import"),"buttonPatternImport",PATTERNSET_PATTERNIMPORT));//花样导入 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0005,tr("Export"),"buttonPatternExport",PATTERNSET_PATTERNEXPORT));//花样导出 + m_allPatternSetList.append(makeAPatternSetItem(0,0x0006,tr("Delete"),"buttonPatternDelete",PATTERNSET_PATTERNDELETE));//花样删除 + +} + +void MultiNeedleRotary::initParaSetList() +{ + m_allParaSetList.clear(); + + m_allParaSetList.append(makeAParaSetItem(0,0x0001,tr("OperatPara"),"buttonPositionParas",PARASET_SETTING));//设置参数 //操作参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0002,tr("ActionSet"),"buttonSpeedParas",PARASET_ACTION));//动作参数 //动作设定 + m_allParaSetList.append(makeAParaSetItem(0,0x0003,tr("SpeedPara"),"buttonActionParas",PARASET_SPEED));//速度参数 //速度控制参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0004,tr("LimitPara"),"buttonDetectParas",PARASET_POSITION));// 位置参数 //限位参数 + m_allParaSetList.append(makeAParaSetItem(0,0x0005,tr("MCPara"),"buttonSettingParas",PARASET_DETECT));//设置参数 //机器参数 + +} + +void MultiNeedleRotary::initSensorList() +{ + QList sensorList; + + sensorList.append(makeASensorItem(0x0000, 0, tr("Start button 1")));//启动按钮1 + sensorList.append(makeASensorItem(0x0001, 0, tr("Pause button 1")));//暂停按钮1 + sensorList.append(makeASensorItem(0x0002, 0, tr("Jog button 1")));//点动按钮1 + sensorList.append(makeASensorItem(0x0003, 0, tr("Open frame button 1")));//开框按钮1 + +} + +void MultiNeedleRotary::initErrorCodeAndStateList() +{ + m_allErrorCodeAndStateList.clear(); + + +} + diff --git a/mctype/patternsingleboard/function/multineedlerotary.h b/mctype/patternsingleboard/function/multineedlerotary.h new file mode 100644 index 0000000..89df8d5 --- /dev/null +++ b/mctype/patternsingleboard/function/multineedlerotary.h @@ -0,0 +1,39 @@ +#ifndef MULTINEEDLEROTARY_H +#define MULTINEEDLEROTARY_H + +#include "mctype/machinetypefun.h" + +/** + * @brief 多帧旋梭 + */ +class MultiNeedleRotary : public MachineTypeFun +{ + Q_OBJECT +public: + MultiNeedleRotary(); + ~MultiNeedleRotary(); + +public: + void initNinebtn1234(); +// virtual void initFileInfoLabel(); + +private: + void initRootParasList();//超级用户参数(包括机器参数、工作参数) + void initPatternsParasList();//花样参数 + void initMcParasList();//主控机器参数 + void initWkParasList();//主控工作参数 + +private: + void initOutCtrlList();//控制动作 + void initShortCutList();//快捷动作 + void initAssistList();//辅助功能 + void initPatternSetList();//花样设置 + void initParaSetList();//参数设置 + +private: + void initSensorList();//初始化传感器列表 + void initErrorCodeAndStateList();//初始化错误代码和状态列表 + +}; + +#endif // MULTINEEDLEROTARY_H diff --git a/mctype/patternsingleboard/mainUI/mainwidget.cpp b/mctype/patternsingleboard/mainUI/mainwidget.cpp new file mode 100644 index 0000000..bb286fc --- /dev/null +++ b/mctype/patternsingleboard/mainUI/mainwidget.cpp @@ -0,0 +1,4395 @@ +#include "mainwidget.h" +#include "ui_mainwidget.h" +#ifdef Q_OS_WIN +#include +#endif +MainWidget::MainWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::MainWidget), + m_pPatternSelectWi(NULL), + m_pParameterSetDlg(NULL), + m_pPatternManageWi(NULL), + m_pSensorInputWi(NULL), + m_pControlActionWi(NULL), + m_pMainWidgetFunction(NULL), + m_pSetWorkAreaWi(NULL), + m_initflag(0), + m_timoutflag(0), + m_pTimer(NULL), + m_pConTimer(NULL), + m_conFlag(0), + m_linkSta(0) +{ + ui->setupUi(this); + + setWindowFlags (Qt::Widget | + Qt::Window | + Qt::FramelessWindowHint | // 无边框窗口 + // Qt::WindowStaysOnTopHint | // 顶层窗口 + Qt::Widget); + + setFocusPolicy(Qt::NoFocus); + + mousePressX = 0; + mousePressY = 0; + mouseReleaseX = 0; + mouseReleaseY = 0; + + this->move(0,0); + initialize(); + + showWorkSpeed(QString("1200"));//初始化数码管的速度是0 + ui->labelSpeed->hide(); +} + +MainWidget::~MainWidget() +{ + if(m_pTimer != NULL) + { + delete m_pTimer; + } + + if(m_pConTimer != NULL) + { + delete m_pConTimer; + } + + if(m_pMinTimer != NULL) + { + delete m_pMinTimer; + } + + if(m_pWifiConTimer != NULL) + { + delete m_pWifiConTimer; + } + + if(m_pRefreshVer != NULL) + { + delete m_pRefreshVer; + } + + if(m_pPatternSelectWi != NULL) + { + delete m_pPatternSelectWi; + } + + if(m_pParameterSetDlg != NULL) + { + delete m_pParameterSetDlg; + } + + if(m_pSensorInputWi != NULL) + { + delete m_pSensorInputWi; + } + + if(m_pSetWorkAreaWi != NULL) + { + delete m_pSetWorkAreaWi; + } + + if(m_pControlActionWi != NULL) + { + delete m_pControlActionWi; + } + + if(m_pMainWidgetFunction != NULL) + { + delete m_pMainWidgetFunction; + } + if(m_pScanComThread != NULL) + { +// m_pScanComThread->wait(); + m_pScanComThread->quit(); + m_pScanComThread->deleteLater(); + } + if(m_pScanComPort != NULL) + m_pScanComPort->deleteLater(); + + delete ui; +} + +void MainWidget::initialize() +{ + memset(&m_expara, 0, sizeof(FileExecPara)); + m_setControlStyle.setUiName(this->objectName()); + + hideMenuFrame(); + //主界面按钮选中 + ui->buttonMainMenu->setCheckable(true); + ui->buttonMainMenu->setChecked(true); + + ui->frameForwardBack->setVisible(false); + clearFileInfo();//清除文件信息 + + ui->labelWorkState->setVisible(true); //正常工作/模拟工作 + ui->labelEnableWorkState->setVisible(false);//允许工作/禁止工作 + + memset(&m_mcStatus,0,sizeof(MCStatus)); + + //定时器 + m_pTimer = new QTimer(this); + m_pTimer->setInterval(1000); // 设置定时间隔1秒 + connect(m_pTimer, SIGNAL(timeout()), this, SLOT(onOneSecondTimer())); + + //定时器 + m_pConTimer = new QTimer(this); + m_pConTimer->setInterval(5000); // 设置定时间隔5秒 + connect(m_pConTimer, SIGNAL(timeout()), this, SLOT(onFiveSecondTimer())); + + //定时器 + m_pWifiConTimer = new QTimer(this); + m_pWifiConTimer->setInterval(100000); // 设置定时间隔10分钟 + connect(m_pWifiConTimer, SIGNAL(timeout()), this, SLOT(onTenMiniteTimer())); + + //测试花样刷新的定时器 + m_pRefreshPatternTimer = new QTimer(this); + m_pRefreshPatternTimer->setInterval(300); // 设置时间 + connect(m_pRefreshPatternTimer, SIGNAL(timeout()), this, SLOT(onRefreshPatternTimer())); + + //一分钟定时任务,记录当前系统时间,用于上电时计算关机时间 + m_pMinTimer = new QTimer(this); + m_pMinTimer->setInterval(60000); // 设置定时间隔60秒 + connect(m_pMinTimer, SIGNAL(timeout()), this, SLOT(onOneMinTimer())); + + m_pRefreshVer = new QTimer(this); + m_pRefreshVer->setInterval(1000); + connect(m_pRefreshVer, SIGNAL(timeout()), this, SLOT(onRefreshVer())); + m_pRefreshVer->start(); + + m_curFilePath.clear(); + m_imageZoom = 0;//花样图片缩放值 + m_imageMoveX = 0;//花样图片平移值X + m_imageMoveY = 0;//花样图片平移值Y + m_curDatIdx = 0;//当前针数索引 + m_curRpm = -1; + m_workStatus = 0; + m_forwardBackNeedleIdx = 0;//前进回退时的针数索引 + m_ifHMIDecrypt = 1; + m_connectMode = USE_TCP_COMM; + + m_speedLevel = 2;//速度默认等于2 + m_errorCode = 0;//错误代码 +} + +//初始化窗体 +void MainWidget::initAllWindows(s16 ifHMIDecrypt,s16 connectMode) +{ + m_connectMode = connectMode; + m_ifHMIDecrypt = ifHMIDecrypt; + if (m_initflag <= 1) + { + connect(g_pCurEmbData,SIGNAL(siDrawNeedleIdx(int)),this,SLOT(slotChangeProgressBar(int))); + m_initflag = 2; + sendInitString(QString(tr("Init windows...")));//初始化窗体... + initControl();//初始化界面控件 + initQuickFunBtn();//初始化快捷功能中的快捷按钮 + initAssisitBtn();//初始化辅助功能中的辅助功能按钮 + initPatternSetBtn();//初始化花样设置功能中的功能按钮 + initParaSetBtn();//初始化参数设置功能中的功能按钮 + + m_pMainWidgetFunction = new MainWidgetFunction();//主界面功能函数对象 + m_pMainWidgetFunction->setErrorCodeAndStateList(m_errorCodeAndStateItemList); + connect(m_pMainWidgetFunction, SIGNAL(siSetButtonUserLogo(int)), this, SLOT(slotSetButtonRootLogo(int))); + connect(m_pMainWidgetFunction, SIGNAL(siClearPatternBreakLineNum()),this,SLOT(slotClearPatternBreakLineNum())); + connect(m_pMainWidgetFunction, SIGNAL(siDebugState()),this,SLOT(slotDebugState())); //调试模式改变字体颜色 + connect(m_pMainWidgetFunction, SIGNAL(siClearPattern()), this, SLOT(slotIfFileExist()));//花样总清后,清除当前所选花版路径//两个信号用一个槽 + connect(m_pMainWidgetFunction, SIGNAL(siClearPatternFcg()), this, SLOT(slotClearPatternFcg()));//花样fcg总清后,清除当前所选花版路径 + connect(m_pMainWidgetFunction,SIGNAL(siShowPercentage(int)),this,SLOT(slotShowPercentage(int))); + connect(m_pMainWidgetFunction,SIGNAL(siWifiState(bool)),this,SLOT(slotRefreshWifiIcon(bool))); + + //connect(m_pMainWidgetFunction, SIGNAL(siRecieveLotDat()),this,SLOT(slotLotDat()));//测试物联网用 + + m_pPatternSelectWi = new PatternSelectWidget(this); + m_pPatternSelectWi->hide(); + connect(m_pPatternSelectWi, SIGNAL(siSelectPattern(QString,s16)), this, SLOT(slotShowPatternPara(QString,s16))); + + m_pPatternManageWi = new PatternManageWidget(this); + connect(m_pPatternManageWi, SIGNAL(siDeletePattern()), this, SLOT(slotIfFileExist())); + connect(m_pPatternManageWi, SIGNAL(siReplacePattrn(QString)), this, SLOT(slotReplacePattrn(QString))); + + m_pParameterSetDlg->hide(); + connect(m_pParameterSetDlg,SIGNAL(siUserLogin(s16)),m_pMainWidgetFunction,SLOT(slotUserLogin(s16))); + connect(m_pParameterSetDlg,SIGNAL(siSetWorkArea()),this,SLOT(slotWorkArea()));//设置平绣可工作区域 + connect(g_pMachine, SIGNAL(siParaChange(int, int)), + m_pParameterSetDlg, SLOT(paraChange(int, int)));// 参数改变 + + connect(m_pParameterSetDlg,SIGNAL(siHMIDecrypt(QString)),m_pMainWidgetFunction,SLOT(slotHMIDecrypt(QString))); + connect(m_pParameterSetDlg,SIGNAL(siExit()),m_pMainWidgetFunction,SLOT(slotExitApp()));//超级用户退出程序 + connect(m_pParameterSetDlg,SIGNAL(siChangePassword()),m_pMainWidgetFunction,SLOT(slotChangePassword()));//超级用户修改一级密码 + connect(m_pParameterSetDlg,SIGNAL(siDeleteIni()),m_pMainWidgetFunction,SLOT(slotDeleteIni()));//删除执行目录下的config.ini文件 + connect(m_pParameterSetDlg,SIGNAL(siImportCSV()),m_pMainWidgetFunction,SLOT(slotImportCSV())); + connect(m_pParameterSetDlg,SIGNAL(siDeleteCSV()),m_pMainWidgetFunction,SLOT(slotDeleteCSV())); + connect(m_pParameterSetDlg,SIGNAL(siResetCSV()),m_pMainWidgetFunction,SLOT(slotResetCSV())); + connect(m_pParameterSetDlg,SIGNAL(siPatternClear()),m_pMainWidgetFunction,SLOT(slotPatternClear()));//超级用户花样总清 + connect(m_pParameterSetDlg,SIGNAL(siDebugMode()),m_pMainWidgetFunction,SLOT(slotDebugMode()));//超级用户界面调试模式 + + connect(m_pMainWidgetFunction,SIGNAL(siAfterDeleteFileid()),this,SLOT(slotClearPatternFcg()));//超级用户删除花样fcg影响fileid的数据之后 + + m_pPatternManageWi->hide(); + + m_pSetWorkAreaWi = new SetWorkArea(this); + m_pSetWorkAreaWi->hide(); + + m_pSensorInputWi->hide(); + m_pControlActionWi->hide(); + connect(this, SIGNAL(siSpeed(int)),m_pControlActionWi,SLOT(slotSpeed(int))); //手动换挡 + + QTimer timer; + connect(&timer, SIGNAL(timeout()), this, SLOT(slotWaitTimout())); + timer.start(1000); + + m_timoutflag = 0; + do + { + QCoreApplication::processEvents(QEventLoop::AllEvents); + }while(m_timoutflag == 0); + timer.stop(); + + sendInitString(QString(tr("Init communication...")));//初始化通讯... + + connect(g_pMachine, SIGNAL(siSensorEnBitmap(SensorsBitmap)), + m_pSensorInputWi, SLOT(slotRefSensorBitmap(SensorsBitmap)));//传感信号有效位图更新信号 + connect(g_pMachine, SIGNAL(siSensorChange(SensorsBitmap)), + m_pSensorInputWi , SLOT(slotRefSensorsDat(SensorsBitmap)));//传感信号更新 + + //显示报错信息 + connect(g_pMachine, SIGNAL(siStatusChange(int)), this, SLOT(slotMachineStatus(int))); + + // 等待通讯结束.... + timer.start(1000); + m_timoutflag = 0; + do + { + QCoreApplication::processEvents(QEventLoop::AllEvents); + }while(m_timoutflag == 0); + timer.stop(); + + refConnectUi(-1);//刷新连接 + + m_pTimer->start();//1秒检查一次连接状态 + m_pConTimer->start();//5秒检查一次连接是否断开,若不需要检测与下位机的心跳包时注释掉此行代码 + //m_pMinTimer->start();//1分钟记录一次当前系统时间 + //m_pMainWidgetFunction->setShutDownTime();//开启计算关机时间 + + //窗体初始化完成后自动加载文件并显示、发送 + m_curFilePath = g_pSettings->readFromIniFile("Pattern/name").toString(); + slotShowPatternPara(m_curFilePath,-1);//不显示花样设置窗体,直接加载花样参数 + + //扫码器 + if(g_emMacType == MACHINE_FIVEHEADPRECISIONSEWING) + { + m_pScanComThread = new QThread(this); + m_pScanComPort = new ComPort(); + m_pScanComPort->setComPortName("/dev/ttyS2"); + + m_pScanComPort->moveToThread(m_pScanComThread); + connect(m_pScanComThread, SIGNAL(started()), m_pScanComPort, SLOT(initComm())); + connect(m_pScanComThread, SIGNAL(finished()), m_pScanComPort, SLOT(deleteLater())); // 退出删除对象 + connect(m_pScanComPort, SIGNAL(siReceiveData(QByteArray)), this, SLOT(slotReceScanData(QByteArray))); + + m_pScanComThread->start(); + } + + + s16 wifi = g_pSettings->readFromIniFile("HMI/wifi").toInt();//是否有wifi + if(wifi == 1) + { + onTenMiniteTimer(); + ui->buttonWifi->setVisible(true); + m_pWifiConTimer->start(); + } + else + { + ui->buttonWifi->setVisible(false); + } + } +} + +//不同机型不同的窗体设置 +void MainWidget::initMcTypeWindows() +{ + m_pParameterSetDlg = new ParameterSetDialog(this); + m_pControlActionWi = new ControlActionWidget(this); + m_pSensorInputWi = new SensorInputWidget(this); + + m_quickItemList.clear(); + m_assistItemList.clear(); + m_patternSetItemList.clear(); + m_paraSetItemList.clear(); + + MachineTypeFun * curMachineType = NULL; + int waterMark = g_pSettings->readFromIniFile("HMI/waterMark").toInt();//是否带水印 + + + switch (g_emMacType) { + case MACHINE_HIGHSPEEDSINGLEQUI: //绗缝机 + curMachineType = new HighSingleQui(); + break; + case MACHINE_FIVEHEADPRECISIONSEWING: //五头精密缝 + curMachineType = new FiveHeadPrecisionSewing(); + break; + case MACHINE_CLOTHINGMAC: // 服装机 + curMachineType = new ClothingMac(); + break; + case MACHINE_MULTINEEDLEROTARY: // 多帧旋梭 + curMachineType = new MultiNeedleRotary(); + break; + + default: + break; + } + + if(waterMark==1)//带logo + { + ui->labelTitle->setText(tr("Richpeace Quilting Control System"));//富怡绗缝控制系统 + } + else + { + ui->labelTitle->setText(tr("Quilting Control System"));//绗缝控制系统 + } + + //初始化快捷按钮列表要在初始化控件前 + m_quickItemList = curMachineType->getShortCutListByFilter(); + m_assistItemList = curMachineType->getAssistListByFilter(); + m_patternSetItemList = curMachineType->getPatternSetListByFilter(); + m_paraSetItemList = curMachineType->getParaSetListByFilter(); + m_pControlActionWi->addItemList(curMachineType->getOutCtrlListByFilter()); + //添加机器参数和工作参数 + m_pParameterSetDlg->addParaItem(curMachineType->getParasListByMcSel()); + m_pParameterSetDlg->setItemList(operate,PARA_TYPE_MACH|PARA_TYPE_WORK); + m_pSensorInputWi->addSensorItems(curMachineType->getSensorList()); + m_nineBtn = curMachineType->getNinebtn(); + m_fileInfo = curMachineType->getFileInfoMSG(); + m_errorCodeAndStateItemList.clear(); + m_errorCodeAndStateItemList = curMachineType->getErrorCodeAndStateList(); + if(curMachineType != NULL) + { + delete curMachineType; + } +} + +//初始化快捷功能中的快捷按钮 +void MainWidget::initQuickFunBtn() +{ + for(int i = 0; i < m_quickBtnList.size(); i++) + { + if(i < m_quickItemList.size()) + { + m_quickBtnList[i]->setVisible(true); + m_quickLabelList[i]->setVisible(true); + + QString name = m_quickItemList[i].m_name; + m_quickLabelList[i]->setText(name); + + QString topImageName = m_quickItemList[i].m_topImageName; + //加载按钮顶图图标 + QString btnStyle = m_setControlStyle.getTopStyleSheet(topImageName); + m_quickBtnList[i]->setTopImage(btnStyle); + + int enumFun = m_quickItemList[i].m_enumFunction; + if(enumFun == FUN_FORWARDORBACK ||//快进快退 + enumFun == FUN_SETSTARTPOINT ||//定起始点 + enumFun == FUN_BACKSTARTPOINT ||//回起始点 + enumFun == FUN_CHECKFRAME ||//边框检查 + enumFun == FUN_BACKWORKPOINT //回工作点 + ) + { + if(m_curFilePath.length() <= 0)//未选择文件时快进快退等按钮不可用 + { + m_quickBtnList[i]->setEnabled(false); + } + } + } + else + { + m_quickBtnList[i]->setVisible(false); + m_quickLabelList[i]->setVisible(false); + } + } +} + +//初始化辅助功能中的辅助按钮 +void MainWidget::initAssisitBtn() +{ + for(int i = 0; i < m_assistBtnList.size(); i++) + { + if(i < m_assistItemList.size()) + { + m_assistBtnList[i]->setVisible(true); + m_assistLabelList[i]->setVisible(true); + + QString name = m_assistItemList[i].m_name; + m_assistLabelList[i]->setText(name); + + QString topImageName = m_assistItemList[i].m_topImageName; + //加载按钮顶图图标 + QString btnStyle = m_setControlStyle.getTopStyleSheet(topImageName); + m_assistBtnList[i]->setTopImage(btnStyle); + } + else + { + m_assistBtnList[i]->setVisible(false); + m_assistLabelList[i]->setVisible(false); + } + } +} + +//初始化花样设置功能中的花样设置按钮 +void MainWidget::initPatternSetBtn() +{ + for(int i = 0; i < m_patternSetBtnList.size(); i++) + { + if(i < m_patternSetItemList.size()) + { + m_patternSetBtnList[i]->setVisible(true); + m_patternSetLabelList[i]->setVisible(true); + + QString name = m_patternSetItemList[i].m_name; + m_patternSetLabelList[i]->setText(name); + + QString topImageName = m_patternSetItemList[i].m_topImageName; + //加载按钮顶图图标 + QString btnStyle = m_setControlStyle.getTopStyleSheet(topImageName); + m_patternSetBtnList[i]->setTopImage(btnStyle); + + //无花样时花样参数、花样色序、参数 + if(m_patternSetItemList[i].m_enumFunction == PATTERNSET_PATTERNPARA) + { + m_patternSetBtnList[i]->setEnabled(false); + } + } + else + { + m_patternSetBtnList[i]->setVisible(false); + m_patternSetLabelList[i]->setVisible(false); + } + } +} + +//初始化参数设置功能中的参数设置按钮 +void MainWidget::initParaSetBtn() +{ + for(int i = 0; i < m_paraSetBtnList.size(); i++) + { + if(i < m_paraSetItemList.size()) + { + m_paraSetBtnList[i]->setVisible(true); + m_paraSetLabelList[i]->setVisible(true); + + QString name = m_paraSetItemList[i].m_name; + m_paraSetLabelList[i]->setText(name); + + QString topImageName = m_paraSetItemList[i].m_topImageName; + //加载按钮顶图图标 + QString btnStyle = m_setControlStyle.getTopStyleSheet(topImageName); + m_paraSetBtnList[i]->setTopImage(btnStyle); + } + else + { + m_paraSetBtnList[i]->setVisible(false); + m_paraSetLabelList[i]->setVisible(false); + } + } +} + +void MainWidget::initPatternInfo(int beginY, int gapY, int valueX, int keyX, int width, int height, int valueHeight) +{ + ui->lab_FileName->setVisible(false); + ui->lab_FileName_2->setVisible(false); + ui->lab_Index->setVisible(false); + ui->lab_Index_2->setVisible(false); + ui->lab_StartPoint->setVisible(false); + ui->lab_StartPoint_2->setVisible(false); + ui->lab_Locate->setVisible(false); + ui->lab_Locate_2->setVisible(false); + ui->lab_Range->setVisible(false); + ui->lab_Range_2->setVisible(false); + ui->lab_Position->setVisible(false); + ui->lab_Position_2->setVisible(false); + ui->lab_Production->setVisible(false); + ui->lab_Production_2->setVisible(false); + + QListIterator iter(m_fileInfo); + while (iter.hasNext()) { + PATTERNINFO item = iter.next(); + // 处理 key 和 value + if(item == FileName){ + ui->lab_FileName->setVisible(true); + ui->lab_FileName_2->setVisible(true); + ui->lab_FileName->setGeometry(keyX,beginY,width,height); + ui->lab_FileName_2->setGeometry(valueX,beginY,valueHeight,height); + } + else if(item == Index){ + ui->lab_Index->setVisible(true); + ui->lab_Index_2->setVisible(true); + ui->lab_Index->setGeometry(keyX,beginY,width,height); + ui->lab_Index_2->setGeometry(valueX,beginY,valueHeight,height); + } + else if(item == BeginPoint){ + ui->lab_StartPoint->setVisible(true); + ui->lab_StartPoint_2->setVisible(true); + ui->lab_StartPoint->setGeometry(keyX,beginY,width,height); + ui->lab_StartPoint_2->setGeometry(valueX,beginY,valueHeight,height); + } + else if(item == LocalPoint){ + ui->lab_Locate->setVisible(true); + ui->lab_Locate_2->setVisible(true); + ui->lab_Locate->setGeometry(keyX,beginY,width,height); + ui->lab_Locate_2->setGeometry(valueX,beginY,valueHeight,height); + } + else if(item == Range){ + ui->lab_Range->setVisible(true); + ui->lab_Range_2->setVisible(true); + ui->lab_Range->setGeometry(keyX,beginY,width,height); + ui->lab_Range_2->setGeometry(valueX,beginY,valueHeight,height); + } + else if(item == Position){ + ui->lab_Position->setVisible(true); + ui->lab_Position_2->setVisible(true); + ui->lab_Position->setGeometry(keyX,beginY,width,height); + ui->lab_Position_2->setGeometry(valueX,beginY,valueHeight,height); + } + else if(item == Production){ + ui->lab_Production->setVisible(true); + ui->lab_Production_2->setVisible(true); + ui->lab_Production->setGeometry(keyX,beginY,width,height); + ui->lab_Production_2->setGeometry(valueX,beginY,valueHeight,height); + } + beginY += gapY; + } + +} + +void MainWidget::setFrameNineBtnStyle() +{ + switch (m_speedLevel) + { + case 1: + ui->buttonNineBtnMiddle->setTopImage(m_setControlStyle.getTopStyleSheet("frameNineBtnMiddle_1")); + break; + case 2: + ui->buttonNineBtnMiddle->setTopImage(m_setControlStyle.getTopStyleSheet("frameNineBtnMiddle_2")); + break; + case 3: + ui->buttonNineBtnMiddle->setTopImage(m_setControlStyle.getTopStyleSheet("frameNineBtnMiddle_3")); + break; + default: + ui->buttonNineBtnMiddle->setTopImage(m_setControlStyle.getTopStyleSheet("frameNineBtnMiddle1")); + break; + } +} + +//清除文件信息 +void MainWidget::clearFileInfo() +{ + ui->lab_FileName_2->setText(""); + ui->lab_Index_2->setText("0/0"); + ui->lab_StartPoint_2->setText("0/0"); + ui->lab_Locate_2->setText("0/0"); + ui->lab_Range_2->setText("0/0"); + ui->lab_Position_2->setText("0/0"); + ui->lab_Production_2->setText("0"); +} + +//初始化窗体控件,包括位置、尺寸、样式 +void MainWidget::initControl() +{ + m_quickBtnList.clear(); + m_quickBtnList.append(ui->buttonQuick1); + m_quickBtnList.append(ui->buttonQuick2); + m_quickBtnList.append(ui->buttonQuick3); + m_quickBtnList.append(ui->buttonQuick4); + m_quickBtnList.append(ui->buttonQuick5); + m_quickBtnList.append(ui->buttonQuick6); + m_quickBtnList.append(ui->buttonQuick7); + m_quickBtnList.append(ui->buttonQuick8); + m_quickBtnList.append(ui->buttonQuick9); + m_quickBtnList.append(ui->buttonQuick10); + m_quickBtnList.append(ui->buttonQuick11); + m_quickBtnList.append(ui->buttonQuick12); + m_quickBtnList.append(ui->buttonQuick13); + m_quickBtnList.append(ui->buttonQuick14); + m_quickBtnList.append(ui->buttonQuick15); + m_quickBtnList.append(ui->buttonQuick16); + m_quickBtnList.append(ui->buttonQuick17); + m_quickBtnList.append(ui->buttonQuick18); + m_quickBtnList.append(ui->buttonQuick19); + m_quickBtnList.append(ui->buttonQuick20); + m_quickBtnList.append(ui->buttonQuick21); + m_quickBtnList.append(ui->buttonQuick22); + m_quickBtnList.append(ui->buttonQuick23); + m_quickBtnList.append(ui->buttonQuick24); + m_quickBtnList.append(ui->buttonQuick25); + m_quickBtnList.append(ui->buttonQuick26); + m_quickBtnList.append(ui->buttonQuick27); + m_quickBtnList.append(ui->buttonQuick28); + + for(int i = 0; i < m_quickBtnList.size(); i++) + { + connect(m_quickBtnList.at(i), + SIGNAL(clicked()), + this, + SLOT(slotQuickBtnClick()) + ); + } + + m_quickLabelList.clear(); + m_quickLabelList.append(ui->labelQuick1); + m_quickLabelList.append(ui->labelQuick2); + m_quickLabelList.append(ui->labelQuick3); + m_quickLabelList.append(ui->labelQuick4); + m_quickLabelList.append(ui->labelQuick5); + m_quickLabelList.append(ui->labelQuick6); + m_quickLabelList.append(ui->labelQuick7); + m_quickLabelList.append(ui->labelQuick8); + m_quickLabelList.append(ui->labelQuick9); + m_quickLabelList.append(ui->labelQuick10); + m_quickLabelList.append(ui->labelQuick11); + m_quickLabelList.append(ui->labelQuick12); + m_quickLabelList.append(ui->labelQuick13); + m_quickLabelList.append(ui->labelQuick14); + m_quickLabelList.append(ui->labelQuick15); + m_quickLabelList.append(ui->labelQuick16); + m_quickLabelList.append(ui->labelQuick17); + m_quickLabelList.append(ui->labelQuick18); + m_quickLabelList.append(ui->labelQuick19); + m_quickLabelList.append(ui->labelQuick20); + m_quickLabelList.append(ui->labelQuick21); + m_quickLabelList.append(ui->labelQuick22); + m_quickLabelList.append(ui->labelQuick23); + m_quickLabelList.append(ui->labelQuick24); + m_quickLabelList.append(ui->labelQuick25); + m_quickLabelList.append(ui->labelQuick26); + m_quickLabelList.append(ui->labelQuick27); + m_quickLabelList.append(ui->labelQuick28); + + m_assistBtnList.clear(); + m_assistBtnList.append(ui->buttonAssist1); + m_assistBtnList.append(ui->buttonAssist2); + m_assistBtnList.append(ui->buttonAssist3); + m_assistBtnList.append(ui->buttonAssist4); + m_assistBtnList.append(ui->buttonAssist5); + m_assistBtnList.append(ui->buttonAssist6); + m_assistBtnList.append(ui->buttonAssist7); + m_assistBtnList.append(ui->buttonAssist8); + m_assistBtnList.append(ui->buttonAssist9); + m_assistBtnList.append(ui->buttonAssist10); + m_assistBtnList.append(ui->buttonAssist11); + m_assistBtnList.append(ui->buttonAssist12); + m_assistBtnList.append(ui->buttonAssist13); + m_assistBtnList.append(ui->buttonAssist14); + m_assistBtnList.append(ui->buttonAssist15); + m_assistBtnList.append(ui->buttonAssist16); + m_assistBtnList.append(ui->buttonAssist17); + m_assistBtnList.append(ui->buttonAssist18); + m_assistBtnList.append(ui->buttonAssist19); + m_assistBtnList.append(ui->buttonAssist20); + m_assistBtnList.append(ui->buttonAssist21); + m_assistBtnList.append(ui->buttonAssist22); + m_assistBtnList.append(ui->buttonAssist23); + m_assistBtnList.append(ui->buttonAssist24); + m_assistBtnList.append(ui->buttonAssist25); + m_assistBtnList.append(ui->buttonAssist26); + m_assistBtnList.append(ui->buttonAssist27); + m_assistBtnList.append(ui->buttonAssist28); + + for(int i = 0; i < m_assistBtnList.size(); i++) + { + connect(m_assistBtnList.at(i), + SIGNAL(clicked()), + this, + SLOT(slotAssistBtnClick()) + ); + } + + m_assistLabelList.clear(); + m_assistLabelList.append(ui->labelAssist1); + m_assistLabelList.append(ui->labelAssist2); + m_assistLabelList.append(ui->labelAssist3); + m_assistLabelList.append(ui->labelAssist4); + m_assistLabelList.append(ui->labelAssist5); + m_assistLabelList.append(ui->labelAssist6); + m_assistLabelList.append(ui->labelAssist7); + m_assistLabelList.append(ui->labelAssist8); + m_assistLabelList.append(ui->labelAssist9); + m_assistLabelList.append(ui->labelAssist10); + m_assistLabelList.append(ui->labelAssist11); + m_assistLabelList.append(ui->labelAssist12); + m_assistLabelList.append(ui->labelAssist13); + m_assistLabelList.append(ui->labelAssist14); + m_assistLabelList.append(ui->labelAssist15); + m_assistLabelList.append(ui->labelAssist16); + m_assistLabelList.append(ui->labelAssist17); + m_assistLabelList.append(ui->labelAssist18); + m_assistLabelList.append(ui->labelAssist19); + m_assistLabelList.append(ui->labelAssist20); + m_assistLabelList.append(ui->labelAssist21); + m_assistLabelList.append(ui->labelAssist22); + m_assistLabelList.append(ui->labelAssist23); + m_assistLabelList.append(ui->labelAssist24); + m_assistLabelList.append(ui->labelAssist25); + m_assistLabelList.append(ui->labelAssist26); + m_assistLabelList.append(ui->labelAssist27); + m_assistLabelList.append(ui->labelAssist28); + + m_patternSetBtnList.clear(); + m_patternSetBtnList.append(ui->buttonPatternSet1); + m_patternSetBtnList.append(ui->buttonPatternSet2); + m_patternSetBtnList.append(ui->buttonPatternSet3); + m_patternSetBtnList.append(ui->buttonPatternSet4); + m_patternSetBtnList.append(ui->buttonPatternSet5); + m_patternSetBtnList.append(ui->buttonPatternSet6); + m_patternSetBtnList.append(ui->buttonPatternSet7); + m_patternSetBtnList.append(ui->buttonPatternSet8); + m_patternSetBtnList.append(ui->buttonPatternSet9); + m_patternSetBtnList.append(ui->buttonPatternSet10); + m_patternSetBtnList.append(ui->buttonPatternSet11); + m_patternSetBtnList.append(ui->buttonPatternSet12); + m_patternSetBtnList.append(ui->buttonPatternSet13); + m_patternSetBtnList.append(ui->buttonPatternSet14); + + for(int i = 0; i < m_patternSetBtnList.size(); i++) + { + connect(m_patternSetBtnList.at(i), + SIGNAL(clicked()), + this, + SLOT(slotPatternSetBtnClick()) + ); + } + + m_patternSetLabelList.append(ui->labelPatternSet1); + m_patternSetLabelList.append(ui->labelPatternSet2); + m_patternSetLabelList.append(ui->labelPatternSet3); + m_patternSetLabelList.append(ui->labelPatternSet4); + m_patternSetLabelList.append(ui->labelPatternSet5); + m_patternSetLabelList.append(ui->labelPatternSet6); + m_patternSetLabelList.append(ui->labelPatternSet7); + m_patternSetLabelList.append(ui->labelPatternSet8); + m_patternSetLabelList.append(ui->labelPatternSet9); + m_patternSetLabelList.append(ui->labelPatternSet10); + m_patternSetLabelList.append(ui->labelPatternSet11); + m_patternSetLabelList.append(ui->labelPatternSet12); + m_patternSetLabelList.append(ui->labelPatternSet13); + m_patternSetLabelList.append(ui->labelPatternSet14); + + m_paraSetBtnList.clear(); + m_paraSetBtnList.append(ui->buttonParaType1); + m_paraSetBtnList.append(ui->buttonParaType2); + m_paraSetBtnList.append(ui->buttonParaType3); + m_paraSetBtnList.append(ui->buttonParaType4); + m_paraSetBtnList.append(ui->buttonParaType5); + m_paraSetBtnList.append(ui->buttonParaType6); + m_paraSetBtnList.append(ui->buttonParaType7); + m_paraSetBtnList.append(ui->buttonParaType8); + m_paraSetBtnList.append(ui->buttonParaType9); + m_paraSetBtnList.append(ui->buttonParaType10); + m_paraSetBtnList.append(ui->buttonParaType11); + m_paraSetBtnList.append(ui->buttonParaType12); + m_paraSetBtnList.append(ui->buttonParaType13); + m_paraSetBtnList.append(ui->buttonParaType14); + + for(int i = 0; i < m_paraSetBtnList.size(); i++) + { + connect(m_paraSetBtnList.at(i), + SIGNAL(clicked()), + this, + SLOT(slotParaTypeBtnClick()) + ); + } + + m_paraSetLabelList.append(ui->labelParaType1); + m_paraSetLabelList.append(ui->labelParaType2); + m_paraSetLabelList.append(ui->labelParaType3); + m_paraSetLabelList.append(ui->labelParaType4); + m_paraSetLabelList.append(ui->labelParaType5); + m_paraSetLabelList.append(ui->labelParaType6); + m_paraSetLabelList.append(ui->labelParaType7); + m_paraSetLabelList.append(ui->labelParaType8); + m_paraSetLabelList.append(ui->labelParaType9); + m_paraSetLabelList.append(ui->labelParaType10); + m_paraSetLabelList.append(ui->labelParaType11); + m_paraSetLabelList.append(ui->labelParaType12); + m_paraSetLabelList.append(ui->labelParaType13); + m_paraSetLabelList.append(ui->labelParaType14); + + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void MainWidget::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + //上状态栏 + this->resize(1920,1080); + ui->frameBack->setGeometry(0,0,1920,1080); + ui->frameUp->setGeometry(0,0,1920,64); + ui->labelTitle->setGeometry(26,0,1200,64); + ui->labelHMIVersion->setGeometry(1095,0,790,64); + ui->buttonWifi->setGeometry(1870,16,32,32); + + //左侧主按钮 + ui->frameMainFunction->setGeometry(0,65,188,938); + ui->buttonPatternSet->setGeometry(26,0,106,106); + ui->buttonParaSet->setGeometry(26,160,106,106); + ui->buttonShortcutFunction->setGeometry(26,320,106,106); + ui->buttonAccessFunction->setGeometry(26,480,106,106); + ui->buttonMainMenu->setGeometry(26,640,106,106); + ui->labelPatternSet->setGeometry(0,106,160,32); + ui->labelParaSet->setGeometry(0,266,160,32); + ui->labelShortcutFunction->setGeometry(0,426,160,32); + ui->labelAccessFunction->setGeometry(0,586,160,32); + ui->labelMainMenu->setGeometry(0,746,160,32); + + //花样显示区域 + ui->framePatternView->setGeometry(103*factoryX,36*factoryY,656*factoryX,510*factoryY); + ui->labelPatternView->setGeometry(0,0,656*factoryX,510*factoryY);//灰色花样图 + + //右上方花样信息 + { + ui->frameEmbInfo->setGeometry(773*factoryX,33*factoryY,235*factoryX,265*factoryY); + int beginY = 25; //起始y + int gapY = 45; //竖直间距 + int valueX = 190; + int keyX = 20; + int width = 180; // 描述文字的label宽度 + int height = 35; + int valueHeight = 230; //值的label宽度 + initPatternInfo(beginY, gapY, valueX, keyX, width, height, valueHeight); + } + + //九宫格 + ui->frameFunctionBtn->setGeometry(772*factoryX,310*factoryY,240*factoryX,268*factoryY); + ui->frameSpeed->setGeometry(0,0,236*factoryX,236*factoryY); + ui->labelSpeed->setGeometry(0,0,235*factoryX,76*factoryY);//显示机器运行速度的数字的数码管64,35 + ui->labelSpeed1->setGeometry(40*factoryX,10*factoryY,39*factoryX,56*factoryY); + ui->labelSpeed2->setGeometry(79*factoryX,10*factoryY,39*factoryX,56*factoryY); + ui->labelSpeed3->setGeometry(118*factoryX,10*factoryY,39*factoryX,56*factoryY); + ui->labelSpeed4->setGeometry(157*factoryX,10*factoryY,39*factoryX,56*factoryY); + ui->buttonSpeedAdd->setGeometry(123*factoryX,80*factoryY,110*factoryX,60*factoryY); + ui->buttonSpeedDec->setGeometry(0,80*factoryY,110*factoryX,60*factoryY); + ui->buttonStartStop->setGeometry(0,160*factoryY,234*factoryX,68*factoryY); + + ui->buttonSpeedDec->setGeometry(0,90*factoryY,110*factoryX,65*factoryY); + ui->buttonSpeedAdd->setGeometry(123*factoryX,90*factoryY,110*factoryX,65*factoryY); + ui->buttonStartStop->setGeometry(0,170*factoryY,234*factoryX,68*factoryY); + + ui->frameSpeed->hide(); + ui->labelSpeed->hide(); + ui->labelSpeed1->hide(); + ui->labelSpeed2->hide(); + ui->labelSpeed3->hide(); + ui->labelSpeed4->hide(); + + ui->frameNineBtn->setGeometry(0*factoryX,0*factoryY,236*factoryX,236*factoryY); + { + int beginX = 0; + int begin1Y = 0; + int board_X = 72*factoryX; + int board_Y = 72*factoryY; + int gapX = board_X + 10*factoryX; + int gap1Y = board_Y + 10*factoryY; + ui->buttonNineBtn1->setGeometry(beginX,begin1Y,board_X,board_Y); + beginX += gapX; + ui->buttonNineBtnUp->setGeometry(beginX,begin1Y,board_X,board_Y); + beginX += gapX; + ui->buttonNineBtn2->setGeometry(beginX,begin1Y,board_X,board_Y); + beginX = 0; + begin1Y += gap1Y; + ui->buttonNineBtnLeft->setGeometry(beginX,begin1Y,board_X,board_Y); + beginX += gapX; + ui->buttonNineBtnMiddle->setGeometry(beginX,begin1Y,board_X,board_Y); + beginX += gapX; + ui->buttonNineBtnRight->setGeometry(beginX,begin1Y,board_X,board_Y); + beginX = 0; + begin1Y += gap1Y; + ui->buttonNineBtn3->setGeometry(beginX,begin1Y,board_X,board_Y); + beginX += gapX; + ui->buttonNineBtnDown->setGeometry(beginX,begin1Y,board_X,board_Y); + beginX += gapX; + ui->buttonNineBtn4->setGeometry(beginX,begin1Y,board_X,board_Y); + } + + //下方状态栏 + ui->frameDown->setGeometry(0,564*factoryY,1024*factoryX,36*factoryY); + ui->progressBar->setGeometry(4*factoryX,28*factoryY,1016*factoryX,2*factoryY); + ui->labelState->setGeometry(15*factoryX,0,200*factoryX,36*factoryY); + ui->labelWorkState->setGeometry(540*factoryX,0,200*factoryX,36*factoryX);//模拟工作 + ui->labelEnableWorkState->setGeometry(772*factoryX,11*factoryY,15*factoryX,15*factoryY);//显示工作状态 + ui->frameMenuBack->setGeometry(101*factoryX, 36*factoryY, 656*factoryX, 513*factoryY);//二级菜单的白色背景显示不齐 -rq + ui->labelScreenshot->setGeometry(0,0,1024*factoryX,36*factoryY);//截屏 + ui->buttonConnect->setGeometry(784*factoryX + 70, 11*factoryY, 15*factoryX, 15*factoryY);//链接状态 + ui->buttonUser->setGeometry(806*factoryX + 66, 11*factoryY, 15*factoryX, 15*factoryY);//用户 + ui->labelTime->setGeometry(826*factoryX + 70, 0, 200*factoryX, 36*factoryY);//时间 + + setViewFont(fontNormal_3); //字体设置 + + //辅助功能 + ui->frameAccessFunction->setGeometry(190,65,1320,934); + u16 hNum = 6;//每行6个 + u16 vNum = 4;//总共4行 + for(int i = 0; i < vNum; i++) + { + for(int j = 0; j < hNum; j++) + { + m_assistBtnList[i*hNum+j]->setGeometry(75+190*j,48+202*i,106,106); + m_assistLabelList[i*hNum+j]->setGeometry(45+190*j,154+202*i,165,45); + } + } + + //花样设置 + ui->framePatternSet->setGeometry(190,65,1320,934); + hNum = 6;//每行6个 + vNum = 2;//总共2行 + for(int i = 0; i < vNum; i++) + { + for(int j = 0; j < hNum; j++) + { + m_patternSetBtnList[i*hNum+j]->setGeometry(75+190*j,48+202*i,106,106); + m_patternSetLabelList[i*hNum+j]->setGeometry(45+190*j,154+202*i,165,66);//1920x1080 英文显示不全 -rq + } + } + + //参数设置 + ui->frameParaSet->setGeometry(190,65,1320,934); + hNum = 6;//每行6个 + vNum = 2;//总共2行 + for(int i = 0; i < vNum; i++) + { + for(int j = 0; j < hNum; j++) + { + m_paraSetBtnList[i*hNum+j]->setGeometry(59+183*j,48+202*i,106,106); + m_paraSetLabelList[i*hNum+j]->setGeometry(29+183*j,154+202*i,165,45); + } + } + + //快进回退 + ui->frameForwardBack->setGeometry(770*factoryX,37*factoryY,240*factoryX,514*factoryY); + ui->frameForwardBackBack->setGeometry(0,0,240*factoryX,514*factoryY); + ui->buttonNeedleIdxImage->setGeometry(23*factoryX,45*factoryY,8*factoryX,25*factoryY); + ui->labelForwardBackTitle->setGeometry(30*factoryX,20*factoryY,155*factoryX,28*factoryY); + ui->labelNeedleCurAndTotal->setGeometry(30*factoryX,50*factoryY,155*factoryX,28*factoryY); + + int boardX = 85*factoryX; + int boardY = 43*factoryY; + int x1begin = 30*factoryX; + int x2begin = x1begin + boardX +10*factoryX; + int ybegin = 110*factoryY; + + ui->buttonNeedleBegin->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleEnd->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47*factoryY; + ui->buttonNeedleDec1->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd1->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47*factoryY; + ui->buttonNeedleDec10->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd10->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47*factoryY; + ui->buttonNeedleDec100->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd100->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47*factoryY; + ui->buttonNeedleDec1000->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd1000->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47*factoryY; + ui->buttonNeedleDec10000->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd10000->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47*factoryY; + ui->buttonElementDec->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonElementAdd->setGeometry(x2begin,ybegin,boardX,boardY); + + ybegin += 47*factoryY; + ui->buttonForwardBackOk->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonForwardBackCancel->setGeometry(x2begin,ybegin,boardX,boardY); + + //快捷功能 + ui->frameShortcutFunction->setGeometry(190,65,1320,934); + hNum = 6;//每行6个 + vNum = 4;//总共4行 + for(int i = 0; i < vNum; i++) + { + for(int j = 0; j < hNum; j++) + { + m_quickBtnList[i*hNum+j]->setGeometry(75+190*j,48+202*i,106,106); + m_quickLabelList[i*hNum+j]->setGeometry(45+190*j,154+202*i,165,45); + } + } + +} + +//初始化窗体控件为1024x600分辨率 +void MainWidget::initResolution1006() +{ + this->resize(1024,600); + ui->frameBack->setGeometry(0,0,1024,600); + ui->frameUp->setGeometry(0,0,1024,30); + ui->labelTitle->setGeometry(15,2,350,30); + ui->labelHMIVersion->setGeometry(595,2,400,30); + ui->buttonWifi->setGeometry(1000,11,15,15); + + //左侧主按钮 + ui->frameMainFunction->setGeometry(0,36,98,532);// x坐标 y坐标 宽高 + ui->buttonPatternSet->setGeometry(13,0,58,58);//花样设定按钮 + ui->buttonParaSet->setGeometry(13,90,58,58);//参数设定按钮 + ui->buttonShortcutFunction->setGeometry(13,180,58,58);//快捷功能按钮 + ui->buttonAccessFunction->setGeometry(13,270,58,58);//辅助功能按钮 + ui->buttonMainMenu->setGeometry(13,360,58,58);//主界面按钮 + ui->labelPatternSet->setGeometry(8,59,70,20);//花样设定文本框 + ui->labelParaSet->setGeometry(8,149,70,20);//参数设定文本框 + ui->labelShortcutFunction->setGeometry(8,239,70,20);//快捷功能文本框 + ui->labelAccessFunction->setGeometry(8,329,70,20);//辅助功能文本框 + ui->labelMainMenu->setGeometry(8,419,70,20);//主界面文本框 + + //九宫格 + ui->frameFunctionBtn->setGeometry(772,310,240,268);// x y w h + ui->frameSpeed->setGeometry(0,0,236,236); + ui->labelSpeed->setGeometry(0,0,235,76);//显示机器运行速度的数字的数码管64,35 + ui->labelSpeed1->setGeometry(40,10,39,56); + ui->labelSpeed2->setGeometry(79,10,39,56); + ui->labelSpeed3->setGeometry(118,10,39,56); + ui->labelSpeed4->setGeometry(157,10,39,56); + ui->buttonSpeedDec->setGeometry(0,90,110,65); + ui->buttonSpeedAdd->setGeometry(123,90,110,65); + ui->buttonStartStop->setGeometry(0,170,234,68); + + ui->frameSpeed->hide(); + ui->labelSpeed->hide(); + ui->labelSpeed1->hide(); + ui->labelSpeed2->hide(); + ui->labelSpeed3->hide(); + ui->labelSpeed4->hide(); + ui->buttonSpeedAdd->hide(); + ui->buttonSpeedDec->hide(); + ui->buttonStartStop->hide(); + ui->frameNineBtn->setGeometry(0,0,236,236); + + {//board_nine 为单个按钮边长,gap_nine为间距大小 + int board_nine = 70; + int gap_nine = 13; + int beginX = 0; + int gapX = board_nine + gap_nine; + int begin1Y = 0; + int gap1Y = board_nine + gap_nine; + ui->buttonNineBtn1->setGeometry(beginX,begin1Y,board_nine,board_nine); + beginX += gapX; + ui->buttonNineBtnUp->setGeometry(beginX,begin1Y,board_nine,board_nine); + beginX += gapX; + ui->buttonNineBtn2->setGeometry(beginX,begin1Y,board_nine,board_nine); + beginX = 0; + begin1Y += gap1Y; + ui->buttonNineBtnLeft->setGeometry(beginX,begin1Y,board_nine,board_nine); + beginX += gapX; + ui->buttonNineBtnMiddle->setGeometry(beginX,begin1Y,board_nine,board_nine); + beginX += gapX; + ui->buttonNineBtnRight->setGeometry(beginX,begin1Y,board_nine,board_nine); + beginX = 0; + begin1Y += gap1Y; + ui->buttonNineBtn3->setGeometry(beginX,begin1Y,board_nine,board_nine); + beginX += gapX; + ui->buttonNineBtnDown->setGeometry(beginX,begin1Y,board_nine,board_nine); + beginX += gapX; + ui->buttonNineBtn4->setGeometry(beginX,begin1Y,board_nine,board_nine); + } + + //字体设置 + setViewFont(fontNormal_4); + + //下方状态栏 + ui->frameDown->setGeometry(0,564,1024,36); + ui->progressBar->setGeometry(4,28,1016,2); + ui->labelState->setGeometry(15,0,200,36); + ui->labelWorkState->setGeometry(540,0,200,36);//模拟工作 + ui->labelEnableWorkState->setGeometry(772,11,15,15);//显示工作状态 + ui->frameMenuBack->setGeometry(101,36,656,513);//二级菜单的白色背景显示不齐 -rq + ui->labelScreenshot->setGeometry(0,0,1024,36);//截屏 + ui->buttonConnect->setGeometry(784,11,15,15);//链接状态 + ui->buttonUser->setGeometry(806,11,15,15);//用户 + ui->labelTime->setGeometry(826,0,200,36);//时间 + + //右上方花样信息 + { + ui->frameEmbInfo->setGeometry(773,33,235,265); + int beginY = 20; //起始y + int gapY = 32; //竖直间距 + int valueX = 100; + int keyX = 10; + int width = 120; // 描述文字的label宽度 + int height = 30; + int valueHeight = 120; //值的label宽度 + initPatternInfo(beginY, gapY, valueX, keyX, width, height, valueHeight); + } + + + //花样显示区域 + ui->framePatternView->setGeometry(103,36,656,510); + ui->labelPatternView->setGeometry(0,0,656,510);//灰色花样图 + + //辅助功能 + ui->frameAccessFunction->setGeometry(108,36,707,513); + u16 hNum = 6;//每行6个 + u16 vNum = 4;//总共4行 + for(int i = 0; i < vNum; i++) + { + for(int j = 0; j < hNum; j++) + { + m_assistBtnList[i*hNum+j]->setGeometry(30+103*j,24+106*i,58,58); + m_assistLabelList[i*hNum+j]->setGeometry(12+103*j,84+106*i,95,30);//字体显示不全 -rq + } + } + + //花样设置 + ui->framePatternSet->setGeometry(108,36,707,513); + hNum = 6;//每行7个 + vNum = 2;//总共2行 + for(int i = 0; i < vNum; i++) + { + for(int j = 0; j < hNum; j++) + { + m_patternSetBtnList[i*hNum+j]->setGeometry(30+103*j,24+106*i,58,58); + m_patternSetLabelList[i*hNum+j]->setGeometry(12+103*j,84+106*i,95,30); + } + } + + //参数设置 + ui->frameParaSet->setGeometry(108,36,656,513); + hNum = 6;//每行6个 + vNum = 2;//总共2行 + for(int i = 0; i < vNum; i++) + { + for(int j = 0; j < hNum; j++) + { + m_paraSetBtnList[i*hNum+j]->setGeometry(30+103*j,24+106*i,58,58); + m_paraSetLabelList[i*hNum+j]->setGeometry(12+103*j,84+106*i,95,30); + } + } + + //快进回退 + ui->frameForwardBack->setGeometry(770,37,240,514); + ui->frameForwardBackBack->setGeometry(0,0,240,514); + ui->buttonNeedleIdxImage->setGeometry(23,45,8,25); + ui->labelForwardBackTitle->setGeometry(30,20,155,28); + ui->labelNeedleCurAndTotal->setGeometry(30,50,155,28); + + int boardX = 85; + int boardY = 42; + int x1begin = 30; + int x2begin = x1begin + boardX +10; + int ybegin = 110; + ui->buttonNeedleBegin->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleEnd->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47; + ui->buttonNeedleDec1->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd1->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47; + ui->buttonNeedleDec10->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd10->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47; + ui->buttonNeedleDec100->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd100->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47; + ui->buttonNeedleDec1000->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd1000->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47; + ui->buttonNeedleDec10000->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonNeedleAdd10000->setGeometry(x2begin,ybegin,boardX,boardY); + ybegin += 47; + ui->buttonElementDec->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonElementAdd->setGeometry(x2begin,ybegin,boardX,boardY); + + ybegin += 47; + ui->buttonForwardBackOk->setGeometry(x1begin,ybegin,boardX,boardY); + ui->buttonForwardBackCancel->setGeometry(x2begin,ybegin,boardX,boardY); + + //快捷功能 + ui->frameShortcutFunction->setGeometry(108,36,656,513);//(108,36,707,513) + hNum = 6;//每行6个 + vNum = 4;//总共4行 + for(int i = 0; i < vNum; i++) + { + for(int j = 0; j < hNum; j++) + { + m_quickBtnList[i*hNum+j]->setGeometry(30+103*j,24+106*i,58,58); + m_quickLabelList[i*hNum+j]->setGeometry(12+103*j,84+106*i,95,42); + } + } + +} + +//初始化窗体控件样式 +void MainWidget::initControlStyle() +{ + //上状态栏时间 + ui->labelTime->setStyleSheet(LABELWHITESTYLE); + ui->buttonWifi->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonWifi->objectName()+"Unconnect")); + + //背景透明 + ui->frameUp->setStyleSheet(TRANSPARENTSTYLE); + ui->frameMainFunction->setStyleSheet(TRANSPARENTSTYLE); + ui->frameAccessFunction->setStyleSheet(TRANSPARENTSTYLE); + ui->framePatternSet->setStyleSheet(TRANSPARENTSTYLE); + ui->frameShortcutFunction->setStyleSheet(TRANSPARENTSTYLE); + ui->frameParaSet->setStyleSheet(TRANSPARENTSTYLE); + ui->frameDown->setStyleSheet(TRANSPARENTSTYLE); + ui->frameEmbInfo->setStyleSheet(TRANSPARENTSTYLE); + + ui->framePatternView->setStyleSheet(TRANSPARENTSTYLE); + ui->frameFunctionBtn->setStyleSheet(TRANSPARENTSTYLE); + QString style = "background-color: rgb(246, 242, 239);outline:none;border:0px;border-radius:10px;"; + ui->frameMenuBack->setStyleSheet(style); + + //设置控件图标 + //背景图 + int waterMark = g_pSettings->readFromIniFile("HMI/waterMark").toInt();//是否带水印 + QString backGroundImgPath; + if(waterMark == 1) + { + backGroundImgPath = m_setControlStyle.getBorderImageStyleSheet(this->objectName()); + } + else if(waterMark == 0) + { + backGroundImgPath = m_setControlStyle.getBorderImageStyleSheet(this->objectName() + "_NoWaterMark"); + qDebug()<frameBack->setStyleSheet(backGroundImgPath); + if(g_emDebugMode == debugMode) + { + ui->labelTitle->setStyleSheet(LABELREDSTYLE); + } + else + { + ui->labelTitle->setStyleSheet(LABELWHITESTYLE); + } + + //获得绘制区域的背景图,用于embdata绘制刷新图形时的背景 + int x = ui->labelPatternView->x() + ui->framePatternView->x(); + int y = ui->labelPatternView->y() + ui->framePatternView->y(); + QImage MainWidgetPix; + MainWidgetPix.load(getBackImagePath(waterMark));//主界面背景图 + + //从主界面背景图截取等于labelPatternView的背景图 + m_embBackPix = QPixmap(ui->labelPatternView->width(),ui->labelPatternView->height()); + m_embBackPix = QPixmap::fromImage(MainWidgetPix.copy(x,y,m_embBackPix.width(),m_embBackPix.height())); + + //状态图标 + ui->buttonConnect->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonConnect->objectName()+"Unconnected")); + ui->buttonUser->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonUser->objectName())); + + //主功能键图标 + ui->labelMainMenu->setStyleSheet(LABELWHITESTYLE); + ui->labelPatternSet->setStyleSheet(LABELWHITESTYLE); + ui->labelAccessFunction->setStyleSheet(LABELWHITESTYLE); + ui->labelParaSet->setStyleSheet(LABELWHITESTYLE); + ui->labelShortcutFunction->setStyleSheet(LABELWHITESTYLE); + //ui->buttonMainMenu->setCheckedBottomImage(m_setControlStyle.getBottomStyleSheet(ui->buttonMainMenu->parent()->objectName())); + ui->buttonMainMenu->setMainBtnBottomStyle(); + ui->buttonMainMenu->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonMainMenu->objectName())); + ui->buttonPatternSet->setMainBtnBottomStyle(); + ui->buttonPatternSet->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonPatternSet->objectName())); + ui->buttonAccessFunction->setMainBtnBottomStyle(); + ui->buttonAccessFunction->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonAccessFunction->objectName())); + ui->buttonParaSet->setMainBtnBottomStyle(); + ui->buttonParaSet->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonParaSet->objectName())); + ui->buttonShortcutFunction->setMainBtnBottomStyle(); + ui->buttonShortcutFunction->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonShortcutFunction->objectName())); + + //速度加减图标 + ui->labelSpeed->setStyleSheet(m_setControlStyle.getStyleSheet("labelSpeed")); + ui->buttonStartStop->setBottomImage(m_setControlStyle.getBottomStyleSheet(ui->buttonStartStop->objectName())); + ui->buttonStartStop->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonStartStop->objectName())); + ui->buttonSpeedAdd->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonSpeedAdd->objectName())); + ui->buttonSpeedAdd->setBottomImage(m_setControlStyle.getBottomStyleSheet(ui->buttonSpeedAdd->objectName())); + ui->buttonSpeedDec->setBottomImage(m_setControlStyle.getBottomStyleSheet(ui->buttonSpeedDec->parent()->objectName())); + ui->buttonSpeedDec->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonSpeedDec->objectName())); + ui->buttonSpeedDec->setBottomImage(m_setControlStyle.getBottomStyleSheet(ui->buttonSpeedDec->objectName())); + + //绣作信息 + ui->lab_FileName->setText(tr("FileName")); //文件 + ui->lab_Index->setText(tr("Index")); //索引 + ui->lab_StartPoint->setText(tr("StartPoint")); // 起始点 + ui->lab_Locate->setText(tr("LocatePoint")); // 定位点 + ui->lab_Range->setText(tr("Range")); // 范围 + ui->lab_Position->setText(tr("Position")); //位置 + ui->lab_Production->setText(tr("Production")); //产量 + ui->lab_FileName->setAlignment(Qt::AlignLeft); + ui->lab_Index->setAlignment(Qt::AlignLeft); + ui->lab_StartPoint->setAlignment(Qt::AlignLeft); + ui->lab_Locate->setAlignment(Qt::AlignLeft); + ui->lab_Range->setAlignment(Qt::AlignLeft); + ui->lab_Position->setAlignment(Qt::AlignLeft); + ui->lab_Production->setAlignment(Qt::AlignLeft); + ui->lab_FileName_2->setAlignment(Qt::AlignRight); + ui->lab_Index_2->setAlignment(Qt::AlignRight); + ui->lab_StartPoint_2->setAlignment(Qt::AlignRight); + ui->lab_Locate_2->setAlignment(Qt::AlignRight); + ui->lab_Range_2->setAlignment(Qt::AlignRight); + ui->lab_Position_2->setAlignment(Qt::AlignRight); + ui->lab_Production_2->setAlignment(Qt::AlignRight); + + ui->lab_FileName->setStyleSheet(LABELWHITESTYLE); + ui->lab_Index->setStyleSheet(LABELWHITESTYLE); + ui->lab_StartPoint->setStyleSheet(LABELWHITESTYLE); + ui->lab_Locate->setStyleSheet(LABELWHITESTYLE); + ui->lab_Range->setStyleSheet(LABELWHITESTYLE); + ui->lab_Position->setStyleSheet(LABELWHITESTYLE); + ui->lab_Production->setStyleSheet(LABELWHITESTYLE); + ui->lab_FileName_2->setStyleSheet(LABELWHITESTYLE); + ui->lab_Index_2->setStyleSheet(LABELWHITESTYLE); + ui->lab_StartPoint_2->setStyleSheet(LABELWHITESTYLE); + ui->lab_Locate_2->setStyleSheet(LABELWHITESTYLE); + ui->lab_Range_2->setStyleSheet(LABELWHITESTYLE); + ui->lab_Position_2->setStyleSheet(LABELWHITESTYLE); + ui->lab_Production_2->setStyleSheet(LABELWHITESTYLE); + + //九宫格图标 + ui->buttonNineBtnUp->setBottomImage(m_setControlStyle.getBottomStyleSheet("buttonNineBtn")); + ui->buttonNineBtnDown->setBottomImage(m_setControlStyle.getBottomStyleSheet("buttonNineBtn")); + ui->buttonNineBtnLeft->setBottomImage(m_setControlStyle.getBottomStyleSheet("buttonNineBtn")); + ui->buttonNineBtnMiddle->setBottomImage(m_setControlStyle.getBottomStyleSheet("buttonNineBtn")); + ui->buttonNineBtnRight->setBottomImage(m_setControlStyle.getBottomStyleSheet("buttonNineBtn")); + + ui->buttonNineBtnUp->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtnUp->objectName())); + ui->buttonNineBtnDown->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtnDown->objectName())); + ui->buttonNineBtnLeft->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtnLeft->objectName())); + ui->buttonNineBtnMiddle->setTopImage(m_setControlStyle.getTopStyleSheet("frameNineBtnMiddle_2"));//默认速度等级为2 + ui->buttonNineBtnRight->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtnRight->objectName())); + + + ui->buttonNineBtn1->setBottomImage(m_setControlStyle.getBottomStyleSheet(ui->buttonNineBtn1->parent()->objectName())); + ui->buttonNineBtn2->setBottomImage(m_setControlStyle.getBottomStyleSheet(ui->buttonNineBtn2->parent()->objectName())); + ui->buttonNineBtn3->setBottomImage(m_setControlStyle.getBottomStyleSheet(ui->buttonNineBtn3->parent()->objectName())); + ui->buttonNineBtn4->setBottomImage(m_setControlStyle.getBottomStyleSheet(ui->buttonNineBtn4->parent()->objectName())); + + ui->buttonNineBtn1->setTopImage(m_setControlStyle.getTopStyleSheet(m_nineBtn.value(1).m_topImageName)); + ui->buttonNineBtn2->setTopImage(m_setControlStyle.getTopStyleSheet(m_nineBtn.value(2).m_topImageName)); + ui->buttonNineBtn3->setTopImage(m_setControlStyle.getTopStyleSheet(m_nineBtn.value(3).m_topImageName)); + ui->buttonNineBtn4->setTopImage(m_setControlStyle.getTopStyleSheet(m_nineBtn.value(4).m_topImageName)); + + //快进快退 + ui->frameForwardBack->setStyleSheet(TRANSPARENTSTYLE); + QString frameForwardBackBackImgPath = m_setControlStyle.getStyleSheet(ui->frameForwardBackBack->objectName()); + + ui->frameForwardBackBack->setStyleSheet(frameForwardBackBackImgPath); + ui->labelForwardBackTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelNeedleCurAndTotal->setStyleSheet(LABELWHITESTYLE); + ui->buttonNeedleBegin->setWhiteBlueBottomStyle(); + ui->buttonNeedleEnd->setWhiteBlueBottomStyle(); + ui->buttonNeedleAdd1->setWhiteBlueBottomStyle(); + ui->buttonNeedleDec10000->setWhiteBlueBottomStyle(); + ui->buttonNeedleAdd10->setWhiteBlueBottomStyle(); + ui->buttonNeedleAdd100->setWhiteBlueBottomStyle(); + ui->buttonNeedleAdd1000->setWhiteBlueBottomStyle(); + ui->buttonNeedleAdd10000->setWhiteBlueBottomStyle(); + ui->buttonNeedleDec1->setWhiteBlueBottomStyle(); + ui->buttonNeedleDec10->setWhiteBlueBottomStyle(); + ui->buttonNeedleDec100->setWhiteBlueBottomStyle(); + ui->buttonNeedleDec1000->setWhiteBlueBottomStyle(); + ui->buttonElementDec->setWhiteBlueBottomStyle(); + ui->buttonElementAdd->setWhiteBlueBottomStyle(); + + ui->buttonNeedleBegin->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleBegin->objectName())); + ui->buttonNeedleEnd->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleEnd->objectName())); + ui->buttonNeedleAdd1->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleAdd1->objectName())); + ui->buttonNeedleAdd10->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleAdd10->objectName())); + ui->buttonNeedleAdd100->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleAdd100->objectName())); + ui->buttonNeedleAdd1000->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleAdd1000->objectName())); + ui->buttonNeedleAdd10000->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleAdd10000->objectName())); + ui->buttonNeedleDec1->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleDec1->objectName())); + ui->buttonNeedleDec10->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleDec10->objectName())); + ui->buttonNeedleDec100->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleDec100->objectName())); + ui->buttonNeedleDec1000->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleDec1000->objectName())); + ui->buttonNeedleDec10000->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNeedleDec10000->objectName())); + ui->buttonElementDec->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonElementDec->objectName())); + ui->buttonElementAdd->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonElementAdd->objectName())); + + ui->buttonForwardBackOk->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonForwardBackOk->setTopImage(m_setControlStyle.getSharedTopStyleSheet("buttonOk"),0,5,0,0); + ui->buttonForwardBackCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonForwardBackCancel->setTopImage(m_setControlStyle.getSharedTopStyleSheet("buttonCancel"),0,5,0,0); + + //快捷功能图标 + for(int i = 0; i < m_quickLabelList.size(); i++) + { + m_quickLabelList[i]->setWordWrap(true); + //28个快捷按钮的底图相同 + m_quickBtnList[i]->setOrangeGradientBottomStyle(BORDER_RADIUS1); + } + + //辅助功能图标 + for(int i = 0; i < m_assistLabelList.size(); i++) + { + //28个快捷按钮的底图相同 + m_assistBtnList[i]->setOrangeGradientBottomStyle(BORDER_RADIUS1); + } + + //花样设置功能图标 + for(int i = 0; i < m_patternSetLabelList.size(); i++) + { + //底图相同 + m_patternSetBtnList[i]->setOrangeGradientBottomStyle(BORDER_RADIUS1); + } + + //参数设置功能图标 + for(int i = 0; i < m_paraSetLabelList.size(); i++) + { + //底图相同 + m_paraSetBtnList[i]->setOrangeGradientBottomStyle(BORDER_RADIUS1); + } + + //下方状态及版本 + ui->progressBar->setStyleSheet(PROGRESSBARSTYLE); + ui->progressBar->setValue(0); + ui->labelState->setStyleSheet(LABELWHITESTYLE); + ui->labelWorkState->setStyleSheet(LABELWHITESTYLE); + ui->labelHMIVersion->setStyleSheet(LABELWHITESTYLE); +} + +//获取背景图的加载路径 +QString MainWidget::getBackImagePath(s16 waterMark) +{ + //<分辨率><主题><窗体名称><图片名称> + QString path = ":/images/"; + + //分辨率 + QString str; + str.clear(); + switch (g_emResolut) + { + case resolution1910: + str = "_1910_logo.png"; + break; + case resolution1006: + str = "_1006_logo.png"; + break; + default: + break; + } + + path += this->objectName() + "/" + this->objectName(); + if(waterMark == 0)//无水印 + { + path += "_NoWaterMark" + str; + } + else + { + path += str; + } + + //qDebug()< "9") + { + return; + } + } + + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + //ui->labelScreenshot->setStyleSheet(setControlStyle.getStyleSheet("labelScreenshot")); + + if(speedsize == 1)//如果是一位数 + {//4显示 + ui->labelSpeed1->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + ui->labelSpeed2->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + ui->labelSpeed3->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + QString getnum; + getnum = speed.mid(0,1); + QString str_label_3 = "Speed" + getnum; + ui->labelSpeed4->setStyleSheet(setControlStyle.getStyleSheet(str_label_3)); + + } + else if (speedsize == 2)//如果是2位 + {//3,4显示 + ui->labelSpeed1->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + ui->labelSpeed2->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + QString getnum; + getnum = speed.mid(0,1); //十位 + QString str_label_2 = "Speed" + getnum; + ui->labelSpeed3->setStyleSheet(setControlStyle.getStyleSheet(str_label_2)); + + getnum = speed.mid(1,1); //个位 + QString str_label_3 = "Speed" + getnum; + ui->labelSpeed4->setStyleSheet(setControlStyle.getStyleSheet(str_label_3)); + } + else if (speedsize == 3) + { + ui->labelSpeed1->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + + QString getnum; + getnum = speed.mid(0,1); //百位 + QString str_label_2 = "Speed" + getnum; + ui->labelSpeed2->setStyleSheet(setControlStyle.getStyleSheet(str_label_2)); + + getnum = speed.mid(1,1); //十位 + QString str_label_3 = "Speed" + getnum; + ui->labelSpeed3->setStyleSheet(setControlStyle.getStyleSheet(str_label_3)); + + getnum = speed.mid(2,1); //个位 + QString str_label_4 = "Speed" + getnum; + ui->labelSpeed4->setStyleSheet(setControlStyle.getStyleSheet(str_label_4)); + + } + else if (speedsize == 4)//如果是4位数 + { + QString getnum; + + getnum = speed.mid(0,1); //百位 + QString str_label_1 = "Speed" + getnum; + ui->labelSpeed1->setStyleSheet(setControlStyle.getStyleSheet(str_label_1)); + + getnum = speed.mid(1,1); //百位 + QString str_label_2 = "Speed" + getnum; + ui->labelSpeed2->setStyleSheet(setControlStyle.getStyleSheet(str_label_2)); + + getnum = speed.mid(2,1); //十位 + QString str_label_3 = "Speed" + getnum; + ui->labelSpeed3->setStyleSheet(setControlStyle.getStyleSheet(str_label_3)); + + getnum = speed.mid(3,1); //个位 + QString str_label_4 = "Speed" + getnum; + ui->labelSpeed4->setStyleSheet(setControlStyle.getStyleSheet(str_label_4)); + } + else + { + ui->labelSpeed1->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + ui->labelSpeed2->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + ui->labelSpeed3->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + ui->labelSpeed4->setStyleSheet(setControlStyle.getStyleSheet("SpeedShut")); + } +} + +void MainWidget::setViewFont(QFont font) +{ + //字体设置 + ui->labelTime->setFont(font); + ui->labelMainMenu->setFont(font); + ui->labelPatternSet->setFont(font); + ui->labelAccessFunction->setFont(font); + ui->labelParaSet->setFont(font); + ui->labelShortcutFunction->setFont(font); + ui->lab_FileName_2->setFont(font); + ui->lab_Index_2->setFont(font); + ui->lab_StartPoint_2->setFont(font); + ui->lab_Locate_2->setFont(font); + ui->lab_Range_2->setFont(font); + ui->lab_Position_2->setFont(font); + ui->lab_Production_2->setFont(font); + ui->lab_FileName->setFont(font); + ui->lab_Index->setFont(font); + ui->lab_StartPoint->setFont(font); + ui->lab_Locate->setFont(font); + ui->lab_Range->setFont(font); + ui->lab_Position->setFont(font); + ui->lab_Production->setFont(font); + ui->labelForwardBackTitle->setFont(font); + ui->labelNeedleCurAndTotal->setFont(font); + ui->labelTitle->setFont(font); + //快捷功能图标 + for(int i = 0; i < m_quickLabelList.size(); i++) + { + m_quickLabelList[i]->setFont(font); + } + + //辅助功能图标 + for(int i = 0; i < m_assistLabelList.size(); i++) + { + m_assistLabelList[i]->setFont(font); + } + + //花样设置功能图标 + for(int i = 0; i < m_patternSetLabelList.size(); i++) + { + m_patternSetLabelList[i]->setFont(font); + } + + //参数设置功能图标 + for(int i = 0; i < m_paraSetLabelList.size(); i++) + { + m_paraSetLabelList[i]->setFont(font); + } + ui->labelState->setFont(font); + ui->labelHMIVersion->setFont(font); +} + +//发送初始化字符串 +void MainWidget::sendInitString(QString str) +{ + Qt::Alignment alignment = Qt::AlignHCenter|Qt::AlignBottom; // 设置一个格式 + emit(siSendLoadingMessage(str, alignment, Qt::red)); +} + +//刷新连接状态(1秒) +void MainWidget::refConnectUi(int alive) +{ + alive = 0; + refConnectUi(g_pMachine, m_linkSta, alive); +} + +//刷新连接状态 +void MainWidget::refConnectUi(Machine *pMachine, int &linkSta, int alive) +{ + if(m_ifHMIDecrypt == 0) + { + return; + } + + if(m_connectMode == USE_SERIAL_COMM)//串口连接方式 + { + if(linkSta != pMachine->isConnected()) + { + linkSta = pMachine->isConnected(); + if(linkSta == Connected) + { + if (pMachine != NULL) + { + //连接后获取机器信息,用于获得剩余可用时间,小于5天主动提示用户 + //此条语句需放在前面 + pMachine->getInfoFromMachine(); + + pMachine->getSensorEnBmpFromMachine();//读取传感器信号 + pMachine->getParasFromMachine();//获取参数 + m_pMinTimer->start();//1分钟记录一次当前系统时间 ,连接成功以后开启计时器,记录时间 -rq + m_pMainWidgetFunction->setShutDownTime();//计算关机时间 + + ui->buttonConnect->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonConnect->objectName())); + ui->labelState->setText(tr("Connected"));//状态:已连接 + } + } + else + { + ui->buttonConnect->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonConnect->objectName()+"Unconnected")); + ui->labelState->setText(tr("Not connected"));//状态:未连接 + } + } + } + else + { + if (pMachine != NULL) + { + if (linkSta != pMachine->isConnected() || + pMachine->isConnected() == Connectting || + alive == -1) + { + if (alive == -1) + { + linkSta = 0; + } + else + { + linkSta = pMachine->isConnected();//获取连接状态 + } + + if (linkSta == Connectting)//连接中... + { + ui->buttonConnect->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonConnect->objectName()+"Connecting")); + ui->labelState->setText(tr("Connnecting..."));//状态:连接中... + } + else if (linkSta == Connected)//已连接 + { + //连接后获取机器信息,用于获得剩余可用时间,小于5天主动提示用户 + //此条语句需放在前面 + pMachine->getInfoFromMachine(); + + pMachine->getSensorEnBmpFromMachine();//读取传感器信号 + pMachine->getParasFromMachine();//获取参数 + m_pMinTimer->start();//1分钟记录一次当前系统时间 ,连接成功以后开启计时器,记录时间 -rq + m_pMainWidgetFunction->setShutDownTime();//计算关机时间 + + ui->buttonConnect->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonConnect->objectName())); + ui->labelState->setText(tr("Connected"));//状态:已连接 + + /*** + 界面启动时也会发送最后绣作的花样文件, + 连接成功后也会发送,但连接速度快,此时ds数据可能还没转换完成, + 所以连接成功后发送文件可能不成功,只是界面加载时会发送文件, + 因此二者不会重复发送文件;若断开连接再连接时此段代码会发送文件, + 界面加载部分不会发送; + ***/ + QByteArray ds16dat = g_pCurEmbData->getDsDat();//获得ds16数据 + //如果当前所选文件路径不为空与ds16数据不为空时 + if(m_curFilePath.length() > 0 && ds16dat.size() > 0) + { + //m_pMainWidgetFunction->sendPatternData(m_curFilePath);//发送花样数据 + //设置为按进度执行模式 + //g_pCurEmbData->setExecIndex(m_curDatIdx); // 设置进度 + } + } + else//未连接 + { + ui->buttonConnect->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonConnect->objectName()+"Unconnected")); + ui->labelState->setText(tr("Not connected"));//状态:未连接 + } + } + } + } +} + +//隐藏菜单栏(frame) +void MainWidget::hideMenuFrame() +{ + ui->frameMenuBack->setVisible(false); + ui->framePatternView->setVisible(false); + ui->framePatternSet->setVisible(false); + ui->frameParaSet->setVisible(false); + ui->frameAccessFunction->setVisible(false); + ui->frameShortcutFunction->setVisible(false); + + //设置按钮为非选中状态 + ui->buttonPatternSet->setChecked(false); + ui->buttonPatternSet->setCheckable(false); + ui->buttonAccessFunction->setChecked(false); + ui->buttonAccessFunction->setCheckable(false); + ui->buttonParaSet->setChecked(false); + ui->buttonParaSet->setCheckable(false); + ui->buttonShortcutFunction->setChecked(false); + ui->buttonShortcutFunction->setCheckable(false); + ui->buttonMainMenu->setChecked(false); + ui->buttonMainMenu->setCheckable(false); +} + +//根据文件格式不同显示不同花样参数 +void MainWidget::showDiffPara(QString ext,s16 setFlag) +{ + if(setFlag == 0) + { + memset((char*)&m_patternSetPara,0,sizeof(PatternSetPara)); + //得到花样参数 + if(ext == "DST") + { + //绣花花样参数-花样设置参数 + m_pParameterSetDlg->setItemList(operate,PARA_TYPE_PATTERN,PATTERNPARA_SORT_DSTR); + + DstHead *head = NULL; + DataFileDst dst; + dst.initFile(m_curFilePath); + head = dst.getDstHead(); + if(head == NULL) + { + head = new DstHead(); + memset((char*)head,0,sizeof(DstHead)); + } + dst.getBeginXYAndAnchorXY(head->startX,head->startY,head->anchorX,head->anchorY); + + m_patternSetPara.rotateStyle = head->rotateStyle; + m_patternSetPara.rotateAngle = head->rotateAngle; + m_patternSetPara.scanX = head->scanX; + m_patternSetPara.scanY = head->scanY; + m_patternSetPara.left = head->left; + m_patternSetPara.front = head->front; + m_patternSetPara.reinMode = head->reinMode; + m_patternSetPara.reinNeedles = head->reinNeedles; + m_patternSetPara.reinNum = head->reinNum; + m_patternSetPara.normalStep = head->normalStep; + m_patternSetPara.angleCorrOffset = head->angleCorrOffset; + m_patternSetPara.angleCorrPosX = head->angleCorrPosX; + m_patternSetPara.angleCorrPosY = head->angleCorrPosY; + m_patternSetPara.angleCorrNegX = head->angleCorrNegX; + m_patternSetPara.angleCorrNegY = head->angleCorrNegY; + m_patternSetPara.startX = head->startX; + m_patternSetPara.startY = head->startY; + m_patternSetPara.anchorX = head->anchorX; + m_patternSetPara.anchorY = head->anchorY; + } + else if(ext == "DSR") + { + //绣花花样参数-花样设置参数 + m_pParameterSetDlg->setItemList(operate,PARA_TYPE_PATTERN,PATTERNPARA_SORT_DSTR); + + DsrHead *head = NULL; + DataFileDsr dsr; + dsr.initFile(m_curFilePath); + head = dsr.getDsrHead(); + if(head == NULL) + { + head = new DsrHead(); + memset((char*)head,0,sizeof(DsrHead)); + } + dsr.getBeginXYAndAnchorXY(*(int*)&head->startX,*(int*)&head->startY,*(int*)&head->anchorX,*(int*)&head->anchorY); + + m_patternSetPara.rotateStyle = head->rotateStyle; + m_patternSetPara.rotateAngle = head->rotateAngle; + m_patternSetPara.scanX = head->scanX; + m_patternSetPara.scanY = head->scanY; + m_patternSetPara.left = head->left; + m_patternSetPara.front = head->front; + m_patternSetPara.reinMode = head->reinMode; + m_patternSetPara.reinNeedles = head->reinNeedles; + m_patternSetPara.reinNum = head->reinNum; + m_patternSetPara.normalStep = head->normalStep; + m_patternSetPara.angleCorrOffset = head->angleCorrOffset; + m_patternSetPara.angleCorrPosX = head->angleCorrPosX; + m_patternSetPara.angleCorrPosY = head->angleCorrPosY; + m_patternSetPara.angleCorrNegX = head->angleCorrNegX; + m_patternSetPara.angleCorrNegY = head->angleCorrNegY; + m_patternSetPara.startX = head->startX; + m_patternSetPara.startY = head->startY; + m_patternSetPara.anchorX = head->anchorX; + m_patternSetPara.anchorY = head->anchorY; + } + else if(ext == "QUI") + { + //绣花花样参数-花样设置参数 + m_pParameterSetDlg->setItemList(operate,PARA_TYPE_PATTERN,PATTERNPARA_SORT_QUI); + + QuiFileHead *head = NULL; + DataFileQui qui; + qui.initFile(m_curFilePath); + head = qui.getQuiHead(); + if(head == NULL) + { + head = new QuiFileHead(); + memset((char*)head,0,sizeof(QuiFileHead)); + } + + m_patternSetPara.rotateStyle = head->rotateStyle; + m_patternSetPara.rotateAngle = head->rotateAngle; + m_patternSetPara.normalStep = head->normalStep; + m_patternSetPara.reinMode = head->reinMode; + m_patternSetPara.reinNeedles = head->reinNeedles; + m_patternSetPara.reinNum = head->reinNum; + m_patternSetPara.angleCorrOffset = head->angleCorrOffset; + m_patternSetPara.angleCorrPosX = head->angleCorrPosX; + m_patternSetPara.angleCorrNegX = head->angleCorrNegX; + m_patternSetPara.angleCorrPosY = head->angleCorrPosY; + m_patternSetPara.angleCorrNegY = head->angleCorrNegY; + m_patternSetPara.left = head->left; + m_patternSetPara.front = head->front; + m_patternSetPara.scanX = head->scanX; + m_patternSetPara.scanY = head->scanY; + } + else if(ext == "QUIX") + { + //绣花花样参数-花样设置参数 + m_pParameterSetDlg->setItemList(operate,PARA_TYPE_PATTERN,PATTERNPARA_SORT_QUI); + + QuixFileHead *head = NULL; + DataFileQuix quix; + quix.initFile(m_curFilePath); + head = quix.getQuixHead(); + if(head == NULL) + { + head = new QuixFileHead(); + memset((char*)head,0,sizeof(QuixFileHead)); + } + + m_patternSetPara.rotateStyle = head->rotateStyle; + m_patternSetPara.rotateAngle = head->rotateAngle; + m_patternSetPara.normalStep = head->normalStep; + m_patternSetPara.reinMode = head->reinMode; + m_patternSetPara.reinNeedles = head->reinNeedles; + m_patternSetPara.reinNum = head->reinNum; + m_patternSetPara.angleCorrOffset = head->angleCorrOffset; + m_patternSetPara.angleCorrPosX = head->angleCorrPosX; + m_patternSetPara.angleCorrNegX = head->angleCorrNegX; + m_patternSetPara.angleCorrPosY = head->angleCorrPosY; + m_patternSetPara.angleCorrNegY = head->angleCorrNegY; + m_patternSetPara.left = head->left; + m_patternSetPara.front = head->front; + m_patternSetPara.scanX = head->scanX; + m_patternSetPara.scanY = head->scanY; + } + + m_pParameterSetDlg->setItemValue(SET_ROTATESTYLE, m_patternSetPara.rotateStyle); //旋转式样 + m_pParameterSetDlg->setItemValue(SET_ROTATEANGLE, m_patternSetPara.rotateAngle); //旋转角度 + m_pParameterSetDlg->setItemValue(SET_SETSTEPSIZE, m_patternSetPara.normalStep); //针步大小 + m_pParameterSetDlg->setItemValue(SET_REINMODE, m_patternSetPara.reinMode); //加固方式 + m_pParameterSetDlg->setItemValue(SET_REINNEEDLE, m_patternSetPara.reinNeedles); //加固针数 + m_pParameterSetDlg->setItemValue(SET_REINNUM, m_patternSetPara.reinNum); //加固次数 + m_pParameterSetDlg->setItemValue(SET_ANGLECORROFFSET, m_patternSetPara.angleCorrOffset); //角度修正量 + m_pParameterSetDlg->setItemValue(SET_ANGLECORRPOSX, m_patternSetPara.angleCorrPosX); //角度修正量X正 + m_pParameterSetDlg->setItemValue(SET_ANGLECORRNEGX, m_patternSetPara.angleCorrNegX); //角度修正量X负 + m_pParameterSetDlg->setItemValue(SET_ANGLECORRPOSY, m_patternSetPara.angleCorrPosY); //角度修正量Y正 + m_pParameterSetDlg->setItemValue(SET_ANGLECORRNEGY, m_patternSetPara.angleCorrNegY); //角度修正量Y负 + m_pParameterSetDlg->setItemValue(SET_SETLEFT, m_patternSetPara.left); //左边 + m_pParameterSetDlg->setItemValue(SET_SETFRONT, m_patternSetPara.front); //前边 + m_pParameterSetDlg->setItemValue(SET_SCANX, m_patternSetPara.scanX); //缩放x + m_pParameterSetDlg->setItemValue(SET_SCANY, m_patternSetPara.scanY); //缩放y + m_pParameterSetDlg->setItemValue(SET_ANCHORX, m_patternSetPara.anchorX); //定位点X + m_pParameterSetDlg->setItemValue(SET_ANCHORY, m_patternSetPara.anchorY); //定位点Y + m_pParameterSetDlg->setItemValue(SET_STARTX, m_patternSetPara.startX); //起始点X + m_pParameterSetDlg->setItemValue(SET_STARTY, m_patternSetPara.startY); //起始点Y + } + else if(setFlag != 0) + { + //文件头花样参数 + m_patternSetPara.rotateStyle = m_pParameterSetDlg->getItemValue(SET_ROTATESTYLE); //旋转式样 + m_patternSetPara.rotateAngle = m_pParameterSetDlg->getItemValue(SET_ROTATEANGLE); //旋转角度 + m_patternSetPara.normalStep = m_pParameterSetDlg->getItemValue(SET_SETSTEPSIZE); //针步大小 + m_patternSetPara.reinMode = m_pParameterSetDlg->getItemValue(SET_REINMODE); //加固方式 + m_patternSetPara.reinNeedles = m_pParameterSetDlg->getItemValue(SET_REINNEEDLE); //加固针数 + m_patternSetPara.reinNum = m_pParameterSetDlg->getItemValue(SET_REINNUM); //加固次数 + m_patternSetPara.angleCorrOffset = m_pParameterSetDlg->getItemValue(SET_ANGLECORROFFSET); //角度修正量 + m_patternSetPara.angleCorrPosX = m_pParameterSetDlg->getItemValue(SET_ANGLECORRPOSX); //角度修正x正 + m_patternSetPara.angleCorrNegX = m_pParameterSetDlg->getItemValue(SET_ANGLECORRNEGX); //角度修正x负 + m_patternSetPara.angleCorrPosY = m_pParameterSetDlg->getItemValue(SET_ANGLECORRPOSY); //角度修正y正 + m_patternSetPara.angleCorrNegY = m_pParameterSetDlg->getItemValue(SET_ANGLECORRNEGY); //角度修正y负 + m_patternSetPara.left = m_pParameterSetDlg->getItemValue(SET_SETLEFT); //左边 + m_patternSetPara.front = m_pParameterSetDlg->getItemValue(SET_SETFRONT); //前边 + m_patternSetPara.scanX = m_pParameterSetDlg->getItemValue(SET_SCANX); //缩放x + m_patternSetPara.scanY = m_pParameterSetDlg->getItemValue(SET_SCANY); //缩放y + m_patternSetPara.anchorX = m_pParameterSetDlg->getItemValue(SET_ANCHORX); //定位点X + m_patternSetPara.anchorY = m_pParameterSetDlg->getItemValue(SET_ANCHORY); //定位点Y + m_patternSetPara.startX = m_pParameterSetDlg->getItemValue(SET_STARTX); //起始点X + m_patternSetPara.startY = m_pParameterSetDlg->getItemValue(SET_STARTY); //起始点Y + } +} + +//计算起始点和定位点并设置 +void MainWidget::calPointsAndSet() +{ + //计算起始点和定位点,并把定位点和起始点更新到ds16数据中 + //花版的定位点为绝对坐标数据点,起始点为相对于定位点的相对坐标点,第一针为相对于起始点的坐标点 + //有的花版起始点有偏移量,第一针偏移量为0,有的花版起始点偏移量为0,第一针有偏移量 + //所以ds16文件头定位点坐标就是花版中的定位点,起始点坐标为花版中的定位点坐标+起始点坐标+第一针的坐标,同时ds16数据的第一针坐标偏移应置为0 + + //单针绗缝机根据向前、向后重新计算起始点 + if(g_emMacType == MACHINE_HIGHSPEEDSINGLEQUI) + { + int left = m_patternSetPara.left; + int front = m_patternSetPara.front; + int minX = g_pCurEmbData->getMinX(); + int minY = g_pCurEmbData->getMinY(); + int oldBeginX = g_pCurEmbData->getBeginX(); + int oldBeginY = g_pCurEmbData->getBeginY(); + int newBeginX = oldBeginX - minX + left; + int newBeginY = oldBeginY - minY + front; + + m_pMainWidgetFunction->funSetStartPoint(m_curFilePath,newBeginX,newBeginY); + } + //五头机、服装机需要设置定位点和起始点 + if(g_emMacType == MACHINE_FIVEHEADPRECISIONSEWING || + g_emMacType == MACHINE_CLOTHINGMAC) + { + m_pMainWidgetFunction->funSetStartPoint(m_curFilePath,m_patternSetPara.startX,m_patternSetPara.startY); + m_pMainWidgetFunction->funSetAnchorPoint(m_curFilePath,m_patternSetPara.anchorX,m_patternSetPara.anchorY); + } +} + +s16 MainWidget::appendDiffAbsData(QString ext) +{ + //添加一个花样文件 + if(ext == "DST")//dst文件 + { + DataFileDst dst; + dst.initFile(m_curFilePath); + dst.convertDataToAbs(); + + //将花样参数配置写回到源文件中 + DstHead *head = dst.getDstHead(); + if(head == NULL){return -1;} + + head->rotateStyle = m_patternSetPara.rotateStyle; + head->rotateAngle = m_patternSetPara.rotateAngle; + head->scanX = m_patternSetPara.scanX; + head->scanY = m_patternSetPara.scanY; + head->left = m_patternSetPara.left; + head->front = m_patternSetPara.front; + head->reinMode = m_patternSetPara.reinMode; + head->reinNeedles = m_patternSetPara.reinNeedles; + head->reinNum = m_patternSetPara.reinNum; + head->normalStep = m_patternSetPara.normalStep; + head->angleCorrOffset = m_patternSetPara.angleCorrOffset; + head->angleCorrPosX = m_patternSetPara.angleCorrPosX; + head->angleCorrPosY = m_patternSetPara.angleCorrPosY; + head->angleCorrNegX = m_patternSetPara.angleCorrNegX; + head->angleCorrNegY = m_patternSetPara.angleCorrNegY; + + dst.writePatternParaToFile(head); + g_pCurEmbData->setAbsDat(dst.getEmbAbsData()); + + m_patternSetPara.scanX = head->scanX*10; + m_patternSetPara.scanY = head->scanY*10; + m_patternSetPara.normalStep *= 10; + } + else if(ext == "DSR")//dsr文件 + { + DataFileDsr dsr; + dsr.initFile(m_curFilePath); + dsr.convertDataToEmbAbs();//转换为绝对数据(中间数据) + + //将花样参数配置写回到源文件中 + DsrHead *head = dsr.getDsrHead(); + if(head == NULL){return -1;} + + head->rotateStyle = m_patternSetPara.rotateStyle; + head->rotateAngle = m_patternSetPara.rotateAngle; + head->scanX = m_patternSetPara.scanX; + head->scanY = m_patternSetPara.scanY; + head->left = m_patternSetPara.left; + head->front = m_patternSetPara.front; + head->reinMode = m_patternSetPara.reinMode; + head->reinNeedles = m_patternSetPara.reinNeedles; + head->reinNum = m_patternSetPara.reinNum; + head->normalStep = m_patternSetPara.normalStep; + head->angleCorrOffset = m_patternSetPara.angleCorrOffset; + head->angleCorrPosX = m_patternSetPara.angleCorrPosX; + head->angleCorrPosY = m_patternSetPara.angleCorrPosY; + head->angleCorrNegX = m_patternSetPara.angleCorrNegX; + head->angleCorrNegY = m_patternSetPara.angleCorrNegY; + + dsr.writePatternParaToFile(head); + m_patternSetPara.scanX = head->scanX*10; + m_patternSetPara.scanY = head->scanY*10; + m_patternSetPara.normalStep *= 10; + g_pCurEmbData->setAbsDat(dsr.getEmbAbsData()); //得到转换后的绝对坐标数据 + } + else if(ext == "QUI") + { + DataFileQui qui; + qui.initFile(m_curFilePath); + + //将花样参数配置写回到源文件中,需放在转换中间数据之前,因为中间数据需要根据文件头参数进行数据变换 + QuiFileHead *head = qui.getQuiHead(); + if(head == NULL){return -1;} + + head->rotateStyle = m_patternSetPara.rotateStyle; + head->rotateAngle = m_patternSetPara.rotateAngle; + head->normalStep = m_patternSetPara.normalStep; + head->reinMode = m_patternSetPara.reinMode; + head->reinNeedles = m_patternSetPara.reinNeedles; + head->reinNum = m_patternSetPara.reinNum; + head->angleCorrOffset = m_patternSetPara.angleCorrOffset; + head->angleCorrPosX = m_patternSetPara.angleCorrPosX; + head->angleCorrPosY = m_patternSetPara.angleCorrPosY; + head->angleCorrNegX = m_patternSetPara.angleCorrNegX; + head->angleCorrNegY = m_patternSetPara.angleCorrNegY; + head->left = m_patternSetPara.left; + head->front = m_patternSetPara.front; + head->scanX = m_patternSetPara.scanX; + head->scanY = m_patternSetPara.scanY; + qui.writePatternParaToFile(head); + + qui.convertDataToEmbAbs();//转换为绝对数据(中间数据) + g_pCurEmbData->setAbsDat(qui.getEmbAbsData());//得到转换后的绝对坐标数据 + + m_patternSetPara.scanX = 0; + m_patternSetPara.scanY = 0; + m_patternSetPara.normalStep = 0; + } + else if(ext == "QUIX") + { + DataFileQuix quix; + quix.initFile(m_curFilePath); + + //将花样参数配置写回到源文件中,需放在转换中间数据之前,因为中间数据需要根据文件头参数进行数据变换 + QuixFileHead *head = quix.getQuixHead(); + if(head == NULL){return -1;} + + head->rotateStyle = m_patternSetPara.rotateStyle; + head->rotateAngle = m_patternSetPara.rotateAngle; + head->normalStep = m_patternSetPara.normalStep; + head->reinMode = m_patternSetPara.reinMode; + head->reinNeedles = m_patternSetPara.reinNeedles; + head->reinNum = m_patternSetPara.reinNum; + head->angleCorrOffset = m_patternSetPara.angleCorrOffset; + head->angleCorrPosX = m_patternSetPara.angleCorrPosX; + head->angleCorrPosY = m_patternSetPara.angleCorrPosY; + head->angleCorrNegX = m_patternSetPara.angleCorrNegX; + head->angleCorrNegY = m_patternSetPara.angleCorrNegY; + head->left = m_patternSetPara.left; + head->front = m_patternSetPara.front; + head->scanX = m_patternSetPara.scanX; + head->scanY = m_patternSetPara.scanY; + quix.writePatternParaToFile(head); + + quix.convertDataToEmbAbs();//转换为绝对数据(中间数据) + g_pCurEmbData->setAbsDat(quix.getEmbAbsData());//得到转换后的绝对坐标数据 + + m_patternSetPara.scanX = 0; + m_patternSetPara.scanY = 0; + m_patternSetPara.normalStep = 0; + } + else if(ext == "PLT") + { + ImportHPGL importHPGL; + + if (importHPGL.IsSecretFile(m_curFilePath) == true) + { + // 文件路径 + QDir apppath(qApp->applicationDirPath()); + QString strSecretFile = apppath.path() + apppath.separator() + "Secret.plt"; + + importHPGL.BitMapDtat(m_curFilePath,strSecretFile); + importHPGL.IniPara(); + importHPGL.ReadSecretFile(strSecretFile); + } + else + { + importHPGL.IniPara(); + importHPGL.Read(m_curFilePath); + } + importHPGL.convertDataToEmbAbs();// 转换为绝对数据(中间数据) + QByteArray ary = importHPGL.getEmbAbsData(); + g_pCurEmbData->setAbsDat(ary);//得到转换后的绝对坐标数据 + } + else if(ext == "DXF") + { + } + else + { + return -1; + } + return 0; +} + +//重置所有数据 +void MainWidget::resetAllData() +{ + m_forwardBackNeedleIdx = 0; + ui->frameForwardBack->setVisible(false); + + g_pCurEmbData->getDsDat(); + g_pCurEmbData->setEmbData(g_emMacType);// ds16数据转换为画图数据 + + //加载图片的进度条显示 + ui->progressBar->setVisible(true); + int value = g_pCurEmbData->getStitchNums() / TENTHOUSANDNEEDLE; + ui->progressBar->setRange(1,value); + ui->progressBar->setValue(1); + + m_dispMode = EmbData::DISP_ALL_EXEC; + g_pCurEmbData->setDispMode(m_dispMode, 1); // 重新画图 + m_dispMode = EmbData::DISP_EXECING; // 设置为执行模式 + g_pCurEmbData->setDispMode(m_dispMode, 0); // 设置为按进度执行模式 + + m_curDatIdx = 0; + + ui->framePatternView->setVisible(true); + QPixmap patternPix = g_pCurEmbData->getPreviewImage(); + ui->labelPatternView->setPixmap(patternPix); + + ui->lab_Index_2->setText("0/0"); + ui->lab_StartPoint_2->setText("0/0"); + ui->lab_Locate_2->setText("0/0"); + ui->lab_Range_2->setText("0/0"); + ui->lab_Position_2->setText("0/0"); + ui->lab_Production_2->setText("0"); + + ui->progressBar->setVisible(false); +} + +//花样选择 +void MainWidget::patternSelect() +{ + //获得花样选择的图标字符 + QString tStyle; + for(int i = 0; i < m_patternSetItemList.size(); i++) + { + if(m_patternSetItemList[i].m_enumFunction == PATTERNSET_PATTERNSELECT) + { + QString topImageName = m_patternSetItemList[i].m_topImageName; + //加载按钮顶图图标 + tStyle = m_setControlStyle.getTopStyleSheet(topImageName); + + break; + } + } + + m_pPatternSelectWi->setTypeLogo(tStyle); + m_pPatternSelectWi->setMainTitle(tr("Pattern selection")); + m_pPatternSelectWi->setSubTitle(tr("Pattern setting > Pattern selection")); + + m_pPatternSelectWi->createCurDirPatterns(); + m_pPatternSelectWi->show(); + + //showPatternPreview(); +} + +//显示机器运行状态中的信息 +void MainWidget::showExecInfo() +{ + // 速度 + if (m_curRpm != (int)m_mcStatus.runSpeed) // 运行速度 + { + m_curRpm = (int)m_mcStatus.runSpeed; + QString str; + str.sprintf("%d", m_curRpm); + showWorkSpeed(str); + } + + // 文件执行进度(当前针数) labelNeedleIdx + if (m_curDatIdx != (int)m_mcStatus.dataIdx) + { + m_curDatIdx = (int)m_mcStatus.dataIdx; + reSetDatIdx(m_curDatIdx); + QPixmap patternPix = g_pCurEmbData->getPreviewImage(); + ui->labelPatternView->setPixmap(patternPix); + } + + //针数索引 + ui->lab_Index_2->setText(QString("%1/%2").arg(QString::number(m_curDatIdx)).arg(QString::number(m_mcStatus.needleNum))); + + //产量 + ui->lab_Production_2->setText(QString::number(m_mcStatus.outCounter)); + + // 当前xy绝对坐标 + double xPos = m_mcStatus.xPos*0.01; + double yPos = m_mcStatus.yPos*0.01; + QString xyStr = QString("%1/%2").arg(QString::number(xPos,'f',1)).arg(QString::number(yPos,'f',1)); + ui->lab_Position_2->setText(xyStr); + +} + +void MainWidget::showPatternPreview() +{ + hideMenuFrame(); + QFile curfile(m_curFilePath); + if(m_curFilePath.length() <= 0 || + (!curfile.exists()))//未选择文件时不显示颜色和花样信息 + { + ui->framePatternView->setVisible(false); + } + else + { + ui->framePatternView->setVisible(true); + ui->labelPatternView->setVisible(true);//非预览模式绘制区域 + } + + //主界面按钮选中 + ui->buttonMainMenu->setCheckable(true); + ui->buttonMainMenu->setChecked(true); +} + +//设置UI界面按钮的使能 +void MainWidget::setUiBtnEnable(bool bValue) +{ + ui->frameMainFunction->setEnabled(bValue); + ui->buttonNineBtn1->setEnabled(bValue); + ui->buttonNineBtn2->setEnabled(bValue); + ui->buttonNineBtn3->setEnabled(bValue); + ui->buttonNineBtnUp->setEnabled(bValue); + ui->buttonNineBtnDown->setEnabled(bValue); + ui->buttonNineBtnLeft->setEnabled(bValue); + ui->buttonNineBtnRight->setEnabled(bValue); +} + +void MainWidget::showSpeedFrame() +{ + //其他按钮隐藏,显示调速表和调速按钮 + ui->buttonNineBtn4->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtn4->objectName()+"Unlock")); +// ui->frameNineBtn->setStyleSheet(m_setControlStyle.getBorderImageStyleSheet(ui->frameNineBtn->objectName()+"Disable")); + + ui->frameNineBtn->hide(); + ui->buttonNineBtn1->hide(); + ui->buttonNineBtnUp->hide(); + ui->buttonNineBtn2->hide(); + ui->buttonNineBtnLeft->hide(); + ui->buttonNineBtnMiddle->hide(); + ui->buttonNineBtnRight->hide(); + ui->buttonNineBtn3->hide(); + ui->buttonNineBtnDown->hide(); + ui->buttonNineBtn4->hide(); + //显示调速表和调速按钮 + ui->frameSpeed->show(); + ui->buttonSpeedAdd->show(); + ui->labelSpeed->show();//显示机器运行速度的数字的数码管 + ui->labelSpeed1->show(); + ui->labelSpeed2->show(); + ui->labelSpeed3->show(); + ui->labelSpeed4->show(); + ui->buttonSpeedDec->show(); + ui->buttonStartStop->show(); +} + +void MainWidget::showNineFrame() +{ + //进入到待机状态,隐藏调速表,显示方向键 + ui->buttonNineBtn4->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtn4->objectName())); + + ui->frameSpeed->hide(); + ui->buttonSpeedAdd->hide(); + ui->labelSpeed->hide(); + ui->labelSpeed1->hide(); + ui->labelSpeed2->hide(); + ui->labelSpeed3->hide(); + ui->labelSpeed4->hide(); + ui->buttonSpeedDec->hide(); + //显示调速表和调速按钮 + ui->frameNineBtn->show(); + ui->buttonNineBtn1->show(); + ui->buttonNineBtn2->show(); + ui->buttonNineBtn3->show(); + ui->buttonNineBtn4->show(); + ui->buttonNineBtnDown->show(); + ui->buttonNineBtnLeft->show(); + ui->buttonNineBtnMiddle->show(); + ui->buttonNineBtnRight->show(); + ui->buttonNineBtnUp->show(); +} + +void MainWidget::setNotExecing() +{ + if(m_dispMode != EmbData::DISP_EXECING)//不是执行状态,重置 + { + g_pCurEmbData->setViewInfo(m_embBackPix);//带背景图的背景 + g_pCurEmbData->setDrawMode(EmbData::DRAW_VIEW);//非预览模式 + g_pCurEmbData->setEmbData(g_emMacType);//ds16数据转换为画图数据 + + m_dispMode = EmbData::DISP_ALL_EXEC; + g_pCurEmbData->setDispMode(m_dispMode, 1); // 重新画图 + + m_dispMode = EmbData::DISP_EXECING; // 设置为执行模式 + g_pCurEmbData->setDispMode(m_dispMode, 0); // 设置为按进度执行模式 + g_pCurEmbData->setExecIndex(m_curDatIdx); // 设置进度 + + QPixmap patternPix = g_pCurEmbData->getPreviewImage(); + ui->labelPatternView->setPixmap(patternPix); + } +} + +void MainWidget::reSetDatIdx(int newidx) +{ + int totalStitchNum = g_pCurEmbData->getStitchNums(); + + if (newidx <= 0) + { + m_curDatIdx = 0; // 当前执行进度 + } + else if (newidx >= totalStitchNum) + { + m_curDatIdx = m_curDatIdx - 1; // 当前执行进度 + } + + // 文件idx信息 + QString str; + str.sprintf("%d", m_curDatIdx); + QString indexStr = ui->lab_Index_2->text(); + QString newindexStr = QString("%1/%2").arg(m_curDatIdx).arg(indexStr.right(indexStr.size() - indexStr.indexOf('/') - 1)); + ui->lab_Index_2->setText(newindexStr); + + // 更新进度显示 + g_pCurEmbData->setExecIndex(m_curDatIdx); +} + +//前进回退 +void MainWidget::funForwardOrBack() +{ + + //显示主界面 + hideMenuFrame(); + setUiBtnEnable(false); + showPatternPreview(); + m_forwardBackNeedleIdx = m_curDatIdx; + + g_pCurEmbData->setExecIndex(m_forwardBackNeedleIdx);// 更新进度显示 + + QPixmap patternPix = g_pCurEmbData->getPreviewImage(); + ui->labelPatternView->setPixmap(patternPix); + + int totalStitchNum = g_pCurEmbData->getStitchNums(); + QString strNeedle; + strNeedle.sprintf("%d / %d",m_forwardBackNeedleIdx,totalStitchNum); + ui->labelNeedleCurAndTotal->setText(strNeedle); + + ui->frameForwardBack->setVisible(true); + ui->frameForwardBack->raise(); +} + +void MainWidget::addOrDecNeedleIdx(int &idx) +{ + if( g_pMachine == NULL || 0 ) + { + return; + } + + if(idx < 0) + { + idx = 0; + } + + int totalStitchNum = g_pCurEmbData->getStitchNums();//总针数 + if(idx > totalStitchNum) + { + idx = totalStitchNum; + } + + memset(&m_expara,0,sizeof(FileExecPara)); + + int posx, posy, cidx; + g_pCurEmbData->getPosInfoFromNeedleIdx(idx, posx, posy, cidx); + + m_expara.newIdx = idx; + m_expara.newXPos = posx; + m_expara.newYPos = posy; + m_expara.newRPos = 0; + + QString strNeedle; + strNeedle.sprintf("%d / %d",idx,totalStitchNum); + ui->labelNeedleCurAndTotal->setText(strNeedle); + + //画执行进度图 + g_pCurEmbData->setExecIndex(idx);// 更新针数 + + QPixmap patternPix = g_pCurEmbData->getPreviewImage(); + ui->labelPatternView->setPixmap(patternPix); +} + +//获取常用按钮样式 +QString MainWidget::getCommonBtnStyle(int idx) +{ + QString styleStr; + //检测快捷按钮条目 + for(int i = 0; i < m_quickItemList.size(); i++)//快捷功能中的快捷条目列表 + { + int enumFun = m_quickItemList[i].m_enumFunction; + if(idx == enumFun)//功能索引等于快捷按钮功能索引 + { + //获取顶层图标样式表 + styleStr = m_quickItemList[i].m_topImageName; + break; + } + } + + if(idx == FUN_PATTERNSELECT)//功能索引等于花样选择 + { + //获得花样选择的图标字符 + for(int i = 0; i < m_patternSetItemList.size(); i++) + { + if(m_patternSetItemList[i].m_enumFunction == PATTERNSET_PATTERNSELECT) + { + styleStr = m_patternSetItemList[i].m_topImageName; + break; + } + } + } + + return styleStr; +} + +void MainWidget::runCommonBtnFunction(int idx) +{ + if(m_pMainWidgetFunction == NULL) + { + return; + } + switch (idx) + { + case FUN_ALLTOZERO://全部归零 + m_pMainWidgetFunction->funAllToZero(); + break; + case FUN_SPINDLEJOG://主轴点动(平绣,毛巾) + m_pMainWidgetFunction->funSpindleJog(); + break; + case FUN_SPINDLEROTATE://主轴旋转 + m_pMainWidgetFunction->funSpindleRotate(); + break; + case FUN_BACKWORKPOINT://回工作点 + m_pMainWidgetFunction->funBackWorkPoint(); + break; + case FUN_BACKTOORIGIN://回原点 + m_pMainWidgetFunction->funBackToOrigin(); + break; + case FUN_SETOFFSETPOINT://定偏移点 + m_pMainWidgetFunction->funSetOffsetPoint(); + break; + case FUN_BACKOFFSETPOINT://回偏移点 + m_pMainWidgetFunction->funBackOffsetPoint(); + break; + case FUN_SETSTARTPOINT://定起始点 + m_pMainWidgetFunction->funSetStartPoint(m_curFilePath,m_mcStatus.xPos,m_mcStatus.yPos,1); + ui->lab_Position_2->setText(QString("%1/%2").arg(QString::number(m_mcStatus.xPos*0.01,'f',1)).arg(QString::number(m_mcStatus.yPos*0.01,'f',1))); + break; + case FUN_BACKSTARTPOINT:// 回起针点 + m_pMainWidgetFunction-> funBackStartPoint(); + break; + case FUN_CHECKFRAME://边框检查 + m_pMainWidgetFunction->funBorderCheck(); + break; + case FUN_FORWARDORBACK://前进回退 + funForwardOrBack(); + break; + case FUN_SIMULATEFRAME://空走边框 + m_pMainWidgetFunction->funSimulateFrame(); + break; + case FUN_PROCESSRESET://流程复位 + m_pMainWidgetFunction->funProcessReset(); + break; + case FUN_MANUALOIL://手动加油 + m_pMainWidgetFunction->funManualOil(); + break; + case FUN_PATTERNSELECT://花样选择 + patternSelect(); + break; + case FUN_SEWAUTOCHANGESHUTTLE://自动换梭 + m_pMainWidgetFunction->funChangeOneShuttle(); + break; + case FUN_SEWBUFF://缝纫状态 + // m_pMainWidgetFunction->funSewBuff(); + break; + case FUN_SHUTTLEDISKBUFF://换梭盘状态 + // m_pMainWidgetFunction->funShuttleDiskBuff(); + break; + case FUN_BACKTHREADPOINT://回穿线点 + // m_pMainWidgetFunction->funBackThreadPoint(); + break; + case FUN_BACKZEROPOINT://回零点 + // m_pMainWidgetFunction->funBackZeroPoint(); + break; + case FUN_SHUTTLETOHEAD://将旋梭从梭盘到机头 + // m_pMainWidgetFunction->funShuttleToHead(); + break; + case FUN_HEADTOSHUTTLE://将旋梭从机头到梭盘 + // m_pMainWidgetFunction->funHeadToShuttle(); + break; + case FUN_COUNTRESET://底线计数清零 + m_pMainWidgetFunction->funBottomLineCountReset(); + break; + case FUN_OUTPUTRESET://产量清零 + // m_pMainWidgetFunction->funOutputReset(); + break; + case FUN_NEDDLEZEROPOS://对针零位 + // m_pMainWidgetFunction->funNeedleZeroPos(); + break; + case FUN_SHUTTLEZEROPOS://对梭零位 + // m_pMainWidgetFunction->funShuttleZeroPos(); + break; + case FUN_MT_ALLZ://所有主轴零位 + m_pMainWidgetFunction->funAllMtZero(); + break; + case FUN_MT_ALLG://所有主轴勾线 + m_pMainWidgetFunction->funAllMtG(); + break; + case FUN_MT_ALLM://所有主轴点动 + m_pMainWidgetFunction->funAllMtM(); + break; + case FUN_MAINSHAFT_ADJUST: // 针梭校对 + m_pMainWidgetFunction->funMainshaftAdjust(); + break; + case FUN_SPINDLETEST:// 所有主轴研车 + m_pMainWidgetFunction->funAllMainShaftRun(); + break; + case FUN_SIMULATED_STATUS://模拟缝纫 + m_pMainWidgetFunction->funSimulatedSewing(); + break; + case FUN_MANUAL_THREAD_CUTTING://手动剪线 + m_pMainWidgetFunction->manualThreadCutting(); + break; + case FUN_HEAD_LIFTUPDOWN://机头升降 + m_pMainWidgetFunction->headLiftUpDown(); + break; + case FUN_HEAD_LIFTING://机头上升 + m_pMainWidgetFunction->headLifting(); + break; + case FUN_GOTO_FEEDT://回穿线点 + g_pMachine->gotoFixPos(); + break; + case FUN_MAKEUP_NOHEAD:// 取消补缝 + m_pMainWidgetFunction->makeup(MAKEUP_NOHEAD); + break; + case FUN_MAKEUP_HEAD1:// 机头1补缝 + m_pMainWidgetFunction->makeup(MAKEUP_HEAD1); + break; + case FUN_MAKEUP_HEAD2:// 机头2补缝 + m_pMainWidgetFunction->makeup(MAKEUP_HEAD2); + break; + case FUN_MAKEUP_HEAD3:// 机头3补缝 + m_pMainWidgetFunction->makeup(MAKEUP_HEAD3); + break; + case FUN_MAKEUP_HEAD4:// 机头4补缝 + m_pMainWidgetFunction->makeup(MAKEUP_HEAD4); + break; + case FUN_MAKEUP_HEAD5:// 机头5补缝 + m_pMainWidgetFunction->makeup(MAKEUP_HEAD5); + break; + case ASSIST_ThCutAct1://机头1 剪线动作 + g_pMachine->motoServoCtrl(ThreadCuttingAction1, UP_OPEN_ON); + break; + case ASSIST_ThCutAct2: + g_pMachine->motoServoCtrl(ThreadCuttingAction2, UP_OPEN_ON); + break; + case ASSIST_ThCutAct3: + g_pMachine->motoServoCtrl(ThreadCuttingAction3, UP_OPEN_ON); + break; + case ASSIST_ThCutAct4: + g_pMachine->motoServoCtrl(ThreadCuttingAction4, UP_OPEN_ON); + break; + case ASSIST_ThCutAct5: + g_pMachine->motoServoCtrl(ThreadCuttingAction5, UP_OPEN_ON); + break; + case FUN_SETANCHORPOINT:// 定定位点(服装机) + m_pMainWidgetFunction->funSetAnchorPoint(m_curFilePath,m_mcStatus.xPos,m_mcStatus.yPos,1); + break; + case FUN_BACKANCHORPOINT://回定位点 + m_pMainWidgetFunction-> funBackAnchorPoint(); + break; + case FUN_BACKSHUTTLE://回换梭位 + m_pMainWidgetFunction->funBackShuttlePos(); + break; + case FUN_NEEDLESHUTTLERESET://针梭校对 + m_pMainWidgetFunction->funNeedleShuttleReset(); + break; + + default: + break; + } +} + +//执行辅助按钮功能 +void MainWidget::runAssistBtnFunction(int funEnum,int idx) +{ + if(m_pMainWidgetFunction == NULL) + { + return; + } + unsigned char cmd[6]{0X04,0xE4,0x04,0x00,0xFF,0x14}; //启动扫码器的指令 + QByteArray scanCmd((const char*)cmd,6); + QString topImageName = m_assistItemList[idx].m_topImageName; + //加载按钮顶图图标 + QString tStyle = m_setControlStyle.getTopStyleSheet(topImageName); + + switch (funEnum) + { + case ASSIST_SENSOR://传感器信号 + { + if (m_pSensorInputWi != NULL) + { + //注释掉此行代码,因为获取位图下位机会返回全on的状态, + //会使传感器界面闪一下,在连接后读取了一下,这里不再读取 + //g_pMachine->getSensorEnBmpFromMachine(); + g_pMachine->entrySensorScan(); + + m_pSensorInputWi->setTypeLogo(tStyle); + m_pSensorInputWi->setMainTitle(tr("Sensor signal")); + m_pSensorInputWi->setSubTitle(tr("Auxiliary function > Sensor signal")); + m_pSensorInputWi->show(); + } + } + break; + + case ASSIST_CONTROLACTION://控制动作 + { + if (m_pControlActionWi != NULL) + { + m_pControlActionWi->setTypeLogo(tStyle); + m_pControlActionWi->setMainTitle(tr("Control action")); + m_pControlActionWi->setSubTitle(tr("Auxiliary function > Control action")); + + m_pControlActionWi->refreshUi(); + m_pControlActionWi->show(); + } + } + break; + + case ASSIST_HMIUPGRADE://界面升级 + { + if(g_emDebugMode == nodebugMode) + { + if(g_emUser != repair)//权限不够先登录 + { + m_pMainWidgetFunction->slotUserLogin(repair); + if(g_emUser != repair)//发送登录信号后,权限如果还没改变就返回 + return; + } + if(m_pMainWidgetFunction != NULL) + { + m_pMainWidgetFunction->funHMIUpgrade(tStyle); + } + } + else + { + if(m_pMainWidgetFunction != NULL) + { + m_pMainWidgetFunction->funHMIUpgrade(tStyle); + } + } + } + break; + + case ASSIST_MCUPGRADE://主控升级 + { + if(g_emUser != repair)//权限不够先登录 + { + m_pMainWidgetFunction->slotUserLogin(repair); + if(g_emUser != repair)//发送登录信号后,权限如果还没改变就返回 + return; + } + + if(m_pMainWidgetFunction != NULL) + { + m_pMainWidgetFunction->funMCUpgrade(tStyle); + } + } + break; + + + case ASSIST_PARAIMPORT://参数导入 + { + if(g_emUser != repair)//权限不够先登录 + { + m_pMainWidgetFunction->slotUserLogin(repair); + if(g_emUser != repair)//发送登录信号后,权限如果还没改变就返回 + { + return;//就不执行下边的代码,不显示界面 + } + } + if(m_pMainWidgetFunction != NULL) + { + m_pMainWidgetFunction->funImportParameter(tStyle); + } + } + break; + + case ASSIST_PARAEXPORT://参数导出 + { + if(g_emUser != repair)//权限不够先登录 + { + m_pMainWidgetFunction->slotUserLogin(repair); + if(g_emUser != repair)//发送登录信号后,权限如果还没改变就返回 + { + return; + } + } + g_pMachine->getInfoFromMachine(); + if(m_pMainWidgetFunction != NULL) + { + m_pMainWidgetFunction->funExportParameter(); + } + } + break; + + case ASSIST_SOFTWARESET://软件设置 + { + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Accessibility")); + m_pParameterSetDlg->setSubTitle(tr("Accessibility > Software setting")); + //软件设置参数 + m_pParameterSetDlg->setItemList(operate,PARA_TYPE_SOFTWARESET); +// m_pParameterSetDlg->setItemValue(SET_THEME,g_emTheme); //主题 + int language = g_pSettings->readFromIniFile("HMI/language").toInt(); + m_pParameterSetDlg->setItemValue(SET_LANGUAGE,language); //语言 +// int fontsize = g_pSettings->readFromIniFile("HMI/fontsize").toInt(); +// m_pParameterSetDlg->setItemValue(SET_FONTSIZE,fontsize); //字体大小 + + m_pParameterSetDlg->exec(); + } + break; + + case ASSIST_AUTHORIZATION://软件授权 + { + m_pMainWidgetFunction->funSoftwareAuthor(); + } + break; + + case ASSIST_NETWORK://网络管理 + { + if(g_emUser != repair)//权限不够先登录 + { + m_pMainWidgetFunction->slotUserLogin(repair); + if(g_emUser != repair)//发送登录信号后,权限如果还没改变就返回 + { + return; + } + } + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Accessibility")); + m_pParameterSetDlg->setSubTitle(tr("Accessibility > Network Manage")); + + //网络管理参数 + //添加相应主板数的IP参数 + m_pParameterSetDlg->setNetworkItemList(PARA_TYPE_NETWORKSET); + m_pParameterSetDlg->exec(); + } + break; + + case ASSIST_WIFI: + { + if(m_pMainWidgetFunction != NULL) + { + m_pMainWidgetFunction->funWIFI(tStyle); + } + } + break; + case ASSIST_TIMESET://时间设置 + { + //得到当前时间 + QDateTime time; + time = QDateTime::currentDateTime();//获取系统现在的时间 + + QString yearStr = time.currentDateTime().toString("yyyy"); + QString monthStr = time.currentDateTime().toString("MM"); + QString dayStr = time.currentDateTime().toString("dd"); + QString hourStr = time.currentDateTime().toString("hh"); + QString minuteStr = time.currentDateTime().toString("mm"); + QString secondStr = time.currentDateTime().toString("ss"); + + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Time setting")); + m_pParameterSetDlg->setSubTitle(tr("Accessibility > Time setting")); + //时间设置参数 + m_pParameterSetDlg->setItemList(operate,PARA_TYPE_TIMESET); + m_pParameterSetDlg->setItemValue(1,yearStr.toInt()); //年 + m_pParameterSetDlg->setItemValue(2,monthStr.toInt()); //月 + m_pParameterSetDlg->setItemValue(3,dayStr.toInt()); //日 + m_pParameterSetDlg->setItemValue(4,hourStr.toInt()); //时 + m_pParameterSetDlg->setItemValue(5,minuteStr.toInt()); //分 + m_pParameterSetDlg->setItemValue(6,secondStr.toInt()); //秒 + + m_pParameterSetDlg->exec(); + } + break; + + case ASSIST_PRODUCTSTATICS://生产统计 + { + int patternBreakLineNum = 0;//花样断线停车次数 + m_pMainWidgetFunction->funProductStatistics(tStyle,m_curFilePath,patternBreakLineNum); + } + break; + + + case ASSIST_ERRORLOG://错误日志 + { + if(g_emDebugMode == nodebugMode) + { + if(g_emUser != repair)//权限不够先登录 + { + m_pMainWidgetFunction->slotUserLogin(repair); + if(g_emUser != repair)//发送登录信号后,权限如果还没改变就返回 + return; + } + if(m_pMainWidgetFunction != NULL) + { + m_pMainWidgetFunction->funJournalError(tStyle); + } + } + else + { + if(m_pMainWidgetFunction != NULL) + { + m_pMainWidgetFunction->funJournalError(tStyle); + } + } + } + break; + + case ASSIST_MCVERSION://N1版本信息 + { + g_pMachine->getInfoFromMachine(); + m_pMainWidgetFunction->funGetMCVersionInfo(); + } + break; + + case ASSIST_BOTTOMLINEDETECT://底线检测 + { + m_pMainWidgetFunction->funBottomDetect(); + } + break; + + case ASSIST_FACELINEDETECT://面线检测 + { + m_pMainWidgetFunction->funFaceDetect(); + } + break; + + + case ASSIST_SPINDLETEST://主轴研车(试机) + { + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Spindle test")); + m_pParameterSetDlg->setSubTitle(tr("Accessibility > Spindle test")); + + //超级用户参数 + m_pParameterSetDlg->setItemList(-1,operate,PARA_TYPE_SPINDLETEST); + if(m_pParameterSetDlg->exec() == 1) + { + if(g_pMachine != NULL) + { + } + } + } + break; + + case ASSIST_CHANGEASHUTTLE: //自动换一个梭 + m_pMainWidgetFunction->funChangeOneShuttle(); + break; + + case ASSIST_ROOT://超级用户 + { + if(g_emDebugMode == nodebugMode) + { + if(g_emUser != factory && g_emUser != root)//超级用户 + { + m_pMainWidgetFunction->slotUserLogin(factory); + } + if(g_emUser == factory) + { + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Root")); + m_pParameterSetDlg->setSubTitle(tr("Accessibility > Root")); + //超级用户参数 + m_pParameterSetDlg->setItemList(factory,PARA_TYPE_ROOT); + m_pParameterSetDlg->exec(); + } + else if (g_emUser == root) + { + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Root")); + m_pParameterSetDlg->setSubTitle(tr("Accessibility > Root")); + //超级用户参数 + m_pParameterSetDlg->setItemList(root,PARA_TYPE_ROOT); + m_pParameterSetDlg->exec(); + } + } + else + { + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Root")); + m_pParameterSetDlg->setSubTitle(tr("Accessibility > Root")); + //超级用户参数 + m_pParameterSetDlg->setItemList(root,PARA_TYPE_ROOT); + m_pParameterSetDlg->exec(); + } + } + break; + + case ASSIST_BOTTOMLINECOUNTRESET://底线计数复位 + { + if(m_pMainWidgetFunction != NULL) + { + m_pMainWidgetFunction->funBottomLineCountReset(); + } + } + break; + + case ASSIST_DEBUGINFO: //调试信息 + m_pMainWidgetFunction->funDebugInfo(); + break; + + case ASSIST_SHUTDOWN: //关机 + m_pMainWidgetFunction->funShutDown(); + break; + + case ASSIST_ScanTest: //扫码测试 + qDebug()<<"scanCmd send" << scanCmd.data(); + QMetaObject::invokeMethod(m_pScanComPort,"slotSendData",Q_ARG(QByteArray,scanCmd)); + break; + default: + break; + } +} + +//执行花样设置按钮功能 +void MainWidget::runPatternSetBtnFunction(int funEnum, int idx) +{ + if(m_pMainWidgetFunction == NULL) + { + return; + } + + QString topImageName = m_patternSetItemList[idx].m_topImageName; + //加载按钮顶图图标 + QString tStyle = m_setControlStyle.getTopStyleSheet(topImageName); + QString bStyle = m_setControlStyle.getBottomStyleSheet(ui->buttonAssist1->parent()->objectName()); + + switch (funEnum) + { + case PATTERNSET_PATTERNSELECT://花样选择 + patternSelect(); + break; + + case PATTERNSET_PATTERNPARA://花样参数 + //showPatternPreview(); + slotShowPatternPara(m_curFilePath); + break; + + case PATTERNSET_PATTERNIMPORT://花样导入 + { + m_pPatternManageWi->setTypeLogo(tStyle); + m_pPatternManageWi->setMainTitle(tr("Pattern import")); + m_pPatternManageWi->setSubTitle(tr("Pattern setting > Pattern import")); + + PatternManageWidget::MANAGE_MODE mode = PatternManageWidget::MANAGE_IMPORT; + + QSize size = m_pPatternSelectWi->getImageSize(); + m_pPatternManageWi->setImportImageSize(size); + m_pPatternManageWi->patternManage(mode); + } + break; + + case PATTERNSET_PATTERNEXPORT://花样导出 + { + m_pPatternManageWi->setTypeLogo(tStyle); + m_pPatternManageWi->setMainTitle(tr("Pattern export")); + m_pPatternManageWi->setSubTitle(tr("Pattern setting > Pattern export")); + + PatternManageWidget::MANAGE_MODE mode = PatternManageWidget::MANAGE_EXPORT; + m_pPatternManageWi->patternManage(mode); + } + break; + + case PATTERNSET_PATTERNDELETE://花样删除 + { + if(g_emUser != repair)//权限不够先登录 + { + m_pMainWidgetFunction->slotUserLogin(repair); + if(g_emUser != repair)//发送登录信号后,权限如果还没改变就返回 + { + return; + } + } + m_pPatternManageWi->setTypeLogo(tStyle); + m_pPatternManageWi->setMainTitle(tr("Pattern delete")); + m_pPatternManageWi->setSubTitle(tr("Pattern setting > Pattern delete")); + + PatternManageWidget::MANAGE_MODE mode = PatternManageWidget::MANAGE_DELETE; + m_pPatternManageWi->patternManage(mode); + } + break; + + default: + break; + } + +} + +//等待超时 +void MainWidget::slotWaitTimout() +{ + m_timoutflag = 1; +} + +//机器状态 +void MainWidget::slotMachineStatus(int toggle) +{ + memcpy(&m_mcStatus, &g_pMachine->getMcStatus(), sizeof(MCStatus)); + + if(m_pMainWidgetFunction != NULL) + { + //收到主控发的机器状态改变的信号,进到这个槽函数里(在MainWidgetFunction.cpp里用于读取电位器值) + m_pMainWidgetFunction->setMcStates(m_mcStatus); + } + m_conFlag = toggle; + + showExecInfo();//显示机器运行状态中的信息 + + //工作状态,工作中按钮不可按,并显示大图 + if(m_workStatus != m_mcStatus.workStatus) + { + m_workStatus = m_mcStatus.workStatus; + + if ((m_workStatus & WORK_STA_SIMULATE) == WORK_STA_SIMULATE) //模拟工作 + { + + ui->labelWorkState->setText(tr("Simulated sewing"));//模拟缝纫 + +// ui->labelWorkState->setStyleSheet(m_setControlStyle.getStyleSheet(ui->labelWorkState->objectName())); +// ui->buttonNineBtn3->setBlueBorderBottomStyle(); +// ui->buttonNineBtn3->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtn3->objectName()+"Simulate")); + ui->labelWorkState->setVisible(true); + } + else //正常工作 + { + ui->labelWorkState->setText(tr("Normal operation"));//正常工作 +// ui->buttonNineBtn3->setBlueBorderBottomStyle(); +// ui->buttonNineBtn3->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtn3->objectName())); + ui->labelWorkState->setVisible(true); + } + + if ((m_workStatus & WORK_STA_ENSTATE) == WORK_STA_ENSTATE) //允许状态 + { +// ui->buttonNineBtn2->setBlueBorderBottomStyle(); +// ui->buttonNineBtn2->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtn2->objectName())); +// ui->labelEnableWorkState->setVisible(false); + } + else //正常工作 + { + //禁止工作 +// ui->labelEnableWorkState->setStyleSheet(m_setControlStyle.getStyleSheet(ui->labelEnableWorkState->objectName())); +// ui->buttonNineBtn2->setBlueBorderBottomStyle(); +// ui->buttonNineBtn2->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtn2->objectName()+"NoAllow")); +// ui->labelEnableWorkState->setVisible(true); + } + + //开始扫码 + if((m_workStatus & WORK_STA_EN_SCAN) == WORK_STA_EN_SCAN) + { + qDebug()<< "WORK_STA_EN_SCAN true"; + unsigned char cmd[6]{0X04,0xE4,0x04,0x00,0xFF,0x14}; //启动扫码器的指令 详见文档ScanHome扫码器指令控制设置-V4.0 + QByteArray scanCmd((const char*)cmd,6); + QMetaObject::invokeMethod(m_pScanComPort,"slotSendData",Q_ARG(QByteArray,scanCmd)); + } + + //正在工作,按钮不可按 + if((m_workStatus & WORK_STA_WORKING) == WORK_STA_WORKING) + { +// ui->buttonNineBtn4->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtn4->objectName()+"Unlock")); +// ui->frameNineBtn->setStyleSheet(m_setControlStyle.getBorderImageStyleSheet(ui->frameNineBtn->objectName()+"Disable")); + qDebug()<< "正在工作"; + showSpeedFrame(); + setUiBtnEnable(false); + + //不是执行状态,重置 + setNotExecing(); + +// ui->frameForwardBack->setVisible(false); + if(!ui->labelPatternView->isVisible())//不是主图灰图界面 + { + hideMenuFrame(); + showPatternPreview(); + ui->buttonMainMenu->setCheckable(true); + ui->buttonMainMenu->setChecked(true); + } + + //如果工作中错误提示窗体显示,则自动消失 + m_pMainWidgetFunction->funSetPromptDlgVisibleFalse(); + } + else + { + showNineFrame(); + setUiBtnEnable(true); +// ui->buttonNineBtn4->setTopImage(m_setControlStyle.getTopStyleSheet(ui->buttonNineBtn4->objectName())); +// ui->frameNineBtn->setStyleSheet(m_setControlStyle.getBorderImageStyleSheet(ui->frameNineBtn->objectName())); + } + } + + //错误代码 + if (m_mcStatus.errorCode == 0) + { + m_errorCode = m_mcStatus.errorCode; + ui->labelState->setText(tr("Ready"));//状态:已就绪 + if((m_workStatus & WORK_STA_WORKING) == WORK_STA_WORKING) + { + ui->labelState->setText(tr("Working"));//状态: 工作中 + } + } + else + { + u32 errcode = m_mcStatus.errorCode; + if(errcode != m_errorCode) + { + m_errorCode = errcode; + + QString info; + info.clear(); + info = getErrStr(m_mcStatus.errorCode); + //如果不是通用错误(即info为空),就从机型cpp中的错误代码查找 + if(info.length() <= 0) + { + for(int i = 0; i < m_errorCodeAndStateItemList.size(); i++) + { + if(m_mcStatus.errorCode == m_errorCodeAndStateItemList[i].m_code) + { + info = m_errorCodeAndStateItemList[i].m_name; + break; + } + } + } + //如果不是通用错误也不是机型cpp中的错误代码,就显示未定义错误 + if(info.length() <= 0) + { + QString errorCode; + errorCode.sprintf("CODE 0x%x", m_mcStatus.errorCode); + info.append(tr("Undefined error,") + errorCode);//未定义错误, + } + + ui->labelState->setText(info);//状态: + + if ((errcode > 0 && errcode < 0x100) || errcode > 0x200) + { + m_pMainWidgetFunction->funErrorPrompt(info); + //将报错代码写入csv + g_pSettings->writeToCsv(info,TYPE_ERROR);//保存 + } + else + { + if(m_mcStatus.errorCode == STA_LINE_TBREAK) + { + //检测断线状态 + int ret = m_pMainWidgetFunction->funDetectBreakLineStatus(); + if(ret != 0)//断线报错 + { + + } + } + } + } + } +} + +void MainWidget::slotShowPercentage(int val) +{ + ui->labelTitle->setText(QString::number(val)+"%"); +} + +void MainWidget::slotRefreshWifiIcon(bool bl) +{ + if(bl == true)//已连接 + { + ui->buttonWifi->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonWifi->objectName()+"Connect")); + } + else + { + ui->buttonWifi->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonWifi->objectName()+"Unconnect")); + } +} + +void MainWidget::slotShowPatternPara(QString filePath,s16 showFlag) +{ + QString beforeFilePath = m_curFilePath; + qDebug()< Head spacing"));// 花样设置 > 机头间距 + headDialog.initDsrFileInfo(m_curFilePath); + headDialog.setTypeLogo(tStyle); + + if((showFlag == 0) && ("DSR" == QFileInfo(filePath).suffix().toUpper())) + { + //执行修改机头间距界面 + int result = headDialog.exec(); + if(result != 1) + { + //点击取消按钮后花样路径恢复为上次选中的花样 + m_curFilePath = beforeFilePath; + return; + } + } + } + + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Pattern para"));//花样参数 + m_pParameterSetDlg->setSubTitle(tr("Pattern setting > Pattern para"));// 花样设置 > 花样参数 + + QFileInfo fileInfo(m_curFilePath); + QString suffix = fileInfo.suffix().toUpper(); + //为plt文件时不显示花样参数设置窗体 + if(suffix != "PLT") + { + showDiffPara(suffix);//根据文件格式不同显示不同花样参数 + } + else + { + memset((char*)&m_patternSetPara,0,sizeof(PatternSetPara)); + showFlag = 1; + } + m_pParameterSetDlg->setCurPage(1); + + s16 value = 0; + if(showFlag != 0)//不显示此窗体直接加载花样参数(适用于开机自动加载花样文件) + { + value = 1; + m_pPatternSelectWi->hide(); + } + else //显示此窗体 + { + value = m_pParameterSetDlg->exec(); + m_pPatternSelectWi->hide(); + +#if(0)//昆仑通态操作屏下有问题,所以注释掉 + if(value == 1) + { + //正在加载花样提示窗体 + m_pPromptDlg->initDialog(PromptDialog::BTN_NONE); + m_pPromptDlg->setTitleStr(tr("Prompt")); + m_pPromptDlg->setContentStr(tr("Loading patterns, please wait...")); //正在加载花样,请等待... + m_pPromptDlg->show(); + QCoreApplication::processEvents(QEventLoop::AllEvents); + } +#endif + } + + if(value == 1)//花样参数设置(点击了确定按钮或直接加载文件后加载花样参数) + { + //TODO 机头列表界面设置 + + //快进快退等功能可用 + for(int i = 0; i < m_quickItemList.size(); i++) + { + int enumFun = m_quickItemList[i].m_enumFunction; + if(enumFun == FUN_FORWARDORBACK ||//快进快退 + enumFun == FUN_SETSTARTPOINT ||//定起始点 + enumFun == FUN_BACKSTARTPOINT ||//回起始点 + enumFun == FUN_CHECKFRAME ||//边框检查 + enumFun == FUN_BACKWORKPOINT //回工作点 + ) + { + if(m_curFilePath.length() > 0)//选择文件后快进快退等按钮可用 + { + m_quickBtnList[i]->setEnabled(true); + } + } + } + + //有花样时花样参数、花样色序、可按 + for(int i = 0; i < m_patternSetItemList.size(); i++) + { + if(m_patternSetItemList[i].m_enumFunction == PATTERNSET_PATTERNPARA) + { + m_patternSetBtnList[i]->setEnabled(true); + } + } + + //为plt文件时不显示花样参数设置窗体,且不设置参数 + if(suffix != "PLT") + { + showDiffPara(suffix,1); + } + + slotSetPatternData();//设置花样数据并显示 + +#if(0)//昆仑通态操作屏下有问题,所以注释掉 + if(m_pPromptDlg->isVisible())//若是可见的 + { + m_pPromptDlg->hide();//隐藏加载花样的提示窗体 + } +#endif + + //发送五头机机头间距数据 + if((m_linkSta == Connected) && (g_emMacType == MACHINE_FIVEHEADPRECISIONSEWING)){ + g_pMachine->setHeadSpacing(headDialog.getHeadData()); + } + + //计算起始点和定位点并设置 + calPointsAndSet(); + + if(m_linkSta == Connected)//已连接 + { + m_pMainWidgetFunction->sendPatternData(m_curFilePath);//发送花样数据 + //设置为按进度执行模式 + g_pCurEmbData->setExecIndex(m_curDatIdx); // 设置进度 + } + } + else + { + //点击取消按钮后花样路径恢复为上次选中的花样 + m_curFilePath = beforeFilePath; + } +} + +//删除文件后判断当前文件是否被删除 +void MainWidget::slotIfFileExist() +{ + if(m_curFilePath.length() > 0) + { + QFile file(m_curFilePath); + if(!file.exists())//不存在 + { + m_curFilePath.clear(); + + //花样参数不可按 + for(int i = 0; i < m_patternSetItemList.size(); i++) + { + if(m_patternSetItemList[i].m_enumFunction == PATTERNSET_PATTERNPARA) + { + m_patternSetBtnList[i]->setEnabled(false); + } + } + + if(g_pMachine != NULL) + { + g_pMachine->invalidateWorkFile(); + } + } + } +} + +//花样导入替换文件,判断替换文件是否是当前所选的花样 +void MainWidget::slotReplacePattrn(QString path) +{ + QFileInfo file(m_curFilePath); + QFileInfo newfile(path); + QString pathPattern = file.fileName(); + QString newPathPattern = newfile.fileName(); + if(m_curFilePath.length() > 0)//当前选择的花样路径 + { + if(pathPattern == newPathPattern)//如果替换的花样等于当前选择的花样 + { + m_curFilePath.clear();//清空当前的花样,并重新选择 + + //花样参数、花样色序不可按 + for(int i = 0; i < m_patternSetItemList.size(); i++) + { + if(m_patternSetItemList[i].m_enumFunction == PATTERNSET_PATTERNPARA || + m_patternSetItemList[i].m_enumFunction == PATTERNSET_PATTERNCOLOR) + { + m_patternSetBtnList[i]->setEnabled(false); + } + } + + if(g_pMachine != NULL) + { + g_pMachine->invalidateWorkFile(); + } + } + } +} + +void MainWidget::slotClearPatternFcg() +{ + if(m_curFilePath.length() > 0)//当前选择的花样路径 + { + m_curFilePath.clear(); + + //花样参数、花样色序不可按 + for(int i = 0; i < m_patternSetItemList.size(); i++) + { + if(m_patternSetItemList[i].m_enumFunction == PATTERNSET_PATTERNPARA) + { + m_patternSetBtnList[i]->setEnabled(false); + } + } + + for(int i = 0; i < m_quickItemList.size(); i++) + { + int enumFun = m_quickItemList[i].m_enumFunction; + if(enumFun == FUN_FORWARDORBACK ||//快进快退 + enumFun == FUN_SETSTARTPOINT ||//定起绣点 + enumFun == FUN_BACKSTARTPOINT ||//回起绣点 + enumFun == FUN_CHECKFRAME ||//边框检查 + enumFun == FUN_BACKWORKPOINT //回工作点 + ) + { + m_quickBtnList[i]->setEnabled(false); + } + } + + ui->buttonNineBtn1->setEnabled(false); + + if(g_pMachine != NULL) + { + g_pMachine->invalidateWorkFile(); + } + } +} + +//设置花样数据 +void MainWidget::slotSetPatternData() +{ + if(m_curFilePath.length() <= 0) + { + return; + } + QFile curfile(m_curFilePath); + if(!curfile.exists()) + { + return; + } + + if(m_pParameterSetDlg == NULL){return;} + + g_pCurEmbData->setViewInfo(m_embBackPix); + g_pCurEmbData->setDrawMode(EmbData::DRAW_VIEW);//非预览模式 + QFileInfo file(m_curFilePath); + QString ext = file.suffix().toUpper(); + QString fileName = file.fileName().left(file.fileName().size() - 4);//去掉结尾dsr + ui->lab_FileName_2->setText(fileName); //去掉结尾的dsr + g_pCurEmbData->clear();//清空当前选择的花样 + + if(appendDiffAbsData(ext) != 0) + { + return; + } + + g_pCurEmbData->appendAEmbAbsFile(m_curFilePath, g_pCurEmbData->getAbsDat());//生成文件信息 + + //旋转式样 + switch (m_patternSetPara.rotateStyle) + { + case 0: + break; + case 1: + g_pCurEmbData->setRotate90(true); + break; + case 2: + g_pCurEmbData->setMirror(3); + break; + case 3: + g_pCurEmbData->setRotate90(false); + break; + case 4: + g_pCurEmbData->setMirror(1); + break; + case 5: + g_pCurEmbData->setMirror(1); + g_pCurEmbData->setRotate90(true); + break; + case 6: + g_pCurEmbData->setMirror(2); + break; + case 7: + g_pCurEmbData->setMirror(1); + g_pCurEmbData->setRotate90(false); + break; + } + + //旋转 + g_pCurEmbData->setRotate(360-m_patternSetPara.rotateAngle); + + g_pCurEmbData->getAbsDatRangeXY();//获得单个图元的宽高范围 + g_pCurEmbData->setDatSizeChange(m_patternSetPara.scanX, m_patternSetPara.scanY); // 设置尺寸变化(缩放) + + //移动起始点改在设置尺寸之后 + //g_pCurEmbData->moveDataBeginPonit(m_patternSetPara.left * 10, m_patternSetPara.front * 10); + + //除qui和quix之外格式进行按固定针步拟合,因为qui和quix拟合在转换为绝对坐标之前已经完成 + if( 0 && ext != "QUI" && ext != "QUIX") + { + //reFitLine的拟合算法更好 + //g_pCurEmbData->reFitByStep(m_patternSetPara.normalStep); + g_pCurEmbData->reFitLine(m_patternSetPara.normalStep); + } + + //加锁针 + g_pCurEmbData->addLockStitchs(m_patternSetPara.reinMode, m_patternSetPara.reinNeedles, m_patternSetPara.reinNum); // 添加锁针针步 + + //角度修正 +#if(0) + g_pCurEmbData->angleCorrection(m_patternSetPara.angleCorrOffset*10); // 角度修正,修正固定值 +#else + // 角度修正,X正负和Y正负分别修正 + g_pCurEmbData->angleCorrectionXY(m_patternSetPara.angleCorrPosX*10,m_patternSetPara.angleCorrNegX*10,m_patternSetPara.angleCorrPosY*10,m_patternSetPara.angleCorrNegY*10); +#endif + + resetAllData(); //显示全部花样区域 + + u32 paraId = calcCrc16((u8*)(&m_patternSetPara.rotateStyle),sizeof(m_patternSetPara)); + u32 headFileId = g_pCurEmbData->getDsDatHead()->checkCrc + paraId; + g_pCurEmbData->setDsDatHeadFileID(headFileId); //将计算得到的fileid写回到数据区 + + ui->lab_Locate_2->setText(QString("%1/%2").arg(QString::number(m_patternSetPara.left/10,'f',1)).arg(QString::number(m_patternSetPara.front/10,'f',1))); //定位点 从左边前边获取 + ui->lab_StartPoint_2->setText(QString("%1/%2").arg(QString::number(g_pCurEmbData->getBeginX()/100,'f',1)).arg(QString::number(g_pCurEmbData->getBeginY()/100,'f',1))); + showPatternPreview(); +} + +void MainWidget::slotWorkArea() +{ + if (m_pSetWorkAreaWi != NULL) + { + m_pSetWorkAreaWi->setTitleStr(tr("Setting workable area")); + m_pSetWorkAreaWi->setHead(SEW); + m_pSetWorkAreaWi->show(); + } +} + +//每十万针主界面加载图片的进度条走一格 +void MainWidget::slotChangeProgressBar(int value) +{ + ui->progressBar->setValue(value); +} + +//快捷功能中的快捷按钮被点击 +void MainWidget::slotQuickBtnClick() +{ + MyButton *button = (MyButton*) this->sender(); + + if(button == NULL) + { + return; + } + + //执行快捷按钮动作 + for(int i = 0; i < m_quickBtnList.size(); i++) + { + if(button == m_quickBtnList[i]) + { + int enumFun = m_quickItemList[i].m_enumFunction; + runCommonBtnFunction(enumFun); + break; + } + } +} + +//辅助功能中的辅助功能按钮被点击 +void MainWidget::slotAssistBtnClick() +{ + MyButton *button = (MyButton*) this->sender(); + + if(button == NULL) + { + return; + } + + //执行快捷按钮动作 + for(int i = 0; i < m_assistBtnList.size(); i++) + { + if(button == m_assistBtnList[i]) + { + int idx = i; + int enumFun = m_assistItemList[idx].m_enumFunction; + runAssistBtnFunction(enumFun,i); + break; + } + } +} + +//花样设置中的花样设置按钮被点击 +void MainWidget::slotPatternSetBtnClick() +{ + MyButton *button = (MyButton*) this->sender(); + + if(button == NULL) + { + return; + } + + //执行快捷按钮动作 + for(int i = 0; i < m_patternSetBtnList.size(); i++) + { + if(button == m_patternSetBtnList[i]) + { + int enumFun = m_patternSetItemList[i].m_enumFunction; + runPatternSetBtnFunction(enumFun,i); + break; + } + } +} + +//参数设置中的参数功能按钮被点击 +void MainWidget::slotParaTypeBtnClick() +{ + MyButton *button = (MyButton*) this->sender(); + + if(button == NULL) + { + return; + } + + QString bStyle = m_setControlStyle.getBottomStyleSheet(ui->buttonParaSet->parent()->objectName()); + QString tStyle = m_setControlStyle.getTopStyleSheet(ui->buttonParaSet->objectName()); + + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Parameter setting")); + + //执行快捷按钮动作 + for(int i = 0; i < m_paraSetBtnList.size(); i++) + { + if(button == m_paraSetBtnList[i]) + { + int paraType = m_paraSetItemList[i].m_paraType; + QString subStr; + int64_t sort = -1; + + switch (paraType) + { + case PARASET_POSITION: +// if(g_emUser != factory)//权限不够先登录 +// { +// m_pMainWidgetFunction->slotUserLogin(factory); +// if(g_emUser != factory)//发送登录信号后,权限如果还没改变就返回 +// { +// return; +// } +// } + subStr = tr("Limit parameter");//限位参数 + sort = MC_SORT_POSITION; + break; + case PARASET_SPEED: +// if(g_emUser != factory)//权限不够先登录 +// { +// m_pMainWidgetFunction->slotUserLogin(factory); +// if(g_emUser != factory)//发送登录信号后,权限如果还没改变就返回 +// { +// return; +// } +// } + subStr = tr("Speed control parameters");//速度控制参数 + sort = MC_SORT_SPEED; + break; + case PARASET_ACTION: + subStr = tr("Action settings");//动作设定 + sort = MC_SORT_ACTION; + break; + case PARASET_SETTING: + subStr = tr("Operating parameters");//操作参数 + break; + case PARASET_DETECT: +// if(g_emUser != factory)//权限不够先登录 +// { +// m_pMainWidgetFunction->slotUserLogin(factory); +// if(g_emUser != factory)//发送登录信号后,权限如果还没改变就返回 +// { +// return; +// } +// } + subStr = tr("Machine parameters");//机器参数 + sort = MC_SORT_DETECT; + break; + default: + subStr = tr("Parameter setting");//参数设置 + sort = -1; + break; + } + + m_pParameterSetDlg->setSubTitle(tr("Parameter setting > ") + subStr);//参数设置 > + //机器参数和工作参数 + m_pParameterSetDlg->setItemList(operate,PARA_TYPE_MACH|PARA_TYPE_WORK,sort); + m_pParameterSetDlg->exec(); + break; + } + } +} + +//设置超级用户图标 +void MainWidget::slotSetButtonRootLogo(int level) +{ + ui->buttonUser->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonUser->objectName()+QString::number(level))); +} + +//清空花版断线次数 +void MainWidget::slotClearPatternBreakLineNum() +{ + +} + +void MainWidget::slotDebugState() +{ + if(g_emDebugMode == debugMode) + { + ui->labelTitle->setStyleSheet(LABELREDSTYLE); + } + else + { + ui->labelTitle->setStyleSheet(LABELWHITESTYLE); + } +} + +void MainWidget::slotReceScanData(QByteArray data) +{ + QString fileName(data.left(data.size() - 1));// 去除结尾 /r + qDebug()<< "FileName:::"<>>Not Dsr File"; + return; + } + + //遍历文件夹 找到目标文件 + QStringList list; + QDir apppath(qApp->applicationDirPath()); + QString filePath = apppath.path() + apppath.separator() + PATTERNPATH; + QString dirPath = QDir(filePath).absolutePath();//为了将"\"变为"/" + qDebug()< 0){ + slotShowPatternPara(list.at(0),-1);//直接显示图片 取第一张 + } + +} + +void MainWidget::slotDebugInfo() +{ + DebugInfo info;//调试信息 + char mDebugInfoStr[1024+1]; + + info = g_pMachine->getDebugInfo(); + memcpy(mDebugInfoStr, info.debugInfoStr, 1024); + + mDebugInfoStr[1024] = 0; + + QString strDebugInfoStr; + strDebugInfoStr.sprintf("%s", mDebugInfoStr); + if(strDebugInfoStr.length()>0) + { + g_pSettings->writeToCsv(strDebugInfoStr,TYPE_DEBUGINFO);//写入csv + } +} + +void MainWidget::onRefreshPatternTimer() +{ + // 文件执行进度(当前针数) labelNeedleIdx + m_curDatIdx++; + reSetDatIdx(m_curDatIdx); + QPixmap patternPix = g_pCurEmbData->getPreviewImage(); + ui->labelPatternView->setPixmap(patternPix); +} + +//1秒定时器 +void MainWidget::onOneSecondTimer() +{ + // 获取系统当前时间 + QDateTime dateTime = QDateTime::currentDateTime(); + ui->labelTime->setText(dateTime.toString("yyyy/MM/dd HH:mm:ss")); + refConnectUi(dateTime.time().second());//刷新连接 +} + +//5秒定时器 +void MainWidget::onFiveSecondTimer() +{ + if(m_conFlag == 0)//已连接 + { + + } + else + { + g_pMachine->setTcpConnectState(1);//将连接状态置为1 + } + m_conFlag = -1; +} + +void MainWidget::onTenMiniteTimer() +{ + s16 rel = m_pMainWidgetFunction->detectWifiConnect(); + if(rel > 0)//已连接 + { + ui->buttonWifi->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonWifi->objectName()+"Connect")); + } + else + { + ui->buttonWifi->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonWifi->objectName()+"Unconnect")); + } +} + +//1分钟定时器,记录当前系统时间,用于上电时 计算 关机时间 +void MainWidget::onOneMinTimer() +{ + // 获取系统当前时间 + QDateTime dateTime = QDateTime::currentDateTime(); + g_pSettings->writeToIniFile(("DateTime/second"),dateTime.toTime_t());//单位为秒 +#if(0) + //30天自动删除是只删除超过30天的记录 + //文件路径 + QDir apppath(qApp->applicationDirPath()); + QString csvfile; + csvfile = apppath.path() + apppath.separator() + CSV_FILEID; + //获取文件的创建时间 + QFileInfo info(csvfile); + qDebug() << info.size();//获取文件大小 + QDateTime dt = info.created();//获取文件创建时间 + int days = dt.daysTo(dateTime);//获取文件相对于当前时间的天数 + if (days >30) + { + QFile::remove(csvfile);//大于30天,删除这个文件 + } +#endif +} + +//刷新版本信息 +void MainWidget::onRefreshVer() +{ + //版本显示 + QString verStr = m_pMainWidgetFunction->getVersionStr(); + // verStr.sprintf("XPlatForm-RP-HMI-L1910-V%d.%02d.%02d", + // EMB_VER_CODE_Y, + // EMB_VER_CODE_M, + // EMB_VER_CODE_D); + + QString boardVerStr; + MCInfo info1 = g_pMachine->getMcInfo(); + QString strBoardVer; + strBoardVer.sprintf("%s",info1.softwareVerStr); + + QStringList listVer = strBoardVer.split(".");// 因为主控改了程序 + + if(listVer.length() >= 3) + { + QString str1 = listVer.at(0); + strBoardVer = str1.right(2); + strBoardVer += listVer.at(1) + listVer.at(2); + } + + if(strBoardVer.length() > 0) + { + boardVerStr = "-DewMock-V" + strBoardVer; + } + ui->labelHMIVersion->setText("RPQC-ALL-XPlatformQ-LAUTO-V231010");//版本: +} + +//主界面 +void MainWidget::on_buttonMainMenu_clicked() +{ + hideMenuFrame(); + showPatternPreview(); + ui->buttonMainMenu->setCheckable(true); + ui->buttonMainMenu->setChecked(true); +} + +//花样设置 +void MainWidget::on_buttonPatternSet_clicked() +{ +#if(0) + //如果为当前显示页面,再点击时需隐藏,显示花样页面 + if(ui->framePatternSet->isVisible()) + { + showPatternPreview(); + } +#endif + hideMenuFrame(); + ui->frameMenuBack->setVisible(true); + ui->framePatternSet->setVisible(true); + ui->buttonPatternSet->setCheckable(true); + ui->buttonPatternSet->setChecked(true); +} + +//参数设定按钮 +void MainWidget::on_buttonParaSet_clicked() +{ + s16 paraSort = g_pSettings->readFromIniFile("HMI/paraSort").toInt(); + + if(paraSort == 1)//分类显示参数 + { + hideMenuFrame(); + ui->frameMenuBack->setVisible(true); + ui->frameParaSet->setVisible(true); + ui->buttonParaSet->setCheckable(true); + ui->buttonParaSet->setChecked(true); + } + else if(paraSort == 0)//不分类显示参数 + { + showPatternPreview(); + + QString tStyle = m_setControlStyle.getTopStyleSheet(ui->buttonParaSet->objectName()); + + m_pParameterSetDlg->setTypeLogo(tStyle); + m_pParameterSetDlg->setMainTitle(tr("Parameter setting")); + m_pParameterSetDlg->setSubTitle(tr("Parameter setting > Parameter setting")); + //机器参数和工作参数 + m_pParameterSetDlg->setItemList(operate,PARA_TYPE_MACH|PARA_TYPE_WORK); + m_pParameterSetDlg->exec(); + } +} + +//快捷功能按钮 +void MainWidget::on_buttonShortcutFunction_clicked() +{ + hideMenuFrame(); + ui->frameMenuBack->setVisible(true); + ui->frameShortcutFunction->raise(); + ui->frameShortcutFunction->setVisible(true); + ui->buttonShortcutFunction->setCheckable(true); + ui->buttonShortcutFunction->setChecked(true); +} + +//辅助功能按钮 +void MainWidget::on_buttonAccessFunction_clicked() +{ + hideMenuFrame(); + ui->frameMenuBack->setVisible(true); + ui->frameAccessFunction->setVisible(true); + ui->buttonAccessFunction->setCheckable(true); + ui->buttonAccessFunction->setChecked(true); +} + +//速度加 +void MainWidget::on_buttonSpeedAdd_clicked() +{ + if(g_pMachine != NULL) + { + int speed = 0; + if(m_speedLevel == 1) + { + speed = 10; + } + else if(m_speedLevel == 2) + { + speed = 50; + } + else if(m_speedLevel == 3) + { + speed = 100; + } + + g_pMachine->msRpmChange(speed,0); + } +} + +//速度减 +void MainWidget::on_buttonSpeedDec_clicked() +{ + if(g_pMachine != NULL) + { + int speed = 0; + if(m_speedLevel == 1) + { + speed = -10; + } + else if(m_speedLevel == 2) + { + speed = -50; + } + else if(m_speedLevel == 3) + { + speed = -100; + } + + g_pMachine->msRpmChange(speed,0); + } +} + +void MainWidget::on_buttonNineBtnUp_pressed() +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(XY_MOVE_FRONT, m_speedLevel); + } +} + +void MainWidget::on_buttonNineBtnUp_released() +{ + setFrameNineBtnStyle(); + if(g_pMachine != NULL) + { + g_pMachine->motoMove(XY_MOVE_FRONT, MT_MOVE_DIR_STOP, 0); + } +} + +void MainWidget::on_buttonNineBtnDown_pressed() +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(XY_MOVE_BACK, m_speedLevel); + } +} + +void MainWidget::on_buttonNineBtnDown_released() +{ + setFrameNineBtnStyle(); + if(g_pMachine != NULL) + { + g_pMachine->motoMove(XY_MOVE_BACK, MT_MOVE_DIR_STOP, 0); + } +} + +void MainWidget::on_buttonNineBtnLeft_pressed() +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(XY_MOVE_LEFT, m_speedLevel); + } +} + +void MainWidget::on_buttonNineBtnLeft_released() +{ + setFrameNineBtnStyle(); + if(g_pMachine != NULL) + { + g_pMachine->motoMove(XY_MOVE_LEFT, MT_MOVE_DIR_STOP, 0); + } +} + +void MainWidget::on_buttonNineBtnRight_pressed() +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(XY_MOVE_RIGHT, m_speedLevel); + } +} + +void MainWidget::on_buttonNineBtnRight_released() +{ + setFrameNineBtnStyle(); + if(g_pMachine != NULL) + { + g_pMachine->motoMove(XY_MOVE_RIGHT, MT_MOVE_DIR_STOP, 0); + } +} + +void MainWidget::on_buttonNineBtnMiddle_pressed() +{ + m_speedLevel = m_speedLevel + 1; + if(m_speedLevel > 3) + { + m_speedLevel = 1; + } + + bool cVal = ui->buttonPatternSet->isEnabled();//按钮是否失能,是否锁界面 + + if(cVal == true) + { +// ui->frameNineBtn->setStyleSheet(m_setControlStyle.getBorderImageStyleSheet("frameNineBtnMiddle")); + } +} + +void MainWidget::on_buttonNineBtnMiddle_released() +{ + bool cVal = ui->buttonPatternSet->isEnabled();//按钮是否失能,是否锁界面 + + if(cVal == true) + { +// ui->frameNineBtn->setStyleSheet(m_setControlStyle.getBorderImageStyleSheet(ui->frameNineBtn->objectName())); + } + + setFrameNineBtnStyle(); +} + +//前进回退 +//void MainWidget::on_buttonNineBtn1_clicked() +//{ +// funForwardOrBack(); +//} + +void MainWidget::on_buttonNineBtn1_clicked() +{ + runCommonBtnFunction(m_nineBtn.value(1).m_enumFunction); +} + +void MainWidget::on_buttonNineBtn2_clicked() +{ + runCommonBtnFunction(m_nineBtn.value(2).m_enumFunction); +} + +void MainWidget::on_buttonNineBtn3_clicked() +{ + runCommonBtnFunction(m_nineBtn.value(3).m_enumFunction); +} + +void MainWidget::on_buttonNineBtn4_clicked() +{ + runCommonBtnFunction(m_nineBtn.value(4).m_enumFunction); +} + +//花样参数的快捷按钮 +void MainWidget::on_buttonPatternInfo_clicked() +{ + if(m_curFilePath.length() <= 0) + { + return; + } + + showPatternPreview(); + slotShowPatternPara(m_curFilePath); +} + +void MainWidget::on_buttonNeedleBegin_clicked() +{ + m_forwardBackNeedleIdx = 0; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleEnd_clicked() +{ + m_forwardBackNeedleIdx = g_pCurEmbData->getStitchNums(); //总针数 + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleDec1_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx - 1; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleAdd1_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx + 1; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleDec10_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx - 10; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleAdd10_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx + 10; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleDec100_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx - 100; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleAdd100_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx + 100; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleDec1000_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx - 1000; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleAdd1000_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx + 1000; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleDec10000_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx - 10000; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonNeedleAdd10000_clicked() +{ + m_forwardBackNeedleIdx = m_forwardBackNeedleIdx + 10000; + addOrDecNeedleIdx(m_forwardBackNeedleIdx); +} + +void MainWidget::on_buttonElementAdd_clicked() +{ + m_forwardBackNeedleIdx = g_pCurEmbData->getNextElementIndex(m_forwardBackNeedleIdx);//获得下一个图元的第一缝纫针步 + addOrDecNeedleIdx(m_forwardBackNeedleIdx);// 更新针数 +} + +void MainWidget::on_buttonElementDec_clicked() +{ + int index = m_forwardBackNeedleIdx -1; + m_forwardBackNeedleIdx = g_pCurEmbData->getPreOrThisElementIndex(index < 0 ? 0 : index);//上一个图元或当前图元的第一缝纫针步 + addOrDecNeedleIdx(m_forwardBackNeedleIdx);// 更新针数 +} + +void MainWidget::on_buttonForwardBackOk_clicked() +{ + if ((m_mcStatus.workStatus & WORK_STA_BUSY) != 0) // 下位机在执行动作 + { + return; + } + + //g_pMachine->setFileExecProgress(0, m_curFileID, m_expara); + g_pMachine->fastJump(m_expara.newIdx);//前进回退 + ui->frameForwardBack->setVisible(false); + setUiBtnEnable(true); + ui->buttonMainMenu->setCheckable(true); + ui->buttonMainMenu->setChecked(true); +} + +void MainWidget::on_buttonForwardBackCancel_clicked() +{ + g_pCurEmbData->setExecIndex(m_curDatIdx);// 更新针数 + + QPixmap patternPix = g_pCurEmbData->getPreviewImage(); + ui->labelPatternView->setPixmap(patternPix); + + ui->frameForwardBack->setVisible(false); + setUiBtnEnable(true); + ui->buttonMainMenu->setCheckable(true); + ui->buttonMainMenu->setChecked(true); +} + +//退出登录 +void MainWidget::on_buttonUser_clicked() +{ + //退回到无密码的普通用户 + if(g_emUser == repair || g_emUser == factory || g_emUser == root) + { + m_pMainWidgetFunction->funExitRoot(); + ui->buttonUser->setStyleSheet(m_setControlStyle.getStyleSheet(ui->buttonUser->objectName())); + } +} + +void MainWidget::mousePressEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + mousePressX = e->x(); + mousePressY = e->y(); + mouseReleaseX = 0; + mouseReleaseY = 0; + } +} + +void MainWidget::mouseReleaseEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + mouseReleaseX = e->x(); + mouseReleaseY = e->y(); + } + + int width = this->width(); + int height = this->height(); + if ((mousePressX >= 0 && mousePressX <= 100) && + ((mousePressY >= (height - 100)) && mousePressY <= height) && + ((mouseReleaseX >= (width - 100)) && ((mouseReleaseX <= (width)))) && + ((mouseReleaseY >= (height - 100)) && mouseReleaseY <= height) + ) + { + m_usbPath.clear();//清空路径字符串 //优盘路径 + m_usbPath = m_pMainWidgetFunction->detectUsb();//优盘检测 + if(m_usbPath.length() <= 0) + { + //优盘不存在 + return; + } + else + { + QPixmap pixmap=QPixmap::grabWindow(this->winId(),0,0,this->width(),this->height());//截屏存放在pixmap + QString name_pc = m_usbPath + "EMB" + // + QDateTime::currentDateTime().toString("yyyyMMdd") +//获取时期时间 + +"_"+ + QDateTime::currentDateTime().toString("hhmmss") + ".png"; + + pixmap.save(name_pc,"png"); // 路径 + + if (m_usbPath!= "") + { + //截屏效果 + ui->labelScreenshot->show(); + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + ui->labelScreenshot->setStyleSheet(setControlStyle.getStyleSheet("labelScreenshot")); + QTimer::singleShot(2000,ui->labelScreenshot,SLOT(hide())); // 停留一秒 隐藏 + } + } + } + + mousePressX = 0; + mousePressY = 0; + mouseReleaseX = 0; + mouseReleaseY = 0; +} + +void MainWidget::on_buttonStartStop_clicked() +{ + g_pMachine->pauseWork(); +} diff --git a/mctype/patternsingleboard/mainUI/mainwidget.h b/mctype/patternsingleboard/mainUI/mainwidget.h new file mode 100644 index 0000000..b173fa6 --- /dev/null +++ b/mctype/patternsingleboard/mainUI/mainwidget.h @@ -0,0 +1,300 @@ +#ifndef MainWidget_H +#define MainWidget_H + +#include +#include +#include +#include +#include +#include +#include "main.h" +#include "mctype/mainwidgetfunction.h" +#include "sharedviews/promptdialog.h" +#include "sharedviews/patternselectwidget.h" +#include "sharedviews/parametersetdialog.h" +#include "sharedviews/patternmanagewidget.h" +#include "sharedviews/sensorinputwidget.h" +#include "sharedviews/controlactionwidget.h" +#include "sharedviews/setworkarea.h" +#include "mctype/patternsingleboard/function/highsinglequilting.h" +#include "machine/error.h" +#include "sharedviews/headspacingsheetdialog.h" +#include "mctype/patternsingleboard/function/fiveheadprecisionsewing.h" +#include "mctype/patternsingleboard/function/clothingmac.h" +#include "mctype/patternsingleboard/function/multineedlerotary.h" +#include + +namespace Ui { +class MainWidget; +} + +typedef struct +{ + s16 rotateStyle; //旋转式样 + s16 rotateAngle; //旋转角度 + s16 reinMode; //加固方式 + s16 reinNeedles; //加固针数 + s16 reinNum; //加固次数 + s32 normalStep; //针步大小 + s32 angleCorrOffset; //角度修正量 + s32 angleCorrPosX; //角度修正x正 + s32 angleCorrNegX; //角度修正x负 + s32 angleCorrPosY; //角度修正y正 + s32 angleCorrNegY; //角度修正y负 + s32 left; //左边 + s32 front; //前边 + s32 scanX; //缩放x + s32 scanY; //缩放y + s32 startX; //起始点X + s32 startY; //起始点Y + s32 anchorX; //定位点X + s32 anchorY; //定位点Y +}__attribute__ ((packed)) PatternSetPara; + +class MainWidget : public QWidget +{ + Q_OBJECT + +public: + explicit MainWidget(QWidget *parent = 0); + ~MainWidget(); + +private: + Ui::MainWidget *ui; + PatternSelectWidget *m_pPatternSelectWi;//花样选择窗体 + ParameterSetDialog *m_pParameterSetDlg;//参数设定窗体 + PatternManageWidget *m_pPatternManageWi;//花样管理窗体(花样导入、导出...) + SensorInputWidget *m_pSensorInputWi; + ControlActionWidget *m_pControlActionWi; + MainWidgetFunction *m_pMainWidgetFunction;//快捷功能函数结构体 + SetWorkArea *m_pSetWorkAreaWi; + Machine * m_pMachine; + QThread * m_pScanComThread; //扫码器 + ComPort * m_pScanComPort; //扫码器串口 + + QList m_quickBtnList;//快捷功能中的快捷按钮列表 + QList m_quickLabelList;//快捷功能中的label显示列表 + + QList m_assistBtnList;//辅助功能中的辅助按钮列表 + QList m_assistLabelList;//辅助功能中的label显示列表 + + QList m_patternSetBtnList;//花样设置中的花样设置按钮列表 + QList m_patternSetLabelList;//花样设置中的label显示列表 + + QList m_paraSetBtnList;//参数设置中的参数设置按钮列表 + QList m_paraSetLabelList;//参数设置中的label显示列表 + QHash m_nineBtn; //九宫格四角按钮的机型化配置 + QList m_fileInfo;//右上角花样信息显示 + + QString m_usbPath;//优盘路径 + QString m_rootPath;//操作屏根路径 + QString m_curPath;//当前路径 + +private: + void initialize();//初始化 + +public: + void initAllWindows(s16 ifHMIDecrypt = 1, s16 connectMode = 0);//初始化窗体 + void initMcTypeWindows();//不同机型不同的窗体设置 + +private: + void initQuickFunBtn();//初始化快捷功能中的快捷按钮 + QList m_quickItemList;//快捷功能中的快捷条目列表 + + void initAssisitBtn();//初始化辅助功能中的辅助按钮 + QList m_assistItemList;//辅助功能中的辅助按钮列表 + + void initPatternSetBtn();//初始化花样设置功能中的花样设置按钮 + QList m_patternSetItemList;//花样设置功能中的花样设置条目列表 + + void initParaSetBtn();//初始化参数设置功能中的参数设置按钮 + QList m_paraSetItemList;//参数设置功能中的参数设置条目列表 + + void initPatternInfo(int beginY,int gapY,int valueX,int keyX,int width,int height, int valueHeight); + QList m_errorCodeAndStateItemList;//错误代码和状态列表 + +private: + u32 m_workStatus;//工作状态 + int m_curRpm; + int m_curDatIdx;//当前针数索引 + + int m_forwardBackNeedleIdx;//前进回退时的针数索引 + s16 m_ifHMIDecrypt;//界面是否授权,1代表已授权解密过,0代表未授权解密过 + s16 m_connectMode;//通讯连接方式 0:网口,1:串口 + +private: + MCStatus m_mcStatus; + u32 m_errorCode;//记录报错代码 + + int m_initflag;//初始化标志 + int m_timoutflag;//超时标志 + QTimer * m_pTimer;//建立连接的定时器 + QTimer * m_pConTimer;//检测上下位机心跳包的定时器 + QTimer * m_pMinTimer;//记录当前时间的定时器 + QTimer * m_pRefreshVer; //刷新版本信息 + QTimer * m_pWifiConTimer;//检测wifi是否连接的定时器 + SetControlStyle m_setControlStyle; + + QTimer * m_pRefreshPatternTimer;//更新花样显示的定时器(测试用) + + int m_conFlag;//连接标志 + int m_linkSta;//连接状态 + + EmbData::DISP_MODE m_dispMode; + QPixmap *m_previewImage; + + QString m_curFilePath;//当前选择的花样路径 + int m_imageZoom;//花样图片缩放值 + int m_imageMoveX;//花样图片平移值X + int m_imageMoveY;//花样图片平移值Y + + int m_curFileFlag; + + PatternSetPara m_patternSetPara;//花样参数 + QPixmap m_embBackPix;//绘制预览图的背景图 + FileExecPara m_expara; + +private: + int m_speedLevel;//速度等级 + +private: + void setFrameNineBtnStyle(); + +private: + void clearFileInfo();//清除文件信息 + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006();//初始化窗体控件为1024x600分辨率 + void initControlStyle();//初始化窗体控件样式 + QString getBackImagePath(s16 waterMark);//获取背景图的加载路径 + void showWorkSpeed(QString speed); //用数字管显示速度 + void setViewFont(QFont font); //设置界面字体大小 + + //鼠标事件 +protected: + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + +private: + int mousePressX; + int mousePressY; + int mouseReleaseX; + int mouseReleaseY; + +private: + void sendInitString(QString str);//发送初始化字符串 + void refConnectUi(int alive);//刷新连接状态(1秒) + + //刷新连接状态 + void refConnectUi(Machine * pMachine,int & linkSta, int alive); + void hideMenuFrame();//隐藏菜单栏(frame) + void showDiffPara(QString ext,s16 setFlag = 0);//根据文件格式不同显示不同花样参数 + void calPointsAndSet();//计算起始点和定位点并设置 + s16 appendDiffAbsData(QString ext);//根据文件格式不同添加不同的绝对坐标中间数据 + void resetAllData();//重置所有数据 + void patternSelect();//花样选择 + +private: + void showExecInfo();//显示机器运行状态中的信息 + void showPatternPreview();//显示花样显示页面 + +private: + QString getCommonBtnStyle(int idx);//获取常用按钮样式 + void runCommonBtnFunction(int idx);//执行常用按钮功能 + void runAssistBtnFunction(int funEnum,int idx);//执行辅助按钮功能 + void runPatternSetBtnFunction(int funEnum,int idx);//执行花样设置按钮功能 + void setUiBtnEnable(bool bValue);//设置UI界面按钮的使能 + void showSpeedFrame(); //隐藏九宫格 显示速度 + void showNineFrame(); //隐藏速度 显示九宫格 + void setNotExecing();//不是执行状态,重置 + +private: + void reSetDatIdx(int newidx); + void funForwardOrBack();//前进回退 + void addOrDecNeedleIdx(int &idx); //加减针 + +signals: + void siSendLoadingMessage(QString info, int alignment, QColor color);//接受加载信息 + void siSpeed(int speed);//手动换挡 + +private slots: + void slotWaitTimout();//等待超时 + void slotMachineStatus(int toggle);//机器状态 + void slotShowPercentage(int val); + void slotRefreshWifiIcon(bool bl); + //void slotLotDat(); //测试物联网用 + +private slots: + void onRefreshVer();//刷新版本信息定时器 + + //选择花样后是否弹出花样参数设置窗体并设置花样参数(默认显示花样参数设置窗体) + void slotShowPatternPara(QString filePath,s16 showFlag = 0);//设置花样参数 + void slotIfFileExist();//删除文件后判断当前文件是否被删除 + void slotClearPatternFcg();//删除fcg后重新选择花版 + void slotReplacePattrn(QString path);//花样导入替换文件 + void slotSetPatternData();//设置花样数据 + void slotWorkArea(); + +public slots: + void slotChangeProgressBar(int value); + +private slots: + void slotQuickBtnClick();//快捷功能中的快捷按钮被点击 + void slotAssistBtnClick();//辅助功能中的辅助功能按钮被点击 + void slotPatternSetBtnClick();//花样设置中的花样设置按钮被点击 + void slotParaTypeBtnClick();//参数设置中的参数功能按钮被点击 + void slotSetButtonRootLogo(int level);//设置超级用户图标 + void slotClearPatternBreakLineNum();//清空花版断线次数 + void slotDebugState();//界面调试模式 + void slotReceScanData(QByteArray data);//接收扫码器数据 + void slotDebugInfo(); +private slots: + void onRefreshPatternTimer();//1秒定时器(刷新花样测试用) + void onOneSecondTimer();//1秒定时器 + void onFiveSecondTimer();//5秒定时器 + void onTenMiniteTimer();//10分钟定时器 + void onOneMinTimer();//1分钟定时器 + void on_buttonMainMenu_clicked();//主界面按钮 + void on_buttonPatternSet_clicked();//花样设置按钮 + void on_buttonParaSet_clicked();//参数设定按钮 + void on_buttonShortcutFunction_clicked();//快捷功能按钮 + void on_buttonAccessFunction_clicked();//辅助功能按钮 + + void on_buttonSpeedAdd_clicked(); + void on_buttonSpeedDec_clicked(); + void on_buttonNineBtnUp_pressed(); + void on_buttonNineBtnUp_released(); + void on_buttonNineBtnDown_pressed(); + void on_buttonNineBtnDown_released(); + void on_buttonNineBtnLeft_pressed(); + void on_buttonNineBtnLeft_released(); + void on_buttonNineBtnRight_pressed(); + void on_buttonNineBtnRight_released(); + void on_buttonNineBtnMiddle_pressed();//九宫格中间键按下 + void on_buttonNineBtnMiddle_released();//九宫格中间键抬起 + void on_buttonNineBtn1_clicked(); + void on_buttonNineBtn2_clicked(); + void on_buttonNineBtn3_clicked(); + void on_buttonNineBtn4_clicked(); + void on_buttonPatternInfo_clicked();//花样参数快捷按钮 + void on_buttonNeedleBegin_clicked(); + void on_buttonNeedleEnd_clicked(); + void on_buttonNeedleDec1_clicked(); + void on_buttonNeedleAdd1_clicked(); + void on_buttonNeedleDec10_clicked(); + void on_buttonNeedleAdd10_clicked(); + void on_buttonNeedleDec100_clicked(); + void on_buttonNeedleAdd100_clicked(); + void on_buttonNeedleDec1000_clicked(); + void on_buttonNeedleAdd1000_clicked(); + void on_buttonNeedleDec10000_clicked(); + void on_buttonNeedleAdd10000_clicked(); + void on_buttonForwardBackOk_clicked(); + void on_buttonForwardBackCancel_clicked(); + void on_buttonUser_clicked(); + void on_buttonStartStop_clicked(); + void on_buttonElementAdd_clicked(); + void on_buttonElementDec_clicked(); +}; + +#endif // MainWidget_H diff --git a/mctype/patternsingleboard/mainUI/mainwidget.ui b/mctype/patternsingleboard/mainUI/mainwidget.ui new file mode 100644 index 0000000..d97a9a2 --- /dev/null +++ b/mctype/patternsingleboard/mainUI/mainwidget.ui @@ -0,0 +1,4524 @@ + + + MainWidget + + + + 0 + 0 + 1024 + 600 + + + + + + + background-color: rgb(122, 122, 122); + + + + + 0 + 0 + 1024 + 30 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 2 + 301 + 20 + + + + Qt::LeftToRight + + + color: rgb(255, 255, 255); +background-color: rgba(255, 255, 255, 0); + + + Richpeace Embroidery Control System + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 830 + 10 + 191 + 16 + + + + color: rgb(255, 255, 255); + + + XPlatForm-RP-HMI-L1910-V210713 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 800 + 0 + 28 + 28 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); + + + + + + + + + + 0 + 30 + 91 + 532 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 60 + 54 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Pattern + + + Qt::AlignCenter + + + + + + 210 + 280 + 54 + 54 + + + + Qt::NoFocus + + + + + + + + + 20 + 330 + 54 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Assist + + + Qt::AlignCenter + + + + + + 20 + 150 + 54 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + ParaSet + + + Qt::AlignCenter + + + + + + 20 + 90 + 54 + 54 + + + + Qt::NoFocus + + + + + + + + + 20 + 180 + 54 + 54 + + + + Qt::NoFocus + + + + + + + + + 20 + 240 + 54 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Shortcut + + + Qt::AlignCenter + + + + + + 20 + 0 + 54 + 54 + + + + Qt::NoFocus + + + QPushButton:checked{image: url(:/images/1920x1080/theme1/MainWidget/frameMainFunction_p1_1.png);} + + + + + + + false + + + false + + + + + + 20 + 420 + 54 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Main + + + Qt::AlignCenter + + + + + + 20 + 360 + 54 + 54 + + + + Qt::NoFocus + + + QPushButton:checked{image: url(:/images/1920x1080/theme1/MainWidget/frameMainFunction_p1_1.png);} + + + + + + + false + + + false + + + + + + + 819 + 30 + 188 + 280 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 20 + 51 + 16 + + + + TextLabel + + + + + + 110 + 20 + 72 + 15 + + + + TextLabel + + + + + + 10 + 50 + 61 + 16 + + + + TextLabel + + + + + + 110 + 50 + 61 + 16 + + + + TextLabel + + + + + + 10 + 80 + 72 + 15 + + + + TextLabel + + + + + + 110 + 80 + 72 + 15 + + + + TextLabel + + + + + + 10 + 110 + 72 + 15 + + + + TextLabel + + + + + + 110 + 110 + 72 + 15 + + + + TextLabel + + + + + + 10 + 140 + 72 + 15 + + + + TextLabel + + + + + + 110 + 140 + 72 + 15 + + + + TextLabel + + + + + + 10 + 170 + 72 + 15 + + + + TextLabel + + + + + + 110 + 170 + 72 + 15 + + + + TextLabel + + + + + + 10 + 200 + 72 + 15 + + + + TextLabel + + + + + + 110 + 200 + 72 + 15 + + + + TextLabel + + + + + + + 820 + 318 + 188 + 242 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 6 + 2 + 174 + 61 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 40 + 40 + 72 + 15 + + + + + + + + + + 50 + 50 + 72 + 15 + + + + + + + + + + 50 + 50 + 72 + 15 + + + + + + + + + + 50 + 50 + 72 + 15 + + + + + + + + + + 50 + 50 + 72 + 15 + + + + + + + + + + 0 + 0 + 44 + 44 + + + + Qt::NoFocus + + + + + + + + true + + + + 76 + 23 + 44 + 41 + + + + Qt::NoFocus + + + + + + + + + 112 + 0 + 44 + 44 + + + + Qt::NoFocus + + + + + + + + + + 6 + 68 + 174 + 164 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 0 + 0 + 48 + 48 + + + + Qt::NoFocus + + + + + + + + + 0 + 56 + 48 + 48 + + + + Qt::NoFocus + + + + + + + + + 0 + 112 + 48 + 48 + + + + Qt::NoFocus + + + + + + + + + 60 + 112 + 48 + 48 + + + + Qt::NoFocus + + + + + + + + + 60 + 0 + 48 + 48 + + + + Qt::NoFocus + + + + + + + + + 60 + 56 + 48 + 48 + + + + Qt::NoFocus + + + + + + + + + 120 + 112 + 48 + 48 + + + + Qt::NoFocus + + + + + + + + + 120 + 0 + 48 + 48 + + + + Qt::NoFocus + + + + + + + + + 120 + 56 + 48 + 48 + + + + Qt::NoFocus + + + + + + buttonNineBtn1 + buttonNineBtnLeft + buttonNineBtn3 + buttonNineBtnDown + buttonNineBtnUp + buttonNineBtn4 + buttonNineBtn2 + buttonNineBtnRight + buttonNineBtnMiddle + + + + + + 0 + 570 + 1024 + 30 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 6 + 160 + 16 + + + + color: rgb(220, 0, 0); + + + Not connected + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 4 + 28 + 1016 + 2 + + + + QProgressBar +{ + border-radius: 5px; + border:0px; +} + +QProgressBar::chunk +{ + background-color: rgb(255, 255, 255); +} + + + 0 + + + + + + 600 + 10 + 160 + 16 + + + + color: rgb(220, 0, 0); + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 370 + 10 + 160 + 16 + + + + color: rgb(220, 0, 0); + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 0 + 0 + 1027 + 31 + + + + + + + + + + 860 + 10 + 160 + 16 + + + + color: rgb(255, 255, 255); + + + 2021/03/08 8:37:16 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 770 + 0 + 28 + 28 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); + + + + + + + + + 810 + 0 + 28 + 28 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); + + + + + + labelState + progressBar + labelScreenshot + labelTime + buttonConnect + buttonUser + labelWorkState + labelEnableWorkState + + + + + 93 + 30 + 709 + 531 + + + + background-color: rgb(240, 240, 240); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 20 + 90 + 81 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 110 + 90 + 81 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 120 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 90 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 220 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 520 + 370 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 520 + 300 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 20 + 300 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 20 + 370 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 320 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 320 + 90 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 320 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 20 + 160 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 121 + 160 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 220 + 160 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 10 + 230 + 81 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 110 + 230 + 91 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 320 + 160 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 610 + 230 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 620 + 160 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 420 + 160 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 521 + 160 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 490 + 230 + 121 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 600 + 90 + 111 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 520 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 500 + 90 + 111 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 620 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 370 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 220 + 300 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 320 + 370 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 320 + 300 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 300 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 370 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 420 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 90 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 120 + 300 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 120 + 370 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 620 + 370 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 620 + 300 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 520 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 20 + 430 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 430 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 320 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 620 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 520 + 430 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 20 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 120 + 430 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 620 + 430 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 120 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 420 + 430 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + assist + + + Qt::AlignCenter + + + + + + 320 + 430 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + + 93 + 30 + 709 + 532 + + + + background-color: rgb(240, 240, 240); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 120 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 520 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 620 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 520 + 100 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 120 + 100 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 420 + 100 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 20 + 100 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 620 + 100 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 220 + 100 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 220 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 320 + 100 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 320 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 20 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 20 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 120 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 120 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 320 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 320 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 420 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 620 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 620 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 520 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 520 + 230 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 420 + 420 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 620 + 420 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 320 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 120 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 320 + 420 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 20 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 520 + 360 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 620 + 360 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 320 + 360 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 120 + 360 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 120 + 280 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 120 + 420 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 360 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 420 + 360 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 320 + 280 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 520 + 280 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 520 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 620 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 520 + 420 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 280 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 280 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 420 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 20 + 420 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 20 + 360 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + 20 + 280 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 620 + 280 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 500 + 60 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + shortcut + + + Qt::AlignCenter + + + + + + + 93 + 30 + 709 + 532 + + + + background-color: rgb(189, 189, 189); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 30 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 10 + 90 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 130 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 110 + 90 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 230 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 210 + 90 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 330 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 310 + 90 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 430 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 410 + 90 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 530 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 510 + 90 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 630 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 610 + 90 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 210 + 220 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 310 + 220 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 30 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 130 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 430 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 610 + 220 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 330 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 230 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 410 + 220 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 530 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 630 + 150 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 10 + 220 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 510 + 220 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + 110 + 220 + 91 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + PatternSet + + + Qt::AlignCenter + + + + + + + 0 + 0 + 1024 + 600 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 100 + 30 + 702 + 532 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 820 + 30 + 191 + 534 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 60 + 40 + 110 + 28 + + + + color: rgb(255, 255, 255); +background-color: rgba(255, 255, 255, 0); + + + 4999 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 20 + 40 + 28 + 28 + + + + Qt::NoFocus + + + + + + + + + 110 + 120 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 10 + 120 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 10 + 170 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 110 + 170 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 10 + 220 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 110 + 220 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 10 + 270 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 110 + 270 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 110 + 320 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 10 + 320 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 10 + 484 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 110 + 484 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 40 + 0 + 110 + 28 + + + + Qt::LeftToRight + + + color: rgb(255, 255, 255); +background-color: rgba(255, 255, 255, 0); + + + Forward or back + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 10 + -10 + 171 + 521 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 110 + 370 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 10 + 370 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 10 + 10 + 72 + 40 + + + + Qt::NoFocus + + + + + + + + + 110 + 10 + 72 + 40 + + + + Qt::NoFocus + + + + + + frameForwardBackBack + labelNeedleCurAndTotal + buttonNeedleIdxImage + buttonNeedleEnd + buttonNeedleBegin + buttonNeedleDec1 + buttonNeedleAdd1 + buttonNeedleDec10 + buttonNeedleAdd10 + buttonNeedleDec100 + buttonNeedleAdd100 + buttonNeedleAdd1000 + buttonNeedleDec1000 + buttonForwardBackOk + buttonForwardBackCancel + labelForwardBackTitle + buttonNeedleAdd10000 + buttonNeedleDec10000 + buttonElementDec + buttonElementAdd + + + + + 93 + 30 + 709 + 461 + + + + background-color: rgb(205, 238, 255); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 40 + 541 + 411 + + + + background-color: rgba(255, 255, 255, 0); + + + + + + Qt::AlignCenter + + + + + + + 93 + 30 + 709 + 532 + + + + background-color: rgb(240, 240, 240); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 10 + 90 + 91 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AutoText + + + Qt::AlignCenter + + + true + + + + + + 109 + 90 + 81 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + true + + + + + + 120 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 210 + 90 + 81 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + true + + + + + + 220 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 320 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 310 + 90 + 81 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + true + + + + + + 410 + 90 + 81 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + true + + + + + + 420 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 520 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 510 + 90 + 81 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + + + + 610 + 90 + 91 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + + + + 620 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 620 + 140 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 510 + 210 + 91 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + + + + 410 + 210 + 91 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + + + + 20 + 140 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 520 + 140 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 10 + 210 + 91 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + + + + 210 + 210 + 81 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + true + + + + + + 320 + 140 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 420 + 140 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 109 + 210 + 81 + 20 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + true + + + + + + 310 + 210 + 81 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + + + + 610 + 210 + 81 + 16 + + + + background-color: rgba(255, 255, 255, 0); + + + labelParaType + + + Qt::AlignCenter + + + + + + 120 + 140 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + 220 + 140 + 60 + 60 + + + + Qt::NoFocus + + + + + + + frameBack + frameMenuBack + frameUp + frameFunctionBtn + frameDown + frameMainFunction + frameShortcutFunction + frameForwardBack + frameEmbInfo + frameAccessFunction + framePatternSet + framePatternView + frameParaSet + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/settings/lotsettings.h b/settings/lotsettings.h new file mode 100644 index 0000000..8efd8a7 --- /dev/null +++ b/settings/lotsettings.h @@ -0,0 +1,112 @@ +#ifndef LOTSETTINGS_H +#define LOTSETTINGS_H + +//物联网数据key +//上行数据属性列表 +#define U00001 "progress" //完成进度(%) int +#define U00002 "products" //生产数量 int +#define U00003 "Action" //动作(0:开始;1:停止;9:剪线) int +#define U00004 "Turns" //转速 int +#define U00005 "xInitCoordinate" //定位点x int +#define U00006 "ynitCoordinate" //定位点y int +#define U00007 "xCoordinate" //当前点位x int +#define U00008 "yCoordinate" //当前点位y int +#define U00009 "realTime" //一天机器实际工作时间时间戳 int +#define U00010 "estimatedTime" //标准时间完成一件产品时间时间戳 int +#define U00011 "totalWork" //工作总量 int +#define U00012 "totalTime" //一天生产总时间时间戳 int +#define U00013 "machineTime" //一天机器做工工作时间时间戳 int +#define U00014 "TotalNeedle" //累计针数 int +#define U00015 "totalTime" //累计刺绣时间 int +#define U00016 "machineName" //机器(设备)名称 string +#define U00017 "deviceID" //设备(机器)ID string +#define U00018 "RackNumber" //机器编号(机架号) int +#define U00019 "Oline" //是否在线(0:离线;1:在线) int +#define U00020 "ErrorCode" //错误编码 int +#define U00021 "Message" //提示信息 string +#define U00022 "MachineEdition" //机器版本 string +#define U00023 "AlarmInformation" //报警信息 string +#define U00024 "TotalAuthorizationTime" //授权总时间(min) int +#define U00025 "AuthorizationTimeRemaining"//授权剩余时间(min) int +#define U00026 "StartupTime" //开机时间(min) int +#define U00027 "RunningTime" //运行时间(min) int +#define U00028 "CurrentProduction" //当前产量 int +#define U00029 "OutputSetting" //产量设定 int +#define U00030 "InterfaceVersion" //界面版本 string +#define U00031 "StagesPasswordState" //分期密码状态(0:未设置;1:已设置) int +#define U00032 "RemoteUpgradeState" //是否远程升级(0,1) int +#define U00033 "DeviceStatus" //设备状态编码 int +#define U00034 "spindleZeroSta" //主轴零位状态 int +#define U00035 "SpindleAngle" //主轴角度 int +#define U00036 "Frame_X" //绣框X坐标 int +#define U00037 "Frame_Y" //绣框y坐标 int +#define U00038 "StartButton1" //启动按钮1(0,1) int +#define U00039 "PauseButton1" //暂停按钮1(0,1) int +#define U00040 "JogButton1" //点动按钮1(0,1) int +#define U00041 "MFrameX_Z" //主框架X零位 int +#define U00042 "MFrameY_Z" //主框架Y零位 int +#define U00043 "MFrameX_N" //主框架X负限位 int +#define U00044 "MFrameY_N" //主框架Y负限位 int +#define U00045 "MFrameX_P" //主框架X正限位 int +#define U00046 "MFrameY_P" //主框架Y正限位 int +#define U00047 "ScissorsReturn" //剪刀回位(0,1) int +#define U000102 "electric_total" //电机总数 int +#define U000103 "sensor_total" //传感器总数 int +#define U000118 "realityTime" //手动输入实际交付时间 string +#define U000119 "manualProgress" //手动输入安装/调试进度 int +#define U000120 "hookMode" //勾线模式 +#define U000121 "taperedMode" //锁头模式 +#define U000122 "sewHeadNumbers" //缝纫机头个数 +#define U000123 "embHeadNumbers" //绣花机头个数 +#define U000124 "embneedleNumbers" //绣花机针个数 +#define U000125 "punchHeadNumbers" //冲孔机头个数 +#define U000126 "punchneedleNumbers" //冲孔机针个数 +#define U000149 "WorkProgress" //机器工作进度 + +#define S0504 "S0504" //已启动 +#define S0505 "S0505" //运行中 +#define S0506 "S0506" //机器空闲 + +//下行数据属性列表 +#define D00001 "StagesPassword " //分期密码 string +#define D00002 "Start" //开机指令(0,1) bool +#define D00003 "Stop" //停止指令(0,1) bool +#define D00004 "SetTurns" //设置转速 int +#define D00005 "RemoteUpgrade" //远程升级(0,1) bool + +//传感器信号索引,对应的excel表 +#define S00000 "S00000" //启动按钮 +#define S00010 "S00010" //暂停按钮 +#define S00020 "S00020" //点动按钮 +#define S00070 "S00070" //气压检测 +#define S00200 "S00200" //主框架X零位 +#define S00201 "S00201" //主框架Y零位 +#define S00220 "S00220" //主框架X负限位 +#define S00221 "S00221" //主框架Y负限位 +#define S00230 "S00230" //主框架X正限位 +#define S00231 "S00231" //主框架Y正限位 +#define S01000 "S01000" //剪刀回位 + +//有毛巾功能的传感器信号 +#define S01020 "S01020" // 毛巾M轴零位 +#define S01021 "S01021" // 毛巾打环轴零位 + +//绣花机电机 +#define M0001 "M0001" //X向移动电机 +#define M0002 "M0002" //Y向移动电机 +#define M0003 "M0003" //平绣主轴 +#define M0004 "M0004" //平绣换色电机 + +//有毛巾功能的电机 +#define M0005 "M0005" //毛巾主轴 +#define M0006 "M0006" //毛巾M轴 +#define M0007 "M0007" //毛巾打环轴 + +//有缠绕功能的电机 +#define M0008 "M0008" //缠绕主轴 +#define M0009 "M0009" //缠绕M轴 +#define M0010 "M0010" //缠绕压脚电机 +#define M0011 "M0011" //缠绕锯齿电机 + + +#endif // LOTSETTINGS_H diff --git a/settings/settings.cpp b/settings/settings.cpp new file mode 100644 index 0000000..7b16e8f --- /dev/null +++ b/settings/settings.cpp @@ -0,0 +1,453 @@ +#include "settings.h" +#include +#include +using namespace std; +Settings::Settings() +{ + m_configFile.clear(); + m_HMIconfigFile.clear(); +} + +void Settings::loadSetting(QString configfile) +{ + if (configfile.isEmpty() == false) + { + m_configFile = configfile; + } + + fillDefaultColor(); +} +void Settings::loadHMISetting(QString configfile) +{ + if (configfile.isEmpty() == false) + { + m_HMIconfigFile = configfile; + } +} + +//写入值到ini文件 +void Settings::writeToIniFile(QString key, QVariant value) +{ + if(m_configFile.length() <= 0){return;} + QSettings iniSetting(m_configFile, QSettings::IniFormat); + iniSetting.setValue(key,value); + //qDebug()<<"key"< > sbv; + sbv.push_back(make_pair(1, 0.7));//尾部插入数字 + sbv.push_back(make_pair(0.9, 0.7)); + sbv.push_back(make_pair(0.7, 0.7)); + sbv.push_back(make_pair(0.5, 0.7)); + sbv.push_back(make_pair(0.3, 0.7)); + sbv.push_back(make_pair(0.1, 0.7)); + sbv.push_back(make_pair(0.1, 1)); + sbv.push_back(make_pair(0.3, 1)); + sbv.push_back(make_pair(0.5, 1)); + sbv.push_back(make_pair(0.7, 1)); + sbv.push_back(make_pair(0.9, 1)); + sbv.push_back(make_pair(1, 1)); + float hv[] = {15, 31, 46, 61, 76, 91, 106, 121, 136, 151, 166, 181, 196, 211, 226, 241, 256, 271, 286, 301, 316, 331, 346}; + QRgb rgb[EMB_MC_SW_ND]; + int num = 0; + for(int i = 0; i < 12; i ++) + { + float s = sbv[i].first; + float b = sbv[i].second; + for(int j = 0; j < 24; j ++) + { + if(j==24) + { + float R = 225; + float G = 225; + float B = 225; + HSItoRGB(hv[j], s, b, &R, &G, &B); + rgb[num ++] = qRgb(R, G, B); + } + else + { + + float R, G, B; + HSItoRGB(hv[j], s, b, &R, &G, &B); + rgb[num ++] = qRgb(R, G, B); + } + } + } + + for (int i = 0; i < EMB_MC_SW_ND; i++) + { + m_colorRGB.append((char*)(&(rgb[i])), sizeof(QRgb)); + } + +#else + u8 r, g, b; + u8 * prgb; + const int cnum = 243; // 3的5次方 + int rcount = 0; + int gcount = 0; + int bcount = 0; + int temp; + r = 102; + g = 255; + b = 154; + for (int i = 0; i < cnum; i++) + { + if ((rcount <= gcount) && (rcount <= bcount)) + { + prgb = &r; + rcount++; + rcount %= 5; + } + else if ((gcount <= rcount) && (gcount <= bcount)) + { + prgb = &g; + gcount++; + gcount %= 5; + } + else if ((bcount <= rcount) && (bcount <= gcount)) + { + prgb = &b; + bcount++; + bcount %= 5; + } + else + { + break; + } + temp = *prgb; + temp += (int)(51.2*3 + 0.5); + if (temp > 255) + { + temp -= 256; + } + *prgb = temp; + + m_colorRGB.append(r); + m_colorRGB.append(g); + m_colorRGB.append(b); + m_colorRGB.append(255); + } +#endif +} + +void Settings::writeToCsv(QString strText,int type) +{ + QString filePath; + filePath.clear(); + + QDir apppath(qApp->applicationDirPath()); + if(type == TYPE_ERROR) + { + filePath = apppath.path() + apppath.separator() + CSV_ERROR; + } + else if(type == TYPE_BREAK) + { + filePath = apppath.path() + apppath.separator() + CSV_BREAK; + } + else if(type == TYPE_DEBUGINFO) + { + filePath = apppath.path() + apppath.separator() + CSV_DEBUGINFO; + } + if(filePath.length() <= 0){return;} + + QFile file(filePath); + if (file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) + { + QString strCurTime = QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss");//时间 + QString strMessage; + QTextStream in(&file);//写 + if(type == TYPE_DEBUGINFO) + { + strMessage = QString("%1//%2").arg(strCurTime).arg(strText);//时间,内容 + } + else + { + strMessage = QString("%1,%2").arg(strCurTime).arg(strText);//时间,内容 + } + in << strMessage << '\n'; + +#ifdef Q_OS_LINUX + system("sync"); +#endif + file.close(); + } +} + +void Settings::clearToCsv(int type) +{ + QString filePath; + filePath.clear(); + + QStringList tempbar; + tempbar.clear(); + + QDir apppath(qApp->applicationDirPath()); + if(type == TYPE_ERROR) + { + filePath = apppath.path() + apppath.separator() + CSV_ERROR; + } + else if(type == TYPE_BREAK) + { + filePath = apppath.path() + apppath.separator() + CSV_BREAK; + } + else if(type == TYPE_DEBUGINFO) + { + filePath = apppath.path() + apppath.separator() + CSV_DEBUGINFO; + } + + if(filePath.length() <= 0){return;} + + QStringList strAlarmInfoList; + int timeFlag = 0; + QFile file(filePath); + if (file.open(QIODevice::ReadOnly)) + { + QTextStream out(&file);//读 + QStringList tempOption = out.readAll().split("\n"); + // 获取系统当前时间 + QDateTime dateTime = QDateTime::currentDateTime(); + int curSecond = dateTime.toTime_t();//当前时间转换为秒 + int differSecond = curSecond-25920000; //30天 = 2592000秒 + QDateTime newDateTime; + + for (int i = 0; i < tempOption.count(); i++)//tempOption文件里的所有行 + { + if(type == TYPE_DEBUGINFO) + { + tempbar= tempOption.at(i).split("//");//获取每一行 以“//”号分开 + } + else + { + tempbar = tempOption.at(i).split(",");//获取每一行 以“,”号分开 + } + QString listTime =tempbar.at(0); + int newTime = newDateTime.fromString(listTime, "yyyy/MM/dd hh:mm:ss").toTime_t();//将字符串转换为秒 + //没超过30天的,存在列表里 + if(newTime >= differSecond) + { + tempbar.removeLast();//一共有2项(时间,内容)移除最后一项 + if (tempbar.size() > 0) + { + if (tempbar.at(0).indexOf(QString("DateTime")) != -1) + continue; + strAlarmInfoList << tempOption[i]; + } + } + else + { + if(newTime != -1)//第一行读不到时间,newTime会等于-1 + { + timeFlag = 1; + } + } + } + if(timeFlag == 1) + { + fileClear(filePath);//清除文件内容 + + for(int i =0;i800) + { + fileClear(filePath);//清除文件内容 + } + } +#ifdef Q_OS_LINUX + system("sync"); +#endif + file.close(); + return; +} +QStringList Settings::readToCsv(int type) +{ + QStringList strAlarmInfoList; + strAlarmInfoList.clear(); + + QStringList strInfoList; + strInfoList.clear(); + + QStringList newTempOption; + newTempOption.clear(); + + QString allinfo; + allinfo.clear(); + + QStringList tempbar; + tempbar.clear(); + + QString filePath;//文件 + filePath.clear(); + + QDir apppath(qApp->applicationDirPath()); + if(type == TYPE_ERROR) + { + filePath = apppath.path() + apppath.separator() + CSV_ERROR; + } + else if(type == TYPE_BREAK) + { + filePath = apppath.path() + apppath.separator() + CSV_BREAK; + } + else if(type == TYPE_DEBUGINFO) + { + filePath = apppath.path() + apppath.separator() + CSV_DEBUGINFO; + } + + if(filePath.length() <= 0){return strAlarmInfoList;} + + QFile file(filePath); + if (file.open(QIODevice::ReadOnly)) + { + QTextStream out(&file);//读 + + QStringList tempOption = out.readAll().split("\n"); + + for (int i = 0; i < tempOption.count(); i++)//tempOption文件里的所有行 + { + if(type == TYPE_DEBUGINFO) + { + tempbar= tempOption.at(i).split("//");//获取每一行 以“//”号分开 + } + else + { + tempbar = tempOption.at(i).split(",");//获取每一行 以“,”号分开 + } + if (tempbar.size() > 0) + { + //DateTime不显示 + if (tempbar.at(0).indexOf(QString("DateTime")) != -1) + continue; + } + + QString time = tempbar.at(0);//一共有2项(时间,内容) + QString info ="'"; + + if(time.length() > 0) + { + info = tempbar.at(1); + time.remove(" ");//清除空格 + if(type == TYPE_DEBUGINFO) + { + allinfo=time+"//"+info; + } + else + { + allinfo=time+","+info; + } + newTempOption.append(allinfo); + strInfoList << newTempOption[newTempOption.count()-1]; + } + } + for(int i = 0; i < strInfoList.count(); i++) + { + //if( (i != 0) && (((strInfoList.count() - 1 - i) >= 0 ) && ((strInfoList.count() - 1 - i) < strInfoList.count()))) + if( ((strInfoList.count() - 1 - i) >= 0 && ((strInfoList.count() - 1 - i) < strInfoList.count()))) + { + strAlarmInfoList << strInfoList[strInfoList.count() -1- i]; //xcy 0313 日志倒序显示 + } + } + } +#ifdef Q_OS_LINUX + system("sync"); +#endif + file.close(); + return strAlarmInfoList; +} + +//清除文件内容,不是删除文件 +void Settings::fileClear(QString filePath) +{ + QFile file(filePath); + file.open(QFile::WriteOnly|QFile::Truncate); +#ifdef Q_OS_LINUX + system("sync"); +#endif + file.close(); +} diff --git a/settings/settings.h b/settings/settings.h new file mode 100644 index 0000000..7f33bf9 --- /dev/null +++ b/settings/settings.h @@ -0,0 +1,57 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include +#include +#include +#include +#include //csv使用到 +#include +#include +#include +#include +#define EMB_MC_SW_ND 448 // 绣花机最大换色数 原为288,lxs20220803客户有一个花样需要448色序,进行更改 + +#define CSV_ERROR "csverro.csv" +#define CSV_BREAK "breakag.csv" +#define CSV_DEBUGINFO "debuginfo.csv" +#define CSV_PROGRESS "progress.csv" +#define BREAKINFOFILE "breakInfo" + +#define TYPE_ERROR 0 +#define TYPE_BREAK 1 +#define TYPE_DEBUGINFO 2 + +class Settings +{ +public: + Settings(); + +public: + void loadSetting(QString configfile); + inline QByteArray & getColorRgbArray() {return m_colorRGB;} + void writeToIniFile(QString key, QVariant value);//写入值到ini文件 + QVariant readFromIniFile(QString key);//从ini文件读取值 + bool ifKeyExists(QString key);//判断是否存在键值 + + void loadHMISetting(QString configfile); + void writeToInHMIiFile(QString key, QVariant value);//写入值到HMIini文件 + QVariant readFromInHMIiFile(QString key);//从HMIini文件读取值 + bool ifHMIKeyExists(QString key);//判断是否存在键值 + + void writeToCsv(QString strText,int type = 0); + QStringList readToCsv(int type = 0); + void clearToCsv(int type = 0); + void fileClear(QString filePath); +private: + QByteArray m_colorRGB; + QString m_configFile; + QString m_HMIconfigFile; + +private: + void fillDefaultColor(); + void HSItoRGB(float h,float s,float i,float *r,float *g,float *b);//hsb转换成rgb + +}; + +#endif // SETTINGS_H diff --git a/sharedviews/brokenlinedialog.cpp b/sharedviews/brokenlinedialog.cpp new file mode 100644 index 0000000..ae51055 --- /dev/null +++ b/sharedviews/brokenlinedialog.cpp @@ -0,0 +1,159 @@ +#include "brokenlinedialog.h" +#include "ui_brokenlinedialog.h" + +BrokenLineDialog::BrokenLineDialog(QWidget *parent) : + QWidget(parent), + ui(new Ui::BrokenLineDialog) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal );//用以设置窗口模态类型 ,ApplicationModal阻塞整个应用程序的所有窗口 + initWidget(); + initControl(); +} + +BrokenLineDialog::~BrokenLineDialog() +{ + delete ui; +} + +void BrokenLineDialog::initWidget() +{ + ui->labelContent->setText(""); + ui->labelContentInfo->setText(""); +} + +void BrokenLineDialog::initControl() +{ + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + initControlStyle();//初始化窗体控件样式 +} +void BrokenLineDialog::initResolution1910() +{ + //上状态栏 + this->resize(1322,820); + //this->move((1920-this->width())/2,(1080-this->height())/2); + this->move(192,62); + ui->frameBack->setGeometry(0,0,1322,820); + ui->labelTitle->setGeometry(20,15,900,56); + ui->labelContent->setGeometry(12,58,1300,700); + ui->labelContentInfo->setGeometry(12,58,1300,700); + ui->buttonOk->setGeometry(1110,710,174,60); +} + +void BrokenLineDialog::initResolution1006() +{ + //上状态栏 + + this->resize(710,460); + //this->move((1024-this->width())/2,(600-this->height())/2); + this->move(100,30); + + ui->frameBack->setGeometry(0,0,710,460); + ui->labelTitle->setGeometry(10,-5,500,56); + + ui->labelContent->setGeometry(15,56,680,340); + ui->labelContentInfo->setGeometry(15,56,680,340); + ui->buttonOk->setGeometry(590,400,96,40); +} +//初始化窗体控件样式 +void BrokenLineDialog::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //设置控件图标 + //背景图 + + ui->frameBack->setStyleSheet(TRANSPARENTSTYLE); + this->setStyleSheet(LABELWHITESTYLE); + ui->frameBack->setStyleSheet(setControlStyle.getStyleSheet(this->objectName())); + ui->labelTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelTitle->setFont(fontNormal_1); + ui->labelTitle->setAlignment(Qt::AlignLeft); + ui->labelTitle->setAlignment(Qt::AlignVCenter); +//数字 + ui->labelContent->setStyleSheet(LABELREDSTYLEBROKEN); // 断线机头 红色 字体加大 -rq + +// QFont font; +// font.setPixelSize(400); + //font.setFamily(FONTTYPE);//字体 +// ui->labelContent->setFont(font); + ui->labelContent->setFont(fontNormal_10); + ui->labelContent->setAlignment(Qt::AlignCenter);//文字水平垂直居中 + //ui->labelContent->setStyleSheet("font-size:400px"); + + // ui->labelContent->setAlignment(Qt::AlignHCenter); +// ui->labelContent->setAlignment(Qt::AlignVCenter); + + + ui->labelContentInfo->setStyleSheet(LABELREDSTYLEBROKEN); // 断线机头文字 红色 字体加大 -rq + QFont font;//设置断线文字大小 + if(g_emResolut == resolution1006 ) + { + font.setPixelSize(51); + } + else if (g_emResolut == resolution1910) + { + font.setPixelSize(101); + } + font.setFamily(FONTTYPE);//字体 + ui->labelContentInfo->setFont(font); + ui->labelContentInfo->setAlignment(Qt::AlignCenter);//文字水平垂直居中 + + ui->buttonOk->setWhiteBlueBottomStyle(); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1"),8); +} + +//设置标题 +void BrokenLineDialog::setTitleStr(QString str) +{ + ui->labelTitle->setText(str); +} + +//设置内容 +void BrokenLineDialog::setContentInfoStr(QString str) +{ + ui->labelContent->setText("");//数字的控件清空 + ui->labelContent->hide();//数字的控件隐藏 + ui->labelContentInfo->setText(str);//设置文字的控件内容 + ui->labelContentInfo->show();//文字的控件显示 +} + +void BrokenLineDialog::setContentStr(QString str) +{ + ui->labelContentInfo->setText(""); + ui->labelContentInfo->hide(); + ui->labelContent->setText(str); + ui->labelContent->show(); +} + +void BrokenLineDialog::show(int flag) +{ + if(flag == 1) + { + ui->labelContent->setStyleSheet(LABELREDSTYLEBROKENBLUE); // 断线机头 蓝色 字体加大 -rq + } + else if (flag == 3) + { + ui->labelContent->setStyleSheet(LABELBLACKSTYLE); // 断线机头 黑色 字体加大 -rq + } + QWidget::show(); +} + +void BrokenLineDialog::on_buttonOk_clicked() +{ + this->hide(); +} diff --git a/sharedviews/brokenlinedialog.h b/sharedviews/brokenlinedialog.h new file mode 100644 index 0000000..ba41031 --- /dev/null +++ b/sharedviews/brokenlinedialog.h @@ -0,0 +1,50 @@ +#ifndef BROKENLINEDIALOG_H +#define BROKENLINEDIALOG_H + +#include +#include +#include +#include "promptdialog.h" +#include "mybutton.h" +#include "setcontrolstyle.h" +//#include "Include/datafiledst.h" +#include "datafile/datafiledst.h" +#include "datafile/datafiledsr.h" +//#include "mctype/mainwidgetfunction.h" +#include +namespace Ui { +class BrokenLineDialog; +} + +class BrokenLineDialog : public QWidget +{ + Q_OBJECT + +public: + explicit BrokenLineDialog(QWidget *parent = 0); + ~BrokenLineDialog(); + +private slots: + + void on_buttonOk_clicked(); +private: + Ui::BrokenLineDialog *ui; + +private: + void initWidget(); + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006();//初始化窗体控件为1024x600分辨率 + void initControlStyle();//初始化窗体控件样式 + +public: + //int m_flag= 0; + void setTitleStr(QString str);//设置标题 + void setContentInfoStr(QString str);//设置内容 + void setContentStr(QString str);//设置内容 + void show(int flag=0); +}; + +#endif // BROKENLINEDIALOG_H + + diff --git a/sharedviews/brokenlinedialog.ui b/sharedviews/brokenlinedialog.ui new file mode 100644 index 0000000..8afd2ad --- /dev/null +++ b/sharedviews/brokenlinedialog.ui @@ -0,0 +1,158 @@ + + + BrokenLineDialog + + + + 0 + 0 + 541 + 300 + + + + Form + + + + + 70 + 69 + 401 + 131 + + + + + Agency FB + 72 + 75 + true + + + + border:0px; +background-color: rgb(240, 240, 240, 255); + + + 1 + + + Qt::AlignCenter + + + true + + + + + + 10 + 10 + 472 + 48 + + + + + + + Broken Line Prompt + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 450 + 250 + 71 + 31 + + + + + Agency FB + 9 + 50 + false + + + + Qt::NoFocus + + + + + + + + + + + + 0 + 0 + 541 + 301 + + + + background-color: rgba(245, 245, 245, 0);color: rgb(255, 255, 255); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 70 + 70 + 401 + 131 + + + + + Agency FB + 72 + 75 + true + + + + border:0px; +background-color: rgb(240, 240, 240, 255); + + + 1 + + + Qt::AlignCenter + + + true + + + frameBack + labelContent + labelTitle + labelContentInfo + buttonOk + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/controlactionwidget.cpp b/sharedviews/controlactionwidget.cpp new file mode 100644 index 0000000..5fc4195 --- /dev/null +++ b/sharedviews/controlactionwidget.cpp @@ -0,0 +1,780 @@ +#include "controlactionwidget.h" +#include "ui_controlactionwidget.h" + +ControlActionWidget::ControlActionWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::ControlActionWidget), + m_itemPerPage(8), + m_btnPerRow(5) +{ + ui->setupUi(this); + + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + + m_mousePressX = 0; + m_mousePressY = 0; + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; + + m_speed = 0; + + this->move(0,0); + + m_curPage = 0; + m_itemList.clear(); + m_allItemList.clear(); + initControl(); +} + +ControlActionWidget::~ControlActionWidget() +{ + delete ui; +} + +//初始化窗体控件,包括位置、尺寸、样式 +void ControlActionWidget::initControl() +{ + m_itemFrameList.clear(); + m_itemFrameList.append(ui->frame1); + m_itemFrameList.append(ui->frame2); + m_itemFrameList.append(ui->frame3); + m_itemFrameList.append(ui->frame4); + m_itemFrameList.append(ui->frame5); + ui->frame6->setVisible(false); + ui->frame7->setVisible(false); + ui->frame8->setVisible(false); + ui->frame9->setVisible(false); + ui->frame10->setVisible(false); + ui->frame11->setVisible(false); + ui->frame12->setVisible(false); + + ///等比例放大全部显示8条 +// if(g_emResolut == resolution1910)//1920x1080的分辨率每页显示12个条目 +// { +// ui->frame6->setVisible(true); +// ui->frame7->setVisible(true); +// ui->frame8->setVisible(true); +// ui->frame9->setVisible(true); +// ui->frame10->setVisible(true); +// ui->frame11->setVisible(true); +// ui->frame12->setVisible(true); +// m_itemFrameList.append(ui->frame6); +// m_itemFrameList.append(ui->frame7); +// m_itemFrameList.append(ui->frame8); +// m_itemFrameList.append(ui->frame9); +// m_itemFrameList.append(ui->frame10); +// m_itemFrameList.append(ui->frame11); +// m_itemFrameList.append(ui->frame12); +// } +// else if(g_emResolut == resolution1006)//1024x600的分辨率每页显示8个条目 + { + ui->frame6->setVisible(true);//显示 + ui->frame7->setVisible(true); + ui->frame8->setVisible(true); + m_itemFrameList.append(ui->frame6); + m_itemFrameList.append(ui->frame7); + m_itemFrameList.append(ui->frame8); + } + + m_itemLabelList.clear(); + m_itemLabelList.append(ui->label1); + m_itemLabelList.append(ui->label2); + m_itemLabelList.append(ui->label3); + m_itemLabelList.append(ui->label4); + m_itemLabelList.append(ui->label5); + m_itemLabelList.append(ui->label6); + m_itemLabelList.append(ui->label7); + m_itemLabelList.append(ui->label8); + m_itemLabelList.append(ui->label9); + m_itemLabelList.append(ui->label10); + m_itemLabelList.append(ui->label11); + m_itemLabelList.append(ui->label12); + + m_itemBtnList.clear(); + m_itemBtnList.append(ui->button1_1); + m_itemBtnList.append(ui->button1_2); + m_itemBtnList.append(ui->button1_3); + m_itemBtnList.append(ui->button1_4); + m_itemBtnList.append(ui->button1_5); + m_itemBtnList.append(ui->button2_1); + m_itemBtnList.append(ui->button2_2); + m_itemBtnList.append(ui->button2_3); + m_itemBtnList.append(ui->button2_4); + m_itemBtnList.append(ui->button2_5); + m_itemBtnList.append(ui->button3_1); + m_itemBtnList.append(ui->button3_2); + m_itemBtnList.append(ui->button3_3); + m_itemBtnList.append(ui->button3_4); + m_itemBtnList.append(ui->button3_5); + m_itemBtnList.append(ui->button4_1); + m_itemBtnList.append(ui->button4_2); + m_itemBtnList.append(ui->button4_3); + m_itemBtnList.append(ui->button4_4); + m_itemBtnList.append(ui->button4_5); + m_itemBtnList.append(ui->button5_1); + m_itemBtnList.append(ui->button5_2); + m_itemBtnList.append(ui->button5_3); + m_itemBtnList.append(ui->button5_4); + m_itemBtnList.append(ui->button5_5); + m_itemBtnList.append(ui->button6_1); + m_itemBtnList.append(ui->button6_2); + m_itemBtnList.append(ui->button6_3); + m_itemBtnList.append(ui->button6_4); + m_itemBtnList.append(ui->button6_5); + m_itemBtnList.append(ui->button7_1); + m_itemBtnList.append(ui->button7_2); + m_itemBtnList.append(ui->button7_3); + m_itemBtnList.append(ui->button7_4); + m_itemBtnList.append(ui->button7_5); + m_itemBtnList.append(ui->button8_1); + m_itemBtnList.append(ui->button8_2); + m_itemBtnList.append(ui->button8_3); + m_itemBtnList.append(ui->button8_4); + m_itemBtnList.append(ui->button8_5); + m_itemBtnList.append(ui->button9_1); + m_itemBtnList.append(ui->button9_2); + m_itemBtnList.append(ui->button9_3); + m_itemBtnList.append(ui->button9_4); + m_itemBtnList.append(ui->button9_5); + m_itemBtnList.append(ui->button10_1); + m_itemBtnList.append(ui->button10_2); + m_itemBtnList.append(ui->button10_3); + m_itemBtnList.append(ui->button10_4); + m_itemBtnList.append(ui->button10_5); + m_itemBtnList.append(ui->button11_1); + m_itemBtnList.append(ui->button11_2); + m_itemBtnList.append(ui->button11_3); + m_itemBtnList.append(ui->button11_4); + m_itemBtnList.append(ui->button11_5); + m_itemBtnList.append(ui->button12_1); + m_itemBtnList.append(ui->button12_2); + m_itemBtnList.append(ui->button12_3); + m_itemBtnList.append(ui->button12_4); + m_itemBtnList.append(ui->button12_5); + for(int var = 0; var < m_itemBtnList.size(); var++) + { + connect(m_itemBtnList.at(var), + SIGNAL(clicked(bool)), + this, + SLOT(slotItemBtnClicked()) + ); + + connect(m_itemBtnList.at(var), + SIGNAL(pressed()), + this, + SLOT(slotItemBtnPressed()) + ); + + connect(m_itemBtnList.at(var), + SIGNAL(released()), + this, + SLOT(slotItemBtnReleased()) + ); + } + + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void ControlActionWidget::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + + this->resize(1024*factoryX,600*factoryY); + ui->frameBack->setGeometry(0,0,1024*factoryX,600*factoryY); + ui->buttonTypeLogo->setGeometry(25*factoryX,30*factoryY,60*factoryX,60*factoryY); + ui->labelMainTitle->setGeometry(100*factoryX,30*factoryY,200*factoryX,24*factoryY); + ui->labelSubTitle->setGeometry(130*factoryX,64*factoryY,270*factoryX,21*factoryY); + + for(int i = 0; i < m_itemPerPage; i++) + { + m_itemFrameList[i]->setGeometry(154*factoryX,(98 + i * 53)*factoryY,718*factoryX,53*factoryY); + //m_itemLabelList[i]->setGeometry(10,22,331,26); + m_itemLabelList[i]->setGeometry(10*factoryX,22*factoryY,340*factoryX,26*factoryY); + } + for(int i = 0; i < m_btnPerRow; i++) + { + for(int j = 0; j < m_itemPerPage; j++) + { + m_itemBtnList[m_btnPerRow*j+i]->setGeometry((283+i*86)*factoryX,12*factoryY,80*factoryX,32*factoryY);//蓝色按钮大小位置 + } + } + + + ui->framePageBtn->setGeometry(700*factoryX,545*factoryY,600*factoryX,45*factoryY); + ui->labelPage->setGeometry(20*factoryX,550*factoryY,110*factoryX,45*factoryY); + ui->buttonPgUp->setGeometry(0,0,96*factoryX,40*factoryY); + ui->buttonPgDn->setGeometry(106*factoryX,0,96*factoryX,40*factoryY); + ui->buttonBack->setGeometry(212*factoryX,0,96*factoryX,40*factoryY); +} +//初始化窗体控件为1024x600分辨率 +void ControlActionWidget::initResolution1006() +{ + ///等比放大全部显示8条 +// m_itemPerPage = m_itemPerPage - 4; + this->resize(1024,600); + + ui->frameBack->setGeometry(0,0,1024,600); + ui->buttonTypeLogo->setGeometry(25,30,60,60); + ui->labelMainTitle->setGeometry(100,30,200,24); + ui->labelSubTitle->setGeometry(130,64,240,21); + + for(int i = 0; i < m_itemPerPage; i++) + { + m_itemFrameList[i]->setGeometry(154,98 + i * 53,718,53); + //m_itemLabelList[i]->setGeometry(10,22,331,26); + m_itemLabelList[i]->setGeometry(10,22,340,26); + } + for(int i = 0; i < m_btnPerRow; i++) + { + for(int j = 0; j < m_itemPerPage; j++) + { + m_itemBtnList[m_btnPerRow*j+i]->setGeometry(283+i*86,12,80,32);//蓝色按钮大小位置 + } + } + + + ui->framePageBtn->setGeometry(700,545,600,45); + ui->labelPage->setGeometry(20,550,102,45); + ui->buttonPgUp->setGeometry(0,0,96,40); + ui->buttonPgDn->setGeometry(106,0,96,40); + ui->buttonBack->setGeometry(212,0,96,40); +} + +//初始化窗体控件样式 +void ControlActionWidget::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //背景图 + QString frameBackImgPath = setControlStyle.getSharedStyleSheet(); + ui->frameBack->setStyleSheet(frameBackImgPath); + ui->labelMainTitle->setFont(fontBold_1); + ui->labelMainTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelSubTitle->setFont(fontNormal_1); + ui->labelSubTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelPage->setFont(fontNormal_1); + ui->labelPage->setStyleSheet(LABELWHITESTYLE); + + //条目frame + for(int i = 0; i < m_itemPerPage; i++) + { + m_itemFrameList[i]->setStyleSheet(TRANSPARENTSTYLE); + } + + //条目label + for(int i = 0; i < m_itemPerPage; i++) + { + m_itemLabelList[i]->setFont(fontNormal_1); + m_itemLabelList[i]->setStyleSheet(LABELWHITESTYLE); + } + + //条目按钮 + for(int i = 0; i < m_itemBtnList.size(); i++) + { + m_itemBtnList[i]->setWhiteBlueBottomStyle();//都用一个底图 + m_itemBtnList[i]->setFont(fontNormal_1); + } + + //四个按钮样式表一样 + ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + + ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + + ui->buttonBack->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonBack->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonBack->objectName()),12); +} + +void ControlActionWidget::refreshUi(int idx) +{ + // m_itemList 所有的控制动作 + if(idx != 0) + { + m_itemList.clear(); + + for( int i= 0; i < m_allItemList.size();i++) + { + m_itemList.append(m_allItemList[i]); + } + } + + int itemNum,pageNums; + if (m_itemList.size() == 0) + { + itemNum = 0; + } + else + { + itemNum = m_itemList.size(); + } + + pageNums = (itemNum+m_itemPerPage-1) / m_itemPerPage; // 计算页数 + + if (m_curPage > pageNums) // 当前页 + { + m_curPage = pageNums; + } + if (m_curPage <= 1) + { + m_curPage = 1; + } + + int itemidx = (m_curPage-1) * m_itemPerPage; + + for (int i = 0; i < m_itemPerPage; i++) + { + if (itemidx < itemNum) + { + m_itemFrameList.at(i)->show(); + OutCtrlItem item = m_itemList.at(itemidx); + m_itemLabelList[i]->setText(item.m_name); + + m_itemBtnList[i*m_btnPerRow]->setText(item.m_btn1Str); + m_itemBtnList[i*m_btnPerRow+1]->setText(item.m_btn2Str); + m_itemBtnList[i*m_btnPerRow+2]->setText(item.m_btn3Str); + m_itemBtnList[i*m_btnPerRow+3]->setText(item.m_btn4Str); + m_itemBtnList[i*m_btnPerRow+4]->setText(item.m_btn5Str); + + m_itemBtnList[i*m_btnPerRow]->setVisible(item.m_btn1Visible); + m_itemBtnList[i*m_btnPerRow+1]->setVisible(item.m_btn2Visible); + m_itemBtnList[i*m_btnPerRow+2]->setVisible(item.m_btn3Visible); + m_itemBtnList[i*m_btnPerRow+3]->setVisible(item.m_btn4Visible); + m_itemBtnList[i*m_btnPerRow+4]->setVisible(item.m_btn5Visible); + + itemidx++; + } + else + { + m_itemFrameList.at(i)->hide(); + } + } + + // 翻页按钮 + if (m_curPage <= 1) + { + ui->buttonPgUp->setEnabled(false); + } + else + { + ui->buttonPgUp->setEnabled(true); + } + if (m_curPage >= pageNums) + { + ui->buttonPgDn->setEnabled(false); + } + else + { + ui->buttonPgDn->setEnabled(true); + } + + if(pageNums == 0) + { + m_curPage = 0; + } + + // 页信息 + QString str = tr("pageNum: ") + QString("%1/%2").arg(m_curPage).arg(pageNums);//页数: + ui->labelPage->setText(str); +} + +//按钮动作 +void ControlActionWidget::btnAction(int rowidx, int btnidx, int event) +{ + int nidx = (rowidx - 1) + (m_curPage - 1) * m_itemPerPage; + int size = m_itemList.size(); + if(size <= 0) + { + return; + } + + if(nidx >= size) + { + return; + } + + OutCtrlItem item = m_itemList[nidx]; + int def = item.m_def; + int fun = -1; + + switch(btnidx) + { + case 1: + switch(event) + { + case BTNCLICK: + fun = item.m_btn1ClickFun; + break; + case BTNPRE: + fun = item.m_btn1PreFun; + break; + case BTNREL: + fun = item.m_btn1RelFun; + break; + } + break; + case 2: + switch(event) + { + case BTNCLICK: + fun = item.m_btn2ClickFun; + break; + case BTNPRE: + fun = item.m_btn2PreFun; + break; + case BTNREL: + fun = item.m_btn2RelFun; + break; + } + break; + case 3: + switch(event) + { + case BTNCLICK: + fun = item.m_btn3ClickFun; + break; + case BTNPRE: + fun = item.m_btn3PreFun; + break; + case BTNREL: + fun = item.m_btn3RelFun; + break; + } + break; + case 4: + switch(event) + { + case BTNCLICK: + fun = item.m_btn4ClickFun; + break; + case BTNPRE: + fun = item.m_btn4PreFun; + break; + case BTNREL: + fun = item.m_btn4RelFun; + break; + } + break; + case 5: + switch(event) + { + case BTNCLICK: + fun = item.m_btn5ClickFun; + break; + case BTNPRE: + fun = item.m_btn5PreFun; + break; + case BTNREL: + fun = item.m_btn5RelFun; + break; + } + break; + default: + fun = -1; + break; + } + excuteOrder(def,fun); +} + +void ControlActionWidget::slotSpeed(int speed) // 手动换挡 +{ + m_speed = speed; +} + +//执行按钮动作 +void ControlActionWidget::excuteOrder(int def, int fun) +{ + if(def < 0 || fun < 0) + return; + PromptDialog promptDlg(this); + QString str = tr("The machine is about to move, please pay attention to safety!");//机器即将运动,请注意安全! + switch(fun) + { + case OUTCONTROL_ENABLE: + g_pMachine->motoServoCtrl(def, UP_OPEN_ON); + break; + case OUTCONTROL_DISABLE: + g_pMachine->motoServoCtrl(def, DOWN_CLOSE_OFF); + break; + case OUTCONTROL_MS_ENABLE://主轴 + break; + case OUTCONTROL_MS_DISABLE: + break; + case OUTCONTROL_JOGP://电机点动正转 + if(m_speed == 1) // 手动换挡 + { + g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 1); + break; + } + else if(m_speed == 2) + { + g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 2); + break; + } + else if(m_speed == 3) + { + g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 3); + break; + } + else + { + g_pMachine->motoMove(def, MT_MOVE_DIR_POSI, 0); + break; + } + + case OUTCONTROL_JOGN://电机点动反转 + if(m_speed == 1) + { + g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 1); + break; + } + else if(m_speed == 2) + { + g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 2); + break; + } + else if(m_speed == 3) + { + g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 3); + break; + } + else + { + g_pMachine->motoMove(def, MT_MOVE_DIR_NEGA, 0); + break; + } + + case OUTCONTROL_STOP://电机点动停止 + g_pMachine->motoMove(def, MT_MOVE_DIR_STOP, 0); + break; + case OUTCONTROL_ZERO://电机归零 + g_pMachine->motoToZero(def); + break; + case OUTCONTROL_LEFT://电机位置前 + g_pMachine->outputCtrl(def, UP_OPEN_ON, 0); + break; + case OUTCONTROL_MIDDLE://电机位置中 + g_pMachine->outputCtrl(def, DOWN_CLOSE_OFF, 0); + break; + case OUTCONTROL_RIGHT://电机位置后 + g_pMachine->outputCtrl(def, OT_ACTION, 0); + break; + case OUTCONTROL_UP://气缸上升,输出控制方式的电机正转 + g_pMachine->outputCtrl(def, UP_OPEN_ON, 0); + break; + case OUTCONTROL_DOWN://气缸下降,输出控制方式的电机反转 + g_pMachine->outputCtrl(def, DOWN_CLOSE_OFF, 0); + break; + case MANUALACTION_RUN://手动动作执行 + g_pMachine->manualAction(def); + break; + case OUTCONTROL_OPEN://电磁阀开 + g_pMachine->outputCtrl(def, UP_OPEN_ON, 0); + break; + case OUTCONTROL_CLOSE://电磁阀合 + g_pMachine->outputCtrl(def, DOWN_CLOSE_OFF, 0); + break; + case OUTCONTROL_STARTOIL://开始(如手动加油) + g_pMachine->manualOil(1); + break; + case OUTCONTROL_STOPOIL://停止(如手动加油) + g_pMachine->manualOil(0); + break; + case ALLTO_ZERO: // 全部归零 + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDlg.setTitleStr(tr("All to zero"));//全部归零 + promptDlg.setContentStr(str); + if(promptDlg.exec() == 1) + g_pMachine->allToZero(); + break; + + default: + break; + } +} + +//设置类型图标 +void ControlActionWidget::setTypeLogo(QString tStyle) +{ + ui->buttonTypeLogo->setUnPreBtnLogo(tStyle); +} + +//设置主title +void ControlActionWidget::setMainTitle(QString str) +{ + ui->labelMainTitle->setText(str); +} + +//设置副title +void ControlActionWidget::setSubTitle(QString str) +{ + ui->labelSubTitle->setText(str); +} + +void ControlActionWidget::addItemList(QList itemList) +{ + m_itemList.append(itemList); + m_allItemList.append(itemList); +} + +//控制按钮被点击 +void ControlActionWidget::slotItemBtnClicked() +{ + MyButton *button = (MyButton*) this->sender() ; + + if(button == NULL) + { + return; + } + + //获取所触发按钮的行和按钮索引 + int rowIdx,btnIdx; + rowIdx = btnIdx = 1; + for(int i = 0; i < m_itemBtnList.size(); i++) + { + if(button == m_itemBtnList[i]) + { + rowIdx = i / m_btnPerRow + 1; + btnIdx = i % m_btnPerRow + 1; + btnAction(rowIdx,btnIdx,BTNCLICK); + break; + } + } +} + +//控制按钮按下 +void ControlActionWidget::slotItemBtnPressed() +{ + MyButton *button = (MyButton*) this->sender() ; + + if(button == NULL) + { + return; + } + + //获取所触发按钮的行和按钮索引 + int rowIdx,btnIdx; + rowIdx = btnIdx = 1; + for(int i = 0; i < m_itemBtnList.size(); i++) + { + if(button == m_itemBtnList[i]) + { + rowIdx = i / m_btnPerRow + 1; + btnIdx = i % m_btnPerRow + 1; + btnAction(rowIdx,btnIdx,BTNPRE); + break; + } + } +} + +//控制按钮抬起 +void ControlActionWidget::slotItemBtnReleased() +{ + MyButton *button = (MyButton*) this->sender() ; + + if(button == NULL) + { + return; + } + + //获取所触发按钮的行和按钮索引 + int rowIdx,btnIdx; + rowIdx = btnIdx = 1; + for(int i = 0; i < m_itemBtnList.size(); i++) + { + if(button == m_itemBtnList[i]) + { + rowIdx = i / m_btnPerRow + 1; + btnIdx = i % m_btnPerRow + 1; + btnAction(rowIdx,btnIdx,BTNREL); + break; + } + } +} + +void ControlActionWidget::on_buttonPgUp_clicked() +{ + m_curPage--; + refreshUi(); +} + +void ControlActionWidget::on_buttonPgDn_clicked() +{ + m_curPage++; + refreshUi(); +} + +void ControlActionWidget::on_buttonBack_clicked() +{ + this->hide(); +} + +void ControlActionWidget::mousePressEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + m_mousePressX = e->x(); + m_mousePressY = e->y(); + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; + } +} + +void ControlActionWidget::mouseReleaseEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + m_mouseReleaseX = e->x(); + m_mouseReleaseY = e->y(); + } + + int width = this->width(); + int height = this->height(); + if ((m_mousePressX >= 0 && m_mousePressX <= 100) && + ((m_mousePressY >= (height - 100)) && m_mousePressY <= height) && + ((m_mouseReleaseX >= (width - 100)) && m_mouseReleaseX <= width) && + ((m_mouseReleaseY >= (height - 100)) && m_mouseReleaseY <= height)) + { + MainWidgetFunction mainFunction; + QString usbPath;//优盘路径 + usbPath = mainFunction.detectUsb();//优盘检测 + if(usbPath.length() <= 0) + { + //优盘不存在 + return; + } + else + { + QPixmap pixmap=QPixmap::grabWindow(this->winId(),0,0,this->width(),this->height());//截屏存放在pixmap + QString name_pc = usbPath + "EMB" + // + QDateTime::currentDateTime().toString("yyyyMMdd") +//获取时期时间 + +"_"+ + QDateTime::currentDateTime().toString("hhmmss") + ".png"; + + pixmap.save(name_pc,"png"); // 路径 + } + } + + m_mousePressX = 0; + m_mousePressY = 0; + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; +} diff --git a/sharedviews/controlactionwidget.h b/sharedviews/controlactionwidget.h new file mode 100644 index 0000000..440b82d --- /dev/null +++ b/sharedviews/controlactionwidget.h @@ -0,0 +1,86 @@ +#ifndef CONTROLACTIONWIDGET_H +#define CONTROLACTIONWIDGET_H + +#include +#include "items/outctrlitem.h" +#include "mybutton.h" +#include "setcontrolstyle.h" +#include +#include +#include "mctype/mainwidgetfunction.h" +#include + +#define BORDER_RADIUS "5" + +namespace Ui { +class ControlActionWidget; +} + +class ControlActionWidget : public QWidget +{ + Q_OBJECT + +public: + explicit ControlActionWidget(QWidget *parent = 0); + ~ControlActionWidget(); + +private: + Ui::ControlActionWidget *ui; + + enum BTNEVENT { BTNCLICK = 1, BTNPRE, BTNREL}; + + int m_itemPerPage;//界面每页条目数 + int m_btnPerRow;//每行按钮数 + int m_curPage;//当前页数 + QList m_itemFrameList; + QList m_itemLabelList; + QList m_itemBtnList; + QList m_allItemList; + QList m_itemList; + + QTimer * m_motorTimer; // 电机停止命令多次发送 + int m_speed;//换挡速度 + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006();//初始化窗体控件为1024x600分辨率 + void initControlStyle();//初始化窗体控件样式 + + void btnAction(int rowidx, int btnidx, int event);//按钮动作,参数包括行、按钮索引、按钮事件 + void excuteOrder(int def,int fun);//执行按钮动作 + +public: + void setTypeLogo(QString tStyle);//设置类型图标 + void setMainTitle(QString str);//设置主title + void setSubTitle(QString str);//设置副title + + void refreshUi(int idx = 0); + +public: + void addItemList(QList itemList); + +private slots: + void slotItemBtnClicked();//控制按钮被点击 + void slotItemBtnPressed();//控制按钮按下 + void slotItemBtnReleased();//控制按钮抬起 + void on_buttonPgUp_clicked(); + void on_buttonPgDn_clicked(); + void on_buttonBack_clicked(); + +public slots: + void slotSpeed(int speed); + //鼠标事件 +protected: + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + +private: + int m_mousePressX; + int m_mousePressY; + int m_mouseReleaseX; + int m_mouseReleaseY; + +}; + +#endif // CONTROLACTIONWIDGET_H diff --git a/sharedviews/controlactionwidget.ui b/sharedviews/controlactionwidget.ui new file mode 100644 index 0000000..f661782 --- /dev/null +++ b/sharedviews/controlactionwidget.ui @@ -0,0 +1,1577 @@ + + + ControlActionWidget + + + + 0 + 0 + 1024 + 600 + + + + Form + + + + + 0 + 0 + 1024 + 600 + + + + background-color: rgb(182, 182, 182); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 30 + 10 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + + + + 760 + 570 + 241 + 31 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 80 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 0 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 160 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + buttonPgUp + buttonPgDn + buttonBack + + + + + 110 + 10 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Control action + + + + + + 140 + 40 + 261 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Control action < Auxiliary function + + + + + + 20 + 570 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + PageNums: 1/1 + + + + + + 140 + 80 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 120 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 240 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 200 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 280 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 160 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 320 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 360 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 400 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 440 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 480 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + 140 + 520 + 760 + 32 + + + + background-color: rgb(239, 239, 239); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 4 + 331 + 16 + + + + TextLabel + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + 350 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 430 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 510 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 590 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + 670 + 4 + 75 + 23 + + + + Qt::NoFocus + + + PushButton + + + + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/debuginfodialog.cpp b/sharedviews/debuginfodialog.cpp new file mode 100644 index 0000000..e9c09f8 --- /dev/null +++ b/sharedviews/debuginfodialog.cpp @@ -0,0 +1,246 @@ +#include "debuginfodialog.h" +#include "ui_debuginfodialog.h" + +DebugInfoDialog::DebugInfoDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::DebugInfoDialog), + m_itemPerPage(25) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setAttribute(Qt::WA_TranslucentBackground, true);//设置窗体背景透明 + setWindowModality(Qt::ApplicationModal); + connect(g_pMachine, SIGNAL(siDebugInfo()), this, SLOT(slotDebugInfo())); + + initDialog(); + initControl(); +} + +DebugInfoDialog::~DebugInfoDialog() +{ + delete ui; +} +void DebugInfoDialog::initDialog() +{ + m_curPages = 1;//当前页数 + m_pageNums = 1;//总页数 + m_infoList.clear(); +} +void DebugInfoDialog::initControl() +{ + m_DebugInfoBtnList.append(ui->button1); + m_DebugInfoBtnList.append(ui->button2); + m_DebugInfoBtnList.append(ui->button3); + m_DebugInfoBtnList.append(ui->button4); + m_DebugInfoBtnList.append(ui->button5); + m_DebugInfoBtnList.append(ui->button6); + m_DebugInfoBtnList.append(ui->button7); + m_DebugInfoBtnList.append(ui->button8); + m_DebugInfoBtnList.append(ui->button9); + m_DebugInfoBtnList.append(ui->button10); + m_DebugInfoBtnList.append(ui->button11); + m_DebugInfoBtnList.append(ui->button12); + m_DebugInfoBtnList.append(ui->button13); + m_DebugInfoBtnList.append(ui->button14); + m_DebugInfoBtnList.append(ui->button15); + m_DebugInfoBtnList.append(ui->button16); + m_DebugInfoBtnList.append(ui->button17); + m_DebugInfoBtnList.append(ui->button18); + m_DebugInfoBtnList.append(ui->button19); + m_DebugInfoBtnList.append(ui->button20); + m_DebugInfoBtnList.append(ui->button21); + m_DebugInfoBtnList.append(ui->button22); + m_DebugInfoBtnList.append(ui->button23); + m_DebugInfoBtnList.append(ui->button24); + m_DebugInfoBtnList.append(ui->button25); + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + initControlStyle();//初始化窗体控件样式 + //refreshUi(); +} +void DebugInfoDialog::initResolution1910() +{ + //上状态栏 + this->resize(1322,935); + this->move(192,65); + ui->frameBack->setGeometry(0,0,1322,935); + ui->labelMainTitle->setGeometry(12,8,300,40); + for(int i = 0; i < m_itemPerPage; i++) + { + m_DebugInfoBtnList[i]->setGeometry(30,52 + i * 34,800,30); + } + ui->labelPage->setGeometry(12,890,400,40); + ui->buttonPgUp->setGeometry(1040,40,118,40); + ui->buttonPgDn->setGeometry(1178,40,118,40); + ui->buttonCancel->setGeometry(1040,100,118,40); +} +void DebugInfoDialog::initResolution1006() +{ + m_itemPerPage = m_itemPerPage -8; + this->resize(707,513); + this->move(101,36); + ui->frameBack->setGeometry(0,0,710,513); + ui->labelMainTitle->setGeometry(10,6,300,28); + for(int i = 0; i < m_itemPerPage; i++) + { + m_DebugInfoBtnList[i]->setGeometry(10,30 + i * 27,500,24); + } + ui->labelPage->setGeometry(10,485,150,30); + ui->buttonPgUp->setGeometry(520,40,82,30); + ui->buttonPgDn->setGeometry(610,40,82,30); + ui->buttonCancel->setGeometry(520,80,82,30); +} +//初始化窗体控件样式 +void DebugInfoDialog::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + //背景图 + //QString style1 = "background-color: rgb(62, 62, 62);outline:none;border:0px;border-radius:10px;"; + QString style1 = "background-color: rgb(246, 242, 239);outline:none;border:0px;border-radius:10px;"; + ui->frameBack->setStyleSheet(style1); + ui->labelMainTitle->setFont(fontNormal_3); + ui->labelMainTitle->setStyleSheet(LABELGREYSTYLE); + + QString style2 = "border:0px;text-align:left;background-color:rgba(255, 255, 255, 0);color: rgb(78, 78, 78);";//0, 183, 13 + for(int i = 0; i < m_DebugInfoBtnList.size(); i++) + { + m_DebugInfoBtnList[i]->setStyleSheet(style2);//文本左对齐 + m_DebugInfoBtnList[i]->setFont(fontNormal_4); + } + ui->labelPage->setFont(fontNormal_4); + ui->labelPage->setStyleSheet(LABELGREYSTYLE); + ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + ui->buttonCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12); +} +void DebugInfoDialog::addListInfo() +{ + m_infoList = g_pSettings->readToCsv(TYPE_DEBUGINFO);//读取 QStringList + refreshUi(); +} +void DebugInfoDialog::refreshUi() +{ + int itemNum; + if (m_infoList.size() <= 0) + { + itemNum = 0; + + for (int i = 0; i < m_itemPerPage; i++) + { + m_DebugInfoBtnList.at(i)->hide(); + } + ui->labelPage->setText(tr("pageNum: 0/0"));//页数: 0/0 + ui->buttonPgUp->setEnabled(false); + ui->buttonPgDn->setEnabled(false); + //ui->buttonOk->setEnabled(false); + + return; + } + else + { + itemNum = m_infoList.size(); + } + + m_pageNums = (itemNum + m_itemPerPage - 1)/m_itemPerPage;// 计算页数 + if (m_curPages > m_pageNums)// 当前页 + { + m_curPages = m_pageNums; + } + if (m_curPages <= 1 && itemNum != 0) + { + m_curPages = 1; + } + + int itemidx = (m_curPages - 1) * m_itemPerPage; + + for (int i = 0; i < m_itemPerPage; i++) + { + if (itemidx < itemNum) + { + //设置图标和文件夹名称 + m_DebugInfoBtnList[i]->setText(m_infoList.at(itemidx)); + m_DebugInfoBtnList.at(i)->show(); + + itemidx++; + } + else + { + m_DebugInfoBtnList.at(i)->hide(); + } + } + + // 翻页按钮 + if (m_curPages <= 1) + { + ui->buttonPgUp->setEnabled(false); + } + else + { + ui->buttonPgUp->setEnabled(true); + } + if (m_curPages >= m_pageNums) + { + ui->buttonPgDn->setEnabled(false); + } + else + { + ui->buttonPgDn->setEnabled(true); + } + + // 页信息 + if(m_pageNums == 0) + { + m_curPages = 0; + } + + QString str = tr("pageNum: ") + QString("%1/%2").arg(m_curPages).arg(m_pageNums);//页数: + ui->labelPage->setText(str); +} +void DebugInfoDialog::slotDebugInfo() +{ + DebugInfo info;//调试信息 + char mDebugInfoStr[1024+1]; + + info = g_pMachine->getDebugInfo(); + memcpy(mDebugInfoStr, info.debugInfoStr, 1024); + mDebugInfoStr[1024] = 0; + + QString strDebugInfoStr; + strDebugInfoStr.sprintf("%s", mDebugInfoStr); + QString strCurTime = QDateTime::currentDateTime().toString("yyyy/MM/dd/hh:mm:ss");//时间 + QString strMessage; + strMessage = QString("%1//%2").arg(strCurTime).arg(strDebugInfoStr);//时间,内容 + m_infoList.insert(0,strMessage); + + //m_infoList = g_pSettings->readToCsv(TYPE_DEBUGINFO);//读取 QStringList + refreshUi(); +} +void DebugInfoDialog::on_buttonCancel_clicked() +{ + done(0); +} +void DebugInfoDialog::on_buttonPgUp_clicked() +{ + m_curPages--; + refreshUi(); +} +void DebugInfoDialog::on_buttonPgDn_clicked() +{ + m_curPages++; + refreshUi(); +} diff --git a/sharedviews/debuginfodialog.h b/sharedviews/debuginfodialog.h new file mode 100644 index 0000000..ee67e57 --- /dev/null +++ b/sharedviews/debuginfodialog.h @@ -0,0 +1,47 @@ +#ifndef DEBUGINFODIALOG_H +#define DEBUGINFODIALOG_H + +#include +#include +#include +#include "setcontrolstyle.h" +#include "mybutton.h" + +namespace Ui { +class DebugInfoDialog; +} + +class DebugInfoDialog : public QDialog +{ + Q_OBJECT + +public: + explicit DebugInfoDialog(QWidget *parent = 0); + ~DebugInfoDialog(); +public: + void initDialog(); + void refreshUi(); + void addListInfo(); +private: + Ui::DebugInfoDialog *ui; +private: + QList m_DebugInfoBtnList; + QStringList m_infoList; + int m_itemPerPage; + int m_curPages;//当前页数 + int m_pageNums;//总页数 + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006(); + void initControlStyle();//初始化窗体控件样式 +public slots: + void slotDebugInfo(); +private slots: + void on_buttonCancel_clicked(); + void on_buttonPgUp_clicked(); + void on_buttonPgDn_clicked(); +}; + +#endif // DEBUGINFODIALOG_H diff --git a/sharedviews/debuginfodialog.ui b/sharedviews/debuginfodialog.ui new file mode 100644 index 0000000..a2d3e3f --- /dev/null +++ b/sharedviews/debuginfodialog.ui @@ -0,0 +1,651 @@ + + + DebugInfoDialog + + + + 0 + 0 + 702 + 603 + + + + Dialog + + + + + + + + 0 + 0 + 701 + 600 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 40 + 440 + 21 + + + + Qt::NoFocus + + + + + + + + + + 0 + 0 + + + + + + + 10 + 189 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 249 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 129 + 440 + 21 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 279 + 440 + 21 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 309 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 369 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 159 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 69 + 440 + 21 + + + + Qt::NoFocus + + + + + + + + + + 0 + 0 + + + + + + + 10 + 219 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 99 + 440 + 21 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 339 + 440 + 21 + + + + Qt::NoFocus + + + + + + + + + + + + 480 + 50 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 560 + 20 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 480 + 20 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 10 + 570 + 101 + 16 + + + + PageNums: 1/1 + + + + + + 10 + 10 + 72 + 15 + + + + DebugInfo: + + + + + + 10 + 399 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 429 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 459 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 489 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 520 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 550 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 550 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 550 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 550 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 550 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 550 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 550 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 550 + 440 + 20 + + + + Qt::NoFocus + + + + + + + + + buttonCancel + buttonPgDn + buttonPgUp + labelPage + labelMainTitle + button1 + button3 + button5 + button9 + button6 + button12 + button10 + button11 + button4 + button7 + button8 + button2 + button13 + button14 + button15 + button16 + button17 + button18 + button19 + button20 + button21 + button22 + button23 + button24 + button25 + + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/fileselectdialog.cpp b/sharedviews/fileselectdialog.cpp new file mode 100644 index 0000000..4cea3de --- /dev/null +++ b/sharedviews/fileselectdialog.cpp @@ -0,0 +1,245 @@ +#include "fileselectdialog.h" +#include "ui_fileselectdialog.h" + +FileSelectDialog::FileSelectDialog(QString filePath, QWidget *parent) : + QDialog(parent), + ui(new Ui::FileSelectDialog), + m_filePath(filePath), + m_itemPerPage(8) +{ + ui->setupUi(this); + setWindowFlags(Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + initControl(); + initData(); + refreshUi(); + m_fileName.clear(); +} + +FileSelectDialog::~FileSelectDialog() +{ + delete ui; +} + +void FileSelectDialog::initControl() +{ + + m_itemBtnList.clear(); + m_itemBtnList.append(ui->button1); + m_itemBtnList.append(ui->button2); + m_itemBtnList.append(ui->button3); + m_itemBtnList.append(ui->button4); + m_itemBtnList.append(ui->button5); + m_itemBtnList.append(ui->button6); + m_itemBtnList.append(ui->button7); + m_itemBtnList.append(ui->button8); + + + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +void FileSelectDialog::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + + this->resize(1024*factoryX,600*factoryY); + ui->frameBack->setGeometry(0,0,1024*factoryX,600*factoryY); + + for(int i = 0; i < m_itemPerPage; i++)//白色按下的效果 + { + m_itemBtnList[i]->setGeometry(153*factoryX,(96 + i * 53)*factoryY,718*factoryX,53*factoryY); + QString style1 = "QPushButton{outline: none;border:0px;border-radius:7px;background-color:rgba(255, 255, 255, 0);color: rgb(255, 255, 255);}"; + m_itemBtnList[i]->setStyleSheet(style1); + m_itemBtnList[i]->setTopImage(NULL); + } + + ui->framePageBtn->setGeometry(595*factoryX, 545*factoryY, 600*factoryX, 45*factoryY); + ui->buttonPgUp->setGeometry(0, 0, 96*factoryX, 40*factoryY); + ui->buttonPgDn->setGeometry(106*factoryX, 0, 96*factoryX, 40*factoryY); + ui->buttonOk->setGeometry(212*factoryX, 0, 96*factoryX, 40*factoryY); + ui->buttonCancel->setGeometry(318*factoryX, 0, 96*factoryX, 40*factoryY); + ui->labelPage->setGeometry(10*factoryX, 570*factoryY, 181*factoryX, 21*factoryY); +} + +void FileSelectDialog::initResolution1006() +{ + + this->resize(1024,600); + ui->frameBack->setGeometry(0,0,1024,600); + + for(int i = 0; i < m_itemPerPage; i++)//白色按下的效果 + { + m_itemBtnList[i]->setGeometry(153,96 + i * 53,718,53); + QString style1 = "QPushButton{outline: none;border:0px;border-radius:7px;background-color:rgba(255, 255, 255, 0);color: rgb(255, 255, 255);}"; + m_itemBtnList[i]->setStyleSheet(style1); + m_itemBtnList[i]->setTopImage(NULL); + m_itemBtnList[i]->setFont(fontNormal_6); + } + + ui->framePageBtn->setGeometry(595,545,600,45); + ui->buttonPgUp->setGeometry(0,0,96,40); + ui->buttonPgDn->setGeometry(106,0,96,40); + ui->buttonOk->setGeometry(212,0,96,40); + ui->buttonCancel->setGeometry(318,0,96,40); + ui->labelPage->setGeometry(10, 570, 181, 21); +} + +void FileSelectDialog::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->parent()->objectName()); + //背景图 + QString frameBackImgPath = setControlStyle.getSharedStyleSheet(); + ui->frameBack->setStyleSheet(frameBackImgPath); + + + //条目 + for(int i = 0; i < m_itemPerPage; i++) + { + m_itemBtnList[i]->setLabelFont(fontNormal_1); + connect(m_itemBtnList[i], SIGNAL(clicked(bool)), this, SLOT(btnclicked())); + } + + //四个按钮样式表一样 + ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + + ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + + ui->buttonOk->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()),12); + + ui->buttonCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12); +} + +void FileSelectDialog::refreshUi() +{ + //清空全部按钮数据 + foreach (QPushButton* button, m_itemBtnList) { + button->setText(""); + button->setEnabled(false); + button->setVisible(false); + } + + //计算页码范围 + m_pageNums = m_fileNameList.size() / m_itemPerPage;//向上取整 总页数 + m_pageNums = (m_fileNameList.size() % m_itemPerPage == 0) ? m_pageNums : m_pageNums + 1; + + if (m_curPages > m_pageNums)// 当前页 + { + m_curPages = m_pageNums; + } + if (m_curPages < 1) + { + m_curPages = 1; + } +// qDebug()<<"m_pageNums" < m_fileNameList.size() - 1) + { + break; + } + else{ + QString str = m_fileNameList[index]; + m_itemBtnList[i]->setText(str); + m_itemBtnList[i]->setEnabled(true); + m_itemBtnList[i]->setVisible(true); + } + } + + // 页信息 + QString str = tr("pageNum: ") + QString("%1/%2").arg(m_curPages).arg(m_pageNums);//页数: + ui->labelPage->setText(str); + +} + +void FileSelectDialog::initData() +{ + m_fileNameList.clear(); + QDir dir(m_filePath); + m_curPages = 0; + m_pageNums = 0; + // 打开文件所在的路径 + if(!dir.exists()) + { + qDebug() << "dirpath not exist, name=" << m_filePath; + dir.mkdir(m_filePath);//创建花样文件夹 + } + dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); // 设置类型过滤器 + dir.setSorting(QDir::DirsFirst | QDir::IgnoreCase); // 设置排序方式 + + QFileInfoList fileList = dir.entryInfoList(); + int count = fileList.count(); + for(int i = 0; i < count ; i++){ + QFileInfo fileInfo = fileList[i]; + if(fileInfo.suffix().toUpper() == "HS"){ + QString str = fileInfo.fileName(); + m_fileNameList.append(str); + qDebug()<sender(); + qDebug()<< pBtn->text(); + + for(int i = 0; i < m_itemPerPage; i++)//白色按下的效果 + { + QString style1 = "QPushButton{outline: none;border:0px;border-radius:7px;background-color:rgba(255, 255, 255, 0);color: rgb(255, 255, 255);}"; + m_itemBtnList[i]->setStyleSheet(style1); + } + QString style1 = "QPushButton{outline: none;border:0px;border-radius:7px;background-color:rgba(255, 255, 255, 50);color: rgb(255, 255, 255);}"; + pBtn->setStyleSheet(style1); + m_fileName = pBtn->text(); +} + +QString FileSelectDialog::getFileName() +{ + return m_fileName; +} + +void FileSelectDialog::on_buttonOk_clicked() +{ + done(1); +} + +void FileSelectDialog::on_buttonCancel_clicked() +{ + done(0); +} + +void FileSelectDialog::on_buttonPgDn_clicked() +{ + m_curPages++; + refreshUi(); +} + +void FileSelectDialog::on_buttonPgUp_clicked() +{ + m_curPages--; + refreshUi(); +} diff --git a/sharedviews/fileselectdialog.h b/sharedviews/fileselectdialog.h new file mode 100644 index 0000000..4d82f98 --- /dev/null +++ b/sharedviews/fileselectdialog.h @@ -0,0 +1,54 @@ +#ifndef FILESELECTDIALOG_H +#define FILESELECTDIALOG_H + +#include +#include "setcontrolstyle.h" +#include "sharedviews/mybutton.h" +#include + +namespace Ui { +class FileSelectDialog; +} + +class FileSelectDialog : public QDialog +{ + Q_OBJECT + +public: + explicit FileSelectDialog(QString filePath, QWidget *parent = 0); + ~FileSelectDialog(); + +private slots: + void on_buttonOk_clicked(); + + void on_buttonCancel_clicked(); + + void on_buttonPgDn_clicked(); + + void on_buttonPgUp_clicked(); + +private: + Ui::FileSelectDialog *ui; + QString m_filePath; + int m_itemPerPage; + QList m_itemBtnList; + int m_curPages;//花样选择界面当前页数 + int m_pageNums;//总页数 + QList m_fileNameList;//花样选择界面花样文件列表 + QString m_fileName; //目标文件名 + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006();//初始化窗体控件为1024x600分辨率 + void initControlStyle();//初始化窗体控件样式 + void refreshUi(); + void initData(); + +public slots: + void btnclicked(); + QString getFileName(); + +}; + +#endif // FILESELECTDIALOG_H diff --git a/sharedviews/fileselectdialog.ui b/sharedviews/fileselectdialog.ui new file mode 100644 index 0000000..748cab3 --- /dev/null +++ b/sharedviews/fileselectdialog.ui @@ -0,0 +1,330 @@ + + + FileSelectDialog + + + + 0 + 0 + 1105 + 609 + + + + Dialog + + + + + 90 + 220 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 90 + 60 + 760 + 32 + + + + Qt::NoFocus + + + Qt::LeftToRight + + + + + + + + + + + + 90 + 140 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 90 + 180 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 90 + 100 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 90 + 300 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 90 + 340 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 90 + 260 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 770 + 570 + 321 + 31 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 80 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 240 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 160 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 0 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + buttonPgUp + buttonPgDn + buttonOk + buttonCancel + + + + + 20 + 10 + 1024 + 600 + + + + background-color: rgb(182, 182, 182); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 570 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + PageNums: 1/1 + + + + frameBack + button5 + button1 + button3 + button4 + button2 + button7 + button8 + button6 + framePageBtn + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/headspacingsheetdialog.cpp b/sharedviews/headspacingsheetdialog.cpp new file mode 100644 index 0000000..79bc75b --- /dev/null +++ b/sharedviews/headspacingsheetdialog.cpp @@ -0,0 +1,612 @@ +#include "headspacingsheetdialog.h" +#include "ui_headspacingsheetdialog.h" + +#define ROW_NUM 10 //按钮行数 +#define COLUMN_NUM 5 //按钮列数 + +HeadSpacingSheetDialog::HeadSpacingSheetDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::HeadSpacingSheetDialog) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + + initWidget(); + initControl(); + + memset(&m_data, 0, sizeof(DsrHeadEx62)); + m_dataNums = 0; + refreshPageUi(); +} + +HeadSpacingSheetDialog::~HeadSpacingSheetDialog() +{ + delete ui; +} + + +void HeadSpacingSheetDialog::refreshPageUi() +{ + //清空全部按钮数据 + foreach (QPushButton* button, m_sheetBtnList) { + button->setText(""); + button->setEnabled(false); + button->setVisible(false); + } + + //计算页码范围 + m_pageNums = m_dataNums / ROW_NUM;//向上取整 总页数 + m_pageNums = (m_dataNums % ROW_NUM == 0) ? m_pageNums : m_pageNums + 1; + + if (m_curPages > m_pageNums)// 当前页 + { + m_curPages = m_pageNums; + } + if (m_curPages < 1) + { + m_curPages = 1; + } + + //刷新列值 + for(int i = 0; i < ROW_NUM; i++) + { + int rowNum = i + 1 + (m_curPages -1) * ROW_NUM; + //如果超过最大值则不显示 + if(rowNum > m_dataNums){ + m_sheetVLabelList[i]->setVisible(false); + } + else{ + m_sheetVLabelList[i]->setText(QString("%1").arg(rowNum)); + m_sheetVLabelList[i]->setFont(fontNormal_1); + m_sheetVLabelList[i]->setVisible(true); + m_sheetVLabelList[i]->setStyleSheet(LABELWHITESTYLE); + m_sheetVLabelList[i]->setAlignment(Qt::AlignRight); + m_sheetVLabelList[i]->setAlignment(Qt::AlignCenter); + } + } + + //显示已存在的数据 + for(int i = 0; i < ROW_NUM; i++){ + int labelIdx = (m_curPages - 1) * ROW_NUM + i; + if(labelIdx > m_dataNums - 1) + { + //超过机头间距总段数 + break; + } + else + { + m_sheetBtnList[i * COLUMN_NUM + 0 ]->setText(charToQString(m_data.headEnableSpacing[labelIdx].iswork)); + m_sheetBtnList[i * COLUMN_NUM + 1 ]->setText(intDiv10(m_data.headEnableSpacing[labelIdx].distance1_2)); + m_sheetBtnList[i * COLUMN_NUM + 2 ]->setText(intDiv10(m_data.headEnableSpacing[labelIdx].distance1_3)); + m_sheetBtnList[i * COLUMN_NUM + 3 ]->setText(intDiv10(m_data.headEnableSpacing[labelIdx].distance1_4)); + m_sheetBtnList[i * COLUMN_NUM + 4 ]->setText(intDiv10(m_data.headEnableSpacing[labelIdx].distance1_5)); + + m_sheetBtnList[i * COLUMN_NUM + 0 ]->setEnabled(true); + m_sheetBtnList[i * COLUMN_NUM + 1 ]->setEnabled(true); + m_sheetBtnList[i * COLUMN_NUM + 2 ]->setEnabled(true); + m_sheetBtnList[i * COLUMN_NUM + 3 ]->setEnabled(true); + m_sheetBtnList[i * COLUMN_NUM + 4 ]->setEnabled(true); + + m_sheetBtnList[i * COLUMN_NUM + 0 ]->setVisible(true); + m_sheetBtnList[i * COLUMN_NUM + 1 ]->setVisible(true); + m_sheetBtnList[i * COLUMN_NUM + 2 ]->setVisible(true); + m_sheetBtnList[i * COLUMN_NUM + 3 ]->setVisible(true); + m_sheetBtnList[i * COLUMN_NUM + 4 ]->setVisible(true); + } + } + + // 页信息 + QString str = tr("pageNum: ") + QString("%1/%2").arg(m_curPages).arg(m_pageNums);//页数: + ui->labelPageNum->setText(str); +} + +void HeadSpacingSheetDialog::setTypeLogo(QString tStyle) +{ + ui->buttonTypeLogo->setUnPreBtnLogo(tStyle); +} + +void HeadSpacingSheetDialog::setMainTitle(QString str) +{ + ui->labelMainTitle->setText(str); +} + +void HeadSpacingSheetDialog::setSubTitle(QString str) +{ + ui->labelSubTitle->setText(str); +} + +void HeadSpacingSheetDialog::on_buttonPgUp_clicked() +{ + m_curPages--; + refreshPageUi(); +} + +void HeadSpacingSheetDialog::slotSheetBtnClicked() +{ + MyButton *button = (MyButton*) this->sender() ; + int index = m_sheetBtnList.indexOf(button); + int rowIndex = index / COLUMN_NUM; + int column = index % COLUMN_NUM; + +// qDebug()<< QString("点击了第%1个按钮").arg(index); +// qDebug()<< rowIndex ; //行 +// qDebug()<< column; //列 + + int listIndex = rowIndex + (m_curPages - 1) * ROW_NUM; + qDebug()<< "listIndex:" << listIndex; + + if(column == 0) //机头开关设置 按bit位 + { + //获取bit位的数据,存入内存 + McHeadDialog mcHeadDialog(this); + mcHeadDialog.setChar(m_data.headEnableSpacing[listIndex].iswork); + int result = mcHeadDialog.exec(); + if(result == 1) + { + unsigned char headIsWork = mcHeadDialog.getChar(); + m_data.headEnableSpacing[listIndex].iswork = headIsWork; //修改内存的值 + button->setText(charToQString(headIsWork)); + } + } + else + { + //机头间距参数设置 + NumerInputDialog ndlg(this); + ndlg.setTitleStr("跨步距离"); + ndlg.setUnitStr("0.1mm"); + ndlg.setValueAndRange((int)button->text().toDouble()*10, 0, 50000, 1); // 界面中的数*10 为内存中的实际值 + int rslt = ndlg.exec(); + + if(rslt == 1){ + s32 val = ndlg.getValue(); // 0.1mm 界面输入500.1 此时的数是5001,但是界面上还是需要显示500.1 + //修改界面的值 + button->setText(intDiv10(val)); + + //修改内存的值 + HeadTable *item = &m_data.headEnableSpacing[listIndex]; + switch (column) + { + case 1: + item->distance1_2 = val; + break; + case 2: + item->distance1_3 = val; + break; + case 3: + item->distance1_4 = val; + break; + case 4: + item->distance1_5 = val; + break; + case 5: + item->distance1_6 = val; + break; + case 6: + item->distance1_7 = val; + break; + case 7: + item->distance1_8 = val; + break; + + default: + break; + } + } + + } + +} + +void HeadSpacingSheetDialog::setHeadData(DsrHeadEx62 data) +{ + m_data = data; + m_curPages = 1; + refreshPageUi(); +} + +DsrHeadEx62 HeadSpacingSheetDialog::getHeadData() +{ + return m_data; +} + +void HeadSpacingSheetDialog::initDsrFileInfo(QString fileName) +{ + QFileInfo fileInfo(fileName); + QString suffer = fileInfo.suffix().toUpper(); + if(suffer != "DSR"){ + return ; + } + //根据文件名加载 + m_fileName = fileName; + DataFileDsr dsr; + dsr.initFile(m_fileName); + dsr.convertDataToEmbAbs(); + m_data = dsr.get62ExHead(); + m_dataNums = dsr.getStepNums(); + refreshPageUi(); +} + +void HeadSpacingSheetDialog::setStepNums(int dataNums) +{ + m_dataNums = dataNums; + refreshPageUi(); +} + +QString HeadSpacingSheetDialog::detectUsb() +{ + QString usbPath = ""; + +#ifdef Q_OS_LINUX + QDir dir(LINUXUSBPATH); + if(!dir.exists()) + { + usbPath = ""; + } + else + { + usbPath = LINUXUSBPATH; + } +#endif + +#ifdef Q_OS_WIN + QFileInfoList list = QDir::drives(); + + for(int i = 0; iframeSheet); + m_sheetBtnList.append(buttonSheet); + connect(buttonSheet, + SIGNAL(clicked()), + this, + SLOT(slotSheetBtnClicked()) + ); + } + } + + for(int i = 0; i < COLUMN_NUM; i++) + { + QLabel *labelH = new QLabel(this); + labelH->setAlignment(Qt::AlignCenter); //设置居中 + m_sheetHLabelList.append(labelH); + } + + for(int i = 0; i < ROW_NUM; i++) + { + QLabel *labelV = new QLabel(this); + m_sheetVLabelList.append(labelV); + } +} + +void HeadSpacingSheetDialog::initControl() +{ + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +void HeadSpacingSheetDialog::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + this->resize(1024*factoryX,600*factoryY); + ui->buttonTypeLogo->setGeometry(25 *factoryX, 30*factoryY,60*factoryX,60*factoryY); + ui->labelMainTitle->setGeometry(100 *factoryX,30*factoryY,200*factoryX,24*factoryY); + ui->labelSubTitle->setGeometry(130 *factoryX,64*factoryY,240*factoryX,21*factoryY); + ui->frameBack->setGeometry(0 *factoryX,0*factoryY,1024*factoryX,600*factoryY); + ui->frameSheet->setGeometry(10 *factoryX,120*factoryY,1000*factoryX,420*factoryY); + ui->labelPageNum->setGeometry(20*factoryX,550*factoryY,300*factoryX,45*factoryY); + ui->framePageBtn->setGeometry(489*factoryX,545*factoryY,600*factoryX,40*factoryY); + ui->buttonPgUp->setGeometry(106*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonPgDn->setGeometry(212*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonOk->setGeometry(318*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonCancel->setGeometry(424*factoryX,0*factoryY,96*factoryX,40*factoryY); + + ui->buttonParaExport->setGeometry(950*factoryX,40*factoryY,50*factoryX,50*factoryY); + ui->buttonParaImport->setGeometry(880*factoryX,40*factoryY,50*factoryX,50*factoryY); + + //label样式 + ui->labelMainTitle->setFont(fontBold_1); + ui->labelMainTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelSubTitle->setFont(fontNormal_1); + ui->labelSubTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelPageNum->setFont(fontNormal_1); + ui->labelPageNum->setStyleSheet(LABELWHITESTYLE); + + for(int i = 0; i < ROW_NUM; i++) + { + for(int j = 0; j < COLUMN_NUM; j++) + { + m_sheetBtnList[i*COLUMN_NUM+j]->setGeometry((100+j*160)*factoryX , (30+i*38) *factoryY, 150*factoryX, 32*factoryY); + } + } + + for(int i = 0; i < COLUMN_NUM; i++) + { + m_sheetHLabelList[i]->setGeometry((180 + i*156) *factoryX, 94*factoryY, 70*factoryX, 40*factoryY); + } + + for(int i = 0; i < ROW_NUM; i++) + { + m_sheetVLabelList[i]->setGeometry(30*factoryX, (149+i*38)*factoryY, 72*factoryX, 32*factoryY); + } +} + +void HeadSpacingSheetDialog::initResolution1006() +{ + this->resize(1024,600); + ui->buttonTypeLogo->setGeometry(25,30,60,60); + ui->labelMainTitle->setGeometry(100,30,200,24); + ui->labelSubTitle->setGeometry(130,64,240,21); + ui->frameBack->setGeometry(0,0,1024,600); + ui->frameSheet->setGeometry(10,120,1000,420); + ui->labelPageNum->setGeometry(20,550,300,45); + ui->framePageBtn->setGeometry(489,545,600,40); + ui->buttonPgUp->setGeometry(106,0,96,40); + ui->buttonPgDn->setGeometry(212,0,96,40); + ui->buttonOk->setGeometry(318,0,96,40); + ui->buttonCancel->setGeometry(424,0,96,40); + + ui->buttonParaExport->setGeometry(950,40,50,50); + ui->buttonParaImport->setGeometry(880,40,50,50); + + for(int i = 0; i < ROW_NUM; i++) + { + for(int j = 0; j < COLUMN_NUM; j++) + { + m_sheetBtnList[i*COLUMN_NUM+j]->setGeometry(100+j*160, 30+i*38, 150, 32); + } + } + + for(int i = 0; i < COLUMN_NUM; i++) + { + m_sheetHLabelList[i]->setGeometry(180 + i*156, 94, 70, 40); + } + + for(int i = 0; i < ROW_NUM; i++) + { + m_sheetVLabelList[i]->setGeometry(30, 149+i*38, 72, 32); + } +} + +void HeadSpacingSheetDialog::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + ui->labelPageNum->setText(tr("PageNum: 0/0"));//页数: 0/0 + ui->frameBack->setStyleSheet(TRANSPARENTSTYLE); + QString str = setControlStyle.getStyleSheet(this->objectName()); + ui->frameBack->setStyleSheet(str); + //四个按钮样式表一样 + ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + + ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + + ui->buttonOk->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()),12); + + ui->buttonCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12); + + ui->buttonParaExport->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonParaExport->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonParaExport->objectName())); + + ui->buttonParaImport->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonParaImport->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonParaImport->objectName())); + + + for(int i = 0; i < COLUMN_NUM; i++) + { + if(i == 0){ + m_sheetHLabelList[i]->setText(QString("1")); + } + else + { + m_sheetHLabelList[i]->setText(QString("1-%1").arg(i+1)); + } + m_sheetHLabelList[i]->setFont(fontNormal_1); + m_sheetHLabelList[i]->setStyleSheet(LABELWHITESTYLE); + m_sheetHLabelList[i]->setAlignment(Qt::AlignCenter); + m_sheetHLabelList[i]->setAlignment(Qt::AlignBottom); + } + + for(int i = 0; i < ROW_NUM; i++) + { + m_sheetVLabelList[i]->setText(QString("%1").arg(i+1)); + m_sheetVLabelList[i]->setFont(fontNormal_1); + m_sheetVLabelList[i]->setStyleSheet(LABELWHITESTYLE); + m_sheetVLabelList[i]->setAlignment(Qt::AlignRight); + m_sheetVLabelList[i]->setAlignment(Qt::AlignCenter); + } + + ui->frameSheet->setStyleSheet(TRANSPARENTSTYLE); + for(int i = 0; i < ROW_NUM; i++) + { + for(int j = 0; j < COLUMN_NUM; j++) + { + m_sheetBtnList[i*COLUMN_NUM+j]->setBlueGradientBottomStyle("5"); + m_sheetBtnList[i*COLUMN_NUM+j]->setFont(fontNormal_1); + } + } +} + +void HeadSpacingSheetDialog::on_buttonPgDn_clicked() +{ + m_curPages++; + refreshPageUi(); +} + +void HeadSpacingSheetDialog::on_buttonOk_clicked() +{ + //数据保存到源文件 + QFile file(m_fileName); + if(file.open(QIODevice::ReadWrite)) + { + QByteArray fileData(sizeof(DsrHeadEx62), 0); + memcpy(fileData.data(), (char*)(&m_data), sizeof(DsrHeadEx62)); + file.seek(sizeof(DsrHead)); + qDebug()<<"HeadSpacingSheetDialog::on_buttonOk_clicked: file.pos:"< charBit(data); + std::string stdStr = to_1string(charBit); + reverse(stdStr.begin(),stdStr.end()); + QString bitStr = QString::fromStdString(stdStr); + return bitStr.left(5); +} diff --git a/sharedviews/headspacingsheetdialog.h b/sharedviews/headspacingsheetdialog.h new file mode 100644 index 0000000..8842d84 --- /dev/null +++ b/sharedviews/headspacingsheetdialog.h @@ -0,0 +1,90 @@ +#ifndef HEADSPACINGSHEETDIALOG_H +#define HEADSPACINGSHEETDIALOG_H + +#include +#include "qmath.h" +#include +#include +#include +#include +#include +#include "mcheaddialog.h" +#include "setcontrolstyle.h" +#include "promptdialog.h" +#include "datafile/datafiledsr.h" +#include "sharedviews/fileselectdialog.h" +#include "sharedviews/promptdialog.h" + +template +std::string to_1string(const std::bitset& b) +{ + return b.template + to_string, allocator >(); +} + +namespace Ui { +class HeadSpacingSheetDialog; +} + +class HeadSpacingSheetDialog : public QDialog +{ + Q_OBJECT + +public: + explicit HeadSpacingSheetDialog(QWidget *parent = 0); + ~HeadSpacingSheetDialog(); + +private: + Ui::HeadSpacingSheetDialog *ui; + +private: + s16 m_reType;//x、y类型 + int m_btnPerPage;//每页按钮数 + int m_curPages;//花样选择界面当前页数 + int m_pageNums;//总页数 + QList m_sheetBtnList;//表格按钮个数 + QList m_sheetHLabelList;//横向label + QList m_sheetVLabelList;//纵向label + QList m_itemXList;//条目数 + QList m_itemYList;//条目数 + DsrHeadEx62 m_data; //数据 + int m_dataNums; //总跨步数 + QString m_fileName; + +public: + void refreshPageUi();//刷新界面显示 + void setTypeLogo(QString tStyle);//设置类型图标 + void setMainTitle(QString str);//设置主title + void setSubTitle(QString str);//设置副title + +private slots: + void on_buttonOk_clicked(); + void on_buttonCancel_clicked(); + void on_buttonPgDn_clicked(); + void on_buttonPgUp_clicked(); + + void on_buttonParaExport_clicked(); + void on_buttonParaImport_clicked(); + + QString intDiv10(int num); //返回整数除10之后保留1位小数的QString + QString charToQString(char data); + +public slots: + void slotSheetBtnClicked();//表格中按钮被点击 + void setHeadData(DsrHeadEx62 data); + DsrHeadEx62 getHeadData(); + //解析文件信息 + void initDsrFileInfo(QString fileName); + void setStepNums(int dataNums); + QString detectUsb(); + +private: + void initWidget(); + void initControl(); + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006(); + void initControlStyle();//初始化窗体控件样式 + +}; + +#endif // HEADSPACINGSHEETDIALOG_H diff --git a/sharedviews/headspacingsheetdialog.ui b/sharedviews/headspacingsheetdialog.ui new file mode 100644 index 0000000..b661e4c --- /dev/null +++ b/sharedviews/headspacingsheetdialog.ui @@ -0,0 +1,264 @@ + + + HeadSpacingSheetDialog + + + + 0 + 0 + 1024 + 600 + + + + Dialog + + + + + 30 + 120 + 901 + 381 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 40 + 570 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + PageNums: 0/0 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 30 + 20 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + + + + 160 + 20 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Sub title + + + + + + 140 + 50 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Sub title < Title + + + + + + 480 + 560 + 531 + 31 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 290 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 450 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 370 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 210 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + + 260 + 550 + 81 + 41 + + + + background-color: rgb(176, 176, 176); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 710 + 30 + 151 + 28 + + + + + + + + + + 530 + 30 + 151 + 28 + + + + + + + frameBack + frameSheet + labelPageNum + buttonTypeLogo + labelMainTitle + labelSubTitle + framePageBtn + buttonParaExport + buttonParaImport + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/mcheaddialog.cpp b/sharedviews/mcheaddialog.cpp new file mode 100644 index 0000000..4f13da6 --- /dev/null +++ b/sharedviews/mcheaddialog.cpp @@ -0,0 +1,233 @@ +#include "mcheaddialog.h" +#include "ui_mcheaddialog.h" + +const QString strOr = "background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(247, 180, 61), stop:1 rgb(222, 162, 55));border-radius:10px;color:rgb(255,255,255);"; +const QString strBlack = "background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(100, 100, 100), stop:1 rgb(100, 100, 100));border-radius:10px;color:rgb(234, 234, 234);"; + +McHeadDialog::McHeadDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::McHeadDialog) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + setAttribute(Qt::WA_TranslucentBackground, true);//设置窗体背景透明 + + initWidget(); + initControl(); +} + +McHeadDialog::~McHeadDialog() +{ + delete ui; +} + +void McHeadDialog::on_buttonOk_clicked() +{ + done(1); +} + +void McHeadDialog::on_buttonCancel_clicked() +{ + done(0); +} + +void McHeadDialog::updataUi(int btnIndex, MyButton *button) +{ + if(btnIndex > 8 || btnIndex < 0) + return; + bitset<8> charBit(m_mcHeadSw); + m_mcHeadSw = setBit(m_mcHeadSw, btnIndex, !charBit[btnIndex]); + + bitset<8> charBitFan(m_mcHeadSw); + cout << charBitFan << endl; + + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + if(charBitFan.test(btnIndex)) + {button->setStyleSheet(strOr);} + else + {button->setStyleSheet(strBlack);} +} + +void McHeadDialog::refreshUi() +{ + bitset<8> charBit(m_mcHeadSw); + if(charBit[0] == 1) + {ui->pushButton->setStyleSheet(strOr);} + else{ui->pushButton->setStyleSheet(strBlack);} + if(charBit[1] == 1) + {ui->pushButton_2->setStyleSheet(strOr);} + else{ui->pushButton_2->setStyleSheet(strBlack);} + if(charBit[2] == 1) + {ui->pushButton_3->setStyleSheet(strOr);} + else{ui->pushButton_3->setStyleSheet(strBlack);} + if(charBit[3] == 1) + {ui->pushButton_4->setStyleSheet(strOr);} + else{ui->pushButton_4->setStyleSheet(strBlack);} + if(charBit[4] == 1) + {ui->pushButton_5->setStyleSheet(strOr);} + else{ui->pushButton_5->setStyleSheet(strBlack);} + if(charBit[5] == 1) + {ui->pushButton_6->setStyleSheet(strOr);} + else{ui->pushButton_6->setStyleSheet(strBlack);} + if(charBit[6] == 1) + {ui->pushButton_7->setStyleSheet(strOr);} + else{ui->pushButton_7->setStyleSheet(strBlack);} + if(charBit[7] == 1) + {ui->pushButton_8->setStyleSheet(strOr);} + else{ui->pushButton_8->setStyleSheet(strBlack);} + qDebug()<< QString::fromStdString(charBit.to_string()); + +} + +char McHeadDialog::setBit(char data, int setoff, bool value) +{ + bitset<8> charBit(data); + charBit.set(setoff, value); + char res = (char)charBit.to_ulong(); + return res; +} + +void McHeadDialog::setChar(char data) +{ + m_mcHeadSw = data; + refreshUi(); +} + +unsigned char McHeadDialog::getChar() +{ + return m_mcHeadSw; +} + +void McHeadDialog::on_pushButton_clicked() +{ + MyButton *button = (MyButton*) this->sender() ; + QMetaObject::invokeMethod(this, "updataUi", Qt::DirectConnection, Q_ARG(int , 0), Q_ARG(MyButton *, button)); +} + +void McHeadDialog::on_pushButton_2_clicked() +{ + MyButton *button = (MyButton*) this->sender() ; + QMetaObject::invokeMethod(this, "updataUi", Qt::DirectConnection, Q_ARG(int , 1), Q_ARG(MyButton *, button)); +} + +void McHeadDialog::on_pushButton_3_clicked() +{ + MyButton *button = (MyButton*) this->sender() ; + QMetaObject::invokeMethod(this, "updataUi", Qt::DirectConnection, Q_ARG(int , 2), Q_ARG(MyButton *, button)); +} + +void McHeadDialog::on_pushButton_4_clicked() +{ + MyButton *button = (MyButton*) this->sender() ; + QMetaObject::invokeMethod(this, "updataUi", Qt::DirectConnection, Q_ARG(int , 3), Q_ARG(MyButton *, button)); +} + +void McHeadDialog::on_pushButton_5_clicked() +{ + MyButton *button = (MyButton*) this->sender() ; + QMetaObject::invokeMethod(this, "updataUi", Qt::DirectConnection, Q_ARG(int , 4), Q_ARG(MyButton *, button)); +} + +void McHeadDialog::on_pushButton_6_clicked() +{ + MyButton *button = (MyButton*) this->sender() ; + QMetaObject::invokeMethod(this, "updataUi", Qt::DirectConnection, Q_ARG(int , 5), Q_ARG(MyButton *, button)); +} + +void McHeadDialog::on_pushButton_7_clicked() +{ + MyButton *button = (MyButton*) this->sender() ; + QMetaObject::invokeMethod(this, "updataUi", Qt::DirectConnection, Q_ARG(int , 6), Q_ARG(MyButton *, button)); +} + +void McHeadDialog::on_pushButton_8_clicked() +{ + MyButton *button = (MyButton*) this->sender() ; + QMetaObject::invokeMethod(this, "updataUi", Qt::DirectConnection, Q_ARG(int , 7), Q_ARG(MyButton *, button)); +} + +void McHeadDialog::initWidget() +{ + m_sheetBtnList.append(ui->pushButton); + m_sheetBtnList.append(ui->pushButton_2); + m_sheetBtnList.append(ui->pushButton_3); + m_sheetBtnList.append(ui->pushButton_4); + m_sheetBtnList.append(ui->pushButton_5); +// m_sheetBtnList.append(ui->pushButton_6); +// m_sheetBtnList.append(ui->pushButton_7); +// m_sheetBtnList.append(ui->pushButton_8); + ui->pushButton_6->setVisible(false); + ui->pushButton_7->setVisible(false); + ui->pushButton_8->setVisible(false); + // QList btns = this->findChildren(); +} + +void McHeadDialog::initControl() +{ + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +void McHeadDialog::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + this->resize(1024*factoryX,600*factoryY); + ui->framePageBtn->setGeometry(489*factoryX,545*factoryY,600*factoryX,40*factoryY); + ui->buttonOk->setGeometry(318*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonCancel->setGeometry(424*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->frameBack->setGeometry(0*factoryX, 0*factoryY, 1024*factoryX, 600*factoryY); + + for(int i = 0; i < m_sheetBtnList.size(); i++){ + m_sheetBtnList[i]->setGeometry((110+i*100)*factoryX, 300*factoryY, 72*factoryX, 40*factoryY); + m_sheetBtnList[i]->setText(QString("%1").arg(i+1)); + m_sheetBtnList[i]->setFont(fontNormal_1); + m_sheetBtnList[i]->setStyleSheet(LABELWHITESTYLE); + } +} + +void McHeadDialog::initResolution1006() +{ + this->resize(1024,600); + ui->framePageBtn->setGeometry(489,545,600,40); + ui->buttonOk->setGeometry(318,0,96,40); + ui->buttonCancel->setGeometry(424,0,96,40); + ui->frameBack->setGeometry(0, 0, 1024, 600); + + for(int i = 0; i < m_sheetBtnList.size(); i++){ + m_sheetBtnList[i]->setGeometry(110+i*100, 300, 72, 40); + m_sheetBtnList[i]->setText(QString("%1").arg(i+1)); + } +} + +void McHeadDialog::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + ui->frameBack->setStyleSheet(TRANSPARENTSTYLE); + ui->frameBack->setStyleSheet(setControlStyle.getStyleSheet(this->objectName())); + + ui->buttonOk->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()),12); + + ui->buttonCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12); + +} diff --git a/sharedviews/mcheaddialog.h b/sharedviews/mcheaddialog.h new file mode 100644 index 0000000..ffe4d43 --- /dev/null +++ b/sharedviews/mcheaddialog.h @@ -0,0 +1,64 @@ +#ifndef MCHEADDIALOG_H +#define MCHEADDIALOG_H + +#include +#include "setcontrolstyle.h" +#include +#include + +using namespace std; +#include "mybutton.h" + +namespace Ui { +class McHeadDialog; +} + +class McHeadDialog : public QDialog +{ + Q_OBJECT + +public: + explicit McHeadDialog(QWidget *parent = 0); + ~McHeadDialog(); + +private slots: + void on_buttonOk_clicked(); + + void on_buttonCancel_clicked(); + + void on_pushButton_clicked(); + + void on_pushButton_2_clicked(); + + void on_pushButton_3_clicked(); + + void on_pushButton_4_clicked(); + + void on_pushButton_5_clicked(); + + void on_pushButton_6_clicked(); + + void on_pushButton_7_clicked(); + + void on_pushButton_8_clicked(); + +public slots: + void initWidget(); + void initControl(); + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006(); + void initControlStyle();//初始化窗体控件样式 + + void updataUi(int btnIndex, MyButton *button); + void refreshUi(); + char setBit(char data, int setoff, bool value); + void setChar(char data); + unsigned char getChar(); + +private: + Ui::McHeadDialog *ui; + unsigned char m_mcHeadSw; //机头开关参数 bit位1-8 , 0关闭 1开启 + QList m_sheetBtnList; +}; + +#endif // MCHEADDIALOG_H diff --git a/sharedviews/mcheaddialog.ui b/sharedviews/mcheaddialog.ui new file mode 100644 index 0000000..2bfdfca --- /dev/null +++ b/sharedviews/mcheaddialog.ui @@ -0,0 +1,213 @@ + + + McHeadDialog + + + + 0 + 0 + 1024 + 600 + + + + Dialog + + + + + 820 + 200 + 93 + 28 + + + + PushButton + + + + + + 80 + 200 + 93 + 28 + + + + PushButton + + + + + + 190 + 200 + 93 + 28 + + + + PushButton + + + + + + 300 + 200 + 93 + 28 + + + + PushButton + + + + + + 620 + 200 + 93 + 28 + + + + PushButton + + + + + + 410 + 200 + 93 + 28 + + + + PushButton + + + + + + 720 + 200 + 93 + 28 + + + + PushButton + + + + + + 520 + 200 + 93 + 28 + + + + PushButton + + + + + + 40 + 450 + 120 + 80 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 480 + 560 + 531 + 31 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 450 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 370 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + frameBack + pushButton_8 + pushButton + pushButton_2 + pushButton_3 + pushButton_6 + pushButton_4 + pushButton_7 + pushButton_5 + framePageBtn + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/mybutton.cpp b/sharedviews/mybutton.cpp new file mode 100644 index 0000000..ef7f71c --- /dev/null +++ b/sharedviews/mybutton.cpp @@ -0,0 +1,367 @@ +#include "mybutton.h" + +MyButton::MyButton(QWidget *parent):QPushButton(parent) +{ + labelImage = NULL; + labelImage = new QLabel(this); + + labelName = NULL; + labelName = new QLabel(this); + + labelValue = NULL; + labelValue = new QLabel(this); +} + +MyButton::~MyButton() +{ + if(labelImage != NULL) + { + delete labelImage; + } + + if(labelName != NULL) + { + delete labelName; + } + + if(labelValue != NULL) + { + delete labelValue; + } +} + +//设置顶图 +void MyButton::setTopImage(QString imagePath,short int y) +{ + setTopImage(imagePath,y,0); +} + +void MyButton::setTopImage(QString imagePath, short y, short x) +{ + setTopImage(imagePath,0,0,x,y); +} + +void MyButton::setTopImage(QString imagePath, short x, short y, short width, short height) +{ + //label加载图片( 方法1) + //QPixmap pix; + //pix.load(imagePath); + //labelImage->setPixmap(pix); + + labelName->hide(); + labelValue->hide(); + labelImage->show(); + + labelImage->setGeometry(x, y, this->width()+width, this->height()+height); + QString style = "outline: none;background-color: rgba(255, 255, 255, 0);border-image: url(" + imagePath + ");border:0px;"; + labelImage->setStyleSheet(style); +} + +void MyButton::setShortCutTopImage(QString imagePath, QPoint point) +{ + labelName->hide(); + labelValue->hide(); + labelImage->show(); + + labelImage->setGeometry(point.x(),point.y(),this->width(),this->height()); + QString style = "outline: none;background-color: rgba(255, 255, 255, 0);border-image: url(" + imagePath + ");border:0px;"; + labelImage->setStyleSheet(style); +} + +void MyButton::setPreviewImage(QImage image) +{ + //label加载图片 + QPixmap pix = QPixmap::fromImage(image); + labelImage->setPixmap(pix); +} + +//设置条目左侧图标 +void MyButton::setItemLeftIcon(QString imagePath) +{ + labelImage->move(0,0); + QString style = "outline: none;background-color: rgba(255, 255, 255, 0);border-image: url(" + imagePath + ");border:0px;"; + labelImage->setStyleSheet(style); +} + +void MyButton::setLabelValueImage(QString imagePath) +{ + if(imagePath.length() <= 0) + { + QPixmap npix; + labelValue->setPixmap(npix); + return; + } + QImage image; + image.load(imagePath); + QPixmap pix = QPixmap::fromImage(image); + labelValue->setPixmap(pix); + +// labelValue->setAlignment(Qt::AlignLeft); +// labelValue->setAlignment(Qt::AlignBottom); +// QString style = "background-color: rgba(255, 255, 255, 0);border:0px;image: url(" + imagePath + ");"; +// labelValue->setStyleSheet(style); +} + +//设置底层图片(按下、抬起、失效) +void MyButton::setBottomImage(QString imagePath) +{ +//第一种加载图片的方法 +// QPixmap pix; +// pix.load(imageRelPath); +// int w = this->width(); +// int h = this->height(); +// this->setIconSize(QSize(w,h)); +// this->setIcon(pix); + + //第二种加载图片的方法 + QString style = "QPushButton{outline: none;background-color: rgba(255, 255, 255, 0);border-image: url(" + imagePath + "_p0.png" + ");border:0px;}"; + style += "QPushButton:pressed{outline: none;border-image: url(" + imagePath + "_p1.png" + ");}"; + style += "QPushButton:disabled{outline: none;border-image: url(" + imagePath + "_p2.png" + ");}"; + style += "QPushButton:checked{outline: none;border-image: url(" + imagePath + "_p1.png" + ");}"; + //style += "QPushButton:disabled{background-color: rgba(220, 220, 220, 50);}"; + this->setStyleSheet(style); +} + +void MyButton::setWhiteBlueBottomStyle() +{ + //白蓝色渐变、灰蓝色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(255, 255, 255), stop:1 rgb(215, 243, 254));border-radius:5px;}"; + style += "QPushButton:pressed{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(217, 222, 224), stop:1 rgb(191,213,223));}"; + style += "QPushButton:disabled{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(230, 230, 230), stop:1 rgb(182,182,182));}"; + this->setStyleSheet(style); +} + +void MyButton::setBlueBorderBottomStyle() +{ + //蓝色渐变带边框 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(65,197,220), stop:1 rgb(57,176,198));border-bottom:1px solid rgb(30, 155, 177);border-radius:10px;}"; + style += "QPushButton:pressed{background-color: rgb(73, 181, 192);}"; + style += "QPushButton:disabled{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(230, 230, 230), stop:1 rgb(182,182,182));border-bottom:1px solid rgb(100,100,100);}"; + this->setStyleSheet(style); +} + +void MyButton::setOrangeGradientBottomStyle(QString str) +{ + //橙色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(247, 180, 61), stop:1 rgb(222, 162, 55));border-radius:"+str+"px;color:rgb(255,255,255);}"; + style += "QPushButton:pressed{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(222, 196, 128), stop:1 rgb(213,125,54));color:rgb(255,255,255);}"; + style += "QPushButton:disabled{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(227, 227, 227), stop:1 rgb(177,177,177));color:rgb(255,255,255);}"; + this->setStyleSheet(style); +} + +void MyButton::setBlueGradientBottomStyle(QString str) +{ + //蓝色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(65,197,220), stop:1 rgb(57,176,198));border-radius:"+str+"px;color:rgb(255,255,255);}"; + style += "QPushButton:pressed{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(63, 175, 203), stop:1 rgb(129,189,204));color:rgb(255,255,255);}"; + style += "QPushButton:disabled{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(227, 227, 227), stop:1 rgb(177,177,177));color:rgb(255,255,255);}"; + this->setStyleSheet(style); +} + +void MyButton::setBlueGradientBottomStyle() +{ + //蓝色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(65,197,220), stop:1 rgb(57,176,198));border-radius:4px;}"; + style += "QPushButton:pressed{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(63, 175, 203), stop:1 rgb(129,189,204));}"; + this->setStyleSheet(style); +} + +void MyButton::setGreenGradientBottomStyle(QString str) +{ + //绿色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(139, 195, 163), stop:1 rgb(86,172,123));border-radius:"+str+"px;}"; + style += "QPushButton:pressed{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(105, 147, 123), stop:1 rgb(84,138,107));}"; + style += "QPushButton:disabled{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(227, 227, 227), stop:1 rgb(177,177,177));color:rgb(255,255,255);}"; + style += "QPushButton:checked{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(105, 147, 100), stop:1 rgb(84,138,90));}"; + this->setStyleSheet(style); +} + +#if(0) +//设置控制动作界面底层图片(按下、抬起),并设置文字前景色 +void MyButton::setControlWidgetBtnBottomImage(QString imagePath, QString color) +{ + QString style = "QPushButton{outline: none;"+ color + "border-image: url(" + imagePath + "_p0.png" + ");border:0px;}"; + style += "QPushButton:pressed{outline: none;border-image: url(" + imagePath + "_p1.png" + ");}"; + style += "QPushButton:disabled{outline: none;border-image: url(" + imagePath + "_p2.png" + ");}"; + //style += "QPushButton:disabled{background-color: rgba(220, 220, 220, 50);}"; + this->setStyleSheet(style); +} +#endif + +//设置主按钮底层图片 +void MyButton::setCheckedBottomImage(QString imagePath) +{ + //第二种加载图片的方法 + QString style = "QPushButton{outline: none;border-image: url(" + imagePath + "_p0.png" + ");border:0px;}"; + style += "QPushButton:disabled{outline: none;border-image: url(" + imagePath + "_p2.png" + ");}"; + style += "QPushButton:checked{outline: none;border-image: url(" + imagePath + "_p1.png" + ");}"; + this->setStyleSheet(style); +} + +void MyButton::setMainBtnBottomStyle() +{ + //蓝色渐变、灰色渐变、橙色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(65,197,220), stop:1 rgb(57,176,198));border-radius:10px;}"; + style += "QPushButton:disabled{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(234, 234, 234), stop:1 rgb(176,176,176));}"; + style += "QPushButton:checked{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(247, 180, 61), stop:1 rgb(222, 162, 55));}"; + this->setStyleSheet(style); +} + +//设置按钮logo(按钮是没有点击事件的) +void MyButton::setUnPreBtnLogo(QString tStyle) +{ + labelName->hide(); + labelValue->hide(); + labelImage->hide(); + + if(tStyle.length() <= 0) + { + return; + } + + //橙色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(65,197,220), stop:1 rgb(57,176,198));border-radius:10px;border-image: url(" + tStyle + ");border:0px;outline: none;}"; + this->setStyleSheet(style); +} + + +//初始化label条目名称和条目值(参数设置) +void MyButton::initLeftNameRightValue(QRect rectName, QRect rectValue, int right) +{ + labelImage->hide(); + + QString style = "outline: none;background-color: rgba(255, 255, 255, 0);"; + style += "color: rgb(255, 255, 255);"; + labelName->setGeometry(rectName); + labelName->setStyleSheet(style); + labelName->setAlignment(Qt::AlignLeft); + labelName->setAlignment(Qt::AlignBottom); + + labelValue->setGeometry(rectValue); + labelValue->setStyleSheet(style); + if(right == 0) + { + labelValue->setAlignment(Qt::AlignLeft | Qt::AlignBottom); + } + else + { + labelValue->setAlignment(Qt::AlignRight | Qt::AlignBottom); + } + + QString style1 = "QPushButton{outline: none;border:0px;border-radius:7px;background-color:rgba(255, 255, 255, 0);}"; + style1 += "QPushButton:pressed{outline: none;background-color: rgba(255, 255, 255, 50);}"; + this->setStyleSheet(style1); +} + +//初始化label图标显示和条目名称(文件导入) +void MyButton::initLeftImageRightName(QRect rectImage, QRect rectName) +{ + labelValue->hide(); + labelImage->show(); + + labelImage->setGeometry(rectImage); + labelImage->setAlignment(Qt::AlignHCenter); + labelImage->setAlignment(Qt::AlignBottom); + + QString style = "outline: none;background-color: rgba(255, 255, 255, 0);"; + style += "color: rgb(255, 255, 255);"; + + labelName->setGeometry(rectName); + labelName->setStyleSheet(style); + labelName->setAlignment(Qt::AlignLeft); + labelName->setAlignment(Qt::AlignBottom); + + QString style1 = "QPushButton{outline: none;border:0px;border-radius:7px;background-color:rgba(255, 255, 255, 0);}"; + style1 += "QPushButton:checked{outline: none;background-color: rgba(255, 255, 255, 50);}"; + this->setStyleSheet(style1); +} + +void MyButton::initUpImageDownName(QRect rectImage, QRect rectName) +{ + labelValue->hide(); + labelImage->show(); + + labelImage->setGeometry(rectImage); + labelImage->setAlignment(Qt::AlignCenter); + labelImage->setStyleSheet("outline: none;background-color: rgba(255, 255, 255, 0);"); + + QString style = "outline: none;background-color: rgba(255, 255, 255, 0);"; + style += "color: rgb(255, 255, 255);"; + + labelName->setGeometry(rectName); + labelName->setStyleSheet(style); + labelName->setAlignment(Qt::AlignLeft); + labelName->setAlignment(Qt::AlignTop); + labelName->setWordWrap(true); +} + +void MyButton::initLabelValue(QRect rectValue) +{ + labelValue->setGeometry(rectValue); + labelValue->setAlignment(Qt::AlignCenter); +} + +//设置label字体 +void MyButton::setLabelFont(QFont font) +{ + labelName->setFont(font); + labelValue->setFont(font); + //labelValue->show(); +} + +void MyButton::setLabelNameFont(QFont font) +{ + labelName->setFont(font); +} + +void MyButton::setLabelValueFont(QFont font) +{ + labelValue->setFont(font); +} + +//设置条目名称 +void MyButton::setLabelName(QString name) +{ + labelName->setText(name); + labelName->show(); +} + +void MyButton::setLabelNameStyle(QString style) +{ + labelName->setStyleSheet(style); +} + +//设置条目值 +void MyButton::setLabelValue(QString value) +{ + labelValue->setText(value); + labelValue->show(); +} + +void MyButton::setLabelValueStyle(QString style) +{ + labelValue->setStyleSheet(style); +} + +void MyButton::setLabelImage(QString style) +{ + labelImage->setStyleSheet(style); +} + +void MyButton::setBtnBackColor(QString style) +{ + style += "outline: none;border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;"; + this->setStyleSheet(style); +} + +void MyButton::setImageBackColor(QString style) +{ + style += "outline: none;border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;"; + labelImage->setStyleSheet(style); +} + +void MyButton::setLabelImageChecked(QString style) +{ + style += "outline: none;border:4px groove rgb(52,52,52);border-style:inset;border-radius:5px;"; + labelImage->setStyleSheet(style); +} diff --git a/sharedviews/mybutton.h b/sharedviews/mybutton.h new file mode 100644 index 0000000..75f60ee --- /dev/null +++ b/sharedviews/mybutton.h @@ -0,0 +1,86 @@ +#ifndef MYBUTTON_H +#define MYBUTTON_H + +//#include +#include +#include +#include + +//自定义的按钮类,按钮上有一个Label,用于显示双层图片 +class MyButton : public QPushButton +{ +public: + MyButton(QWidget *parent=0); + ~MyButton(); + +public: + QLabel *labelImage;//顶层logo + QLabel *labelName;//参数设置按钮的条目名称 + QLabel *labelValue;//参数设置按钮的条目值 + +public: + void setTopImage(QString imagePath,short int y = 0);//设置顶层图片 + void setTopImage(QString imagePath,short int y,short int x); + void setTopImage(QString imagePath,short int x,short int y,short int width, short int height); + void setShortCutTopImage(QString imagePath,QPoint point);//设置快捷按钮顶层图片 + + void setPreviewImage(QImage image);//设置花样选择预览图片 + void setItemLeftIcon(QString imagePath);//设置条目左侧图标 + void setLabelValueImage(QString imagePath);//设置开关图片 + + //设置底层图片(按下、抬起、失效) + void setBottomImage(QString imagePath); + + //设置白蓝渐变底层按钮样式(匹绣、快进快退、开位线绣) + void setWhiteBlueBottomStyle(); + + //设置蓝色加border底层按钮样式(常用按钮) + void setBlueBorderBottomStyle(); + + //设置橙色渐变底层按钮样式(界面菜单按钮) + void setOrangeGradientBottomStyle(QString str); + + //设置蓝色渐变底层按钮样式(界面菜单按钮) + void setBlueGradientBottomStyle(QString str); + + //设置蓝色渐变底层按钮样式(控制动作) + void setBlueGradientBottomStyle(); + + //设置绿色渐变底层按钮样式 + void setGreenGradientBottomStyle(QString str); + +#if(0) + //设置控制动作界面底层图片(按下、抬起),并设置文字前景色 + void setControlWidgetBtnBottomImage(QString imagePath,QString color); +#endif + + //设置主按钮底层图片(选中、失效) + void setCheckedBottomImage(QString imagePath); + + //设置主按钮底层样式(选中、失效) + void setMainBtnBottomStyle(); + + //设置按钮logo(按钮是没有点击事件的) + void setUnPreBtnLogo(QString tStyle); + + void initLeftNameRightValue(QRect rectName, QRect rectValue, int right = 0);//初始化label条目名称和条目值(参数设置) + void initLeftImageRightName(QRect rectImage, QRect rectName);//初始化label图标显示和条目名称(文件导入) + void initUpImageDownName(QRect rectImage,QRect rectName);//初始化label图标和名称(花样选择) + void initLabelValue(QRect rectValue);//初始化labelValue + + void setLabelFont(QFont font);//设置label字体 + void setLabelNameFont(QFont font);//设置label字体 + void setLabelValueFont(QFont font);//设置label字体 + + void setLabelName(QString name);//设置条目名称 + void setLabelNameStyle(QString style);//设置条目名称样式 + void setLabelValue(QString value);//设置条目值 + void setLabelValueStyle(QString style);//设置条目值样式 + void setLabelImage(QString style);//设置图片 + + void setBtnBackColor(QString style); + void setImageBackColor(QString style); + void setLabelImageChecked(QString style); +}; + +#endif // MYBUTTON_H diff --git a/sharedviews/numerinputdialog.cpp b/sharedviews/numerinputdialog.cpp new file mode 100644 index 0000000..14a5fa9 --- /dev/null +++ b/sharedviews/numerinputdialog.cpp @@ -0,0 +1,792 @@ +#include "numerinputdialog.h" +#include "ui_numerinputdialog.h" + +NumerInputDialog::NumerInputDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::NumerInputDialog) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + setAttribute(Qt::WA_TranslucentBackground, true);//设置窗体背景透明 + + initDialog(); + initControl(); +} + +NumerInputDialog::~NumerInputDialog() +{ + delete ui; +} + +QString NumerInputDialog::getShowString(int64_t val, int pointflag) +{ + double value = val; + + if (pointflag < 0) + { + pointflag = 0; + } + else if (pointflag > 5) + { + pointflag = 5; + } + + for (int i = 1; i < pointflag; i++) + { + value /= 10; + } + + QString str; + if (pointflag == 0) + { + str.sprintf("%.0f", value); + } + else if (pointflag == 1) + { + str.sprintf("%.0f", value); + str += "."; + } + else if (pointflag == 2) + { + str.sprintf("%.1f", value); + } + else if (pointflag == 3) + { + str.sprintf("%.2f", value); + } + else if (pointflag == 4) + { + str.sprintf("%.3f", value); + } + else // if (pointflag >= 5) + { + str.sprintf("%.4f", value); + } + return str; +} + +int NumerInputDialog::checkValueRange(int64_t val, int pointflag) +{ + int i, xsws; + int64_t min, max; + min = m_min; + max = m_max; + + xsws = pointflag - 1; + if (xsws < 0) + { + xsws = 0; + } + xsws = m_afterPoint - xsws; + if (xsws < 0) + { + xsws = 0; + } + + for (i = 0; i < xsws; i++) + { + min /= 10; + max /= 10; + } + + if (val < min || val > max) + { + return 1; + } + return 0; +} + +int64_t NumerInputDialog::fixValue(int64_t val, int pointflag) +{ + int i, xsws; + int64_t min, max; + min = m_min; + max = m_max; + + xsws = pointflag - 1; + if (xsws < 0) + { + xsws = 0; + } + xsws = m_afterPoint - xsws; + if (xsws < 0) + { + xsws = 0; + } + + for (i = 0; i < xsws; i++) + { + min /= 10; + max /= 10; + } + + if (val < min) + { + val = min; + } + if (val > max) + { + val = max; + } + + return val; +} + +int NumerInputDialog::getPointMuti(int pointflag) +{ + int muti = 1; + for (int i = 1; i < pointflag; i++) + { + muti *= 10; + } + return muti; +} + +void NumerInputDialog::showValue() +{ + ui->labelValue->setText(getShowString(m_value, m_pointFlag)); + + QString str = ui->labelValue->text(); + + // 修复判断数值范围时,无法正确区分小数点的问题 + int val = m_value; + int i; + if (m_pointFlag <= 1) + { + for (i=0; i 0 && val >= m_min && val <= m_max) + { + ui->buttonOk->setEnabled(true); + } + else + { + ui->buttonOk->setEnabled(false); + } +} + +void NumerInputDialog::showRange() +{ + QString min, max, def; + + if (m_afterPoint == 0) + { + min = getShowString(m_min, 0); + max = getShowString(m_max, 0); + def = getShowString(m_defVal, 0); + } + else + { + min = getShowString(m_min, m_afterPoint+1); + max = getShowString(m_max, m_afterPoint+1); + def = getShowString(m_defVal, m_afterPoint+1); + } + + QString rangeStr = "(" + min + "~" + max + ")" + m_unitStr; + ui->labelRange->setText(rangeStr); +} + +void NumerInputDialog::addNum(int num) +{ + if (((m_pointFlag < 5) && + ((m_afterPoint == 0) || (m_pointFlag < m_afterPoint + 1)) && + ((m_value > -100000000) && (m_value < 100000000)) && // 修复数值太大时显示错乱的问题 + 1 ) || + (m_defFlag == 0) || + 0 ) + { + int64_t val; + int pflag; + + if (m_defFlag == 0) + {// 第一次按数字键,从0开始计数,解决每次修改值之前都需要按C键的问题 + m_value = 0; + m_pointFlag = 0; + m_defFlag = 1; + } + val = m_value; + pflag = m_pointFlag; + + if (num < 0) + { + num = 0; + } + else if (num > 9) + { + num = 9; + } + + val *= 10; + val += num*((m_value<0)?-1:1); + + if (pflag != 0) + { + pflag++; + if (pflag > 5) + { + pflag = 5; + } + } + + //if (checkValueRange(val, pflag) == 0) + { + m_value = val; + m_pointFlag = pflag; + } + } +} + +void NumerInputDialog::changeValue(int weights) +{ + int64_t val; + //int pflag; + + val = m_value; + + m_defFlag = 0; // 初始值 + if (weights > -1 && weights < 1) // 小数 + { + + } + + //pflag = m_pointFlag; + val += weights*getPointMuti(m_pointFlag); + + //if (checkValueRange(val, pflag) == 0) + { + // val = fixValue(val, m_pointFlag); + // if (val != m_value) + { + m_value = val; + showValue(); + } + } +} + +//初始化窗体 +void NumerInputDialog::initDialog() +{ + setTitleStr(""); + m_value = 0; + m_min = 0; + m_max = 0; + m_afterPoint = 0; + m_defVal = 0; + m_defFlag = 0; + m_pointFlag = 0; + m_unitStr.clear(); + + m_leftNumberBtnList.clear(); + m_leftNumberBtnList.append(ui->buttonPlusMinus); + m_leftNumberBtnList.append(ui->buttonClean); + m_leftNumberBtnList.append(ui->buttonDelete); + m_leftNumberBtnList.append(ui->buttonNum7); + m_leftNumberBtnList.append(ui->buttonNum8); + m_leftNumberBtnList.append(ui->buttonNum9); + m_leftNumberBtnList.append(ui->buttonNum4); + m_leftNumberBtnList.append(ui->buttonNum5); + m_leftNumberBtnList.append(ui->buttonNum6); + m_leftNumberBtnList.append(ui->buttonNum1); + m_leftNumberBtnList.append(ui->buttonNum2); + m_leftNumberBtnList.append(ui->buttonNum3); + m_leftNumberBtnList.append(ui->buttonNum00); + m_leftNumberBtnList.append(ui->buttonNum0); + m_leftNumberBtnList.append(ui->buttonPoint); + + m_rightNumberBtnList.clear(); + m_rightNumberBtnList.append(ui->buttonDec1000); + m_rightNumberBtnList.append(ui->buttonInc1000); + m_rightNumberBtnList.append(ui->buttonDec100); + m_rightNumberBtnList.append(ui->buttonInc100); + m_rightNumberBtnList.append(ui->buttonDec10); + m_rightNumberBtnList.append(ui->buttonInc10); + m_rightNumberBtnList.append(ui->buttonDec1); + m_rightNumberBtnList.append(ui->buttonInc1); + m_rightNumberBtnList.append(ui->buttonDec01); + m_rightNumberBtnList.append(ui->buttonInc01); +} + +//初始化窗体控件,包括位置、尺寸、样式 +void NumerInputDialog::initControl() +{ + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void NumerInputDialog::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + + this->resize(1024*factoryX,600*factoryY); + ui->frameBack->setGeometry(0*factoryX,0*factoryY,1024*factoryX,600*factoryY); + ui->labelTitle->setGeometry(160*factoryX,25*factoryY,544*factoryX,48*factoryY); + ui->labelValue->setGeometry(290*factoryX,110*factoryY,284*factoryX,44*factoryY); + ui->labelRange->setGeometry(605*factoryX,118*factoryY,220*factoryX,21*factoryY); + for(int i = 0; i < 5; i++) + { + for(int j = 0; j < 3; j ++) + { + m_leftNumberBtnList[i*3+j]->setGeometry((183+j*130)*factoryX,(180+i*65)*factoryY,106*factoryX,39*factoryY); + } + } + + for(int i = 0; i < 5; i++) + { + for(int j = 0; j < 2; j ++) + { + m_rightNumberBtnList[i*2+j]->setGeometry((605+j*130)*factoryX,(180+i*65)*factoryY,106*factoryX,39*factoryY); + } + } + ui->buttonOk->setGeometry(605*factoryX,510*factoryY,106*factoryX,39*factoryY); + ui->buttonCancel->setGeometry(735*factoryX,510*factoryY,106*factoryX,39*factoryY); +} + +//初始化窗体控件为1024x600分辨率 +void NumerInputDialog::initResolution1006() +{ + this->resize(1024,600); +// this->move((1024-this->width())/2,(600-this->height())/2); + ui->frameBack->setGeometry(0,0,1024,600);//更改参数数值时的九键数字输入窗口(0,0,584,448) lxs更改尺寸 + ui->labelTitle->setGeometry(160,25,544,48); + ui->labelValue->setGeometry(290,110,284,44); + ui->labelRange->setGeometry(605,118,220,21); + for(int i = 0; i < 5; i++) + { + for(int j = 0; j < 3; j ++) + { + m_leftNumberBtnList[i*3+j]->setGeometry(183+j*130,180+i*65,106,39); + } + } + + for(int i = 0; i < 5; i++) + { + for(int j = 0; j < 2; j ++) + { + m_rightNumberBtnList[i*2+j]->setGeometry(605+j*130,180+i*65,106,39); + } + } + ui->buttonOk->setGeometry(605,510,106,39); + ui->buttonCancel->setGeometry(735,510,106,39); +} + +//初始化窗体控件样式 +void NumerInputDialog::initControlStyle() +{ + //白蓝色渐变、灰蓝色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(255, 255, 255), stop:1 rgb(215, 243, 254));border-radius:5px;color:rgb(0, 0, 0);}"; + style += "QPushButton:pressed{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(217, 222, 224), stop:1 rgb(191,213,223));color:rgb(0, 0, 0);}"; + style += "QPushButton:disabled{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(230, 230, 230), stop:1 rgb(182,182,182));color:rgb(0, 0, 0);}"; + + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + ui->frameBack->setStyleSheet(setControlStyle.getStyleSheet(this->objectName())); + + for(int i = 0; i < m_leftNumberBtnList.size(); i++) + { + m_leftNumberBtnList[i]->setStyleSheet(style); + m_leftNumberBtnList[i]->setFont(fontNormal_1); + } + + for(int i = 0; i < m_rightNumberBtnList.size(); i++) + { + m_rightNumberBtnList[i]->setStyleSheet(style); + m_rightNumberBtnList[i]->setFont(fontNormal_1); + } + + ui->labelTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelTitle->setFont(fontNormal_1); + ui->labelTitle->setAlignment(Qt::AlignLeft); + ui->labelTitle->setAlignment(Qt::AlignVCenter); + + ui->labelValue->setStyleSheet(LABELWHITESTYLE); + ui->labelValue->setFont(fontNormal_1); + + ui->labelRange->setStyleSheet(LABELWHITESTYLE); + ui->labelRange->setFont(fontNormal_1); + ui->labelRange->setAlignment(Qt::AlignLeft); + ui->labelRange->setAlignment(Qt::AlignVCenter); + + ui->buttonOk->setWhiteBlueBottomStyle(); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1"),12); + ui->buttonCancel->setWhiteBlueBottomStyle(); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"),12); +} + +//设置标题 +void NumerInputDialog::setTitleStr(QString str) +{ + ui->labelTitle->setText(str); +} + +void NumerInputDialog::setUnitStr(QString str) +{ + m_unitStr = str; +// showRange(); +} + +void NumerInputDialog::setValueAndRange(int64_t val, int64_t min, int64_t max, int afterpoint, int defen, int64_t defvalue) +{ + m_value = val; + m_min = min; + m_max = max; + m_afterPoint = afterpoint; + + if (m_min < -999999999) + { + m_min = -999999999; // 这个值看起来更舒服些 + } + if (m_max > 999999999) + { + m_max = 999999999; // 这个值看起来更舒服些 + } + if (m_min > m_max) + { + double tmp = m_min; + m_min = m_max; + m_max = tmp; + } + + if (m_afterPoint < 0) + { + m_afterPoint = 0; + } + if (m_afterPoint > 4) + { + m_afterPoint = 4; + } + + if (m_value < m_min) + { + m_value = m_min; + } + if (m_value > m_max) + { + m_value = m_max; + } + + if (m_afterPoint != 0) + { + m_pointFlag = m_afterPoint + 1; + } + else + { + m_pointFlag = 0; + } + + m_defFlag = defen; + m_defVal = defvalue; + + showRange(); + showValue(); +} + +int64_t NumerInputDialog::getValue() +{ + int i, j; + int64_t val = m_value; + i = m_pointFlag; + j = m_afterPoint; + if (j != 0) + { + j += 1; + } + + while (i < j) + { + if (i != 0) + { + val *= 10; + } + i++; + } + + return val; +} + +void NumerInputDialog::on_buttonClean_clicked() +{ + m_pointFlag = 0; + m_value = 0; + m_defFlag = 0; + showValue(); +} + +void NumerInputDialog::on_buttonNum00_clicked() +{ + addNum(0); + addNum(0); + showValue(); +} + +void NumerInputDialog::on_buttonDelete_clicked() +{ + m_defFlag = 1; + + if (m_pointFlag != 1) + { + int64_t val; + int pflag; + val = m_value; + pflag = m_pointFlag; + val /= 10; + pflag--; + if (pflag < 0) + { + pflag = 0; + } + //if (checkValueRange(val, pflag) == 0) + { + m_value = val; + } + } + if (m_pointFlag != 0) + { + m_pointFlag--; + } + showValue(); +} + +void NumerInputDialog::on_buttonNum7_clicked() +{ + addNum(7); + showValue(); +} + +void NumerInputDialog::on_buttonNum8_clicked() +{ + addNum(8); + showValue(); +} + +void NumerInputDialog::on_buttonNum9_clicked() +{ + addNum(9); + showValue(); +} + +void NumerInputDialog::on_buttonNum4_clicked() +{ + addNum(4); + showValue(); +} + +void NumerInputDialog::on_buttonNum5_clicked() +{ + addNum(5); + showValue(); +} + +void NumerInputDialog::on_buttonNum6_clicked() +{ + addNum(6); + showValue(); +} + +void NumerInputDialog::on_buttonNum1_clicked() +{ + addNum(1); + showValue(); +} + +void NumerInputDialog::on_buttonNum2_clicked() +{ + addNum(2); + showValue(); +} + +void NumerInputDialog::on_buttonNum3_clicked() +{ + addNum(3); + showValue(); +} + +void NumerInputDialog::on_buttonPlusMinus_clicked() +{ + int64_t val; + val = m_value; + val *= -1; + //if (checkValueRange(val, m_pointFlag) == 0) + { + m_value = val; + showValue(); + } +} + +void NumerInputDialog::on_buttonNum0_clicked() +{ + addNum(0); + showValue(); +} + +void NumerInputDialog::on_buttonPoint_clicked() +{ + if (m_pointFlag == 0 && m_afterPoint != 0) + { + m_pointFlag = 1; + showValue(); + } +} + +void NumerInputDialog::on_buttonDec1000_clicked() +{ + changeValue(-1000); +} + +void NumerInputDialog::on_buttonInc1000_clicked() +{ + changeValue(1000); +} + +void NumerInputDialog::on_buttonDec100_clicked() +{ + changeValue(-100); +} + +void NumerInputDialog::on_buttonInc100_clicked() +{ + changeValue(100); +} + +void NumerInputDialog::on_buttonDec10_clicked() +{ + changeValue(-10); +} + +void NumerInputDialog::on_buttonInc10_clicked() +{ + changeValue(10); +} + +void NumerInputDialog::on_buttonDec1_clicked() +{ + changeValue(-1); +} + +void NumerInputDialog::on_buttonInc1_clicked() +{ + changeValue(1); +} + +void NumerInputDialog::on_buttonDec01_clicked() +{ + if (m_afterPoint != 0) + { + + m_defFlag = 0; + int64_t val; + int pflag, muti; + + int dir; + int weights = -1; + muti = 1; + + //dir = m_value > 0 ? 1:-1; + dir = m_value > 0 ? 1:1; + val = m_value; + pflag = m_pointFlag; + + if (m_pointFlag <= 1) // 是整数 + { + val *= 10; + pflag = 2; // 转换为1位小数 + } + else // 小数 + { + for (int i = 2; i < m_pointFlag; i++) + { + muti *= 10; + } + } + + val += weights * dir * muti; + + //if (checkValueRange(val, pflag) == 0) + { + // val = fixValue(val, pflag); + m_value = val; + m_pointFlag = pflag; + showValue(); + } + } +} + +void NumerInputDialog::on_buttonInc01_clicked() +{ + if (m_afterPoint != 0) + { + + m_defFlag = 0; + int64_t val; + int pflag, muti; + int dir; + int weights = 1; + + //dir = m_value > 0 ? 1:-1; + dir = m_value > 0 ? 1:1; + muti = 1; + + val = m_value; + pflag = m_pointFlag; + + if (m_pointFlag <= 1) // 是整数 + { + val *= 10; + pflag = 2; // 转换为1位小数 + } + else // 小数 + { + + for (int i = 2; i < m_pointFlag; i++) + { + muti *= 10; + } + } + + val += weights * dir * muti; + + //if (checkValueRange(val, pflag) == 0) + { + // val = fixValue(val, pflag); + m_value = val; + m_pointFlag = pflag; + showValue(); + } + } +} + +void NumerInputDialog::on_buttonOk_clicked() +{ + done(1); +} + +void NumerInputDialog::on_buttonCancel_clicked() +{ + done(0); +} diff --git a/sharedviews/numerinputdialog.h b/sharedviews/numerinputdialog.h new file mode 100644 index 0000000..ce71827 --- /dev/null +++ b/sharedviews/numerinputdialog.h @@ -0,0 +1,100 @@ +#ifndef NUMERINPUTDIALOG_H +#define NUMERINPUTDIALOG_H + +#include +#include "mybutton.h" +#include "setcontrolstyle.h" +#define NUM_BAK_LAG 100 // 数据撤销次数 + +namespace Ui { +class NumerInputDialog; +} + +class NumerInputDialog : public QDialog +{ + Q_OBJECT + +public: + explicit NumerInputDialog(QWidget *parent = 0); + ~NumerInputDialog(); + +private: + Ui::NumerInputDialog *ui; + +private: + int64_t m_value; + int64_t m_min; + int64_t m_max; + int m_afterPoint; + int64_t m_defVal; + +private: + int m_defFlag; + int m_pointFlag; // 小数点标志 + QString m_unitStr; + QList m_leftNumberBtnList; + QList m_rightNumberBtnList; + +private: + int64_t m_valuebak[NUM_BAK_LAG]; // 数值恢复备份 + int m_pointFlagbak[NUM_BAK_LAG]; // 小数点恢复备份 + int m_bakIdx; // 数组索引 + +private: + QString getShowString(int64_t val, int pointflag); + int checkValueRange(int64_t val, int pointflag); + int64_t fixValue( int64_t val, int pointflag); + int getPointMuti(int pointflag); + void showValue(); + void showRange(); + void addNum(int num); + void changeValue(int weights); + + void bakValue(); // 备份撤销数据 + void chkbakValue(); // 校验备份撤销数据 + void rebakValue(); // 恢复备份撤销数据 + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006(); + void initControlStyle();//初始化窗体控件样式 + +public: + void initDialog();//初始化窗体 + void setTitleStr(QString str);//设置标题 + void setUnitStr(QString str); + void setValueAndRange(int64_t val, int64_t min, int64_t max, int afterpoint, int defen = 0, int64_t defvalue = 1); + int64_t getValue(); + +private slots: + void on_buttonClean_clicked(); + void on_buttonNum00_clicked(); + void on_buttonDelete_clicked(); + void on_buttonNum7_clicked(); + void on_buttonNum8_clicked(); + void on_buttonNum9_clicked(); + void on_buttonNum4_clicked(); + void on_buttonNum5_clicked(); + void on_buttonNum6_clicked(); + void on_buttonNum1_clicked(); + void on_buttonNum2_clicked(); + void on_buttonNum3_clicked(); + void on_buttonPlusMinus_clicked(); + void on_buttonNum0_clicked(); + void on_buttonPoint_clicked(); + void on_buttonDec1000_clicked(); + void on_buttonInc1000_clicked(); + void on_buttonDec100_clicked(); + void on_buttonInc100_clicked(); + void on_buttonDec10_clicked(); + void on_buttonInc10_clicked(); + void on_buttonDec1_clicked(); + void on_buttonInc1_clicked(); + void on_buttonDec01_clicked(); + void on_buttonInc01_clicked(); + void on_buttonOk_clicked(); + void on_buttonCancel_clicked(); +}; + +#endif // NUMERINPUTDIALOG_H diff --git a/sharedviews/numerinputdialog.ui b/sharedviews/numerinputdialog.ui new file mode 100644 index 0000000..0575d22 --- /dev/null +++ b/sharedviews/numerinputdialog.ui @@ -0,0 +1,1052 @@ + + + NumerInputDialog + + + + 0 + 0 + 545 + 467 + + + + Dialog + + + + + 120 + 116 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + C + + + false + + + + + + 340 + 114 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + -1000 + + + false + + + + + + 440 + 408 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + + + + false + + + + + + 440 + 114 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + +1000 + + + false + + + + + + 340 + 288 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + -1 + + + false + + + + + + 220 + 232 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 6 + + + false + + + + + + 119 + 174 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 8 + + + false + + + + + + 330 + 70 + 131 + 21 + + + + + + + (0~3000)rmp + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 440 + 230 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + +10 + + + false + + + + + + 20 + 348 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 00 + + + false + + + + + + 220 + 174 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 9 + + + false + + + + + + 22 + 64 + 284 + 44 + + + + background-color: rgb(255, 255, 255); + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 440 + 172 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + +100 + + + false + + + + + + 440 + 288 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + +1 + + + false + + + + + + 220 + 348 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + + + + false + + + + + + 340 + 172 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + -100 + + + false + + + + + + 119 + 232 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 5 + + + false + + + + + + 340 + 408 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + + + + false + + + + + + 18 + 174 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 7 + + + false + + + + + + 18 + 232 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 4 + + + false + + + + + + 0 + 0 + 545 + 48 + + + + + + + Number input + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 220 + 116 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + + + + false + + + + + + 18 + 116 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + -/+ + + + false + + + + + + 119 + 290 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 2 + + + false + + + + + + 119 + 348 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 0 + + + false + + + + + + 18 + 290 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 1 + + + false + + + + + + 440 + 346 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + +0.1 + + + false + + + + + + 220 + 290 + 92 + 50 + + + + + 61 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + 3 + + + false + + + + + + 340 + 346 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + -0.1 + + + false + + + + + + 340 + 230 + 92 + 50 + + + + + 90 + 10 + + + + + 200 + 80 + + + + Qt::NoFocus + + + + + + -10 + + + false + + + + + + 0 + 0 + 545 + 467 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + frameBack + buttonClean + buttonDec1000 + buttonCancel + buttonInc1000 + buttonDec1 + buttonNum6 + buttonNum8 + labelRange + buttonInc10 + buttonNum00 + buttonNum9 + labelValue + buttonInc100 + buttonInc1 + buttonPoint + buttonDec100 + buttonNum5 + buttonOk + buttonNum7 + buttonNum4 + labelTitle + buttonDelete + buttonPlusMinus + buttonNum2 + buttonNum0 + buttonNum1 + buttonInc01 + buttonNum3 + buttonDec01 + buttonDec10 + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/parametersetdialog.cpp b/sharedviews/parametersetdialog.cpp new file mode 100644 index 0000000..bf3e1dc --- /dev/null +++ b/sharedviews/parametersetdialog.cpp @@ -0,0 +1,2210 @@ +#include "parametersetdialog.h" +#include "ui_parametersetdialog.h" + +ParameterSetDialog::ParameterSetDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ParameterSetDialog), + m_itemPerPage(8) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + + this->move(0,0); + m_setedFlag = 0; + m_rootCurPage = 0; + + //获取网卡ID + m_networkCardID.clear(); + QList interfaces = QNetworkInterface::allInterfaces(); + if(interfaces.size() == 1) + { + QNetworkInterface item = interfaces.at(0); + m_networkCardID = item.hardwareAddress(); + } + else + { + int nCnt = interfaces.count(); + for(int i = 0; i < nCnt; i++) + { + //QNetworkInterface item = interfaces.at(i); + //m_networkCardID = item.hardwareAddress(); + + // 如果此网络接口被激活并且正在运行并且不是回环地址,则就是我们需要找的Mac地址 + if(interfaces[i].flags().testFlag(QNetworkInterface::IsUp) && + interfaces[i].flags().testFlag(QNetworkInterface::IsRunning) && + !interfaces[i].flags().testFlag(QNetworkInterface::IsLoopBack)) + { + m_networkCardID = interfaces[i].hardwareAddress(); + qDebug()<button1); + m_itemBtnList.append(ui->button2); + m_itemBtnList.append(ui->button3); + m_itemBtnList.append(ui->button4); + m_itemBtnList.append(ui->button5); + ui->button6->setVisible(false);//隐藏 + ui->button7->setVisible(false); + ui->button8->setVisible(false); + ui->button9->setVisible(false); + ui->button10->setVisible(false); + ui->button11->setVisible(false); + ui->button12->setVisible(false); + + //五头精密缝等比放大 +// if(g_emResolut == resolution1910)//1920x1080的分辨率每页显示12个条目 +// { +// ui->button6->setVisible(true); +// ui->button7->setVisible(true); +// ui->button8->setVisible(true); +// ui->button9->setVisible(true); +// ui->button10->setVisible(true); +// ui->button11->setVisible(true); +// ui->button12->setVisible(true); +// m_itemBtnList.append(ui->button6); +// m_itemBtnList.append(ui->button7); +// m_itemBtnList.append(ui->button8); +// m_itemBtnList.append(ui->button9); +// m_itemBtnList.append(ui->button10); +// m_itemBtnList.append(ui->button11); +// m_itemBtnList.append(ui->button12); +// } +// else if(g_emResolut == resolution1006)//1024x600的分辨率每页显示8个条目 + { + ui->button6->setVisible(true);//显示 + ui->button7->setVisible(true); + ui->button8->setVisible(true); + m_itemBtnList.append(ui->button6); + m_itemBtnList.append(ui->button7); + m_itemBtnList.append(ui->button8); + } + + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void ParameterSetDialog::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + + this->resize(1024*factoryX,600*factoryY); + ui->frameBack->setGeometry(0*factoryX,0*factoryY,1024*factoryX,600*factoryY); + ui->buttonTypeLogo->setGeometry(25*factoryX,30*factoryY,54*factoryX,54*factoryY); + ui->labelMainTitle->setGeometry(100*factoryX,30*factoryY,200*factoryX,24*factoryY); + ui->labelSubTitle->setGeometry(130*factoryX,64*factoryY,240*factoryX,21*factoryY); + ui->labelRepetitions->setGeometry(330*factoryX,64*factoryY,340*factoryX,21*factoryY); + + ui->frameRightUp->setGeometry(746*factoryX,40*factoryY,800*factoryX,61*factoryY); + ui->buttonParaRestore->setGeometry(150*factoryX,0*factoryY,50*factoryX,50*factoryY); + ui->buttonReturn->setGeometry(214*factoryX,0*factoryY,50*factoryX,50*factoryY); + + //内容的位置 + QRect rectName(40*factoryX,-1*factoryY,400*factoryX,53*factoryY); + QRect rectValue(460*factoryX,-1*factoryY,220*factoryX,53*factoryY); + for(int i = 0; i < m_itemPerPage; i++)//白色按下的效果 + { + m_itemBtnList[i]->setGeometry(153*factoryX,(96 + i * 53)*factoryY,718*factoryX,53*factoryY); + m_itemBtnList[i]->initLeftNameRightValue(rectName,rectValue,1); + } + + ui->framePageBtn->setGeometry(595*factoryX,545*factoryY,600*factoryX,45*factoryY); + ui->labelPage->setGeometry(20*factoryX,550*factoryY,102*factoryX,45*factoryY); + ui->buttonPgUp->setGeometry(0*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonPgDn->setGeometry(106*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonOk->setGeometry(212*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonCancel->setGeometry(318*factoryX,0*factoryY,96*factoryX,40*factoryY); +} + +//初始化窗体控件为1024x600分辨率 +void ParameterSetDialog::initResolution1006() +{ +// m_itemPerPage = m_itemPerPage - 4; + this->resize(1024,600); + ui->frameBack->setGeometry(0,0,1024,600); + ui->buttonTypeLogo->setGeometry(25,30,60,60); + ui->labelMainTitle->setGeometry(100,30,200,24); + ui->labelSubTitle->setGeometry(130,64,240,21); + ui->labelRepetitions->setGeometry(330,64,340,21); + + ui->frameRightUp->setGeometry(746,40,800,61); + ui->buttonParaRestore->setGeometry(150,0,50,50); + ui->buttonReturn->setGeometry(214,0,50,50); + + //内容的位置 + QRect rectName(40,-1,400,53); + QRect rectValue(460,-1,220,53); + for(int i = 0; i < m_itemPerPage; i++)//白色按下的效果 + { + m_itemBtnList[i]->setGeometry(153,96 + i * 53,718,53); + m_itemBtnList[i]->initLeftNameRightValue(rectName,rectValue,1); + } + + ui->framePageBtn->setGeometry(595,545,600,45); + ui->labelPage->setGeometry(20,550,102,45); + ui->buttonPgUp->setGeometry(0,0,96,40); + ui->buttonPgDn->setGeometry(106,0,96,40); + ui->buttonOk->setGeometry(212,0,96,40); + ui->buttonCancel->setGeometry(318,0,96,40); +} + +//初始化窗体控件样式 +void ParameterSetDialog::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //背景图 + QString frameBackImgPath = setControlStyle.getSharedStyleSheet(); + ui->frameBack->setStyleSheet(frameBackImgPath); + ui->labelMainTitle->setFont(fontBold_1); + ui->labelMainTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelSubTitle->setFont(fontNormal_1); + ui->labelSubTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelPage->setFont(fontNormal_1); + ui->labelPage->setStyleSheet(LABELWHITESTYLE); + ui->labelRepetitions->setFont(fontNormal_1); + ui->labelRepetitions->setStyleSheet(LABELWHITESTYLE); + + //右上方 + ui->frameRightUp->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonParaRestore->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonParaRestore->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonParaRestore->objectName())); + ui->buttonReturn->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonReturn->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonReturn->objectName())); + + //条目 + for(int i = 0; i < m_itemPerPage; i++) + { + m_itemBtnList[i]->setLabelFont(fontNormal_1); + } + + //四个按钮样式表一样 + ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + + ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + + ui->buttonOk->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()),12); + + ui->buttonCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12); +} + +void ParameterSetDialog::refreshUi() +{ + ui->buttonOk->setVisible(true);//再进入界面时,刷新界面确认按钮就显示 + ui->labelRepetitions->setVisible(false);//先隐藏 + + if(m_paraType == PARA_TYPE_HMICONFIGURATION)//等于界面配置 + { + refreshProductType();//刷新产品类型 + } + + if (m_itemList.size() <= 0)//参数列表 + { + for (int i = 0; i < m_itemPerPage; i++) + { + m_itemBtnList.at(i)->hide(); + } + ui->labelPage->setText("PageNum: 0/0"); + ui->buttonPgUp->setEnabled(false); + ui->buttonPgDn->setEnabled(false); + ui->buttonOk->setEnabled(false); + ui->frameRightUp->setVisible(false); + + return;//下边的代码不执行 + } + + if(m_itemPerPage <= 0) + { + return; + } + + ui->buttonOk->setEnabled(true); + QString split1 = ":"; + QString split2 = ";"; + QString str; + + //----------- + int itemNum, pageNums; + itemNum = m_itemList.size();//列表总个数 + pageNums = (itemNum+m_itemPerPage-1) / m_itemPerPage;//一共有的页数 + + if(m_paraType == PARA_TYPE_ROOT)//等于超级用户界面 + { + if (m_rootCurPage > pageNums) // 当前页 + { + m_rootCurPage = pageNums; + } + if (m_rootCurPage <= 1) + { + m_rootCurPage = 1; + } + + } + else + { + if (m_curPage > pageNums) // 当前页 + { + m_curPage = pageNums; + } + if (m_curPage <= 1) + { + m_curPage = 1; + } + } + + // 条目信息 + int i, itemidx; + if(m_paraType == PARA_TYPE_ROOT)//等于超级用户界面 + { + itemidx = (m_rootCurPage-1) * m_itemPerPage; + } + else + { + itemidx = (m_curPage-1) * m_itemPerPage; + } + + + for (i = 0; i < m_itemPerPage; i++) + { + if (itemidx < m_itemList.size()) + { + const ParaItem & item = m_itemList.at(itemidx); + + if (item.readonly != 0) // 只读,不能设置 + { + m_itemBtnList.at(i)->show(); + m_itemBtnList.at(i)->setEnabled(false); + } + else + { + //超级用户选择工作参数开关型后回到遍历设置会显示开关,以下代码隐藏开关 + if(item.valueType == PARA_VALUE_TYPE_CLICK) + { + m_itemBtnList.at(i)->setLabelValueImage(""); + } + m_itemBtnList.at(i)->show(); + m_itemBtnList.at(i)->setEnabled(true); + } + + m_itemBtnList.at(i)->setLabelName(item.paraName); + + if (item.valueType == PARA_VALUE_TYPE_INT) // = 1, 数字输入型 + { + str = getValueStr(item.value, item.afterPoint);//显示的是默认参数 + str += " " + item.unitStr; + // qDebug()<< item.value << item.afterpoint << item.unitstr; + m_itemBtnList.at(i)->setLabelValue(str);//设置参数显示的值,没连上就显示的默认参数 + m_itemBtnList.at(i)->show(); + } + else if (item.valueType == PARA_VALUE_TYPE_SW) // = 2, 开关选择型 + { + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + QString path; + path = setControlStyle.getBottomStyleSheet1(""); + + if (item.value != 0)//打开 + { + path += "switchOn_logo.png"; + } + else + { + path += "switchOff_logo.png"; + } + + m_itemBtnList.at(i)->setLabelValueImage(path); + } + else if (item.valueType == PARA_VALUE_TYPE_LIST) // = 3, 列表选择型 + { + QStringList vallist; + if(item.selList.indexOf(split1) == -1) + { + // 没找到 二级分割 + vallist = item.selList.split(split2, QString::SkipEmptyParts); + if (vallist.size() <= 0) + { + str = ""; + } + else + { + int selIdx = item.selIdx; + if (selIdx < 0) + { + selIdx = 0; + } + if (selIdx >= vallist.size()) + { + selIdx = vallist.size() - 1; + } + str = vallist.at(selIdx); + } + } + else + { + // 二级分割 + vallist = item.selList.split(split2, QString::SkipEmptyParts); + if (vallist.size() <= 0) + { + str = ""; + } + else + { + int miniIndex = vallist.first().split(split1, QString::SkipEmptyParts).at(1).toInt(); + int maxIndex = vallist.last().split(split1, QString::SkipEmptyParts).at(1).toInt(); + + //int selIdx = item.value; + int selIdx = item.selIdx; + if (selIdx < miniIndex) + { + selIdx = miniIndex; + } + if (selIdx >= maxIndex) + { + selIdx = maxIndex; + } + for (int var = 0; var < vallist.size(); ++var) + { + QStringList sublist = vallist.at(var).split(split1, QString::SkipEmptyParts); + if(sublist.at(1).toInt() == selIdx) + { + str = sublist.at(0); + } + } + } + } + if((m_paraType == PARA_TYPE_PATTERN && item.indexInPara == SET_ROTATESTYLE) || //旋转式样 + (m_paraType == PARA_TYPE_PATTERN && item.indexInPara == SET_HORIZONTALSTYLE) || //水平翻转 + (m_paraType == PARA_TYPE_PATTERN && item.indexInPara == SET_VERTICALSTYLE)) //垂直翻转 + { + //旋转式样加载P的图片 + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + QString path = setControlStyle.getSharedBottomStyleSheet("") + str + "_logo.png"; + m_itemBtnList.at(i)->setLabelValueImage(path); + } + else + { + m_itemBtnList.at(i)->setLabelValue(str); + } + } + else if (item.valueType == PARA_VALUE_TYPE_STRINPUT) // = 4, 字符串输入型 + { + str = item.valueStr; + m_itemBtnList.at(i)->setLabelValue(str); + m_itemBtnList.at(i)->show(); + } + else // = 0, 无值 + { + m_itemBtnList.at(i)->setLabelValue(""); + } + itemidx++; + } + else + { + m_itemBtnList.at(i)->setEnabled(false); + m_itemBtnList.at(i)->hide(); + } + } + + if(m_paraType == PARA_TYPE_ROOT)//等于超级用户界面 + { + // 超级用户界面按钮 + if (m_rootCurPage <= 1) + { + ui->buttonPgUp->setEnabled(false); + } + else + { + ui->buttonPgUp->setEnabled(true); + } + + if (m_rootCurPage >= pageNums) + { + ui->buttonPgDn->setEnabled(false); + } + else + { + ui->buttonPgDn->setEnabled(true); + } + } + else + { + // 按钮 + if (m_curPage <= 1) + { + ui->buttonPgUp->setEnabled(false); + } + else + { + ui->buttonPgUp->setEnabled(true); + } + + if (m_curPage >= pageNums) + { + ui->buttonPgDn->setEnabled(false); + } + else + { + ui->buttonPgDn->setEnabled(true); + } + } + + // 页信息 + QString strPage; + if(m_paraType == PARA_TYPE_ROOT)//等于超级用户界面 + { + strPage = tr("pageNum: ") + QString("%1/%2").arg(m_rootCurPage).arg(pageNums);//页数: + } + else + { + strPage = tr("pageNum: ") + QString("%1/%2").arg(m_curPage).arg(pageNums);//页数: + } + + ui->labelPage->setText(strPage); + + if(m_paraType == PARA_TYPE_ROOT) + { + ui->buttonOk->setEnabled(false); + //ui->buttonOk->setEnabled(true);//增加了界面调试模式,超级用户界面按钮可用 + } + + if(m_paraType == PARA_TYPE_MACH || + m_paraType == PARA_TYPE_WORK)//机头板参数或换色板参数或机器参数或工作参数(机器参数或工作参数为超级用户目录下的) + { + ui->frameRightUp->setVisible(true); + ui->buttonParaRestore->setVisible(true);//恢复默认参数按钮 + ui->buttonReturn->setVisible(true);//返回上一级按钮或重置反复绣次数 + } + else if( m_paraType == PARA_TYPE_HMICONFIGURATION||//界面配置 + m_paraType == PARA_TYPE_IOTCONFIGURATION //物联网配置 + ) + { + ui->frameRightUp->setVisible(true); + ui->buttonParaRestore->setVisible(false); + ui->buttonReturn->setVisible(true);//返回上一级按钮 + } + else + { + ui->frameRightUp->setVisible(false); + } + //超级用户界面配置 + if(m_paraType == PARA_TYPE_HMICONFIGURATION) + { + ui->buttonOk->setEnabled(true); + } +} + +QString ParameterSetDialog::getValueStr(int64_t val, int afterpoint) +{ + QString str; + double value = val; + if (afterpoint <= 0) + { + str.sprintf("%.0f", value); + } + else if (afterpoint == 1) + { + value /= 10; + str.sprintf("%.1f", value); + } + else if (afterpoint == 2) + { + value /= 100; + str.sprintf("%.2f", value); + } + else if (afterpoint == 3) + { + value /= 1000; + str.sprintf("%.3f", value); + } + else // if (afterpoint >= 4) + { + value /= 10000; + str.sprintf("%.4f", value); + } + return str; +} + +void ParameterSetDialog::changeValue(int buttenidx) +{ +#if(0) + //等于机器参数或工作参数 + if(((m_paraType & PARA_TYPE_MACH) == PARA_TYPE_MACH) || + ((m_paraType & PARA_TYPE_WORK) == PARA_TYPE_WORK)) + { + if(g_emUser != repair)//权限不够先登录 + { + emit siUserLogin(repair); + if(g_emUser != repair)//发送登录信号后,权限如果还没改变就返回 + return; + } + } +#endif + + QString split1 = ":"; + QString split2 = ";"; + + if (buttenidx < 0 || buttenidx >= m_itemPerPage) + { + return ; + } + + int itemidx; + int selIdx = 0; + if(m_paraType == PARA_TYPE_ROOT)//等于超级用户界面 + { + itemidx = (m_rootCurPage-1) * m_itemPerPage; + } + else + { + itemidx = (m_curPage-1) * m_itemPerPage; + } + + itemidx += buttenidx; + + if (itemidx < m_itemList.size()) + { + int chgflag = 0; + s32 newvalue; + QString newStrValue; + const ParaItem & item = m_itemList.at(itemidx); + newvalue = item.value;//等于这个列表现在的值 + newStrValue = item.valueStr; + + if (item.valueType == PARA_VALUE_TYPE_INT) // 数字型 + { + int rslt; + NumerInputDialog ndlg(this); + ndlg.setTitleStr(item.paraName); + ndlg.setUnitStr(item.unitStr); + ndlg.setValueAndRange(item.value, item.minVal, item.maxVal, item.afterPoint); + rslt = ndlg.exec(); + + if (rslt == 1)//点了确认按钮 + { + s32 val = ndlg.getValue(); + if (val != newvalue)//更改后的值不等于之前存的值 + { + + if(getItemValue(SET_EQUAL) == 1){ //等比缩放 调整x或y之后自动调整另一个的比例 + s32 x1 = getItemValue(SET_SCANX); //缩放x + s32 y1 = getItemValue(SET_SCANY); //缩放y + float pro = (float)x1/y1; + if(item.indexInPara == SET_SCANX)//缩放x + { + s32 y = (1/pro)*val; + setItemValue(SET_SCANY, y);//缩放y + }else if(item.indexInPara == SET_SCANY)//缩放y + { + s32 x = pro*val; + setItemValue(SET_SCANX, x);//缩放x + }; + } + + chgflag = 1; + newvalue = val; + } + } + } + else if (item.valueType == PARA_VALUE_TYPE_SW) // 开关型 + { + if (newvalue == 0) + { + newvalue = 1; + } + else + { + newvalue = 0; + } + chgflag = 1; + } + else if (item.valueType == PARA_VALUE_TYPE_LIST) + { + QStringList vallist; + if(item.selList.indexOf(split2) == -1) + { //没找到 二级分割 + vallist = item.selList.split(split1, QString::SkipEmptyParts); + if (vallist.size() > 0) + { + selIdx = item.selIdx + 1; + if (selIdx < 0) + { + selIdx = 0; + } + if (selIdx >= vallist.size()) // 循环选择 + { + selIdx = 0; + } + chgflag = 1; + } + } + else + { + //二级分割 注意 key 是 int val是字符串 + //分清楚 key 并不是 字符串的index 需要区分 + vallist = item.selList.split(split2, QString::SkipEmptyParts); + if (vallist.size() <= 0) + { + return; + } + else + { + // 使用 qmap 组成key: val + int miniVal = vallist.first().split(split1, QString::SkipEmptyParts).at(1).toInt(); + int maxVal = vallist.last().split(split1, QString::SkipEmptyParts).at(1).toInt(); + QMap seachDat ; + + for (int var = 0; var < vallist.size(); ++var) + { + QStringList mapDatList = vallist.at(var).split(split1, QString::SkipEmptyParts); + seachDat.insert(mapDatList.at(1).toInt(),mapDatList.at(0)); + } + + selIdx = item.selIdx; + + if(seachDat.contains(selIdx)) + { + //存在这个key + + } + else + { + //不存在这个key 用默认值存储 + selIdx = item.defValue; + } + + //找到下一个val vallist seach_dat + + for (int var = 0; var < vallist.size(); ++var) + { + if( vallist.at(var).split(split1, QString::SkipEmptyParts).at(1).toInt() == selIdx) + { + var++ ; + if( var >= vallist.size()) + { + var = 0 ; + } + selIdx = vallist.at(var).split(split1, QString::SkipEmptyParts).at(1).toInt(); + break; + } + } + if (selIdx < miniVal) + { + selIdx = miniVal; + } + if (selIdx > maxVal) + { + selIdx = maxVal; + } + chgflag = 1; + } + } + } + else if (item.valueType == PARA_VALUE_TYPE_STRINPUT) // 字符输入型 + { + PassWordDialog passWordDlg(this); + QString str(""); + passWordDlg.setTitleStr(tr("Input"),-1);//输入 + passWordDlg.setShowIfVisible(true); + int rslt = passWordDlg.exec(); + if(rslt == 1) + { + str = passWordDlg.getInputStr(); + if (str != item.valueStr) + { + chgflag = 1; + newStrValue = str; + } + } + } + else if (item.valueType == PARA_VALUE_TYPE_CLICK) // 点击触发型 + { + s16 fun = item.indexInPara; + execItemClickEvent(fun); + return; + } + + if (chgflag != 0) + { + if(item.valueType == PARA_VALUE_TYPE_LIST) + { + m_itemList[itemidx].selIdx = selIdx; + m_itemList[itemidx].value = selIdx; + } + else if(item.valueType == PARA_VALUE_TYPE_STRINPUT) + { + m_itemList[itemidx].valueStr = newStrValue; + } + else + { + m_itemList[itemidx].value = newvalue;//列表里的值等于弹窗输入的值 + + } + // qDebug()<< " newvalue " << newvalue; + refreshUi();//在这个函数里刷新 + } + } +} + +//刷新参数值 +void ParameterSetDialog::refreshValue() +{ + m_mcParaValues = m_mcParaValues; + m_wkParaValues = m_wkParaValues; + + for (int i = 0; i < m_itemList.size(); i++) + { + int type = m_itemList[i].paraType; + int idx = m_itemList.at(i).indexInPara; + int bitInWord = m_itemList[i].bitInWord; + s32 mcTempValue = m_mcParaValues.buf[idx]; + s32 wkTempValue = m_wkParaValues.buf[idx]; + + if (idx < PARA_NUM) + { + if (type == PARA_TYPE_MACH) + { + // ljs++ + if (bitInWord == 0) + { + m_itemList[i].value = mcTempValue;//列表里的值,变成主控里的值 + if(m_itemList[i].valueType == PARA_VALUE_TYPE_LIST) + { + m_itemList[i].selIdx = mcTempValue; + } + } + else + { + u32 bitval = 0x01; + bitval <<= (bitInWord - 1); + if ((mcTempValue & bitval) == 0) + { + m_itemList[i].selIdx = 0; + m_itemList[i].value = 0; + } + else + { + m_itemList[i].selIdx = 1; + m_itemList[i].value = 1; + } + } + } + else if (type == PARA_TYPE_WORK) + { + // ljs++ + if (bitInWord == 0) + { + m_itemList[i].value = wkTempValue; + if(m_itemList[i].valueType == PARA_VALUE_TYPE_LIST) + { + m_itemList[i].selIdx = wkTempValue; + } + } + else + { + u32 bitval = 0x01; + bitval <<= (bitInWord - 1); + if ((wkTempValue & bitval) == 0) + { + m_itemList[i].selIdx = 0; + m_itemList[i].value = 0; + } + else + { + m_itemList[i].selIdx = 1; + m_itemList[i].value = 1; + } + } + } +} + } +} + +//收到下位机参数改变信号的槽 +void ParameterSetDialog::paraChange(int type, int id) +{ + //点了主板的按钮后,现在这个g_pMachine就是对应主板的 + if (type == SEW_MCPARA_MACH) + { + if (id == 0) + { //得到当前主板的参数 + memcpy(&m_mcParaValues, &g_pMachine->getMcPara(), sizeof(ParaStruct)); + + m_setedFlag |= 0x01;//当前的主板 收到参数包 的标志改变 + } + } + else if (type == SEW_MCPARA_WORK) + { + if (id == 0) + { + memcpy(&m_wkParaValues, &g_pMachine->getWkPara(), sizeof(ParaStruct)); + m_setedFlag |= 0x02; + } + } + + m_mcParaValues = m_mcParaValues; + m_wkParaValues = m_wkParaValues; + + //等于机器参数或工作参数 + if(((m_paraType & PARA_TYPE_MACH) == PARA_TYPE_MACH) || + ((m_paraType & PARA_TYPE_WORK) == PARA_TYPE_WORK)) + { + if (m_setedFlag == 0x03)// = 0x03就是机器参数和主控参数都读过 + { + if (m_itemList.size() > 0)//参数列表 + { + ui->buttonOk->setEnabled(true);//如果从下位机得到了数据包,说明与下位机建立了联系。可以点击确认按钮 + } + refreshValue(); + refreshUi(); + } + } +} + +void ParameterSetDialog::saveParas(int idx) +{ + qDebug()<<"step 1"; + if (m_setedFlag == 0x03 && + (m_paraType == (PARA_TYPE_MACH | PARA_TYPE_WORK) || + m_paraType == PARA_TYPE_MACH || m_paraType == PARA_TYPE_WORK)) + { + int size = m_itemList.size(); + if (idx < 0) + { + int i; + for (i = 0; i < size; i++) + { + int id = m_itemList.at(i).indexInPara; + int type = m_itemList.at(i).paraType; + int bitInWord = m_itemList.at(i).bitInWord; + int value = m_itemList.at(i).value; + if (id < PARA_NUM && type == PARA_TYPE_MACH) + { + if (bitInWord == 0) // ljs++ + { + m_mcParaValues.buf[id] = m_itemList.at(i).value; + } + else + { + u32 bitval = 0x01; + bitval <<= (bitInWord - 1); + if (value == 0) + { + m_mcParaValues.buf[id] &= ~bitval; + } + else + { + m_mcParaValues.buf[id] |= bitval; + } + } + } + } + + qDebug()<<"step 2"; +#if(0) + for(int i = 0; i < MACHINE_NUMBER; i++) + { + g_pMachine[i]->setMcPara(&m_mcParaValues); + } +#endif + //当前主板的g_pMachine + g_pMachine->setMcPara(&m_mcParaValues); + qDebug()<<"step 3"; + + for (i = 0; i < size; i++) + { + int id = m_itemList.at(i).indexInPara; + int type = m_itemList.at(i).paraType; + int bitInWord = m_itemList.at(i).bitInWord; + int value = m_itemList.at(i).value; + if (id < PARA_NUM && type == PARA_TYPE_WORK) + { + if (bitInWord == 0) // ljs++ + { + m_wkParaValues.buf[id] = m_itemList.at(i).value; + } + else + { + u32 bitval = 0x01; + bitval <<= (bitInWord - 1); + if (value == 0) + { + m_wkParaValues.buf[id] &= ~bitval; + } + else + { + m_wkParaValues.buf[id] |= bitval; + } + } + } + } + + qDebug()<<"step 4"; +#if(0) + for(int i = 0; i < MACHINE_NUMBER; i++) + { + g_pMachine[i]->setWkPara(&m_wkParaValues); + } +#endif + g_pMachine->setWkPara(&m_wkParaValues); + qDebug()<<"step 5"; + } + else if (idx < size) + { + int id = m_itemList.at(idx).indexInPara; + int type = m_itemList.at(idx).paraType; + int value = m_itemList.at(idx).value; + int bitInWord = m_itemList.at(idx).bitInWord; // ljs++ + if (id < PARA_NUM && type == PARA_TYPE_MACH) + { + if (bitInWord == 0) + { + m_mcParaValues.buf[id] = value; + } + else + { + u32 bitval = 0x01; + bitval <<= (bitInWord - 1); + if (value == 0) + { + m_mcParaValues.buf[id] &= ~bitval; + } + else + { + m_mcParaValues.buf[id] |= bitval; + } + value = m_mcParaValues.buf[id]; + } + + qDebug()<<"step 6"; +#if(0) + for(int i = 0; i < MACHINE_NUMBER; i++) + { + g_pMachine[i]->setAMcPara(id+1, value); + } +#endif + g_pMachine->setAMcPara(id+1, value); + qDebug()<<"step 7"; + } + else if (id < PARA_NUM && type == PARA_TYPE_WORK) + { + if (bitInWord == 0) + { + m_wkParaValues.buf[id] = value; + } + else + { + u32 bitval = 0x01; + bitval <<= (bitInWord - 1); + if (value == 0) + { + m_wkParaValues.buf[id] &= ~bitval; + } + else + { + m_wkParaValues.buf[id] |= bitval; + } + value = m_wkParaValues.buf[id]; + } + + qDebug()<<"step 8"; +#if(0) + for(int i = 0; i < MACHINE_NUMBER; i++) + { + g_pMachine[i]->setAWkPara(id+1, value); + } +#endif + g_pMachine->setAWkPara(id+1, value); + qDebug()<<"step 9"; + } + } + } +} + +//执行点击触发型参数的触发事件 +void ParameterSetDialog::execItemClickEvent(s16 fun) +{ + g_pMachine->getParasFromMachine();//读取参数 + + switch (fun) + { + case ROOT_HMICONFIGURATION://进入界面配置 + setMainTitle(tr("HMI Configuration")); + setSubTitle(tr("Root > HMI Configuration")); + //得到界面配置列表 + if(g_emDebugMode == nodebugMode) + { + if(g_emUser == factory) + { + setItemList(factory,PARA_TYPE_HMICONFIGURATION);//最高权限 + } + else if(g_emUser == root) + { + setItemList(root,PARA_TYPE_HMICONFIGURATION);//最高权限 + } + } + else + { + setItemList(root,PARA_TYPE_HMICONFIGURATION);//最高权限 + } + //设置参数值 + setItemValue(ROOT_RESOLUTION,g_emResolut); //分辨率 + setItemValue(SET_CONNECTMODE,g_pSettings->readFromIniFile("HMI/connectMode").toInt()); + setItemValue(ROOT_MACTYPE,g_emMacType); //机器类型 + setItemValue(ROOT_PRODUCTTYPE,g_emProductType); //产品类型 + setItemValue(ROOT_SHUTTLECHANGE,g_pSettings->readFromIniFile("HMI/shuttleChange").toInt());//自动换梭 + setItemValue(ROOT_WATERMARKSET,g_pSettings->readFromIniFile("HMI/waterMark").toInt()); + setItemValue(ROOT_WIFI,g_pSettings->readFromIniFile("HMI/wifi").toInt()); + setItemValue(ROOT_PARASORTSET,g_pSettings->readFromIniFile("HMI/paraSort").toInt()); + refreshUi(); + break; + + case ROOT_IOTCONFIGURATION: //物联网配置 + setMainTitle(tr("IOT Configuration")); + setSubTitle(tr("Root > IOT Configuration")); + // 得到界面配置列表 + setItemList(factory,PARA_TYPE_IOTCONFIGURATION);//最高权限 + //设置参数值 + setItemValue(ROOT_GATEWAYCONNECTIONMETHOD,g_pSettings->readFromIniFile("IOT/gatewayConnectMode").toInt()); //网关连接 + setItemValue(ROOT_RACKNUMBERINPUT,g_pSettings->readFromIniFile("IOT/rackNumber").toInt());//机架号 + setItemStr(ROOT_DELIVERYTIME,g_pSettings->readFromIniFile("IOT/deliveryTime").toString()); //工厂预计交货时间 + setItemValue(ROOT_DEBUGPROGRESS,g_pSettings->readFromIniFile("IOT/debugProgress").toInt());//调试进度 + + refreshUi(); + break; + + case ROOT_NETWORKSETTINGS: //网络设置 + setMainTitle(tr("Network Settings")); + setSubTitle(tr("IOT Configuration > Network Settings")); + //得到界面配置列表 + //setItemList(factory,PARA_TYPE_NETWORKSETTINGS); + + //设置参数值 + //setItemValue(ROOT_SERVERIPSETTINGS,g_pSettings->readFromIniFile("server/ip").toInt()); //服务器ip设置 + //setItemValue(ROOT_SERVERPORTSETTINGS); + + setGatewayNetworkItemList(PARA_TYPE_NETWORKSETTINGS); + + refreshUi(); + break; + + case ROOT_MACHINEPARA://加载机器参数 + //也用此窗体加载参数 + setMainTitle(tr("Machine parameters")); + setSubTitle(tr("Root > Machine parameters")); + //机器参数 + if(g_emUser == factory) + { + setItemList(factory,PARA_TYPE_MACH);//二级权限 262574 + } + else + { + setItemList(root,PARA_TYPE_MACH);//最高权限 951103 + } + + if(m_setedFlag == 0x03)//如果有从下位机得到过参数包 + { + refreshValue();//不管连没连上,都显示上次保存的值 + } + if(g_pMachine->isConnected() == 3) + { + if(m_setedFlag != 0x03)//界面上显示已就绪 但是没有从下位机得到过参数包(刚上电时) + { + PromptDialog dlg(this); + dlg.initDialog(PromptDialog::BTN_OK); + dlg.setTitleStr(tr("Network error")); + dlg.setContentStr(tr("read parameter..."));//读取参数中... + dlg.exec(); + } + } + else + { +#ifdef Q_OS_LINUX//为了方便windows下查看参数所以加了linux编译条件 + PromptDialog dlg(this); + dlg.initDialog(PromptDialog::BTN_OK); + dlg.setTitleStr(tr("Network error")); + dlg.setContentStr(tr("No connection")); + dlg.exec(); + done(0); +#endif + } + refreshUi(); + break; + + case ROOT_WORKPARA://加载工作参数 + //也用此窗体加载参数 + setMainTitle(tr("Work parameters")); + setSubTitle(tr("Root > Work parameters")); + //工作参数 + if(g_emUser == factory) + { + setItemList(factory,PARA_TYPE_WORK);//二级权限 262574 + } + else + { + setItemList(root,PARA_TYPE_WORK);//最高权限 951103 + } + + if(m_setedFlag == 0x03)//如果有从下位机得到过参数包 + { + refreshValue();//不管连没连上,都显示上次保存的值 + } + if(g_pMachine->isConnected() == 3) + { + if(m_setedFlag != 0x03)//界面上显示已就绪 但是没有从下位机得到过参数包(刚上电时) + { + PromptDialog dlg(this); + dlg.initDialog(PromptDialog::BTN_OK); + dlg.setTitleStr(tr("Network error")); + dlg.setContentStr(tr("read parameter..."));//读取参数中... + dlg.exec(); + } + } + else + { +#ifdef Q_OS_LINUX//为了方便windows下查看参数所以加了linux编译条件 + PromptDialog dlg(this); + dlg.initDialog(PromptDialog::BTN_OK); + dlg.setTitleStr(tr("Network error")); + dlg.setContentStr(tr("No connection")); + dlg.exec(); + done(0); +#endif + } + refreshUi(); + break; + + case ROOT_HMIDECRYPT://界面解密 + emit siHMIDecrypt(m_networkCardID); + break; + + case ROOT_CLEARPATTERN://花样总清 + emit siPatternClear(); + break; + + case ROOT_CHANGEPASSWORD://修改一级密码 + emit siChangePassword(); + break; + + case ROOT_DELETEINI://删除配置文件 + emit siDeleteIni();//删除执行目录下的config + break; + + case ROOT_DEBUGMODE://界面进入调试模式 + emit siDebugMode(); + break; + + case PSE_SOFTWAREPARA_IMPORTPARA://参数导入 + emit siParameterImport(); + break; + + case PSE_SOFTWAREPARA_EXPORTPARA://参数导出 + emit siParameterExport(); + break; + + case PSE_SOFTWAREPARA_HMIUPDATE://界面升级 + emit siHMIUpgrade(); + break; + + case PSE_SOFTWAREPARA_MCUPDATE://主控升级 + emit siMCUpgrade(); + break; + case PSE_SOFTWAREPARA_EXIT://退出程序 + emit siExit(); + break; + default: + break; + } +} + +void ParameterSetDialog::initData() +{ + m_curPage = 0; + m_rootCurPage = 0; + m_paraType = 0; //参数类型(机器参数、工作参数、花样参数等) + m_paraTypeSort = 0; //参数类型分类型(动作参数、位置参数、亮片参数等) + ui->labelRepetitions->setText(tr("Repetitions : 0")); //反复次数:0 + m_itemList.clear(); + m_allItemList.clear(); + + if (m_setedFlag == 0) + { + memset(m_mcParaValues.buf, 0, sizeof(ParaStruct)); + memset(m_wkParaValues.buf, 0, sizeof(ParaStruct)); + } + + m_filePath.clear(); +} + +//设置类型图标 +void ParameterSetDialog::setTypeLogo(QString tStyle) +{ + ui->buttonTypeLogo->setUnPreBtnLogo(tStyle); +} + +//设置主title +void ParameterSetDialog::setMainTitle(QString str) +{ + ui->labelMainTitle->setText(str); +} + +//设置副title +void ParameterSetDialog::setSubTitle(QString str) +{ + ui->labelSubTitle->setText(str); +} + +//(参数权限、参数类型、参数种类)得到相应参数类型列表 +// sort参数分类的小分类 +void ParameterSetDialog::setItemList(int authority,int64_t type,int64_t sort) +{ + m_paraType = type; + m_paraTypeSort = sort; + m_itemList.clear();//最后筛选出的列表 + + //参数筛选 + for(int i = 0; i < m_allItemList.size(); i++) + { + int aType= m_allItemList.at(i).paraType; + int aAuthority = m_allItemList.at(i).authority; + + if((aType & type) == aType) + { + int aSort= m_allItemList.at(i).paraTypeSort; + if(sort == -1)//等于-1加载全部 + { + //外边传进来的权限 等于 factory + if(authority == factory)//加载除了root所有的 + { + if(aAuthority != root)//如果当前的权限不是root,就是 factory和 operate repair的参数 + { + m_itemList.append(m_allItemList.at(i)); + } + } + else if(authority == root) + { + m_itemList.append(m_allItemList.at(i)); + } + else + { //当前列表里的权限 等于 传进来的权限 + if(aAuthority == authority)//参数权限 + { + m_itemList.append(m_allItemList.at(i)); + } + } + } + else + { + if((aSort & sort)== sort)//参数类型 + { + if(authority == factory)//最高参数权限 + { + if(aAuthority != root) + { + m_itemList.append(m_allItemList.at(i)); + } + } + else if(authority == root) + { + m_itemList.append(m_allItemList.at(i)); + } + else + { + if(aAuthority == authority)//参数权限 + { + m_itemList.append(m_allItemList.at(i)); + } + } + } + } + } + } +} + +void ParameterSetDialog::refreshProductType() +{ + int mcType = 0; + for(int i = 0; i < m_itemList.size(); i++) + { + if(m_itemList[i].indexInPara == ROOT_MACTYPE) + { + mcType = m_itemList[i].selIdx; + break; + } + } + + for(int i = 0; i < m_itemList.size(); i++) + { + int index = m_itemList.at(i).indexInPara; + + if(index == ROOT_PRODUCTTYPE)//等于产品类型 + { + switch (mcType) //机器类型 + { + + case 0: + break; + + default://其他机型 + g_emProductType = PRODUCT_NULL; + m_itemList[i].minVal = PRODUCT_NULL; + m_itemList[i].maxVal = PRODUCT_NULL; + m_itemList[i].value = PRODUCT_NULL; + m_itemList[i].selIdx = g_emProductType; + break; + } + break; + } + } +} + +//设置网关网络参数(IP和端口) +void ParameterSetDialog::setGatewayNetworkItemList(int64_t type) +{ + m_paraType = type; + m_itemList.clear(); + + QDir apppath(qApp->applicationDirPath()); + QString serverip, localip; + quint16 serverport, localport; + //服务器IP及端口设置 + int idx = 0; + QString configfile; + configfile = apppath.path() + apppath.separator() + "lotconfig.ini"; + QSettings configIni(configfile, QSettings::IniFormat); + + serverip = configIni.value("server/ip", QVariant("192.168.16.250")).toString(); + ParaItem slpItem; + slpItem.indexInPara = idx; + slpItem.readonly = 0; + slpItem.valueType = PARA_VALUE_TYPE_STRINPUT; + slpItem.paraName = tr("Server IP settings"); //服务器IP设置; + slpItem.valueStr = serverip; + m_itemList.append(slpItem); + + serverport = configIni.value("server/port", QVariant(5001)).toInt(); + idx++; + ParaItem sPortItem; + sPortItem.indexInPara = idx; + sPortItem.readonly = 0; + sPortItem.valueType = PARA_VALUE_TYPE_INT; + sPortItem.paraName = tr("Server Port settings") ;//服务器端口设置 + sPortItem.value = serverport; + sPortItem.minVal = 0; + sPortItem.maxVal = U16_MAX; + sPortItem.defValue = serverport; + m_itemList.append(sPortItem); + + //本地IP设置条目 + localip = configIni.value("local/ip", QVariant("192.168.16.41")).toString(); + idx ++; + ParaItem lIpItem; + lIpItem.indexInPara = idx; + lIpItem.readonly = 0; + lIpItem.valueType = PARA_VALUE_TYPE_STRINPUT; + lIpItem.paraName = tr("Local IP settings");//本地IP设置 + lIpItem.valueStr = localip; + m_itemList.append(lIpItem); + + localport = configIni.value("local/port", QVariant(5000)).toInt(); + idx++; + ParaItem lPortItem; + lPortItem.indexInPara = idx; + lPortItem.readonly = 0; + lPortItem.valueType = PARA_VALUE_TYPE_INT; + lPortItem.paraName = tr("Local Port settings");//本口端口设置 + lPortItem.value = localport; + lPortItem.minVal = 0; + lPortItem.maxVal = U16_MAX; + lPortItem.defValue = localport; + m_itemList.append(lPortItem); +} + +//设置网络参数(IP和端口) +void ParameterSetDialog::setNetworkItemList(int64_t type) +{ + m_paraType = type; + m_itemList.clear(); + + QDir apppath(qApp->applicationDirPath()); + QString serverip,localip; + quint16 serverport,localport; + //服务器IP及端口设置条目(包括网关) + int idx = 0; + QString configfile; + configfile = apppath.path() + apppath.separator() + "mcconfig.ini";//读取的配置文件名字 + QSettings configIni(configfile, QSettings::IniFormat); + serverip = configIni.value("server/ip", QVariant("192.168.16.253")).toString();//把配置文件里的号转换成字符串 + localip = configIni.value("local/ip", QVariant("192.168.16.41")).toString(); + + ParaItem sIpItem; + sIpItem.indexInPara = idx; + sIpItem.readonly = 0; + sIpItem.valueType = PARA_VALUE_TYPE_STRINPUT; + sIpItem.paraName = tr("Board IP settings");//主板IP设置 + sIpItem.valueStr = serverip;//列表里的值就显示从配置文件读上来的 + m_itemList.append(sIpItem);//把这行加到列表里 + + serverport = configIni.value("server/port", QVariant(5000)).toInt(); + idx++; + ParaItem sPortItem; + sPortItem.indexInPara = idx; + sPortItem.readonly = 0; + sPortItem.valueType = PARA_VALUE_TYPE_INT; + sPortItem.paraName = tr("Board port settings");//主板端口设置 + sPortItem.value = serverport; + sPortItem.minVal = 0; + sPortItem.maxVal = U16_MAX; + sPortItem.defValue = serverport; + m_itemList.append(sPortItem); + + idx++; + + //本地IP设置条目 + ParaItem lIpItem; + lIpItem.indexInPara = idx; + lIpItem.readonly = 0; + lIpItem.valueType = PARA_VALUE_TYPE_STRINPUT; + lIpItem.paraName = tr("Local IP settings");//本地IP设置 + lIpItem.valueStr = localip; + m_itemList.append(lIpItem); + idx++; + + //本地端口设置条目 + localport = configIni.value("local/port", QVariant(5000)).toInt(); + + ParaItem lPortItem; + lPortItem.indexInPara = idx; + lPortItem.readonly = 0; + lPortItem.valueType = PARA_VALUE_TYPE_INT; + lPortItem.paraName = tr("Local port settings");//本地端口设置 + lPortItem.value = localport; + lPortItem.minVal = 0; + lPortItem.maxVal = U16_MAX; + lPortItem.defValue = 5000; + m_itemList.append(lPortItem); +} + +void ParameterSetDialog::setCurPage(int idx) +{ + if(m_paraType == PARA_TYPE_ROOT)//等于超级用户界面 + { + m_rootCurPage = idx; + } + else + { + m_curPage = idx; + } +} + +//设置参数值 +void ParameterSetDialog::setItemValue(int idx,int value) +{ + //筛选参数 + for(int i = 0; i < m_itemList.size(); i++) + { + int index = m_itemList.at(i).indexInPara; + int min = m_itemList.at(i).minVal; + int max = m_itemList.at(i).maxVal; + + if(idx == index)//参数枚举 + { + if(value > max || value < min) // + { + value = m_itemList.at(i).defValue; + } + m_itemList[i].selIdx = value; + m_itemList[i].value = value; + } + } +} + +void ParameterSetDialog::setItemStr(int idx, QString str) +{ + for(int i = 0; i < m_itemList.size(); i++) + { + int index = m_itemList.at(i).indexInPara; + + if(idx == index) + { + m_itemList[i].valueStr = str; + } + } +} + +int ParameterSetDialog::getItemValue(int idx) +{ + int value = 0; + for(int i = 0; i < m_itemList.size(); i++) + { + if(idx == m_itemList.at(i).indexInPara) + { + value = m_itemList.at(i).value; + } + } + return value; +} + +int ParameterSetDialog::exec() +{ + //等于机器参数或工作参数 + if(((m_paraType & PARA_TYPE_MACH) == PARA_TYPE_MACH) || + ((m_paraType & PARA_TYPE_WORK) == PARA_TYPE_WORK)) + { + if (g_pMachine != NULL) + { + qDebug("send GetParasFromMachine"); + + if(m_setedFlag == 0x03)//如果有从下位机得到过参数包 + { + //这个函数会把从主控得到的参数保存在item.value里 + refreshValue();//不管连没连上,都显示上次保存的值,多主板保存各自主板的值 + } + + if(g_pMachine->isConnected() == 3)//这个isConnected检测机制是5秒 + { + if(((m_paraType & PARA_TYPE_MACH) == PARA_TYPE_MACH) || + ((m_paraType & PARA_TYPE_WORK) == PARA_TYPE_WORK)) + { + // 多主板的之前就设置好了g_pMachine 点哪个按钮,就用向哪个主板获取参数 + g_pMachine->getParasFromMachine();//如果连上了主板,发送一个读取参数信息的包 + } + if(m_setedFlag != 0x03)//界面上显示已就绪 但是没有从下位机得到过参数包(刚上电时) + { + PromptDialog dlg(this); + dlg.initDialog(PromptDialog::BTN_OK); + dlg.setTitleStr(tr("Network error")); + dlg.setContentStr(tr("read parameter..."));//读取参数中... + dlg.exec(); + return -1; + } + } + else//如果没连接上 + { +#ifdef Q_OS_LINUX//为了方便windows下查看参数所以加了linux编译条件 + PromptDialog dlg(this); + dlg.initDialog(PromptDialog::BTN_OK); + dlg.setTitleStr(tr("Network error")); + dlg.setContentStr(tr("No connection")); + dlg.exec(); + return -1; + //不进行下边的函数 +#endif + } + } + } + //刷新这个函数,就显示item.value的值 + //ui->buttonOk->setEnabled(false); + refreshUi();//没连接主板的时候就先进到这个函数,就会显示的默认参数 + return QDialog::exec(); +} + +int ParameterSetDialog::addParaItem(const QList &itemList) +{ + int size = m_allItemList.size(); + m_allItemList.append(itemList); + return size; +} + +int ParameterSetDialog::addParaItem(const ParaItem &item) +{ + int size = m_allItemList.size(); + m_allItemList.append(item); + return size; +} + +void ParameterSetDialog::on_button1_clicked() +{ + changeValue(0); +} + +void ParameterSetDialog::on_button2_clicked() +{ + changeValue(1); +} + +void ParameterSetDialog::on_button3_clicked() +{ + changeValue(2); +} + +void ParameterSetDialog::on_button4_clicked() +{ + changeValue(3); +} + +void ParameterSetDialog::on_button5_clicked() +{ + changeValue(4); +} + +void ParameterSetDialog::on_button6_clicked() +{ + changeValue(5); +} + +void ParameterSetDialog::on_button7_clicked() +{ + changeValue(6); +} + +void ParameterSetDialog::on_button8_clicked() +{ + changeValue(7); +} + +void ParameterSetDialog::on_button9_clicked() +{ + changeValue(8); +} + +void ParameterSetDialog::on_button10_clicked() +{ + changeValue(9); +} + +void ParameterSetDialog::on_button11_clicked() +{ + changeValue(10); +} + +void ParameterSetDialog::on_button12_clicked() +{ + changeValue(11); +} + +void ParameterSetDialog::on_buttonPgUp_clicked() +{ + if(m_paraType == PARA_TYPE_ROOT)//等于超级用户界面 + { + m_rootCurPage--; + } + else + { + m_curPage--; + } + + refreshUi(); +} + +void ParameterSetDialog::on_buttonPgDn_clicked() +{ + if(m_paraType == PARA_TYPE_ROOT)//等于超级用户界面 + { + m_rootCurPage++; + } + else + { + m_curPage++; + } + refreshUi(); +} + +void ParameterSetDialog::on_buttonOk_clicked() +{ + PromptDialog promptDlg(this); + qDebug()<<"para ok 1"; + + //等于机器参数或工作参数 + if(((m_paraType & PARA_TYPE_MACH) == PARA_TYPE_MACH) || + ((m_paraType & PARA_TYPE_WORK) == PARA_TYPE_WORK)) + { + qDebug()<<"para ok 4"; + saveParas(); + } + + //等于软件设置参数 + if((m_paraType & PARA_TYPE_SOFTWARESET) == PARA_TYPE_SOFTWARESET) + { + qDebug()<<"para ok 5"; + + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDlg.setTitleStr(tr("Prompt")); + + QString str; + str = tr("The settings take effect after restarting the interface!");//重启界面后设置生效! + promptDlg.setContentStr(str); + if(promptDlg.exec() == 1) + { +// g_emTheme = (Theme)(m_itemList.at((s16)SET_THEME).value);//主题 + int language = m_itemList.at((s16)SET_LANGUAGE).value;//语言 +// int fontsize = m_itemList.at((s16)SET_FONTSIZE).value;//字体大小 + //int connectMode = m_itemList.at((s16)SET_CONNECTMODE).value;//连接通讯方式 + +// g_pSettings->writeToIniFile("HMI/theme",g_emTheme); + g_pSettings->writeToIniFile("HMI/language",language); +// g_pSettings->writeToIniFile("HMI/fontsize",fontsize); + //g_pSettings->writeToIniFile("HMI/connectMode",connectMode); + +#ifdef Q_OS_WIN + qApp->exit(); +#endif + +#ifdef Q_OS_LINUX + qDebug()<<"reboot before"; + system("reboot"); + qDebug()<<"reboot end"; +#endif + } + + qDebug()<<"para ok 6"; + return; + } + + //等于网络管理参数 + if((m_paraType & PARA_TYPE_NETWORKSET) == PARA_TYPE_NETWORKSET) + { + qDebug()<<"para ok 7"; + + //网络设置完成,需重启后重新建立连接 + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + QString str = tr("Network settings are completed, re-establish after reboot"); + promptDlg.setTitleStr(tr("Prompt")); + promptDlg.setContentStr(str); + if(promptDlg.exec() == 1) + { + QDir apppath(qApp->applicationDirPath()); + + s16 idx = 0;//参数索引 + QString configfile; + configfile = apppath.path() + apppath.separator() + "mcconfig.ini"; + QSettings configIni(configfile, QSettings::IniFormat); + + QString serverip = m_itemList.at(idx).valueStr;//服务器IP + idx++; + int serverport = m_itemList.at(idx).value;//服务器端口 + + // 回写参数 + configIni.setValue("server/ip", serverip); + configIni.setValue("server/port", serverport); + + idx++; + + QString localip = m_itemList.at(idx).valueStr;//本地IP + // 回写参数 + configIni.setValue("local/ip", localip); + + idx++; + + int localport = m_itemList.at(idx).value;//本地端口 + // 回写参数 + configIni.setValue("local/port", localport); + +#ifdef Q_OS_WIN + qApp->exit(); +#endif + +#ifdef Q_OS_LINUX + system("reboot"); +#endif + } + return; + } + + //等于网关网络设置参数 + if((m_paraType & PARA_TYPE_NETWORKSETTINGS) == PARA_TYPE_NETWORKSETTINGS) + { + //网络设置完成,需重启后重新建立连接 + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + QString str = tr("Network settings are completed, re-establish after reboot"); + promptDlg.setTitleStr(tr("Prompt")); + promptDlg.setContentStr(str); + if(promptDlg.exec() == 1) + { + QDir apppath(qApp->applicationDirPath()); + + s16 idx =0; //参数索引 + QString configfile; + configfile = apppath.path() + apppath.separator() +"lotconfig.ini"; + QSettings configIni(configfile, QSettings::IniFormat); + + QString serverip = m_itemList.at(idx).valueStr;//服务器IP + idx++; + int serverport = m_itemList.at(idx).value;//服务器端口 + idx++; + QString localip = m_itemList.at(idx).valueStr;//本地IP + idx++; + int localport = m_itemList.at(idx).value;//本地端口 + + // 回写参数 + configIni.setValue("server/ip", serverip); + configIni.setValue("server/port", serverport); + configIni.setValue("local/ip", localip); + configIni.setValue("local/port", localport); + +#ifdef Q_OS_WIN + qApp->exit(); +#endif + +#ifdef Q_OS_LINUX + system("reboot"); +#endif + } + return; + } + + //等于时间设置参数 + if((m_paraType & PARA_TYPE_TIMESET) == PARA_TYPE_TIMESET) + { + int yearValue = m_itemList.at(0).value; + int monthValue = m_itemList.at(1).value; + int dayValue = m_itemList.at(2).value; + +#ifdef Q_OS_LINUX + int hourValue = m_itemList.at(3).value; + int minuteValue = m_itemList.at(4).value; + int secondValue = m_itemList.at(5).value; +#endif + + int temp = 0; + + //判断是否为闰年,闰年2月份是29天,其他是28天 + if((yearValue % 4 == 0) && (yearValue % 100 != 0)) + { + if(monthValue == 2) + { + if(dayValue > 29) + { + temp = -1; + } + } + } + else + { + if(monthValue == 2) + { + if(dayValue > 28) + { + temp = -1; + } + } + } + + //1、3、5、7、8、10、12是31天,其他是30天 + if(monthValue == 4 || monthValue == 6 || monthValue == 9 || monthValue == 11) + { + if(dayValue > 30) + { + temp = -1; + } + } + + QString showStr; + if(temp == 0) + { + //设置时间 +#ifdef Q_OS_LINUX + struct tm rtcTime; + rtcTime.tm_year = yearValue - 1900; + rtcTime.tm_mon = monthValue - 1; + rtcTime.tm_mday = dayValue; + rtcTime.tm_hour = hourValue; + rtcTime.tm_min = minuteValue; + rtcTime.tm_sec = secondValue; + rtcTime.tm_isdst = 0; + rtcTime.tm_yday = 0; + rtcTime.tm_wday = 0; + + int retval = hal_set_rtc_time(&rtcTime); + if(retval != 0) + { + qDebug("set_rtc_time failed: %d!", retval); + temp = -2; + } +#endif + //时间设置完成,重启后生效 + promptDlg.initDialog(PromptDialog::BTN_RESTART); + showStr = tr("The time setting is completed and will take effect after restart"); + } + else if(temp == -1) + { + //时间设置不合理,请重新设置 + promptDlg.initDialog(PromptDialog::BTN_OK); + showStr = tr("Unreasonable time setting, please reset"); + } + + if(temp == -2) + { + //时间设置失败,请重新设置 + promptDlg.initDialog(PromptDialog::BTN_OK); + showStr = tr("Time setting failed, please reset"); + } + + promptDlg.setTitleStr(tr("Prompt")); + promptDlg.setContentStr(showStr); + promptDlg.exec(); + return; + } + + //等于超级用户界面配置参数 + if((m_paraType & PARA_TYPE_HMICONFIGURATION) == PARA_TYPE_HMICONFIGURATION) + { + qDebug()<<"para ok 5"; + + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDlg.setTitleStr(tr("Prompt")); + + QString str; + str = tr("The settings take effect after restarting the interface!");//重启界面后设置生效! + promptDlg.setContentStr(str); + if(promptDlg.exec() == 1) + { + //重置初始花样 + g_pSettings->writeToIniFile("Pattern/name",""); + //界面配置里的参数都放在了 点击触发型参数枚举 里,要筛选才能获取到相应的value值 + for(int i = 0; i < m_itemList.size(); i++) + { + if(m_itemList[i].indexInPara == ROOT_RESOLUTION) + { + g_emResolut = (Resolution)(m_itemList[i].value);//分辨率 + g_pSettings->writeToIniFile("HMI/resolution",g_emResolut); + } + else if (m_itemList[i].indexInPara == SET_CONNECTMODE) + { + int connectMode = (s16)m_itemList[i].value;//连接通讯方式 + g_pSettings->writeToIniFile("HMI/connectMode",connectMode); + } + + else if(m_itemList[i].indexInPara == ROOT_PRODUCTTYPE) + { + g_emProductType =(ProductType)(m_itemList[i].value);//产品类型 + g_pSettings->writeToIniFile("HMI/productType",g_emProductType); + } + + else if(m_itemList[i].indexInPara == ROOT_SHUTTLECHANGE) + { + s16 shuttleChange =(s16)(m_itemList[i].value);//自动换梭 + g_pSettings->writeToIniFile("HMI/shuttleChange",shuttleChange); + } + + else if(m_itemList[i].indexInPara == ROOT_WATERMARKSET) + { + s16 waterMark =(s16)(m_itemList[i].value);//主背景是否带水印 + g_pSettings->writeToIniFile("HMI/waterMark",waterMark); + } + else if(m_itemList[i].indexInPara == ROOT_WIFI) + { + s16 wifi =(s16)(m_itemList[i].value);//是否带wifi + g_pSettings->writeToIniFile("HMI/wifi",wifi); + } + + else if(m_itemList[i].indexInPara == ROOT_PARASORTSET) + { + s16 paraSort =(s16)(m_itemList[i].value);//参数是否分类显示 + g_pSettings->writeToIniFile("HMI/paraSort",paraSort); + } + else if(m_itemList[i].indexInPara == ROOT_MACTYPE) + { + g_emMacType = (MachineType)(m_itemList[i].value);//机器类型 + g_pSettings->writeToIniFile("HMI/machineType",g_emMacType); + } +} + +#ifdef Q_OS_WIN + qApp->exit(); +#endif + +#ifdef Q_OS_LINUX + system("reboot"); +#endif + } + return; + } + + //等于超级用户物联网配置参数 + if((m_paraType & PARA_TYPE_IOTCONFIGURATION) == PARA_TYPE_IOTCONFIGURATION) + { + qDebug()<<"para ok 66"; + + for(int i = 0; iwriteToIniFile("IOT/rackNumber",RackNumber); + } + else if(m_itemList[i].indexInPara == ROOT_DELIVERYTIME) + { + QString deliveryTime = m_itemList[i].valueStr;//工厂预计交货时间 + g_pSettings->writeToIniFile("IOT/deliveryTime",deliveryTime); + } + else if(m_itemList[i].indexInPara == ROOT_DEBUGPROGRESS) + { + int debugProgress = m_itemList[i].value;//调试进度 + g_pSettings->writeToIniFile("IOT/debugProgress",debugProgress); + } + } + + //网关连接方式改变时需要提示重启 + s16 cFlag = 0; + for(int i = 0; ireadFromIniFile("IOT/gatewayConnectMode").toInt(); + int eVal = m_itemList[i].value;//网关连接方式 + if(bVal != eVal) + { + cFlag = 1; + } + break; + } + } + + if(cFlag == 1) + { + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDlg.setTitleStr(tr("Prompt")); + QString str; + str = tr("Connection mode changes, take effect after the reboot!");//连接方式改变,重启界面后生效! + promptDlg.setContentStr(str); + if(promptDlg.exec() == 1) + { + for(int i = 0; iwriteToIniFile("IOT/gatewayConnectMode",gatewayConnect); + break; + } + } + +#ifdef Q_OS_WIN + qApp->exit(); +#endif + +#ifdef Q_OS_LINUX + system("reboot"); +#endif + } + return; + } + else + { + done(1); + } + } + //超级用户密码权限,单次有效 + g_emUser = operate; + done(1);//0是关掉 + + qDebug()<<"para ok 8"; + +} + +void ParameterSetDialog::on_buttonCancel_clicked() +{ + //超级用户密码权限,单次有效 + g_emUser = operate; + done(0); +} + +//恢复默认的参数 +void ParameterSetDialog::on_buttonParaRestore_clicked() +{ + if(g_emDebugMode == nodebugMode) + { + if(g_emUser != resetpara)//权限不够先登录 + { + emit siUserLogin(resetpara); + if(g_emUser != resetpara)//发送登录信号后,权限如果还没改变就返回 + { + return; + } + } + PromptDialog promptDlg(this); + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDlg.setTitleStr(tr("Prompt")); + + if(m_paraType == PARA_TYPE_MACH || + m_paraType == PARA_TYPE_WORK) + { + promptDlg.setContentStr(tr("Whether to recover the default parameters for the board?"));//是否恢复为主板默认参数? + } + + if(promptDlg.exec() == 1) + { + if(g_pMachine != NULL) + { + if(m_paraType == PARA_TYPE_MACH || + m_paraType == PARA_TYPE_WORK)//设置主板默认参数 + { + g_pMachine->setToDefaultParas(UCMD_SET_DEF_PARA, 0); + } + } + } + } + g_emUser = factory; +} + +//返回上一级菜单 +void ParameterSetDialog::on_buttonReturn_clicked() +{ + if(g_emDebugMode == nodebugMode) + { + if(g_emUser == factory) + { + setMainTitle(tr("Root")); + setSubTitle(tr("Accessibility > Root")); + //超级用户参数 + setItemList(factory,PARA_TYPE_ROOT); + refreshUi(); + } + else if (g_emUser == root) + { + setMainTitle(tr("Root")); + setSubTitle(tr("Accessibility > Root")); + //超级用户参数 + setItemList(root,PARA_TYPE_ROOT); + refreshUi(); + } + } + else + { + setMainTitle(tr("Root")); + setSubTitle(tr("Accessibility > Root")); + //超级用户参数 + setItemList(root,PARA_TYPE_ROOT); + refreshUi(); + } +} diff --git a/sharedviews/parametersetdialog.h b/sharedviews/parametersetdialog.h new file mode 100644 index 0000000..e46d9f6 --- /dev/null +++ b/sharedviews/parametersetdialog.h @@ -0,0 +1,149 @@ +#ifndef PARAMETERSETDIALOG_H +#define PARAMETERSETDIALOG_H + +#include +#include +#include +#include +#include + +#include "items/paraitem.h" +#include "numerinputdialog.h" +#include "passworddialog.h" +#include "mybutton.h" +#include "promptdialog.h" +#include "setcontrolstyle.h" +#include "Lot/csvcode.h" + +#define TEST_EMBROIDERY 1 +#define TEST_PUNCH 2 + +//设置时间的头文件 +#ifdef Q_OS_LINUX +#include +#include +#endif + +namespace Ui { +class ParameterSetDialog; +} + +class ParameterSetDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ParameterSetDialog(QWidget *parent = 0); + ~ParameterSetDialog(); + +private: + Ui::ParameterSetDialog *ui; + int m_itemPerPage;//界面每页条目数 + int m_curPage;//当前页数 + int m_rootCurPage;//超级用户界面当前页数 + QList m_itemBtnList; + QList m_itemList; + QList m_allItemList; + MCStatus m_mcStatus;//机器状态 + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006();//初始化窗体控件为1024x600分辨率 + void initControlStyle();//初始化窗体控件样式 + void refreshUi(); + +private: + QString getValueStr(int64_t val, int afterpoint); + void changeValue(int buttenidx); + void refreshValue(); + +public slots: + void paraChange(int type, int id); + +private: + void refreshSensorPara(int min, int max, int num, ParaItem &item, u32 traverseState ,int m_nodeType);//刷新信号参数显示 + void saveParas(int idx = -1); + void execItemClickEvent(s16 fun);//执行点击触发型参数的触发事件 + +private: + ParaStruct m_mcParaValues; + ParaStruct m_wkParaValues; + + int m_setedFlag; + int m_paraType; //参数类型(机器参数、工作参数、花样参数等) + int m_paraTypeSort; //参数类型分类 + QString m_networkCardID;//网卡ID(MAC地址) + + QString m_filePath;//配置文件 + bool isAuthority = true;//是否需要权限 + +public: + void initData(); + void setTypeLogo(QString tStyle);//设置类型图标 + void setMainTitle(QString str);//设置主title + void setSubTitle(QString str);//设置副title + //(参数权限、参数类型、参数种类)得到相应参数类型列表,目前参数种类分类未使用 + void setItemList(int authority,int64_t type,int64_t sort = -1); + void refreshProductType();//刷新产品类型 + + //设置网络参数(IP和端口) + void setNetworkItemList(int64_t type); + + //设置网关网络参数(IP和端口) + void setGatewayNetworkItemList(int64_t type); + + void setCurPage(int idx);//设置当前页数 + void setItemValue(int idx,int value);//设置int型参数值 + void setItemStr(int idx,QString str);//设置字符型参数值 + int getItemValue(int idx); + inline int getParaType(){return m_paraType;}//获取参数类型 + int exec(); + +public: + int addParaItem(const QList & itemList); + int addParaItem(const ParaItem & item); + +private slots: + void on_button1_clicked(); + void on_button2_clicked(); + void on_button3_clicked(); + void on_button4_clicked(); + void on_button5_clicked(); + void on_button6_clicked(); + void on_button7_clicked(); + void on_button8_clicked(); + void on_button9_clicked(); + void on_button10_clicked(); + void on_button11_clicked(); + void on_button12_clicked(); + + void on_buttonPgUp_clicked(); + void on_buttonPgDn_clicked(); + + void on_buttonOk_clicked(); + void on_buttonCancel_clicked(); + + void on_buttonParaRestore_clicked(); + void on_buttonReturn_clicked(); + +signals: + void siUserLogin(s16 user); + void siHMIDecrypt(QString id);//界面解密 + void siParameterImport(); + void siParameterExport(); + void siHMIUpgrade(); + void siMCUpgrade(); + void siSetWorkArea();//设置可工作区域 + void siExit();//退出程序 + void siChangePassword();//修改一级密码 + void siDeleteIni();//删除执行目录下的config.ini + void siImportCSV();//导入csv文件 + void siDeleteCSV();//删除csv文件 + void siResetCSV();//重置安装调试进度 + void siDebugMode();//界面调试模式 + void siPatternClear();//花样总清 + void siVerRecovery();//版本恢复 +}; + +#endif // PARAMETERSETDIALOG_H diff --git a/sharedviews/parametersetdialog.ui b/sharedviews/parametersetdialog.ui new file mode 100644 index 0000000..68e6692 --- /dev/null +++ b/sharedviews/parametersetdialog.ui @@ -0,0 +1,543 @@ + + + ParameterSetDialog + + + + 0 + 0 + 1024 + 600 + + + + Dialog + + + + + 140 + 200 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 30 + 10 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + + + + 20 + 570 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + PageNums: 1/1 + + + + + + 140 + 320 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 0 + 0 + 1024 + 600 + + + + background-color: rgb(182, 182, 182); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 140 + 80 + 760 + 32 + + + + Qt::NoFocus + + + Qt::LeftToRight + + + + + + + + + + + + 140 + 360 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 440 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 280 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 400 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 110 + 10 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Sub title + + + + + + 140 + 240 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 120 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 680 + 570 + 321 + 31 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 80 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 240 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 160 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 0 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + buttonPgUp + buttonPgDn + buttonOk + buttonCancel + + + + + 140 + 160 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 480 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 520 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 40 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Sub title < Title + + + + + + 430 + 10 + 581 + 51 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 500 + 10 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 420 + 10 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + + 330 + 20 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Repetitions + + + frameBack + buttonTypeLogo + labelPage + labelMainTitle + framePageBtn + labelSubTitle + button1 + button2 + button3 + button4 + button5 + button6 + button7 + button8 + button9 + button10 + button11 + button12 + frameRightUp + labelRepetitions + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/passworddialog.cpp b/sharedviews/passworddialog.cpp new file mode 100644 index 0000000..c8e4fdc --- /dev/null +++ b/sharedviews/passworddialog.cpp @@ -0,0 +1,312 @@ +#include "passworddialog.h" +#include "ui_passworddialog.h" + +PassWordDialog::PassWordDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::PassWordDialog) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + setAttribute(Qt::WA_TranslucentBackground, true);//设置窗体背景透明 + + initControl(); + m_inputStr.clear(); + m_ifShow = false; + m_cleanFlag = 0; + m_ipLength = 0; + refreshUi(); +} + +PassWordDialog::~PassWordDialog() +{ + delete ui; +} + +//初始化窗体控件,包括位置、尺寸、样式 +void PassWordDialog::initControl() +{ + m_NumerBtnlist.clear(); + m_NumerBtnlist.append(ui->buttonNum7); + m_NumerBtnlist.append(ui->buttonNum8); + m_NumerBtnlist.append(ui->buttonNum9); + m_NumerBtnlist.append(ui->buttonNum4); + m_NumerBtnlist.append(ui->buttonNum5); + m_NumerBtnlist.append(ui->buttonNum6); + m_NumerBtnlist.append(ui->buttonNum1); + m_NumerBtnlist.append(ui->buttonNum2); + m_NumerBtnlist.append(ui->buttonNum3); + m_NumerBtnlist.append(ui->buttonNum0); + + for(int var = 0; var < m_NumerBtnlist.size(); var++) + { + connect(m_NumerBtnlist.at(var), + SIGNAL(clicked()), + this, + SLOT(numerBtnClick()) + ); + } + + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void PassWordDialog::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + + this->resize(1024*factoryX,600*factoryY); + this->move((1024*factoryX-this->width())/2,(600*factoryY-this->height())/2); + ui->frameBack->setGeometry(0,0,1024*factoryX,600*factoryY);//416,505 + int x = 326 ; //x偏移 + int y = 240; //y便宜 + ui->labelTitle->setGeometry((322)*factoryX, (97)*factoryY,328*factoryX,48*factoryY); + ui->labelValue->setGeometry((370)*factoryX+76, (172)*factoryY,270*factoryX,44*factoryY); + + + for(int i = 0; i < 4; i++) + { + for(int j = 0; j < 3; j ++) + { + if(i*3+j == m_NumerBtnlist.size()-1) + { + m_NumerBtnlist[i*3+j]->setGeometry((x+(j+1)*124)*factoryX,(y+i*50)*factoryY,112*factoryX,40*factoryY); + break; + } + else + { + m_NumerBtnlist[i*3+j]->setGeometry((x+j*124)*factoryX,(y+i*50)*factoryY,112*factoryX,40*factoryY); + } + } + } + + ui->buttonClean->setGeometry((x)*factoryX, (390)*factoryY,112*factoryX,40*factoryY); + ui->buttonBack->setGeometry((x+248)*factoryX,(390)*factoryY,112*factoryX,40*factoryY); + + ui->buttonOk->setGeometry((x+124)*factoryX, (440)*factoryY,112*factoryX,40*factoryY); + ui->buttonCancel->setGeometry((x+248)*factoryX, (440)*factoryY,112*factoryX,40*factoryY); +} +//初始化窗体控件为1024x600分辨率 +void PassWordDialog::initResolution1006() +{ + int x = 326 ; //x偏移 + int y = 240; //y便宜 + this->resize(1024,600); + this->move((1024-this->width())/2,(600-this->height())/2); + ui->frameBack->setGeometry(0,0,1024,600); + + ui->labelTitle->setGeometry(322, 97,328,48); + ui->labelValue->setGeometry(370, 172,270,44); + + for(int i = 0; i < 4; i++) + { + for(int j = 0; j < 3; j ++) + { + if(i*3+j == m_NumerBtnlist.size()-1) + { + m_NumerBtnlist[i*3+j]->setGeometry(x+(j+1)*124,y+i*50,112,40); + break; + } + else + { + m_NumerBtnlist[i*3+j]->setGeometry(x+j*124,y+i*50,112,40); + } + } + } + + ui->buttonClean->setGeometry(x, 390,112,40); + ui->buttonBack->setGeometry(x+248,390,112,40); + + ui->buttonOk->setGeometry(x+124,440,112,40); + ui->buttonCancel->setGeometry(x+248,440,112,40); +} +//初始化窗体控件样式 +void PassWordDialog::initControlStyle() +{ + //白蓝色渐变、灰蓝色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(255, 255, 255), stop:1 rgb(215, 243, 254));border-radius:5px;}"; + style += "QPushButton:pressed{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(217, 222, 224), stop:1 rgb(191,213,223));}"; + style += "QPushButton:disabled{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(230, 230, 230), stop:1 rgb(182,182,182));}"; + + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + for(int i = 0; i < m_NumerBtnlist.size(); i++) + { + m_NumerBtnlist[i]->setStyleSheet(style); + m_NumerBtnlist[i]->setFont(fontNormal_1); + } + + ui->frameBack->setStyleSheet(setControlStyle.getStyleSheet(this->objectName())); + + ui->labelTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelTitle->setFont(fontNormal_1); + ui->labelTitle->setAlignment(Qt::AlignLeft); + ui->labelTitle->setAlignment(Qt::AlignVCenter); + + ui->labelValue->setStyleSheet(LABELWHITESTYLE); + ui->labelValue->setFont(fontNormal_1); + ui->labelValue->setAlignment(Qt::AlignCenter); + + ui->buttonClean->setStyleSheet(style); + ui->buttonClean->setFont(fontNormal_1); + ui->buttonBack->setStyleSheet(style); + ui->buttonBack->setFont(fontNormal_1); + + ui->buttonOk->setWhiteBlueBottomStyle(); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1"),10); + ui->buttonCancel->setWhiteBlueBottomStyle(); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"),12); +} + +void PassWordDialog::refreshUi() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + QString showStr(""); + QString password = cod->toUnicode("●"); + for (int var = 0; var < m_inputStr.size(); var++) + { + showStr = showStr + password; + } + + if(m_ifShow == false)//不可见 + { + ui->labelValue->setText(showStr); + } + else//可见 + { + ui->labelValue->setText(m_inputStr); + } + + if(g_emResolut == resolution1910) + { + if(m_inputStr.length() > 0) + { + ui->buttonOk->setEnabled(true); + } + else + { + ui->buttonOk->setEnabled(false); + } + } + else + { + + if(m_inputStr.length() > 0) + { + ui->buttonOk->setEnabled(true); + } + else + { + ui->buttonOk->setEnabled(false); + } + } +} + +void PassWordDialog::numerBtnClick() +{ + QPushButton *button = (QPushButton*) this->sender() ; + + if(button == NULL) + { + return; + } + QString str = button->text(); + m_inputStr.append(str); + refreshUi(); +} + +void PassWordDialog::setTitleStr(QString str,int cFlag) +{ + ui->labelTitle->setText(str); + m_inputStr.clear(); + if(cFlag != 0) + { + m_cleanFlag = cFlag; + ui->buttonClean->setText("."); + } + refreshUi(); +} + +void PassWordDialog::setShowIfVisible(bool bShow) +{ + m_ifShow = bShow; +} + +void PassWordDialog::setIpStr(QString ip) +{ + m_inputStr= ip; + m_ipLength = ip.length(); + refreshUi(); +} + +QString PassWordDialog::getInputStr() +{ + return m_inputStr; +} +void PassWordDialog::on_buttonClean_clicked() +{ + if(m_cleanFlag != 0) + { + QString str = ui->buttonClean->text(); + m_inputStr.append(str); + } + else + { + m_inputStr.clear(); + } + refreshUi(); +} + +void PassWordDialog::on_buttonBack_clicked() +{ + if(m_inputStr.length() <= m_ipLength) + { + return; + } + m_inputStr = m_inputStr.mid(0 , m_inputStr.size() - 1); + refreshUi(); +} + +void PassWordDialog::on_buttonOk_clicked() +{ + if(m_inputStr.indexOf(".") != -1) + { + //检测IP地址是否合法 + QRegExp regExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"); + if (!regExp.exactMatch(m_inputStr)) + { + PromptDialog promptDlg(this); + promptDlg.initDialog(PromptDialog::BTN_OK); + promptDlg.setTitleStr(tr("Prompt")); + QString str = tr("IP settings are unreasonable!");//IP设置不合理! + promptDlg.setContentStr(str); + promptDlg.exec(); + + return; + } + } + + done(1); +} + +void PassWordDialog::on_buttonCancel_clicked() +{ + m_inputStr.clear(); + done(0); +} diff --git a/sharedviews/passworddialog.h b/sharedviews/passworddialog.h new file mode 100644 index 0000000..28befc2 --- /dev/null +++ b/sharedviews/passworddialog.h @@ -0,0 +1,50 @@ +#ifndef PASSWORDDIALOG_H +#define PASSWORDDIALOG_H + +#include +#include "setcontrolstyle.h" +#include "promptdialog.h" +#include + +namespace Ui { +class PassWordDialog; +} + +class PassWordDialog : public QDialog +{ + Q_OBJECT + +public: + explicit PassWordDialog(QWidget *parent = 0); + ~PassWordDialog(); + +private: + Ui::PassWordDialog *ui; + QString m_inputStr; + QList m_NumerBtnlist; + bool m_ifShow;//输入字符是否可见 + s16 m_cleanFlag;//清除按钮的显示及作用,清空或者. + s16 m_ipLength; + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006(); + void initControlStyle();//初始化窗体控件样式 + void refreshUi(); + +private slots: + void numerBtnClick(); + void on_buttonClean_clicked(); + void on_buttonBack_clicked(); + void on_buttonOk_clicked(); + void on_buttonCancel_clicked(); + +public: + void setTitleStr(QString str,int cFlag = 0);//设置标题并修改按钮文本 + void setShowIfVisible(bool bShow);//设置输入内容是否可见 + void setIpStr(QString ip); + QString getInputStr(); +}; + +#endif // PASSWORDDIALOG_H diff --git a/sharedviews/passworddialog.ui b/sharedviews/passworddialog.ui new file mode 100644 index 0000000..b68e76a --- /dev/null +++ b/sharedviews/passworddialog.ui @@ -0,0 +1,3930 @@ + + + PassWordDialog + + + + 0 + 0 + 328 + 416 + + + + Dialog + + + + + 220 + 352 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 200 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + + + + false + + + + + + 120 + 352 + 92 + 50 + + + + + 90 + 0 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + + + + false + + + + + + 30 + 62 + 270 + 44 + + + + + 100 + 44 + + + + + 360 + 80 + + + + + wqy-microhei + 16 + 50 + false + false + + + + Qt::LeftToRight + + + background-color: rgba(255, 255, 245, 255); + + + + + + + Qt::AlignCenter + + + + + + 0 + 0 + 328 + 48 + + + + + + + Password + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 0 + 0 + 328 + 416 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 222 + 124 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 9 + + + false + + + + + + 20 + 236 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 1 + + + false + + + + + + 122 + 236 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 2 + + + false + + + + + + 222 + 292 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 200 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + + + + false + + + + + + 222 + 236 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 3 + + + false + + + + + + 222 + 180 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 6 + + + false + + + + + + 122 + 124 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 8 + + + false + + + + + + 20 + 292 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 200 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + C + + + false + + + + + + 122 + 292 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 0 + + + false + + + + + + 122 + 180 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 5 + + + false + + + + + + 20 + 124 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 7 + + + false + + + + + + 20 + 180 + 92 + 50 + + + + + 90 + 40 + + + + + 500 + 500 + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + 10 + 10 + 10 + + + + + + + 10 + 10 + 10 + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 168 + 197 + 226 + + + + + 186 + 220 + 255 + + + + + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 110 + 110 + 110 + + + + + + + 110 + 110 + 110 + + + + + + + 200 + 200 + 200 + + + + + + + 200 + 200 + 200 + + + + + + + + Qt::NoFocus + + + + + + 4 + + + false + + + frameBack + buttonCancel + buttonOk + labelValue + labelTitle + buttonNum9 + buttonNum1 + buttonNum2 + buttonBack + buttonNum3 + buttonNum6 + buttonNum8 + buttonClean + buttonNum0 + buttonNum5 + buttonNum7 + buttonNum4 + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/patternmanagewidget.cpp b/sharedviews/patternmanagewidget.cpp new file mode 100644 index 0000000..4874d87 --- /dev/null +++ b/sharedviews/patternmanagewidget.cpp @@ -0,0 +1,1615 @@ +#include "patternmanagewidget.h" +#include "ui_patternmanagewidget.h" + +PatternManageWidget::PatternManageWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::PatternManageWidget), + m_itemPerPage(16) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + + m_mousePressX = 0; + m_mousePressY = 0; + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; + + m_itemBtnList.clear(); + + m_itemBtnList.append(ui->button1); + m_itemBtnList.append(ui->button2); + m_itemBtnList.append(ui->button3); + m_itemBtnList.append(ui->button4); + m_itemBtnList.append(ui->button5); + + ui->button6->setVisible(false);//隐藏 + ui->button7->setVisible(false); + ui->button8->setVisible(false); + ui->button9->setVisible(false); + ui->button10->setVisible(false); + ui->button11->setVisible(false); + + { + ui->button6->setVisible(true);//显示 + ui->button7->setVisible(true); + ui->button8->setVisible(true); + m_itemBtnList.append(ui->button6); + m_itemBtnList.append(ui->button7); + m_itemBtnList.append(ui->button8); + } + + + m_itemBtnList.append(ui->button12); + m_itemBtnList.append(ui->button13); + m_itemBtnList.append(ui->button14); + m_itemBtnList.append(ui->button15); + m_itemBtnList.append(ui->button16); + ui->button17->setVisible(false);//隐藏 + ui->button18->setVisible(false); + ui->button19->setVisible(false); + ui->button20->setVisible(false); + ui->button21->setVisible(false); + ui->button22->setVisible(false); + + { + ui->button17->setVisible(true); + ui->button18->setVisible(true); + ui->button19->setVisible(true); + m_itemBtnList.append(ui->button17); + m_itemBtnList.append(ui->button18); + m_itemBtnList.append(ui->button19); + } + + initControl(); + initialize(); +} + +PatternManageWidget::~PatternManageWidget() +{ + delete ui; +} + +//初始化 +void PatternManageWidget::initialize() +{ + m_curPages = 1; + m_pageNums = 1; + m_fileItemList.clear();//文件列表清空 + m_selectFileItemList.clear(); + m_rootPath.clear();//操作屏根路径 + m_curPath.clear();//当前路径 + m_selectAll = -1; + + QDir apppath(qApp->applicationDirPath()); + QString filePath = apppath.path() + apppath.separator() + PATTERNPATH; + m_rootPath = QDir(filePath).absolutePath();//为了将"\"变为"/" +} + +//初始化窗体控件,包括位置、尺寸、样式 +void PatternManageWidget::initControl() +{ + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void PatternManageWidget::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + + this->resize(1024*factoryX,600*factoryY); + ui->frameBack->setGeometry(0,0,1024*factoryX,600*factoryY); + + ui->buttonTypeLogo->setGeometry(25*factoryX,30*factoryY,60*factoryX,60*factoryY); + ui->labelMainTitle->setGeometry(100*factoryX,30*factoryY,200*factoryX,24*factoryY); + ui->labelSubTitle->setGeometry(130*factoryX,64*factoryY,270*factoryX,21*factoryY); + ui->labelPage->setGeometry(48*factoryX,0,200*factoryX,70*factoryY); + ui->labelPage->setAlignment(Qt::AlignLeft); + + QRect rectImage(0,0,26*factoryX,28*factoryY); + QRect rectName(30*factoryX,0,200*factoryX,36*factoryY);//花样名称 + for(int i = 0; i < 2; i++) + { + s16 num = m_itemBtnList.size()/2; + for(int j = 0; j < num; j++) + { + m_itemBtnList[i*num + j]->setLabelFont(fontNormal_1); + m_itemBtnList[i*num + j]->setGeometry((44+i*378)*factoryX,(138+j*47)*factoryY,337*factoryX,38*factoryY); + m_itemBtnList[i*num + j]->initLeftImageRightName(rectImage,rectName); + } + } + + ui->frameRightUp->setGeometry(800*factoryX,40*factoryY,800*factoryX,61*factoryY); + ui->buttonBackUpDir->setGeometry(150*factoryX,0,50*factoryX,50*factoryY); + ui->buttonSelectAll->setGeometry(93*factoryX,0,50*factoryX,50*factoryY); + ui->buttonNewFolder->setGeometry(37*factoryX,0,50*factoryX,50*factoryY); + + ui->labelPatternView->setGeometry(806*factoryX,152*factoryY,161*factoryX,137*factoryY); + ui->labelNameValue->setGeometry(816*factoryX,315*factoryY,146*factoryX,22*factoryY); + + ui->labelX->setGeometry(816*factoryX,350*factoryY,141*factoryX,20*factoryY); + ui->labelY->setGeometry(816*factoryX,375*factoryY,91*factoryX,20*factoryY); + ui->labelW->setGeometry(816*factoryX,400*factoryY,91*factoryX,20*factoryY); + ui->labelH->setGeometry(816*factoryX,425*factoryY,91*factoryX,20*factoryY); + ui->labelC->setGeometry(816*factoryX,450*factoryY,91*factoryX,20*factoryY); + ui->labelN->setGeometry(816*factoryX,475*factoryY,91*factoryX,20*factoryY); + + ui->labelXValue->setGeometry(865*factoryX,350*factoryY,91*factoryX,20*factoryY); + ui->labelYValue->setGeometry(865*factoryX,375*factoryY,91*factoryX,20*factoryY); + ui->labelWValue->setGeometry(865*factoryX,400*factoryY,91*factoryX,20*factoryY); + ui->labelHValue->setGeometry(865*factoryX,425*factoryY,91*factoryX,20*factoryY); + ui->labelCValue->setGeometry(865*factoryX,450*factoryY,91*factoryX,20*factoryY); + ui->labelNValue->setGeometry(865*factoryX,475*factoryY,91*factoryX,20*factoryY); + + ui->framePageBtn->setGeometry(595*factoryX,545*factoryY,600*factoryX,45*factoryY); + ui->labelPage->setGeometry(20*factoryX,550*factoryY,110*factoryX,45*factoryY); + ui->buttonPgUp->setGeometry(0,0,96*factoryX,40*factoryY); + ui->buttonPgDn->setGeometry(106*factoryX,0,96*factoryX,40*factoryY); + ui->buttonOk->setGeometry(212*factoryX,0,96*factoryX,40*factoryY); + ui->buttonCancel->setGeometry(318*factoryX,0,96*factoryX,40*factoryY); +} +//初始化窗体控件为1024x600分辨率 +void PatternManageWidget::initResolution1006() +{ + this->resize(1024,600); + ui->frameBack->setGeometry(0,0,1024,600); + + ui->buttonTypeLogo->setGeometry(25,30,60,60); + ui->labelMainTitle->setGeometry(100,30,200,24); + ui->labelSubTitle->setGeometry(130,64,270,21); + ui->labelPage->setGeometry(48,0,200,70); + ui->labelPage->setAlignment(Qt::AlignLeft); + + QRect rectImage(0,0,26,28); + QRect rectName(30,0,200,36);//花样名称 + for(int i = 0; i < 2; i++) + { + s16 num = m_itemBtnList.size()/2; + for(int j = 0; j < num; j++) + { + m_itemBtnList[i*num + j]->setLabelFont(fontNormal_1); + m_itemBtnList[i*num + j]->setGeometry(44+i*378,138+j*47,337,38); + m_itemBtnList[i*num + j]->initLeftImageRightName(rectImage,rectName); + } + } + + ui->frameRightUp->setGeometry(800,40,800,61); + ui->buttonBackUpDir->setGeometry(150,0,50,50); + ui->buttonSelectAll->setGeometry(93,0,50,50); + ui->buttonNewFolder->setGeometry(37,0,50,50); + + ui->labelPatternView->setGeometry(806,152,161,137); + ui->labelNameValue->setGeometry(816,315,146,22); + + ui->labelX->setGeometry(816,350,141,20); + ui->labelY->setGeometry(816,375,91,20); + ui->labelW->setGeometry(816,400,91,20); + ui->labelH->setGeometry(816,425,91,20); + ui->labelC->setGeometry(816,450,91,20); + ui->labelN->setGeometry(816,475,91,20); + + ui->labelXValue->setGeometry(865,350,91,20); + ui->labelYValue->setGeometry(865,375,91,20); + ui->labelWValue->setGeometry(865,400,91,20); + ui->labelHValue->setGeometry(865,425,91,20); + ui->labelCValue->setGeometry(865,450,91,20); + ui->labelNValue->setGeometry(865,475,91,20); + + ui->framePageBtn->setGeometry(595,545,600,45); + ui->labelPage->setGeometry(20,550,110,45); + ui->buttonPgUp->setGeometry(0,0,96,40); + ui->buttonPgDn->setGeometry(106,0,96,40); + ui->buttonOk->setGeometry(212,0,96,40); + ui->buttonCancel->setGeometry(318,0,96,40); +} + +//初始化窗体控件样式 +void PatternManageWidget::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //背景图 + QString frameBackImgPath = setControlStyle.getStyleSheet1(this->objectName()); + ui->frameBack->setStyleSheet(frameBackImgPath); + + //label样式 + ui->labelMainTitle->setFont(fontBold_1); + ui->labelMainTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelSubTitle->setFont(fontNormal_1); + ui->labelSubTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelPage->setFont(fontNormal_1); + ui->labelPage->setStyleSheet(LABELWHITESTYLE); + + ui->labelPatternView->setStyleSheet(TRANSPARENTSTYLE); + ui->labelNameValue->setFont(fontNormal_1); + ui->labelNameValue->setStyleSheet(LABELWHITESTYLE); + ui->labelX->setFont(fontNormal_1); + ui->labelX->setStyleSheet(LABELWHITESTYLE); + ui->labelXValue->setFont(fontNormal_1); + ui->labelXValue->setStyleSheet(LABELWHITESTYLE); + ui->labelY->setFont(fontNormal_1); + ui->labelY->setStyleSheet(LABELWHITESTYLE); + ui->labelYValue->setFont(fontNormal_1); + ui->labelYValue->setStyleSheet(LABELWHITESTYLE); + ui->labelW->setFont(fontNormal_1); + ui->labelW->setStyleSheet(LABELWHITESTYLE); + ui->labelWValue->setFont(fontNormal_1); + ui->labelWValue->setStyleSheet(LABELWHITESTYLE); + ui->labelH->setFont(fontNormal_1); + ui->labelH->setStyleSheet(LABELWHITESTYLE); + ui->labelHValue->setFont(fontNormal_1); + ui->labelHValue->setStyleSheet(LABELWHITESTYLE); + ui->labelC->setFont(fontNormal_1); + ui->labelC->setStyleSheet(LABELWHITESTYLE); + ui->labelCValue->setFont(fontNormal_1); + ui->labelCValue->setStyleSheet(LABELWHITESTYLE); + ui->labelN->setFont(fontNormal_1); + ui->labelN->setStyleSheet(LABELWHITESTYLE); + ui->labelNValue->setFont(fontNormal_1); + ui->labelNValue->setStyleSheet(LABELWHITESTYLE); + + ui->framePageBtn->setStyleSheet(TRANSPARENTSTYLE); + ui->frameRightUp->setStyleSheet(TRANSPARENTSTYLE); + + ui->buttonSelectAll->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonSelectAll->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonSelectAll->objectName())); + + ui->buttonBackUpDir->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonBackUpDir->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonBackUpDir->objectName())); + + ui->buttonNewFolder->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonNewFolder->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonNewFolder->objectName())); + + //四个按钮样式表一样 + ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + + ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + + ui->buttonOk->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()),12); + + ui->buttonCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12); +} + +//设置类型图标 +void PatternManageWidget::setTypeLogo(QString tStyle) +{ + ui->buttonTypeLogo->setUnPreBtnLogo(tStyle); +} + +//设置主title +void PatternManageWidget::setMainTitle(QString str) +{ + ui->labelMainTitle->setText(str); +} + +//设置副title +void PatternManageWidget::setSubTitle(QString str) +{ + ui->labelSubTitle->setText(str); +} + +//初始化当前路径花样(点击选择花样时刷新) +void PatternManageWidget::initDirPath(QString path) +{ + int flag = -1;//该路径下是否存在dst文件或dsr文件的扫描标志 + m_curPath = path; + if(m_curPath == m_usbPath || m_curPath == m_rootPath)//如果当前目录等于优盘目录或操作屏根目录,返回上级按钮不可按 + { + ui->buttonBackUpDir->setEnabled(false); + } + else + { + ui->buttonBackUpDir->setEnabled(true); + } + + m_fileItemList.clear();//文件列表清空 + QDir dir(m_curPath); + //打开路径 + if(!dir.exists()) + { + m_curPages = 0; + m_pageNums = 0; + return; + } + + FileItem item; + QString fileName; + QString filePath; + QString imagePath; + + dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); // 设置类型过滤器,只为文件夹和文件格式 + dir.setSorting(QDir::DirsFirst | QDir::IgnoreCase); //设置排序方式,文件夹优先 + + QFileInfoList fileList = dir.entryInfoList(); + int count = fileList.count(); + for(int i = 0; i < count; i++) + { + QFileInfo fileInfo = fileList[i]; + + if(fileInfo.isDir())//为文件夹 + { + filePath = fileInfo.absoluteFilePath(); + fileName = fileInfo.baseName(); + imagePath = ":/images/folder.png"; + item.setFileInfo(filePath,fileName,imagePath); + m_fileItemList.append(item); + } + else//为文件 + { + QString suffix = fileInfo.suffix().toUpper(); + if(suffix == "DST" || suffix == "DSR" || suffix == "QUI" || suffix == "QUIX" || suffix == "PLT" || suffix == "DXF") + { + filePath = fileInfo.absoluteFilePath(); + fileName = fileInfo.fileName(); + imagePath = ":/images/file.png"; + item.setFileInfo(filePath,fileName,imagePath); + m_fileItemList.append(item); + flag = 1;//扫描到dst或dsr + } + } + } + + if(flag == -1)//未扫描到dst或dsr + { + ui->buttonSelectAll->setEnabled(false); + } + else//扫描到dst或dsr + { + ui->buttonSelectAll->setEnabled(true); + } + + refreshUi(); +} + +void PatternManageWidget::initExecDirPath(QString path) +{ + m_curPath = path; + if(m_curPath == m_usbPath || m_curPath == m_rootPath)//如果当前目录等于优盘目录或操作屏根目录,返回上级按钮不可按 + { + ui->buttonBackUpDir->setEnabled(false); + } + else + { + ui->buttonBackUpDir->setEnabled(true); + } + + m_fileItemList.clear();//文件列表清空 + QDir dir(m_curPath); + //打开路径 + if(!dir.exists()) + { + m_curPages = 0; + m_pageNums = 0; + return; + } + + FileItem item; + QString fileName; + QString filePath; + QString imagePath; + + dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); // 设置类型过滤器,只为文件夹和文件格式 + + QFileInfoList fileList = dir.entryInfoList(); + int count = fileList.count(); + for(int i = 0; i < count; i++) + { + QFileInfo fileInfo = fileList[i]; + + if(fileInfo.isDir())//为文件夹 + { + filePath = fileInfo.absoluteFilePath(); + fileName = fileInfo.baseName(); + imagePath = ":/images/folder.png"; + item.setFileInfo(filePath,fileName,imagePath); + m_fileItemList.append(item); + } + } + + refreshUi(); +} + +//刷新界面显示 +void PatternManageWidget::refreshUi() +{ + if(m_manageMode == MANAGE_IMPORT_EXEC || m_manageMode == MANAGE_EXPORT_EXEC) + { + QString path = m_curPath; + if(m_manageMode == MANAGE_IMPORT_EXEC) + { + path = path.remove(m_rootPath); + } + if(m_manageMode == MANAGE_EXPORT_EXEC) + { + path = path.remove(m_usbPath); + } + setSubTitle(path); + } + + int itemNum; + if (m_fileItemList.size() <= 0) + { + itemNum = 0; + + for (int i = 0; i < m_itemPerPage; i++) + { + m_itemBtnList.at(i)->hide(); + } + ui->labelPage->setText("pageNum: 0/0"); + ui->buttonPgUp->setEnabled(false); + ui->buttonPgDn->setEnabled(false); + ui->buttonOk->setEnabled(false); + ui->buttonSelectAll->setEnabled(false); + + return; + } + else + { + itemNum = m_fileItemList.size(); + } + + m_pageNums = (itemNum + m_itemPerPage - 1)/m_itemPerPage;// 计算页数 + if (m_curPages > m_pageNums)// 当前页 + { + m_curPages = m_pageNums; + } + if (m_curPages <= 1 && itemNum != 0) + { + m_curPages = 1; + } + + int itemidx = (m_curPages - 1) * m_itemPerPage; + + for (int i = 0; i < m_itemPerPage; i++) + { + if (itemidx < itemNum) + { + //设置图标和文件名 + m_itemBtnList[i]->setItemLeftIcon(m_fileItemList.at(itemidx).getImagePath()); + m_itemBtnList[i]->setLabelName(m_fileItemList.at(itemidx).getShowInfo()); + m_itemBtnList.at(i)->show(); + + itemidx++; + } + else + { + m_itemBtnList.at(i)->hide(); + } + } + + // 翻页按钮 + if (m_curPages <= 1) + { + ui->buttonPgUp->setEnabled(false); + } + else + { + ui->buttonPgUp->setEnabled(true); + } + if (m_curPages >= m_pageNums) + { + ui->buttonPgDn->setEnabled(false); + } + else + { + ui->buttonPgDn->setEnabled(true); + } + + // 页信息 + if(m_pageNums == 0) + { + m_curPages = 0; + } + + QString str = tr("pageNum: ") + QString("%1/%2").arg(m_curPages).arg(m_pageNums);//页数: + ui->labelPage->setText(str); + + refreshCheckedPage(); +} + +QString PatternManageWidget::detectUsb() +{ + QString usbPath = ""; + +#ifdef Q_OS_LINUX + QDir dir(LINUXUSBPATH); + if(!dir.exists()) + { + usbPath = ""; + } + else + { + usbPath = LINUXUSBPATH; + } +#endif + +#ifdef Q_OS_WIN + QFileInfoList list = QDir::drives(); + + for(int i = 0; isetCheckable(true); + m_itemBtnList.at(var)->setChecked(true); + } + else + { + // 不被选中 + m_itemBtnList.at(var)->setChecked(false); + m_itemBtnList.at(var)->setCheckable(false); + } + } + } +} + +//点击某一条目 lxs走到最新的 +void PatternManageWidget::clickItem(int idx) +{ + //全选时点击条目,全选标志置为非全选 + if(m_selectAll == 1) + { + m_selectAll = m_selectAll * -1; + } + + if(idx < 0) //都不选中 + { + m_selectAll = -1; + m_selectFileItemList.clear(); + // 刷新页面中被选择的条目 + for (int var = 0; var < m_itemPerPage ; var++) + { + // 不被选中 + m_itemBtnList[var]->setChecked(false); + m_itemBtnList[var]->setCheckable(false); + ui->buttonOk->setEnabled(false); + } + //清空图片 + QPixmap pix = QPixmap(); + ui->labelPatternView->setPixmap(pix); + clearFileInfo(); + } + else + { + // 计算当前选择按钮对应的花版 + int itemidx = (m_curPages - 1) * m_itemPerPage + idx - 1; + + if (m_fileItemList.size() <= 0) + { + itemidx = -1; + return; + } + else + { + + if (itemidx >= m_fileItemList.size()) + { + return; + } + } + + QString filePath = m_fileItemList.at(itemidx).getFilePath(); + QFileInfo fileInfo(filePath); + + QString fileName = fileInfo.fileName(); + int size = fileName.length(); + if(size > NAMEMAXLENGTH)//花样名称过长时截取 + { + fileName = fileName.mid(0,NAMEMAXLENGTH) + "~"; + } + + if(fileInfo.isDir())//为文件夹 + { + if(m_manageMode == MANAGE_IMPORT_EXEC || m_manageMode == MANAGE_EXPORT_EXEC) + { + initExecDirPath(filePath); + } + else + { + initDirPath(filePath); + } + clickItem(-1); + } + else + { + int retIdx = m_selectFileItemList.indexOf(filePath); + + if(retIdx == -1) + { + // 没有找到相同的文件名 + // 添加条目 + m_selectFileItemList.append(filePath); + } + else + { + m_selectFileItemList.takeAt(retIdx); + } + refreshCheckedPage(); + + if(m_selectFileItemList.size() > 0) + { + QFileInfo lfileInfo(m_selectFileItemList.last()); //最后一个选中Item + QString fileNamePath = lfileInfo.absoluteFilePath(); + QString suffix = lfileInfo.suffix();//后缀 + + QImage image(QSize(ui->labelPatternView->width(), ui->labelPatternView->height()),QImage::Format_ARGB32); + ui->labelNameValue->setText(lfileInfo.fileName()); + + if(suffix.toUpper() == "DST") + { + DataFileDst dst; + dst.initFile(fileNamePath);//最后一个选中Item + dst.createPreviewImage(&image, 0, PEN_WIDTH,1);// 生成预览文件,第2个参数为0不保存图片,1为保存图片 + //刷新文件信息 + ui->labelNValue->setText(QString::number(dst.getStitchNums())); + + double width = dst.getDatWidth()*0.01; + ui->labelWValue->setText(QString("%1").arg(width)); + + double height = dst.getDatHeight()*0.01; + ui->labelHValue->setText(QString("%1").arg(height)); + + double xPos = dst.getMaxX()*0.01; + ui->labelXValue->setText(QString("%1").arg(xPos)); + + double yPos = dst.getMaxY()*0.01; + ui->labelYValue->setText(QString("%1").arg(yPos)); + } + else if(suffix.toUpper() == "DSR") + { + DataFileDsr dsr; + dsr.initFile(fileNamePath);//最后一个选中Item + dsr.convertDataToEmbAbs(); + dsr.createPreviewImage(&image, 0, PEN_WIDTH,1);// 生成预览文件,第2个参数为0不保存图片,1为保存图片 + //刷新文件信息 + ui->labelNValue->setText(QString::number(dsr.getStitchNums())); + + double width = dsr.getDatWidth()*0.01; + ui->labelWValue->setText(QString("%1").arg(width)); + + double height = dsr.getDatHeight()*0.01; + ui->labelHValue->setText(QString("%1").arg(height)); + + double xPos = dsr.getMaxX()*0.01; + ui->labelXValue->setText(QString("%1").arg(xPos)); + + double yPos = dsr.getMaxY()*0.01; + ui->labelYValue->setText(QString("%1").arg(yPos)); + } + else if(suffix == "QUI") + { + } + else if(suffix == "QUIX") + { + } + else if(suffix == "PLT") + { + } + else if(suffix == "DXF") + { + } + + QPixmap pix = QPixmap::fromImage(image); + ui->labelPatternView->setPixmap(pix); + } + else + { + QPixmap pix = QPixmap(); + ui->labelPatternView->setPixmap(pix); + //清空文件信息 + clearFileInfo(); + } + } + } + + if(m_manageMode == MANAGE_IMPORT_EXEC || m_manageMode == MANAGE_EXPORT_EXEC) + { + //清空图片 + QPixmap pix = QPixmap(); + ui->labelPatternView->setPixmap(pix); + //清空文件信息 + clearFileInfo(); + ui->buttonOk->setEnabled(true); //导入导出文件 + } + else//选择文件 + { + if(m_selectFileItemList.size() <= 0) + { + ui->buttonOk->setEnabled(false); + + //清空图片 + QPixmap pix = QPixmap(); + ui->labelPatternView->setPixmap(pix); + } + else + { + ui->buttonOk->setEnabled(true); + } + } +} + +void PatternManageWidget::patternImportOrExport(QString mainStr,QString subStr,QString path) +{ + QDir apppath(qApp->applicationDirPath()); + + if(m_curPath.length() <= 0) + { + return; + } + + PromptDialog promptDlg(this); + promptDlg.setRange(0, m_cpSelectFileItemList.size()-1); + promptDlg.show(); + s16 showFlag = 1; + + for(int i = 0; i < m_cpSelectFileItemList.size(); i++) + { + QFileInfo fileInfo(m_cpSelectFileItemList.at(i)); + QString fileName = fileInfo.fileName(); + QString suffix = fileInfo.suffix(); + QString newFileName = m_curPath + apppath.separator() + fileName; + + //非5.2和6.3版本的dsr不可导入 + //dst格式错误不可导入 + if(suffix.toUpper() == "DSR" || + suffix.toUpper() == "DST" || + suffix.toUpper() == "QUI" || + suffix.toUpper() == "QUIX" || + suffix.toUpper() == "PLT" || + suffix.toUpper() == "DXF" ) + { + int rel = 0; + if(suffix.toUpper() == "DSR") + { + DataFileDsr dsr; + dsr.initFile(m_cpSelectFileItemList.at(i)); + rel = dsr.checkDsrVersion(); + } + else if(suffix.toUpper() == "DST") + { + DataFileDst dst; + dst.initFile(m_cpSelectFileItemList.at(i)); + rel = dst.checkDstFile(); + } + else if(suffix.toUpper() == "QUI") + { + } + else if(suffix.toUpper() == "QUIX") + { + } + else if(suffix.toUpper() == "PLT") + { + } + else if(suffix.toUpper() == "DXF") + { + } + + if(rel < 0) + { + promptDlg.initDialog(PromptDialog::BTN_OK); + promptDlg.setTitleStr(tr("Prompt")); + + QString str; + if(rel == -2) + { + str = fileName + " " + tr("Over 1.28 million stitches, can not be imported!");//针数超过128万,不能导入! + } + else + { + str = fileName + " " + tr("Format error, can not be imported!");//格式错误,不能导入! + } + promptDlg.setContentStr(str); + promptDlg.exec(); + showFlag = 0; + continue; + } + } + + qDebug()<<"Pattern ImportOrExport"; + qDebug()<<"fileName"< NAMEMAXLENGTH + 12)//花样名称过长时截取 + { + fileName = fileName.mid(0,NAMEMAXLENGTH + 12) + "~"; + } + + wordInputDlg.setOldWordsStr(fileName); + if(wordInputDlg.exec() == 1) + { + if(m_manageMode == MANAGE_IMPORT)//导入文件 + { + //文件名称 + QString name = wordInputDlg.getInputStr(); + QString newName = m_curPath + apppath.separator() + name + "." + suffix; + QFile::copy(m_cpSelectFileItemList.at(i), newName); + QFile::copy(m_cpSelectFileItemList.at(i) + ".fcg", newName + ".fcg"); + } + else if(m_manageMode == MANAGE_EXPORT)//导出文件 + { + //文件名称 + QString name = wordInputDlg.getInputStr();//导出文件路径 + QString newName = m_curPath + apppath.separator() + name + "." + suffix; + QFile::copy(m_cpSelectFileItemList.at(i), newName); + QFile::copy(m_cpSelectFileItemList.at(i) + ".fcg", newName + ".fcg"); + QFile::copy(m_cpSelectFileItemList.at(i) + ".ds16", newName + ".ds16"); + } + } + } + else if(ret == 2)//替换 + { + if(m_manageMode == MANAGE_IMPORT)//导入文件 + { + QFile::remove(newFileName); + QFile::remove(newFileName + ".fcg"); + QFile::remove(newFileName + ".ds16"); + QFile::copy(m_cpSelectFileItemList.at(i), newFileName); + emit siReplacePattrn(newFileName); + //newFileName = D:/work/workQT/XPlatform/Windows/debug/datafiles\0.7盾牌.dst + //QFile::copy(m_cpSelectFileItemList.at(i) + ".fcg", newFileName + ".fcg"); + } + else if(m_manageMode == MANAGE_EXPORT)//导出文件 + { + QFile::remove(newFileName); + QFile::remove(newFileName + ".fcg"); + QFile::copy(m_cpSelectFileItemList.at(i), newFileName); + QFile::copy(m_cpSelectFileItemList.at(i) + ".fcg", newFileName + ".fcg"); + QFile::copy(m_cpSelectFileItemList.at(i) + ".ds16", newFileName + ".ds16"); + } + } + } + else + { + promptDlg.initDialog(PromptDialog::BTN_P_NONE); + promptDlg.setTitleStr(tr("Prompt")); + + if(m_manageMode == MANAGE_IMPORT)//导入文件 + { + promptDlg.setContentProcessStr(tr("Importing ") + fileName); //正在导入 + } + else if(m_manageMode == MANAGE_EXPORT)//导出文件 + { + promptDlg.setContentProcessStr(tr("Exporting ") + fileName); //正在导出 + } + + if(showFlag == 0) + { + promptDlg.show(); + showFlag = 1; + } + if(m_manageMode == MANAGE_IMPORT)//导入文件 + { + QFile::copy(m_cpSelectFileItemList.at(i),newFileName); + //QFile::copy(m_cpSelectFileItemList.at(i) + ".fcg", newFileName + ".fcg"); + } + else if(m_manageMode == MANAGE_EXPORT)//导出文件 + { + QFile::copy(m_cpSelectFileItemList.at(i),newFileName); + QFile::copy(m_cpSelectFileItemList.at(i) + ".fcg", newFileName + ".fcg"); + QFile::copy(m_cpSelectFileItemList.at(i) + ".ds16", newFileName + ".ds16"); + } + + } + + qDebug()<<"processEvents before"; + QCoreApplication::processEvents(QEventLoop::AllEvents); + qDebug()<<"processEvents end"; + + if(m_manageMode == MANAGE_IMPORT)//导入文件 + { + QImage image(m_imgSize,QImage::Format_ARGB32); + + if(suffix.toUpper() == "DST") + { + DataFileDst dst; + dst.initFile(newFileName); + dst.createPreviewImage(&image, 1, PEN_WIDTH);// 生成渐进绘制预览图片,第2个参数为0不保存图片,1为保存图片 + + qDebug()<<"dst.createPreviewImage end"; + } + else if(suffix.toUpper() == "DSR") + { + DataFileDsr dsr; + dsr.initFile(newFileName); + dsr.convertDataToEmbAbs(); + dsr.createPreviewImage(&image, 1, PEN_WIDTH);// 生成渐进绘制预览图片,第2个参数为0不保存图片,1为保存图片 + } + else if(suffix.toUpper() == "QUI") + { + } + else if(suffix.toUpper() == "QUIX") + { + } + else if(suffix.toUpper() == "PLT") + { + } + else if(suffix.toUpper() == "DXF") + { + } + } + + promptDlg.setValue(i); + } + +#ifdef Q_OS_LINUX + system("sync"); +#endif + if(m_manageMode == MANAGE_IMPORT)//导入文件 + { + promptDlg.setContentStr(tr("Import complete")); //导入完成 + } + else if(m_manageMode == MANAGE_EXPORT)//导出文件 + { + promptDlg.setContentStr(tr("Export complete")); //导出完成 + } + promptDlg.hide(); + + setMainTitle(mainStr); + setSubTitle(subStr); + initialize(); + initDirPath(path); + clickItem(-1); + ui->buttonSelectAll->show(); + ui->buttonNewFolder->hide(); +} + +void PatternManageWidget::patternDelete() +{ + if(m_selectAll == 1)//全选时删除整个文件夹 + { + for(int i = 0; i < m_selectFileItemList.size(); i++) + { + QFile::remove(m_selectFileItemList.at(i)); + QFile::remove(m_selectFileItemList.at(i)+".fcg"); + QFile::remove(m_selectFileItemList.at(i)+".ds16"); + QFile::remove(m_selectFileItemList.at(i)+".ds8"); + QFile::remove(m_selectFileItemList.at(i)+".preview.png"); + } + + if(m_curPath != m_rootPath)//非根目录 + { + //得到上级目录 + QDir upDir(m_curPath); + upDir.cdUp(); + QString upPath = upDir.absolutePath(); + + QDir remDir(m_curPath); + if(remDir.exists() == true) + { + remDir.rmpath(remDir.absolutePath());//删除整个文件夹 + } + + initDirPath(upPath);//初始化上级目录 + } + else + { + initDirPath(m_curPath);//初始化当前目录(根目录) + } + } + else + { + //所选文件个数等于目录文件总个数时删除整个文件夹 + if(m_selectFileItemList.size() == m_fileItemList.size()) + { + for(int i = 0; i < m_selectFileItemList.size(); i++) + { + QFile::remove(m_selectFileItemList.at(i)); + QFile::remove(m_selectFileItemList.at(i)+".fcg"); + QFile::remove(m_selectFileItemList.at(i)+".ds16"); + QFile::remove(m_selectFileItemList.at(i)+".ds8"); + QFile::remove(m_selectFileItemList.at(i)+".preview.png"); + } + + if(m_curPath != m_rootPath)//非根目录 + { + //得到上级目录 + QDir upDir(m_curPath); + upDir.cdUp(); + QString upPath = upDir.absolutePath(); + + QDir remDir(m_curPath); + if(remDir.exists() == true) + { + remDir.rmpath(remDir.absolutePath());//删除整个文件夹 + } + + initDirPath(upPath);//初始化上级目录 + } + else + { + initDirPath(m_curPath);//初始化当前目录(根目录) + } + } + else + { + //所选文件个数不等于目录文件总个数时删除整个文件夹 + for(int i = 0; i < m_selectFileItemList.size(); i++) + { + QFile::remove(m_selectFileItemList.at(i)); + QFile::remove(m_selectFileItemList.at(i)+".fcg"); + QFile::remove(m_selectFileItemList.at(i)+".ds16"); + QFile::remove(m_selectFileItemList.at(i)+".ds8"); + QFile::remove(m_selectFileItemList.at(i)+".preview.png"); + initDirPath(m_curPath); + } + } + } + clickItem(-1); +} + +void PatternManageWidget::clearFileInfo() +{ + ui->labelNameValue->setText(""); + ui->labelNValue->setText(""); + ui->labelCValue->setText(""); + ui->labelWValue->setText(""); + ui->labelHValue->setText(""); + ui->labelXValue->setText(""); + ui->labelYValue->setText(""); +} + +//花样导入 +void PatternManageWidget::patternManage(MANAGE_MODE mode) +{ + initialize(); + if(mode != MANAGE_DELETE)//删除操作不检测优盘 + { + m_usbPath.clear(); + m_usbPath = detectUsb(); + if(m_usbPath.length() <= 0) + { + //优盘不存在 + PromptDialog dlg(this); + dlg.initDialog(PromptDialog::BTN_OK); + dlg.setTitleStr(tr("Prompt")); + + QString str; + str = tr("USB flash drive is not detected!");//未检测到优盘! + dlg.setContentStr(str); + dlg.exec(); + return; + } + } + + if(mode == MANAGE_IMPORT) + { + initDirPath(m_usbPath); + } + else + { + initDirPath(m_rootPath); + } + clickItem(-1); + + m_manageMode = mode;//花样导入、导出、删除 + ui->buttonNewFolder->hide(); + ui->buttonSelectAll->show(); + this->show(); +} + +void PatternManageWidget::setImportImageSize(QSize imgSize) +{ + m_imgSize = imgSize; +} + +void PatternManageWidget::on_button1_clicked() +{ + clickItem(1); +} + +void PatternManageWidget::on_button2_clicked() +{ + clickItem(2); +} + +void PatternManageWidget::on_button3_clicked() +{ + clickItem(3); +} + +void PatternManageWidget::on_button4_clicked() +{ + clickItem(4); +} + +void PatternManageWidget::on_button5_clicked() +{ + clickItem(5); +} + +void PatternManageWidget::on_button6_clicked() +{ + clickItem(6); +} + +void PatternManageWidget::on_button7_clicked() +{ + clickItem(7); +} + +void PatternManageWidget::on_button8_clicked() +{ + clickItem(8); +} + +void PatternManageWidget::on_button9_clicked() +{ + clickItem(9); +} + +void PatternManageWidget::on_button10_clicked() +{ + clickItem(10); +} + +void PatternManageWidget::on_button11_clicked() +{ + clickItem(11); +} + +void PatternManageWidget::on_button12_clicked() +{ + clickItem(9); +} + +void PatternManageWidget::on_button13_clicked() +{ + clickItem(10); +} + +void PatternManageWidget::on_button14_clicked() +{ + clickItem(11); +} + +void PatternManageWidget::on_button15_clicked() +{ + clickItem(12); +} + +void PatternManageWidget::on_button16_clicked() +{ + + clickItem(13); +} + +void PatternManageWidget::on_button17_clicked() +{ + clickItem(14); +} + +void PatternManageWidget::on_button18_clicked() +{ + clickItem(15); +} + +void PatternManageWidget::on_button19_clicked() +{ + clickItem(16); +} + +void PatternManageWidget::on_button20_clicked() +{ + clickItem(20); +} + +void PatternManageWidget::on_button21_clicked() +{ + clickItem(21); +} + +void PatternManageWidget::on_button22_clicked() +{ + clickItem(22); +} + +void PatternManageWidget::on_buttonPgUp_clicked() +{ + m_curPages--; + refreshUi(); +} + +void PatternManageWidget::on_buttonPgDn_clicked() +{ + m_curPages++; + refreshUi(); +} + +void PatternManageWidget::on_buttonOk_clicked() +{ + if(m_manageMode == MANAGE_DELETE)//花样删除 + { + //是否删除花样的提示 + PromptDialog dlg(this); + dlg.initDialog(PromptDialog::BTN_OK_CANCEL); + dlg.setTitleStr(tr("Prompt")); + + qDebug()<<"import begin 1"; + QString str; + str = tr("Whether to delete the pattern?");//是否删除花样? + dlg.setContentStr(str); + if(dlg.exec() == 1) + { + patternDelete(); + emit siDeletePattern();//删除文件后判断当前文件是否被删除 + } + } + else + { + qDebug()<<"import begin 1.5"; + QString str; + QString path; + if(m_manageMode == MANAGE_IMPORT)//花样导入 + { + qDebug()<<"import begin 2"; + + str = tr("Operation screen");//操作屏 + //导入路径 + path = m_rootPath; + m_manageMode = MANAGE_IMPORT_EXEC; + m_cpSelectFileItemList.clear(); + m_cpSelectFileItemList.append(m_selectFileItemList); + + qDebug()<<"import begin 2.5"; + } + else if(m_manageMode == MANAGE_EXPORT)//花样导出 + { + qDebug()<<"import begin XXX"; + + str = tr("USB");//优盘 + //导出路径 + path = m_usbPath; + m_manageMode = MANAGE_EXPORT_EXEC; + m_cpSelectFileItemList.clear(); + m_cpSelectFileItemList.append(m_selectFileItemList); + qDebug()<<"import begin 3.5"; + } + else if(m_manageMode == MANAGE_IMPORT_EXEC)//花样导入执行 + { + + qDebug()<<"import begin 4"; + m_manageMode = MANAGE_IMPORT; + QString mainStr,subStr,path; + mainStr = tr("Pattern Import"); + subStr = tr("Pattern Import < Pattern setting"); + path = m_usbPath; + patternImportOrExport(mainStr,subStr,path); + + return; + qDebug()<<"import begin 4.5"; + } + else if(m_manageMode == MANAGE_EXPORT_EXEC)//花样导出执行 + { + + qDebug()<<"import begin 5"; + m_manageMode = MANAGE_EXPORT; + QString mainStr,subStr,path; + mainStr = tr("Pattern Export"); + subStr = tr("Pattern Export < Pattern setting"); + path = m_rootPath; + patternImportOrExport(mainStr,subStr,path); + + return; + qDebug()<<"import begin 5.5"; + } + + ui->buttonNewFolder->show(); + ui->buttonSelectAll->hide(); + setMainTitle(str); + setSubTitle(path); + initialize(); + initExecDirPath(path); + clickItem(-1); + } +} + +void PatternManageWidget::on_buttonCancel_clicked() +{ + QString mainStr,subStr,path; + if(m_manageMode == MANAGE_IMPORT || + m_manageMode == MANAGE_EXPORT || + m_manageMode == MANAGE_DELETE )//花样导入、花样导出、花样删除 + { + this->hide(); + return; + } + else if(m_manageMode == MANAGE_IMPORT_EXEC)//花样导入执行 + { + m_manageMode = MANAGE_IMPORT; + mainStr = tr("Pattern Import"); + subStr = tr("Pattern Import < Pattern setting"); + path = m_usbPath; + } + else if(m_manageMode == MANAGE_EXPORT_EXEC)//花样导出执行 + { + m_manageMode = MANAGE_EXPORT; + mainStr = tr("Pattern Import"); + subStr = tr("Pattern Import < Pattern setting"); + path = m_rootPath; + } + + ui->buttonNewFolder->hide(); + ui->buttonSelectAll->show(); + setMainTitle(mainStr); + setSubTitle(subStr); + initialize(); + initDirPath(path); + clickItem(-1); + //密码权限,单次有效 + g_emUser = operate; +} + +void PatternManageWidget::on_buttonBackUpDir_clicked() +{ + QDir dir(m_curPath); + dir.cdUp();//返回上级目录 + QString path = dir.absolutePath();//得到上级目录 + if(m_manageMode == MANAGE_IMPORT_EXEC || m_manageMode == MANAGE_EXPORT_EXEC) + { + initExecDirPath(path); + } + else + { + initDirPath(path); + } + clickItem(-1); +} + +void PatternManageWidget::on_buttonSelectAll_clicked() +{ + m_selectAll = m_selectAll * -1; + if(m_selectAll == 1)//全选 + { + QDir dir(m_curPath); + //打开路径 + if(!dir.exists()) + { + return; + } + + QStringList filters; + filters<labelPatternView->width(), ui->labelPatternView->height()),QImage::Format_ARGB32); + ui->labelNameValue->setText(lfileInfo.fileName()); + + if(suffix.toUpper() == "DST") + { + DataFileDst dst; + dst.initFile(fileNamePath);//最后一个选中Item + dst.createPreviewImage(&image, 0, PEN_WIDTH,1);// 生成预览文件,第2个参数为0不保存图片,1为保存图片 + //刷新文件信息 + ui->labelNValue->setText(QString::number(dst.getStitchNums())); + + double width = dst.getDatWidth()*0.01; + ui->labelWValue->setText(QString("%1").arg(width)); + + double height = dst.getDatHeight()*0.01; + ui->labelHValue->setText(QString("%1").arg(height)); + + double xPos = dst.getMaxX()*0.01; + ui->labelXValue->setText(QString("%1").arg(xPos)); + + double yPos = dst.getMaxY()*0.01; + ui->labelYValue->setText(QString("%1").arg(yPos)); + } + else if(suffix.toUpper() == "DSR") + { + DataFileDsr dsr; + dsr.initFile(fileNamePath);//最后一个选中Item + dsr.convertDataToEmbAbs(); + dsr.createPreviewImage(&image, 0, PEN_WIDTH,1);// 生成预览文件,第2个参数为0不保存图片,1为保存图片 + //刷新文件信息 + ui->labelNValue->setText(QString::number(dsr.getStitchNums())); + + double width = dsr.getDatWidth()*0.01; + ui->labelWValue->setText(QString("%1").arg(width)); + + double height = dsr.getDatHeight()*0.01; + ui->labelHValue->setText(QString("%1").arg(height)); + + double xPos = dsr.getMaxX()*0.01; + ui->labelXValue->setText(QString("%1").arg(xPos)); + + double yPos = dsr.getMaxY()*0.01; + ui->labelYValue->setText(QString("%1").arg(yPos)); + } + else if(suffix.toUpper() == "QUI") + { + } + else if(suffix.toUpper() == "QUIX") + { + } + else if(suffix.toUpper() == "PLT") + { + } + else if(suffix.toUpper() == "DXF") + { + } + + QPixmap pix = QPixmap::fromImage(image); + ui->labelPatternView->setPixmap(pix); + } + else if(m_selectAll == -1)//全不选 + { + clickItem(m_selectAll); + } + + if(m_selectFileItemList.size() <= 0) + { + ui->buttonOk->setEnabled(false); + } + else + { + ui->buttonOk->setEnabled(true); + } +} + +//新建文件夹 +void PatternManageWidget::on_buttonNewFolder_clicked() +{ + WordsInputDialog wordInputDlg; + wordInputDlg.clean(); + wordInputDlg.setTitleStr(tr("new folder"));//新文件夹 + wordInputDlg.setOldWordsStr(""); + if(wordInputDlg.exec() == 1) + { + //文件路径 + QString name = wordInputDlg.getInputStr(); + QDir apppath(qApp->applicationDirPath()); + QString newFolderPath = m_curPath + apppath.separator() + name; + newFolderPath = QDir(newFolderPath).absolutePath();//为了将"\"变为"/" + + QDir dir(newFolderPath); + if(dir.exists() == false) + { + dir.mkdir(newFolderPath); + initExecDirPath(m_curPath); + } + else + { + PromptDialog dlg(this); + dlg.initDialog(PromptDialog::BTN_OK); + dlg.setTitleStr(tr("Prompt")); + + QString str; + str = tr("This folder already exists!");//此文件夹已经存在! + dlg.setContentStr(str); + dlg.exec(); + return; + } + } +} + +void PatternManageWidget::mousePressEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + m_mousePressX = e->x(); + m_mousePressY = e->y(); + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; + } +} + +void PatternManageWidget::mouseReleaseEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + m_mouseReleaseX = e->x(); + m_mouseReleaseY = e->y(); + } + + int width = this->width(); + int height = this->height(); + if ((m_mousePressX >= 0 && m_mousePressX <= 100) && + ((m_mousePressY >= (height - 100)) && m_mousePressY <= height) && + ((m_mouseReleaseX >= (width - 100)) && m_mouseReleaseX <= width) && + ((m_mouseReleaseY >= (height - 100)) && m_mouseReleaseY <= height)) + { + MainWidgetFunction mainFunction; + QString usbPath;//优盘路径 + usbPath = mainFunction.detectUsb();//优盘检测 + if(usbPath.length() <= 0) + { + //优盘不存在 + return; + } + else + { + QPixmap pixmap=QPixmap::grabWindow(this->winId(),0,0,this->width(),this->height());//截屏存放在pixmap + QString name_pc = usbPath + "EMB" + // + QDateTime::currentDateTime().toString("yyyyMMdd") +//获取时期时间 + +"_"+ + QDateTime::currentDateTime().toString("hhmmss") + ".png"; + + pixmap.save(name_pc,"png"); // 路径 + } + } + + m_mousePressX = 0; + m_mousePressY = 0; + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; +} diff --git a/sharedviews/patternmanagewidget.h b/sharedviews/patternmanagewidget.h new file mode 100644 index 0000000..bf15d76 --- /dev/null +++ b/sharedviews/patternmanagewidget.h @@ -0,0 +1,132 @@ +#ifndef PatternManageWidget_H +#define PatternManageWidget_H + +#include +#include + +#ifdef Q_OS_WIN +#include +#include +#endif + +#include "setcontrolstyle.h" +#include "mybutton.h" +#include "items/fileitem.h" +#include "promptdialog.h" +#include "wordsinputdialog.h" +//#include "Include/datafiledst.h" +#include "datafile/datafiledst.h" +#include "datafile/datafiledsr.h" +#include +#include +#include "mctype/mainwidgetfunction.h" + +namespace Ui { +class PatternManageWidget; +} + +class PatternManageWidget : public QWidget +{ + Q_OBJECT + +public: + explicit PatternManageWidget(QWidget *parent = 0); + ~PatternManageWidget(); + enum MANAGE_MODE {MANAGE_IMPORT = 0, MANAGE_EXPORT, MANAGE_DELETE,MANAGE_IMPORT_EXEC,MANAGE_EXPORT_EXEC}; + +private: + Ui::PatternManageWidget *ui; + int m_itemPerPage;//界面每页条目数 + QList m_itemBtnList; + +private: + QList m_fileItemList;//文件列表 + QList m_selectFileItemList;//选中文件列表 + QList m_cpSelectFileItemList;//选中文件列表 + + int m_curPages;//当前页 + int m_pageNums;//总页数 + QString m_usbPath;//优盘路径 + QString m_rootPath;//操作屏根路径 + QString m_curPath;//当前路径 + int m_selectAll;//1:全选 -1:全不选 + MANAGE_MODE m_manageMode;//导入、导出、删除 + + QSize m_imgSize; + +private: + void initialize();//初始化 + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006();//初始化窗体控件为1024x600分辨率 + void initControlStyle();//初始化窗体控件样式 + +public: + void setTypeLogo(QString tStyle);//设置类型图标 + void setMainTitle(QString str);//设置主title + void setSubTitle(QString str);//设置副title + +private: + void initDirPath(QString path);//初始化目录中的目录和文件 + void initExecDirPath(QString path);//初始化目录中的目录 + + void refreshUi();//刷新界面显示 + QString detectUsb();//检测优盘是否存在 + void refreshCheckedPage();//刷新条目选中状态 + void clickItem(int idx);//点击某一条目 + void patternImportOrExport(QString mainStr,QString subStr,QString path);//花样导入或导出 + void patternDelete();//花样删除 + void clearFileInfo(); + +public: + void patternManage(MANAGE_MODE mode);//花样导入 + void setImportImageSize(QSize imgSize); //设置导入花样时生成预览图片的图片大小(与花样选择界面的图片大小相同) + +signals: + void siDeletePattern();//删除了文件的信号 + void siReplacePattrn(QString path);//替换了文件的信号 + +private slots: + void on_button1_clicked(); + void on_button2_clicked(); + void on_button3_clicked(); + void on_button4_clicked(); + void on_button5_clicked(); + void on_button6_clicked(); + void on_button7_clicked(); + void on_button8_clicked(); + void on_button9_clicked(); + void on_button10_clicked(); + void on_button11_clicked(); + void on_button12_clicked(); + void on_button13_clicked(); + void on_button14_clicked(); + void on_button15_clicked(); + void on_button16_clicked(); + void on_button17_clicked(); + void on_button18_clicked(); + void on_button19_clicked(); + void on_button20_clicked(); + void on_button21_clicked(); + void on_button22_clicked(); + void on_buttonPgUp_clicked(); + void on_buttonPgDn_clicked(); + void on_buttonOk_clicked(); + void on_buttonCancel_clicked(); + void on_buttonBackUpDir_clicked(); + void on_buttonSelectAll_clicked(); + void on_buttonNewFolder_clicked(); + + //鼠标事件 +protected: + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + +private: + int m_mousePressX; + int m_mousePressY; + int m_mouseReleaseX; + int m_mouseReleaseY; +}; + +#endif // PatternManageWidget_H diff --git a/sharedviews/patternmanagewidget.ui b/sharedviews/patternmanagewidget.ui new file mode 100644 index 0000000..5c3c2b8 --- /dev/null +++ b/sharedviews/patternmanagewidget.ui @@ -0,0 +1,1026 @@ + + + PatternManageWidget + + + + 0 + 0 + 1024 + 600 + + + + Form + + + background-color: rgb(172, 172, 172); + + + + + 20 + 560 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + PageNums: 0/0 + + + + + + 100 + 430 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 110 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 470 + 550 + 531 + 31 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 290 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 450 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 370 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 210 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + + 100 + 310 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 470 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 150 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 70 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 390 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 270 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 350 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 190 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 230 + 300 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 30 + 10 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 40 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Sub title < Title + + + + + + 110 + 10 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Sub title + + + + + + 770 + 70 + 200 + 200 + + + + background-color: rgb(255, 255, 255); + + + + + + + + + 0 + 0 + 1024 + 600 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 420 + 270 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 310 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 70 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 390 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 150 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 430 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 350 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 470 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 190 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 230 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 420 + 110 + 241 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 860 + 420 + 72 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + 1000.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 830 + 400 + 20 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + W + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 860 + 360 + 72 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + 500.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 860 + 440 + 72 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + 999 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 830 + 420 + 20 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + H + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 860 + 460 + 72 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + 1000000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 860 + 400 + 72 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + 1000.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 830 + 380 + 20 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Y + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 830 + 360 + 20 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + X + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 860 + 380 + 72 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + 800.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 800 + 330 + 72 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + dst + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 830 + 440 + 20 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + C + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 830 + 460 + 20 + 16 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + N + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 700 + 10 + 291 + 51 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 130 + 10 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 210 + 10 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 40 + 10 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + frameBack + labelPage + button10 + button2 + framePageBtn + button7 + button11 + button3 + button1 + button9 + button6 + button8 + button4 + button5 + buttonTypeLogo + labelSubTitle + labelMainTitle + labelPatternView + button17 + button18 + button12 + button20 + button14 + button21 + button19 + button22 + button15 + button16 + button13 + labelHValue + labelW + labelXValue + labelCValue + labelH + labelNValue + labelWValue + labelY + labelX + labelYValue + labelNameValue + labelC + labelN + frameRightUp + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/patternselectwidget.cpp b/sharedviews/patternselectwidget.cpp new file mode 100644 index 0000000..3a264d7 --- /dev/null +++ b/sharedviews/patternselectwidget.cpp @@ -0,0 +1,947 @@ +#include "patternselectwidget.h" +#include "ui_patternselectwidget.h" + +PatternSelectWidget::PatternSelectWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::PatternSelectWidget), + m_itemPerPage(10) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + + m_mousePressX = 0; + m_mousePressY = 0; + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; + + this->move(0,0); + initControl(); + initialize(); +} + +PatternSelectWidget::~PatternSelectWidget() +{ + delete ui; +} + +//初始化窗体控件,包括位置、尺寸、样式 +void PatternSelectWidget::initControl() +{ + m_imageButtonList.clear(); + m_imageButtonList.append(ui->buttonImage1); + m_imageButtonList.append(ui->buttonImage2); + m_imageButtonList.append(ui->buttonImage3); + m_imageButtonList.append(ui->buttonImage4); + m_imageButtonList.append(ui->buttonImage5); + m_imageButtonList.append(ui->buttonImage6); + m_imageButtonList.append(ui->buttonImage7); + m_imageButtonList.append(ui->buttonImage8); + m_imageButtonList.append(ui->buttonImage9); + m_imageButtonList.append(ui->buttonImage10); + + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void PatternSelectWidget::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + this->resize(1024*factoryX,600*factoryY); + ui->frameBack->setGeometry(0*factoryX,0*factoryY,1024*factoryX,600*factoryY); + ui->buttonTypeLogo->setGeometry(25*factoryX,30*factoryY,60*factoryX,60*factoryY); + ui->labelMainTitle->setGeometry(100*factoryX,30*factoryY,200*factoryX,24*factoryY); + ui->labelSubTitle->setGeometry(130*factoryX,64*factoryY,270*factoryX,21*factoryY); + ui->frameImage->setGeometry(27*factoryX,108*factoryY,1000*factoryX,431*factoryY); + + //预览图片 + QRect rectImage(18*factoryX,9*factoryY,120*factoryX,120*factoryY); + QRect rectName(30*factoryX,144*factoryY,120*factoryX,42*factoryY); + for(int i = 0; i < 2; i++) + { + s16 num = m_imageButtonList.size()/2; + for(int j = 0; j < num; j++) + { + m_imageButtonList.at(i*num + j)->setGeometry((25+j*190)*factoryX,(10+i*220)*factoryY,158*factoryX,197*factoryY); + m_imageButtonList.at(i*num + j)->initUpImageDownName(rectImage,rectName); + } + } + + ui->frameRightUp->setGeometry(650*factoryX,40*factoryY,450*factoryX,61*factoryY); + ui->buttonBackUpDir->setGeometry(300*factoryX,0*factoryY,50*factoryX,50*factoryY); + + //label样式 + ui->labelMainTitle->setFont(fontBold_1); + ui->labelMainTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelSubTitle->setFont(fontNormal_1); + ui->labelSubTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelPageNum->setFont(fontNormal_1); + ui->labelPageNum->setStyleSheet(LABELWHITESTYLE); + +// ui->frameInfo1->setGeometry(1528,210,328,284); + ui->frameInfo1->hide(); //屏蔽右侧状态栏 + + QList labelList1; + labelList1.append(ui->labelPatternName); + labelList1.append(ui->labelTotalNeedle); + labelList1.append(ui->labelPatternWidth); + labelList1.append(ui->labelPatternHeight); + labelList1.append(ui->labelX); + labelList1.append(ui->labelY); + for(int i = 0; i < labelList1.size(); i++) + { + labelList1[i]->setGeometry(5*factoryX,(i*26)*factoryY,90*factoryX,32*factoryY); + labelList1[i]->setFont(fontNormal_6); + labelList1[i]->setStyleSheet(LABELWHITESTYLE); + } + + QList labelList2; + labelList2.append(ui->labelPatternNameValue); + labelList2.append(ui->labelTotalNeedleValue); + labelList2.append(ui->labelPatternWidthValue); + labelList2.append(ui->labelPatternHeightValue); + labelList2.append(ui->labelXValue); + labelList2.append(ui->labelYValue); + for(int i = 0; i < labelList2.size(); i++) + { + labelList2[i]->setGeometry(42*factoryX,(i*26)*factoryY,140*factoryX,32*factoryY); + labelList2[i]->setFont(fontNormal_6); + labelList2[i]->setStyleSheet(LABELWHITESTYLE); + } + + ui->framePageBtn->setGeometry(595*factoryX,545*factoryY,600*factoryX,45*factoryY); + ui->labelPageNum->setGeometry(20*factoryX,560*factoryY,181*factoryX,21*factoryY); + ui->buttonPgUp->setGeometry(0*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonPgDn->setGeometry(106*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonOk->setGeometry(212*factoryX,0*factoryY,96*factoryX,40*factoryY); + ui->buttonCancel->setGeometry(318*factoryX,0*factoryY,96*factoryX,40*factoryY); +} + +//初始化窗体控件为1024x600分辨率 +void PatternSelectWidget::initResolution1006() +{ + this->resize(1024,600); + ui->frameBack->setGeometry(0,0,1024,600); + ui->buttonTypeLogo->setGeometry(25,30,60,60); + ui->labelMainTitle->setGeometry(100,30,200,24); + ui->labelSubTitle->setGeometry(130,64,270,21); + ui->frameImage->setGeometry(27,108,1000,431); + + //预览图片 + QRect rectImage(18,9,120,120);//(7,9,120,120) lxs更改选择花样尺寸 + QRect rectName(30,144,120,42);//(18,144,120,42) + for(int i = 0; i < 2; i++) + { + s16 num = m_imageButtonList.size()/2; + for(int j = 0; j < num; j++) + { +// m_imageButtonList[j]->setBottomImage(setControlStyle.getBottomStyleSheet(ui->frameImage->objectName())); +// m_imageButtonList[j]->setTopImage(setControlStyle.getTopStyleSheet(ui->frameImage->objectName())); + m_imageButtonList.at(i*num + j)->setGeometry(25+j*190,10+i*220,158,197);//(0+j*155,0+i*220,134,197) + m_imageButtonList.at(i*num + j)->initUpImageDownName(rectImage,rectName); + } + } + + ui->frameRightUp->setGeometry(650,40,450,61); + ui->buttonBackUpDir->setGeometry(300,0,50,50); + + + //label样式 + ui->labelMainTitle->setFont(fontBold_1); + ui->labelMainTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelSubTitle->setFont(fontNormal_1); + ui->labelSubTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelPageNum->setFont(fontNormal_1); + ui->labelPageNum->setStyleSheet(LABELWHITESTYLE); + + ui->frameInfo1->setGeometry(804,110,222,191); + ui->frameInfo1->hide(); //屏蔽右侧状态栏 + + QList labelList1; + labelList1.append(ui->labelPatternName); + labelList1.append(ui->labelTotalNeedle); + labelList1.append(ui->labelPatternWidth); + labelList1.append(ui->labelPatternHeight); + labelList1.append(ui->labelX); + labelList1.append(ui->labelY); + for(int i = 0; i < labelList1.size(); i++) + { + labelList1[i]->setGeometry(5,i*26,90,32); + labelList1[i]->setFont(fontNormal_6); + labelList1[i]->setStyleSheet(LABELWHITESTYLE); + } + + QList labelList2; + labelList2.append(ui->labelPatternNameValue); + labelList2.append(ui->labelTotalNeedleValue); + labelList2.append(ui->labelPatternWidthValue); + labelList2.append(ui->labelPatternHeightValue); + labelList2.append(ui->labelXValue); + labelList2.append(ui->labelYValue); + for(int i = 0; i < labelList2.size(); i++) + { + labelList2[i]->setGeometry(42,i*26,140,32); + labelList2[i]->setFont(fontNormal_6); + labelList2[i]->setStyleSheet(LABELWHITESTYLE); + } + + ui->framePageBtn->setGeometry(595,545,600,45); + ui->labelPageNum->setGeometry(20,560,181,21); + ui->buttonPgUp->setGeometry(0,0,96,40); + ui->buttonPgDn->setGeometry(106,0,96,40); + ui->buttonOk->setGeometry(212,0,96,40); + ui->buttonCancel->setGeometry(318,0,96,40); +} + +//初始化窗体控件样式 +void PatternSelectWidget::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //背景图 + QString frameBackImgPath = setControlStyle.getStyleSheet(this->objectName()); + ui->frameBack->setStyleSheet(frameBackImgPath); + + //frame样式 + ui->framePageBtn->setStyleSheet(TRANSPARENTSTYLE); + ui->frameImage->setStyleSheet(TRANSPARENTSTYLE); + ui->frameInfo1->setStyleSheet(TRANSPARENTSTYLE); + ui->frameRightUp->setStyleSheet(TRANSPARENTSTYLE); + + //条目 + for(int i = 0; i < m_itemPerPage; i++) + { + m_imageButtonList[i]->setCheckedBottomImage(setControlStyle.getBottomStyleSheet(m_imageButtonList[i]->parent()->objectName())); + m_imageButtonList[i]->setLabelFont(fontNormal_12); + } + + ui->buttonBackUpDir->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonBackUpDir->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonBackUpDir->objectName())); + + //四个按钮样式表一样 + ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + + ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + + ui->buttonOk->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()),12); + + ui->buttonCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12); +} + +//初始化 +void PatternSelectWidget::initialize() +{ + m_firstFilePath.clear(); + m_curFilePath.clear(); + m_fileItemList.clear(); + + m_curPages = 1;//花样选择界面当前页数 + m_pageNums = 1;//总页数 + m_selectedPattenIdx = -1;//被选中的花版号 + + initPattern(); +} + +//初始化花样 +void PatternSelectWidget::initPattern() +{ + //花样文件目录 + QDir apppath(qApp->applicationDirPath()); + QString filePath = apppath.path() + apppath.separator() + PATTERNPATH; + m_firstFilePath = QDir(filePath).absolutePath();//为了将"\"变为"/" + getDirPatternFiles(m_firstFilePath); +} + +//获取花样文件下的路径或者花样 +void PatternSelectWidget::getDirPatternFiles(QString dirPath) +{ + m_curFilePath = dirPath;//记录当前目录 + if(m_curFilePath == m_firstFilePath)//如果当前目录为一级目录 + { + ui->buttonBackUpDir->setEnabled(false);//设置按钮不可按(返回上级目录按钮) + } + else + { + ui->buttonBackUpDir->setEnabled(true);//设置按钮可按(返回上级目录按钮) + } + + createCurDirPatterns(); +} +//刷新界面显示 +void PatternSelectWidget::refreshPageUi() +{ + int itemNum; + if (m_fileItemList.size() <= 0) + { + itemNum = 0; + + for (int i = 0; i < m_itemPerPage; i++) + { + m_imageButtonList.at(i)->hide(); + } + ui->labelPageNum->setText(tr("PageNum: 0/0"));//页数: 0/0 + ui->buttonPgUp->setEnabled(false); + ui->buttonPgDn->setEnabled(false); + ui->buttonOk->setEnabled(false); + + clearFileInfo(); + return; + } + else + { + itemNum = m_fileItemList.size(); + } + + m_pageNums = (itemNum + m_itemPerPage - 1)/m_itemPerPage;// 计算页数 + if (m_curPages > m_pageNums)// 当前页 + { + m_curPages = m_pageNums; + } + if (m_curPages <= 1) + { + m_curPages = 1; + } + + int itemidx = (m_curPages - 1) * m_itemPerPage; + + for (int i = 0; i < m_itemPerPage; i++) + { + if (itemidx < itemNum) + { + QImage image = m_fileItemList.at(itemidx).getPreviewImage(); + m_imageButtonList[i]->setPreviewImage(image); + m_imageButtonList[i]->setLabelName(m_fileItemList.at(itemidx).getShowInfo()); + m_imageButtonList.at(i)->show(); + + itemidx++; + } + else + { + m_imageButtonList.at(i)->hide(); + } + } + + // 翻页按钮 + if (m_curPages <= 1) + { + ui->buttonPgUp->setEnabled(false); + } + else + { + ui->buttonPgUp->setEnabled(true); + } + if (m_curPages >= m_pageNums) + { + ui->buttonPgDn->setEnabled(false); + } + else + { + ui->buttonPgDn->setEnabled(true); + } + + // 页信息 + if(m_pageNums == 0) + { + m_curPages = 0; + } + + // 页信息 + QString str = tr("pageNum: ") + QString("%1/%2").arg(m_curPages).arg(m_pageNums);//页数: + ui->labelPageNum->setText(str); + + //refreshCheckedPage(); + refreshChecked(); +} + +//刷新条目选中状态 +void PatternSelectWidget::refreshCheckedPage() +{ + int num =m_fileItemList.size(); + if (num <= m_selectedPattenIdx)//没有花版 num = 0 + { + m_selectedPattenIdx = -1; + } + + if(m_selectedPattenIdx == -1)//被选中的花版号初始化的时候就是-1 + { + clearFileInfo();//清空花样信息 + ui->buttonOk->setEnabled(false); + } + else + { + ui->buttonOk->setEnabled(true); + } + + // 刷新页面中被选择的条目 + for(int var = 0; var < m_itemPerPage; var++)//var < 花样选择界面每页图片数 + { + int idx = (m_curPages - 1) * (m_itemPerPage) + var; + if(m_selectedPattenIdx == idx)//选中的花版号等于 idx + { + QString filePath = m_fileItemList.at(m_selectedPattenIdx).getFilePath();//m_fileItemList 花样列表,从0开始 + QFileInfo file(filePath); + if(file.isDir())//为文件夹 + { + m_selectedPattenIdx = -1; + getDirPatternFiles(filePath); + return; + } + + //所选文件 + QString ext = file.suffix().toUpper(); + getFileInfo(filePath,ext);//获取花样信息 + + // 条目被选中 + m_imageButtonList.at(var)->setCheckable(true); + m_imageButtonList.at(var)->setChecked(true); + } + else + { + // 不被选中 + m_imageButtonList.at(var)->setChecked(false); + m_imageButtonList.at(var)->setCheckable(false); + } + } +} + +void PatternSelectWidget::refreshChecked() +{ + int num =m_fileItemList.size(); + if (num <= m_selectedPattenIdx)//没有花版 num = 0 + { + m_selectedPattenIdx = -1; + } + + if(m_selectedPattenIdx == -1)//被选中的花版号初始化的时候就是-1 + { + clearFileInfo();//清空花样信息 + ui->buttonOk->setEnabled(false); + } + else + { + ui->buttonOk->setEnabled(true); + } + + // 刷新页面中被选择的条目 + for(int var = 0; var < m_itemPerPage; var++)//var < 花样选择界面每页图片数 + { + int idx = (m_curPages - 1) * (m_itemPerPage) + var; + if(m_selectedPattenIdx == idx)//选中的花版号等于 idx + { + QString filePath = m_fileItemList.at(m_selectedPattenIdx).getFilePath();//m_fileItemList 花样列表,从0开始 + QFileInfo file(filePath); + if(file.isDir())//为文件夹 + { + m_selectedPattenIdx = -1; + getDirPatternFiles(filePath); + return; + } + + // 条目被选中 + m_imageButtonList.at(var)->setCheckable(true); + m_imageButtonList.at(var)->setChecked(true); + } + else + { + // 不被选中 + m_imageButtonList.at(var)->setChecked(false); + m_imageButtonList.at(var)->setCheckable(false); + } + } +} + +//点击花样图片 +void PatternSelectWidget::clickItem(int idx) +{ + if(m_fileItemList.size() <= 0) + { + return; + } + m_selectedPattenIdx = (m_curPages - 1) * m_itemPerPage + idx - 1; + refreshCheckedPage(); +} + +//清空花样信息 +void PatternSelectWidget::clearFileInfo() +{ + ui->labelPatternHeightValue->clear(); + ui->labelPatternNameValue->clear(); + ui->labelPatternWidthValue->clear(); + ui->labelTotalNeedleValue->clear(); + ui->labelXValue->clear(); + ui->labelYValue->clear(); +} + +//获取花样信息 +void PatternSelectWidget::getFileInfo(QString filePath, QString suffix) +{ + QFileInfo file(filePath); + QString fileName = file.fileName(); + int size = fileName.length(); + if(size > NAMEMAXLENGTH)//花样名称过长时截取 + { + fileName = fileName.mid(0,NAMEMAXLENGTH) + "~"; + } + + if(suffix == "DST")//dst文件 + { + //qDebug()<<"dst click begin"; + + DataFileDst dst; + dst.initFile(filePath); + + //qDebug()<<"dst.convertDataToAbs() begin"; + dst.convertDataToAbs(); + //qDebug()<<"dst.convertDataToAbs() end"; + + ui->labelPatternNameValue->setText(fileName); + ui->labelTotalNeedleValue->setText(QString::number(dst.getStitchNums())); + + double width = dst.getDatWidth()*0.01; + ui->labelPatternWidthValue->setText(QString("%1").arg(width)); + + double height = dst.getDatHeight()*0.01; + ui->labelPatternHeightValue->setText(QString("%1").arg(height)); + + double maxX = dst.getMaxX()*0.01; + double minX = dst.getMinX()*0.01; + ui->labelXValue->setText(QString("(%1,%2)").arg(maxX).arg(minX)); + + double maxY = dst.getMaxY()*0.01; + double minY = dst.getMinY()*0.01; + ui->labelYValue->setText(QString("(%1,%2)").arg(maxY).arg(minY)); + + //qDebug()<<"showfileinfo end"; + } + else if(suffix == "DSR")//dsr文件 + { + // + DataFileDsr dsr; + dsr.initFile(filePath); + dsr.convertDataToEmbAbs(); + ui->labelPatternNameValue->setText(fileName); + ui->labelTotalNeedleValue->setText(QString::number(dsr.getStitchNums())); + + double width = dsr.getDatWidth()*0.01; + ui->labelPatternWidthValue->setText(QString("%1").arg(width)); + + double height = dsr.getDatHeight()*0.01; + ui->labelPatternHeightValue->setText(QString("%1").arg(height)); + + double maxX = dsr.getMaxX()*0.01; + double minX = dsr.getMinX()*0.01; + ui->labelXValue->setText(QString("(%1,%2)").arg(maxX).arg(minX)); + + double maxY = dsr.getMaxY()*0.01; + double minY = dsr.getMinY()*0.01; + ui->labelYValue->setText(QString("(%1,%2)").arg(maxY).arg(minY)); + } + else if(suffix == "QUI") + { + DataFileQui qui; + qui.initFile(filePath); + qui.convertDataToEmbAbs(); + + ui->labelPatternNameValue->setText(fileName); + ui->labelTotalNeedleValue->setText(QString::number(qui.getStitchNums())); + + double width = qui.getDatWidth()*0.01; + ui->labelPatternWidthValue->setText(QString("%1").arg(width)); + + double height = qui.getDatHeight()*0.01; + ui->labelPatternHeightValue->setText(QString("%1").arg(height)); + + double maxX = qui.getMaxX()*0.01; + double minX = qui.getMinX()*0.01; + ui->labelXValue->setText(QString("(%1,%2)").arg(maxX).arg(minX)); + + double maxY = qui.getMaxY()*0.01; + double minY = qui.getMinY()*0.01; + ui->labelYValue->setText(QString("(%1,%2)").arg(maxY).arg(minY)); + } + else if(suffix == "QUIX") + { + DataFileQuix quix; + quix.initFile(filePath); + quix.convertDataToEmbAbs(); + + ui->labelPatternNameValue->setText(fileName); + ui->labelTotalNeedleValue->setText(QString::number(quix.getStitchNums())); + + double width = quix.getDatWidth()*0.01; + ui->labelPatternWidthValue->setText(QString("%1").arg(width)); + + double height = quix.getDatHeight()*0.01; + ui->labelPatternHeightValue->setText(QString("%1").arg(height)); + + double maxX = quix.getMaxX()*0.01; + double minX = quix.getMinX()*0.01; + ui->labelXValue->setText(QString("(%1,%2)").arg(maxX).arg(minX)); + + double maxY = quix.getMaxY()*0.01; + double minY = quix.getMinY()*0.01; + ui->labelYValue->setText(QString("(%1,%2)").arg(maxY).arg(minY)); + } + else if(suffix == "PLT") + { + } + else if(suffix == "DXF") + { + } + + //qDebug()<<"get patternpara begin"; +} + +//设置类型图标 +void PatternSelectWidget::setTypeLogo(QString tStyle) +{ + ui->buttonTypeLogo->setUnPreBtnLogo(tStyle); +} + +//设置主title +void PatternSelectWidget::setMainTitle(QString str) +{ + ui->labelMainTitle->setText(str); +} + +//设置副title +void PatternSelectWidget::setSubTitle(QString str) +{ + ui->labelSubTitle->setText(str); +} + +//生成当前路径花样 +void PatternSelectWidget::createCurDirPatterns() +{ + m_fileItemList.clear(); + QDir dir(m_curFilePath); + + // 打开文件所在的路径 + if(!dir.exists()) + { + m_curPages = 0; + m_pageNums = 0; + qDebug() << "dirpath not exist, name=" << m_curFilePath; + + dir.mkdir(m_curFilePath);//创建花样文件夹 + } + + QString fileName; + QString filePath; + FileItem item; + + dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); // 设置类型过滤器,只为文件夹和文件格式 + dir.setSorting(QDir::DirsFirst | QDir::IgnoreCase); // 设置排序方式 + + QFileInfoList fileList = dir.entryInfoList(); + int count = fileList.count(); + + for(int i = 0; i < count; i++) + { + QImage image(QSize(ui->buttonImage1->labelImage->width(), ui->buttonImage1->labelImage->height()), IMAGE_TYPE); + QFileInfo fileInfo = fileList[i]; + + if(fileInfo.isDir())//为文件夹 + { + filePath = fileInfo.absoluteFilePath(); + fileName = fileInfo.baseName(); + //QString imageName = ":/images/folder.png"; + image.load(":/images/folderBig.png"); + item.setFileInfo(filePath,fileName,image); + m_fileItemList.append(item); + } + else//为文件 + { + filePath = fileInfo.absoluteFilePath(); + fileName = fileInfo.fileName(); + QString imageName = filePath + ".preview.png"; + QFile imageFile(imageName); + + if(fileInfo.suffix().toUpper() == "DST" && g_emMacType != MACHINE_FIVEHEADPRECISIONSEWING)//为dst文件 + { + if(!imageFile.exists())//图片不存在时生成图片 + { + DataFileDst dst; + //重新改变图片大小,因为文件夹的图标大小与图片大小不同 + dst.initFile(filePath); + dst.createPreviewImage(&image, 1, PEN_WIDTH);// 生成预览文件 + } + else + { + image.load(imageName); + } + item.setFileInfo(filePath,fileName,image); + m_fileItemList.append(item); + } + else if(fileInfo.suffix().toUpper() == "DSR")//dsr文件 + { + if(!imageFile.exists())//图片不存在时生成图片 + { + DataFileDsr dsr; + dsr.initFile(filePath); + dsr.createPreviewImage(&image, 1, PEN_WIDTH);// 生成预览文件 + } + else + { + image.load(imageName); + } + item.setFileInfo(filePath,fileName,image); + m_fileItemList.append(item); + } + else if(fileInfo.suffix().toUpper() == "QUI" && g_emMacType != MACHINE_FIVEHEADPRECISIONSEWING) + { + if(!imageFile.exists())//图片不存在时生成图片 + { + DataFileQui qui; + qui.initFile(filePath); + qui.createPreviewImage(&image, 1, PEN_WIDTH);// 生成预览文件 + } + else + { + image.load(imageName); + } + item.setFileInfo(filePath,fileName,image); + m_fileItemList.append(item); + } + else if(fileInfo.suffix().toUpper() == "QUIX" && g_emMacType != MACHINE_FIVEHEADPRECISIONSEWING) + { + if(!imageFile.exists())//图片不存在时生成图片 + { + DataFileQuix quix; + quix.initFile(filePath); + quix.createPreviewImage(&image, 1, PEN_WIDTH);// 生成预览文件 + } + else + { + image.load(imageName); + } + item.setFileInfo(filePath,fileName,image); + m_fileItemList.append(item); + } + else if(fileInfo.suffix().toUpper() == "PLT" && g_emMacType != MACHINE_FIVEHEADPRECISIONSEWING) + { + if(!imageFile.exists())//图片不存在时生成图片 + { + ImportHPGL importHPGL; + //判断是否为加密文件 + if (importHPGL.IsSecretFile(filePath) == true) + { + // 文件路径 + QDir apppath(qApp->applicationDirPath()); + QString strSecretFile = apppath.path() + apppath.separator() + "Secret.plt"; + + importHPGL.BitMapDtat(filePath,strSecretFile); + importHPGL.IniPara(); + importHPGL.ReadSecretFile(strSecretFile); + } + else + { + importHPGL.IniPara(); + importHPGL.Read(filePath); + } + importHPGL.createPreviewImage(&image, 1, PEN_WIDTH);// 生成预览文件 + } + else + { + image.load(imageName); + } + item.setFileInfo(filePath,fileName,image); + m_fileItemList.append(item); + } + else if(fileInfo.suffix().toUpper() == "DXF" && g_emMacType != MACHINE_FIVEHEADPRECISIONSEWING) + { + } + } + } + + refreshPageUi(); + refreshChecked(); +} + +//获取绘图区域大小 +QSize PatternSelectWidget::getImageSize() +{ + QSize size = ui->buttonImage1->labelImage->size(); + return size; +} + +void PatternSelectWidget::on_buttonImage1_clicked() +{ + clickItem(1); +} + +void PatternSelectWidget::on_buttonImage2_clicked() +{ + clickItem(2); +} + +void PatternSelectWidget::on_buttonImage3_clicked() +{ + clickItem(3); +} + +void PatternSelectWidget::on_buttonImage4_clicked() +{ + clickItem(4); +} + +void PatternSelectWidget::on_buttonImage5_clicked() +{ + clickItem(5); +} + +void PatternSelectWidget::on_buttonImage6_clicked() +{ + clickItem(6); +} + +void PatternSelectWidget::on_buttonImage7_clicked() +{ + clickItem(7); +} + +void PatternSelectWidget::on_buttonImage8_clicked() +{ + clickItem(8); +} + +void PatternSelectWidget::on_buttonImage9_clicked() +{ + clickItem(9); +} + +void PatternSelectWidget::on_buttonImage10_clicked() +{ + clickItem(10); +} + +void PatternSelectWidget::on_buttonBackUpDir_clicked() +{ + if(m_curFilePath.size() <= 0) + { + return; + } + + QDir dir(m_curFilePath); + dir.cdUp();//返回上级目录 + QString path = dir.absolutePath();//得到上级目录 + m_fileItemList.clear(); + m_selectedPattenIdx = -1; + getDirPatternFiles(path);//打开上级目录 +} + +void PatternSelectWidget::on_buttonPgUp_clicked() +{ + m_curPages--; + refreshPageUi(); +} + +void PatternSelectWidget::on_buttonPgDn_clicked() +{ + m_curPages++; + refreshPageUi(); +} + +void PatternSelectWidget::on_buttonOk_clicked() +{ + if(m_selectedPattenIdx < 0) + { + return; + } + + int patternNeedles = ui->labelTotalNeedleValue->text().toInt(); + if(patternNeedles > EMBALLOWNEEDLELIMIT)//大于200万针 + { + PromptDialog promptDlg(this); + promptDlg.initDialog(PromptDialog::BTN_OK); + promptDlg.setTitleStr(tr("Prompt")); + + QString str; + //所选花样针数已达上限(200万针),不可绣作! + str = tr("The number of stitches of the selected pattern has reached the upper limit (2 million stitches), and it cannot be embroidered!"); + promptDlg.setContentStr(str); + + promptDlg.exec(); + return; + } + emit siSelectPattern(m_fileItemList.at(m_selectedPattenIdx).getFilePath()); + + //this->hide(); +} + +void PatternSelectWidget::on_buttonCancel_clicked() +{ + this->hide(); +} + +void PatternSelectWidget::mousePressEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + m_mousePressX = e->x(); + m_mousePressY = e->y(); + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; + } +} + +void PatternSelectWidget::mouseReleaseEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + m_mouseReleaseX = e->x(); + m_mouseReleaseY = e->y(); + } + + int width = this->width(); + int height = this->height(); + if ((m_mousePressX >= 0 && m_mousePressX <= 100) && + ((m_mousePressY >= (height - 100)) && m_mousePressY <= height) && + ((m_mouseReleaseX >= (width - 100)) && m_mouseReleaseX <= width) && + ((m_mouseReleaseY >= (height - 100)) && m_mouseReleaseY <= height)) + { + MainWidgetFunction mainFunction; + QString usbPath;//优盘路径 + usbPath = mainFunction.detectUsb();//优盘检测 + if(usbPath.length() <= 0) + { + //优盘不存在 + return; + } + else + { + QPixmap pixmap=QPixmap::grabWindow(this->winId(),0,0,this->width(),this->height());//截屏存放在pixmap + QString name_pc = usbPath + "EMB" + // + QDateTime::currentDateTime().toString("yyyyMMdd") +//获取时期时间 + +"_"+ + QDateTime::currentDateTime().toString("hhmmss") + ".png"; + + pixmap.save(name_pc,"png"); // 路径 + } + } + + m_mousePressX = 0; + m_mousePressY = 0; + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; +} diff --git a/sharedviews/patternselectwidget.h b/sharedviews/patternselectwidget.h new file mode 100644 index 0000000..c42122d --- /dev/null +++ b/sharedviews/patternselectwidget.h @@ -0,0 +1,115 @@ +#ifndef PATTERNSELECTWIDGET_H +#define PATTERNSELECTWIDGET_H + +#include +#include +#include +#include + +#include "mybutton.h" +#include "items/fileitem.h" +#include "setcontrolstyle.h" +//#include "Include/datafiledst.h" +//#include "Include/datafilecomb.h" +//#include "Include/embdata.h" +#include "datafile/datafiledst.h" +#include "datafile/datafiledsr.h" +#include "datafile/datafilequi.h" +#include "datafile/datafilequix.h" +#include "datafile/hpgl/importhpgl.h" +#include "promptdialog.h" +#include +#include +#include "mctype/mainwidgetfunction.h" + +#define EMBALLOWNEEDLELIMIT 2000000 //绣作允许最大针数上限 + +namespace Ui { +class PatternSelectWidget; +} + +class PatternSelectWidget : public QWidget +{ + Q_OBJECT + +public: + explicit PatternSelectWidget(QWidget *parent = 0); + ~PatternSelectWidget(); + +private: + Ui::PatternSelectWidget *ui; + int m_itemPerPage;//花样选择界面每页图片数 + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006(); + void initControlStyle();//初始化窗体控件样式 + +private: + QString m_firstFilePath;//文件一级目录 + QString m_curFilePath;//当前选择目录 + QList m_fileItemList;//花样选择界面花样文件列表 + + int m_curPages;//花样选择界面当前页数 + int m_pageNums;//总页数 + int m_selectedPattenIdx;//被选中的花版号 + + QList m_imageButtonList; + +private: + void initialize();//初始化 + void initPattern();//初始化花样 + void getDirPatternFiles(QString dirPath);//获取路径下的花样 + void refreshPageUi();//刷新界面显示 + void refreshCheckedPage();//刷新条目选中状态 + void refreshChecked();//刷新条目选中状态 + void clickItem(int idx);//点击花样图片 + void clearFileInfo();//清空花样信息 + void getFileInfo(QString filePath, QString suffix);//获取花样信息 + +public: + void setTypeLogo(QString tStyle);//设置类型图标 + void setMainTitle(QString str);//设置主title + void setSubTitle(QString str);//设置副title + void createCurDirPatterns();//生成当前路径花样 + +public: + QSize getImageSize();//获取绘图区域大小 + +private slots: + //点击图片按钮事件 + void on_buttonImage1_clicked(); + void on_buttonImage2_clicked(); + void on_buttonImage3_clicked(); + void on_buttonImage4_clicked(); + void on_buttonImage5_clicked(); + void on_buttonImage6_clicked(); + void on_buttonImage7_clicked(); + void on_buttonImage8_clicked(); + void on_buttonImage9_clicked(); + void on_buttonImage10_clicked(); + void on_buttonBackUpDir_clicked(); + void on_buttonPgUp_clicked(); + void on_buttonPgDn_clicked(); + void on_buttonOk_clicked(); + void on_buttonCancel_clicked(); + +signals: + void siSelectPattern(QString filePath, s16 showFlag = 0);//选择花样并点击确定按钮 + void siPatchPattern(QString filePath,s16 showFlag = 0);//贴补绣花样并点击确定按钮 + + //鼠标事件 + protected: + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + + private: + int m_mousePressX; + int m_mousePressY; + int m_mouseReleaseX; + int m_mouseReleaseY; + +}; + +#endif // PATTERNSELECTWIDGET_H diff --git a/sharedviews/patternselectwidget.ui b/sharedviews/patternselectwidget.ui new file mode 100644 index 0000000..44a2a19 --- /dev/null +++ b/sharedviews/patternselectwidget.ui @@ -0,0 +1,648 @@ + + + PatternSelectWidget + + + + 0 + 0 + 1024 + 600 + + + + Form + + + background-color: rgb(162, 162, 162); + + + + + 0 + 90 + 791 + 431 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 10 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 10 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + 270 + 10 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + 400 + 10 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + 530 + 10 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + 10 + 196 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + 530 + 196 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + 400 + 196 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + 270 + 196 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 196 + 120 + 120 + + + + Qt::NoFocus + + + + + + + + + + + + + 710 + 540 + 301 + 60 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 10 + 64 + 40 + + + + Qt::NoFocus + + + + + + + + + 80 + 10 + 64 + 40 + + + + Qt::NoFocus + + + + + + + + + 150 + 10 + 64 + 40 + + + + Qt::NoFocus + + + + + + + + + 220 + 10 + 64 + 40 + + + + Qt::NoFocus + + + + + + + + + + 800 + 90 + 222 + 191 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 10 + 110 + 16 + + + + Name: + + + + + + 10 + 30 + 110 + 16 + + + + N + + + + + + 10 + 90 + 110 + 16 + + + + H + + + + + + 10 + 70 + 110 + 16 + + + + W + + + + + + 10 + 110 + 110 + 16 + + + + X + + + + + + 10 + 130 + 110 + 16 + + + + Y + + + + + + 130 + 70 + 84 + 16 + + + + Width + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 130 + 130 + 84 + 16 + + + + Y + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 130 + 30 + 84 + 16 + + + + NeedleNum + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 130 + 110 + 84 + 16 + + + + X + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 130 + 10 + 84 + 16 + + + + Name + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 130 + 90 + 84 + 16 + + + + Height + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0 + 0 + 1024 + 600 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 20 + 10 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + + + + 100 + 10 + 181 + 21 + + + + + + + Pattern Select + + + + + + 130 + 40 + 181 + 21 + + + + + + + Pattern Select < Pattern Setting + + + + + + 629 + 20 + 381 + 61 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 300 + 20 + 64 + 40 + + + + Qt::NoFocus + + + + + + + + + + 20 + 560 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + PageNums: 0/0 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + frameBack + frameImage + framePageBtn + frameInfo1 + buttonTypeLogo + labelMainTitle + labelSubTitle + frameRightUp + labelPageNum + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/promptdialog.cpp b/sharedviews/promptdialog.cpp new file mode 100644 index 0000000..4ce8acf --- /dev/null +++ b/sharedviews/promptdialog.cpp @@ -0,0 +1,1067 @@ +#include "promptdialog.h" +#include "ui_promptdialog.h" + +PromptDialog::PromptDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::PromptDialog) +{ + ui->setupUi(this); + + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + + setAttribute(Qt::WA_TranslucentBackground, true); + connect(g_pMachine, SIGNAL(siMcInfoChange()), this, SLOT(slotMCInfoChange())); + + initDialog(); + initControl(); +} + +PromptDialog::~PromptDialog() +{ + delete ui; +} + +//初始化窗体 +void PromptDialog::initDialog(int sel) +{ + m_funType = sel; + m_filePath.clear(); + + m_spindleAngle = 0;//主轴旋转角度值 + m_area = 0; + + setTitleStr(""); + setContentStr(""); + setContentProcessStr(""); + ui->frameProcess->hide(); + ui->labelContentInfo->setText(""); + ui->labeBreakHead->setText(""); + ui->frameTwo->hide(); + ui->frameThree->hide(); + ui->frameProcessBtn->hide(); + + ui->buttonOk->setEnabled(true); + + //蓝色 + buttonStyle1 = "QPushButton{outline: none;color:rgb(10,10,10);background-color:rgb(0,151,226);border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;}"; + //白色 + buttonStyle2 = "QPushButton{outline: none;color:rgb(10,10,10);background-color:rgb(250,250,250);border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;}"; + if (sel == BTN_OK_CANCEL)//确定、取消 + { + ui->frameTwo->show(); + ui->frameThree->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->frameDetecBtn->hide(); + ui->buttonOk->show(); + ui->buttonCancel->show(); + ui->buttonForward->hide();//隐藏正转按钮 + ui->buttonReverse->hide();//隐藏反转按钮 + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameSpindleRotate->hide(); + ui->frameWorkArea->hide(); + + ui->buttonOk->move(m_btnOkPoint); + ui->buttonCancel->move(m_btnCancelPoint); + } + else if (sel == BTN_OK)//确定 + { + ui->frameTwo->show(); + ui->frameThree->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->frameDetecBtn->hide(); + ui->buttonOk->show(); + ui->buttonCancel->hide(); + ui->buttonForward->hide();//隐藏正转按钮 + ui->buttonReverse->hide();//隐藏反转按钮 + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameSpindleRotate->hide(); + ui->frameWorkArea->hide(); + + ui->buttonOk->move(m_btnCancelPoint); + } + else if (sel == BTN_R_R_S)//重命名、替换、跳过 + { + ui->frameTwo->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->frameDetecBtn->hide(); + ui->frameThree->show(); + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameSpindleRotate->hide(); + ui->frameWorkArea->hide(); + } + else if (sel == BTN_RESTART)//重启 + { + ui->frameTwo->hide(); + ui->frameThree->hide(); + ui->frameWarrantBtn->hide(); + ui->frameDetecBtn->hide(); + ui->frameProcessBtn->show(); + ui->buttonRestart->show(); + ui->buttonUpdataCancel->hide(); + ui->buttonRestart->move(m_btnCancelPoint); + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameSpindleRotate->hide(); + ui->frameWorkArea->hide(); + } + else if (sel == BTN_UCANCEL)//升级取消 + { + ui->frameTwo->hide(); + ui->frameThree->hide(); + ui->frameWarrantBtn->hide(); + ui->frameDetecBtn->hide(); + ui->frameProcessBtn->show(); + ui->buttonRestart->hide(); + ui->buttonUpdataCancel->show(); + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameSpindleRotate->hide(); + ui->frameWorkArea->hide(); + } + else if (sel == BTN_WARRANT)//授权按钮 + { + ui->frameTwo->hide(); + ui->frameThree->hide(); + ui->frameDetecBtn->hide(); + ui->frameProcessBtn->hide(); + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameSpindleRotate->hide(); + ui->frameWarrantBtn->show(); + ui->frameWorkArea->hide(); + } + // 底线检测,面线检测 + else if(sel == BTN_BOTTOM || sel == BTN_FACE) + { + ui->frameDetecBtn->show(); + ui->frameTwo->hide(); + ui->frameThree->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->frameProcess->hide(); + ui->labelContentInfo->hide(); + ui->labeBreakHead->hide(); + ui->labelContentProcess->hide(); + ui->labelContentWarrant->hide(); + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameSpindleRotate->hide(); + ui->frameWorkArea->hide(); + } + else if(sel == BTN_NONE)//无按钮 + { + ui->frameTwo->hide(); + ui->frameThree->hide(); + ui->frameDetecBtn->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->frameProcess->hide(); + ui->labelContentInfo->hide(); + ui->labeBreakHead->hide(); + ui->labelContentProcess->hide(); + ui->labelContentWarrant->hide(); + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameSpindleRotate->hide(); + ui->frameWorkArea->hide(); + } + else if(sel == BTN_P_NONE)//无按钮 + { + ui->frameTwo->hide(); + ui->frameThree->hide(); + ui->frameDetecBtn->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->labelContentInfo->hide(); + ui->labeBreakHead->hide(); + ui->labelContentWarrant->hide(); + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameSpindleRotate->hide(); + ui->frameWorkArea->hide(); + } + else if(sel == BTN_HMI_DECRYPT)//界面解密 + { + ui->frameThree->hide(); + ui->frameDetecBtn->hide(); + ui->frameProcess->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->labelContentInfo->hide(); + ui->labeBreakHead->hide(); + ui->labelContentWarrant->hide(); + ui->frameSpindleRotate->hide(); + ui->frameHMIDecrypt->show(); + ui->frameChangePassword->hide(); + ui->frameTwo->show(); + ui->frameWorkArea->hide(); + + ui->buttonOk->show(); + ui->buttonCancel->show(); + ui->buttonForward->hide();//隐藏正转按钮 + ui->buttonReverse->hide();//隐藏反转按钮 + + ui->buttonOk->move(m_btnOkPoint); + ui->buttonCancel->move(m_btnCancelPoint); + } + else if(sel == BTN_CHANGE_PASSWORD)//修改一级密码 + { + ui->frameThree->hide(); + ui->frameDetecBtn->hide(); + ui->frameProcess->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->labelContentInfo->hide(); + ui->labeBreakHead->hide(); + ui->labelContentWarrant->hide(); + ui->frameSpindleRotate->hide(); + ui->frameHMIDecrypt->hide();//界面解密隐藏 + ui->frameChangePassword->show(); + ui->frameWorkArea->hide(); + + ui->frameTwo->show(); + ui->buttonOk->show(); + ui->buttonCancel->show(); + ui->buttonForward->hide();//隐藏正转按钮 + ui->buttonReverse->hide();//隐藏反转按钮 + + ui->buttonOk->move(m_btnOkPoint); + ui->buttonCancel->move(m_btnCancelPoint); + } + else if(sel == BTN_SPINDLE_ROTATE)//主轴旋转角度 + { + ui->frameSpindleRotate->show(); + ui->buttonSpindleAngleValue->setText("0.00"); + ui->frameThree->hide(); + ui->frameDetecBtn->hide(); + ui->frameProcess->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->labelContentInfo->hide(); + ui->labeBreakHead->hide(); + ui->labelContentWarrant->hide(); + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameTwo->show(); + ui->frameWorkArea->hide(); + + ui->buttonOk->show(); + ui->buttonCancel->show(); + ui->buttonForward->show();//显示正转按钮 + ui->buttonReverse->show();//显示反转按钮 + + ui->buttonOk->move(m_btnOkPoint); + ui->buttonCancel->move(m_btnCancelPoint); + } + else if(sel == BTN_WORK_AREA)//设置可工作区域 + { + ui->frameWorkArea->show(); + + ui->buttonX1->setText(tr("X +")); + ui->buttonX2->setText(tr("X -")); + ui->buttonY1->setText(tr("Y +")); + ui->buttonY2->setText(tr("Y -")); + + ui->frameSpindleRotate->hide(); + ui->frameThree->hide(); + ui->frameDetecBtn->hide(); + ui->frameProcess->hide(); + ui->frameProcessBtn->hide(); + ui->frameWarrantBtn->hide(); + ui->labelContentInfo->hide(); + ui->labeBreakHead->hide(); + ui->labelContentWarrant->hide(); + ui->frameHMIDecrypt->hide(); + ui->frameChangePassword->hide(); + ui->frameTwo->show(); + + ui->buttonOk->show(); + ui->buttonCancel->show(); + ui->buttonForward->hide();//隐藏正转按钮 + ui->buttonReverse->hide();//隐藏反转按钮 + + + ui->buttonOk->move(m_btnOkPoint); + ui->buttonCancel->move(m_btnCancelPoint); + } +} + +//初始化窗体控件,包括位置、尺寸、样式 +void PromptDialog::initControl() +{ + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + initResolution1910(); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void PromptDialog::initResolution1910() +{ + double factoryX = 1.875; + double factoryY = 1.8; + //上状态栏 + this->resize(1024*factoryX,600*factoryY); + this->move((1920-this->width())/2,(1080-this->height())/2); + + ui->frameBack->setGeometry(0,0,1920,1080); + ui->labelTitle->setGeometry(265*factoryX ,150*factoryY,400*1.875,56*factoryY);//(20,-4,400,56) + ui->labelContent->setGeometry(291*factoryX ,194*factoryY,340*1.875,285*factoryY);//(46,40,340,285) + ui->labelContentInfo->setGeometry(291*factoryX ,194*factoryY,350*1.875,285*factoryY);//(46,40,350,285) + + ui->labeBreakHead->setGeometry(40*factoryX,40*factoryY,380*factoryX,285*factoryY); + ui->labelContentWarrant->setGeometry(302*factoryX,193*factoryY,300*factoryX,225*factoryY); + ui->frameProcess->setGeometry(145*factoryX,150*factoryY,800*factoryX,280*factoryY);//(20,70,480,130) + ui->labelContentProcess->setGeometry(150*factoryX,80*factoryY,398*factoryX,40*factoryY);//(10,10,398,40) + ui->progressBar->setGeometry(150*factoryX,120*factoryY,446*factoryX,26*factoryY);//进度条(10,50,446,26) + + ui->frameTwo->setGeometry(245*factoryX,379*factoryY,900*factoryX,500*factoryY);//(0,225,500,51) + ui->buttonForward->setGeometry(72*factoryX,0,96*factoryX,45*factoryY); + ui->buttonReverse->setGeometry(178*factoryX,0,96*factoryX,45*factoryY); + ui->buttonOk->setGeometry(284*factoryX,0,96*factoryX,45*factoryY);//(284,0,96,45) + ui->buttonCancel->setGeometry(390*factoryX,-1*factoryY,96*factoryX,45*factoryY);//(390,-1,96,45) + + m_btnOkPoint.setX(284*factoryX);//ok按钮位置(284) + m_btnOkPoint.setY(0); + m_btnCancelPoint.setX(390*factoryX);//cancel按钮位置(390) + m_btnCancelPoint.setY(1*factoryY); + + ui->frameProcessBtn->setGeometry(260*factoryX,385*factoryY,500*factoryX,51*factoryY);//传送文件中提示弹框中的X按钮 + ui->buttonRestart->setGeometry(284*factoryX,0,96*factoryX,45*factoryY); + ui->buttonUpdataCancel->setGeometry(390*factoryX,1*factoryY,96*factoryX,45*factoryY); + + ui->frameWarrantBtn->setGeometry(256*factoryX,388*factoryY,500*factoryX,51*factoryY);//授权 已修改 + ui->buttonWarrant->setGeometry(284*factoryX,0,96*factoryX,45*factoryY); + ui->buttonWarrantCancel->setGeometry(390*factoryX,1*factoryY,96*factoryX,45*factoryY); + + ui->frameWorkArea->setGeometry(40*factoryX,58*factoryY,440*factoryX,161*factoryY); + ui->buttonX1->setGeometry(170*factoryX,60*factoryY,70*factoryX,38*factoryY); + ui->buttonX2->setGeometry(10*factoryX,60*factoryY,70*factoryX,38*factoryY); + ui->buttonY1->setGeometry(90*factoryX,10*factoryY,70*factoryX,38*factoryY);//y+ + ui->buttonY2->setGeometry(90*factoryX,120*factoryY,70*factoryX,38*factoryY); + + //主轴角度旋转 + ui->frameSpindleRotate->setGeometry(30*factoryX,78*factoryY,440*factoryX,161*factoryY); + ui->labelSpindleAngle->setGeometry(0*factoryX,12*factoryY,120*factoryX,40*factoryY); + ui->buttonSpindleAngleValue->setGeometry(125*factoryX,10*factoryY,78*factoryX,40*factoryY); + ui->labelSpindleAngleUnit->setGeometry(214*factoryX,12*factoryY,91*factoryX,40*factoryY); + + //界面解密 + ui->frameHMIDecrypt->setGeometry(40*factoryX,78*factoryY,440*factoryX,161*factoryY); + ui->labelNetworkCardID->setGeometry(10*factoryX,12*factoryY,110*factoryX,40*factoryY); + ui->labelNetworkCardIDValue->setGeometry(130*factoryX,12*factoryY,200*factoryX,40*factoryY); + ui->labelHMIPassword->setGeometry(10*factoryX,52*factoryY,110*factoryX,40*factoryY); + ui->buttonHMIPassword->setGeometry(130*factoryX,50*factoryY,200*factoryX,40*factoryY); + ui->labelDecryptInfo->setGeometry(10*factoryX,92*factoryY,110*factoryX,40*factoryY); + ui->labelDecryptInfoValue->setGeometry(130*factoryX,92*factoryY,200*factoryX,40*factoryY); + + //修改一级密码 + ui->frameChangePassword->setGeometry(0,78*factoryY,440*factoryX,161*factoryY); + ui->labelNewPassword->setGeometry(0,0,140*factoryX,40*factoryY); + ui->buttonNewPassword->setGeometry(180*factoryX,0,200*factoryX,40*factoryY); + ui->labelConfirmPassword->setGeometry(0,52*factoryY,140*factoryX,40*factoryY); + ui->buttonConfirmPassword->setGeometry(180*factoryX,52*factoryY,200*factoryX,40*factoryY); + + ui->frameThree->setGeometry(280*factoryX,390*factoryY,500*factoryX,51*factoryY); + ui->buttonRename->setGeometry(187*factoryX,0,96*factoryX,45*factoryY); + ui->buttonReplace->setGeometry(289*factoryX,0,96*factoryX,45*factoryY); + ui->buttonSkip->setGeometry(390*factoryX,1*factoryY,96*factoryX,45*factoryY); + + ui->frameDetecBtn->setGeometry(280*factoryX,390*factoryY,500*factoryX,51*factoryY); + ui->buttonDetectBegin->setGeometry(187*factoryX,0,96*factoryX,45*factoryY); + ui->buttonDetectEnd->setGeometry(284*factoryX,0,96*factoryX,45*factoryY); + ui->buttonDetectClose->setGeometry(390*factoryX,1*factoryY,96*factoryX,45*factoryY); +} + +//初始化窗体控件为1024x600分辨率 +void PromptDialog::initResolution1006() +{ + //上状态栏 + this->resize(1024,600);//(508,304); + this->move((1024-this->width())/2,(600-this->height())/2); + + ui->frameBack->setGeometry(0,0,1024,600);//(0,0,508,304) + ui->labelTitle->setGeometry(265,150,400,56);//(20,-4,400,56) + ui->labelContent->setGeometry(291,194,340,285);//(46,40,340,285) + ui->labelContentInfo->setGeometry(291,194,350,285);//(46,40,350,285) + + ui->labeBreakHead->setGeometry(40,40,380,285); + ui->labelContentWarrant->setGeometry(302,193,300,225); + ui->frameProcess->setGeometry(145,150,800,280);//(20,70,480,130) + ui->labelContentProcess->setGeometry(150,80,398,40);//(10,10,398,40) + ui->progressBar->setGeometry(150,120,446,26);//进度条(10,50,446,26) + + ui->frameTwo->setGeometry(245,379,500,51);//(0,225,500,51) + ui->buttonForward->setGeometry(72,0,96,45); + ui->buttonReverse->setGeometry(178,0,96,45); + ui->buttonOk->setGeometry(284,0,96,45);//(284,0,96,45) + ui->buttonCancel->setGeometry(390,-1,96,45);//(390,-1,96,45) + m_btnOkPoint.setX(284);//ok按钮位置(284) + m_btnOkPoint.setY(0); + m_btnCancelPoint.setX(390);//cancel按钮位置(390) + m_btnCancelPoint.setY(1); + + ui->frameProcessBtn->setGeometry(260,385,500,51);//(0,235,500,51)传送文件中提示弹框中的X按钮 + ui->buttonRestart->setGeometry(284,0,96,45);//(284,0,96,45) + ui->buttonUpdataCancel->setGeometry(390,1,96,45);//(390,1,96,45) + + ui->frameWarrantBtn->setGeometry(256,388,500,51);//授权 已修改 + ui->buttonWarrant->setGeometry(284,0,96,45); + ui->buttonWarrantCancel->setGeometry(390,1,96,45); + + ui->frameWorkArea->setGeometry(40,58,440,161); + ui->buttonX1->setGeometry(170,60,70,38); + ui->buttonX2->setGeometry(10,60,70,38); + ui->buttonY1->setGeometry(90,10,70,38);//y+ + ui->buttonY2->setGeometry(90,120,70,38); + + //主轴角度旋转 + ui->frameSpindleRotate->setGeometry(30,78,440,161); + ui->labelSpindleAngle->setGeometry(0,12,120,40); + ui->buttonSpindleAngleValue->setGeometry(125,10,78,40); + ui->labelSpindleAngleUnit->setGeometry(214,12,91,40); + + //界面解密 + ui->frameHMIDecrypt->setGeometry(40,78,440,161); + ui->labelNetworkCardID->setGeometry(10,12,110,40); + ui->labelNetworkCardIDValue->setGeometry(130,12,200,40); + ui->labelHMIPassword->setGeometry(10,52,110,40); + ui->buttonHMIPassword->setGeometry(130,50,200,40); + ui->labelDecryptInfo->setGeometry(10,92,110,40); + ui->labelDecryptInfoValue->setGeometry(130,92,200,40); + + //修改一级密码 + ui->frameChangePassword->setGeometry(0,78,440,161); + ui->labelNewPassword->setGeometry(0,0,140,40); + ui->buttonNewPassword->setGeometry(180,0,200,40); + ui->labelConfirmPassword->setGeometry(0,52,140,40); + ui->buttonConfirmPassword->setGeometry(180,52,200,40); + + ui->frameThree->setGeometry(280,390,500,51); + ui->buttonRename->setGeometry(187,0,96,45); + ui->buttonReplace->setGeometry(289,0,96,45); + ui->buttonSkip->setGeometry(390,1,96,45); + + ui->frameDetecBtn->setGeometry(280,390,500,51); + ui->buttonDetectBegin->setGeometry(187,0,96,45); + ui->buttonDetectEnd->setGeometry(284,0,96,45); + ui->buttonDetectClose->setGeometry(390,1,96,45); +} + +//初始化窗体控件样式 +void PromptDialog::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //设置控件图标 + //背景图 + this->setStyleSheet(LABELWHITESTYLE); + ui->frameBack->setStyleSheet(TRANSPARENTSTYLE); + ui->frameBack->setStyleSheet(setControlStyle.getStyleSheet(this->objectName())); + ui->labelTitle->setStyleSheet(LABELBLACKSTYLE); + ui->labelTitle->setFont(fontNormal_1); + ui->labelTitle->setAlignment(Qt::AlignLeft); + ui->labelTitle->setAlignment(Qt::AlignVCenter); + + ui->frameProcess->setStyleSheet(TRANSPARENTSTYLE); + ui->progressBar->setFont(fontNormal_1); + + ui->labelContent->setStyleSheet(LABELWHITESTYLE); + ui->labelContent->setFont(fontNormal_1); + ui->labelContent->setAlignment(Qt::AlignLeft); + ui->labelContent->setAlignment(Qt::AlignVCenter); + + ui->labeBreakHead->setStyleSheet(LABELREDSTYLE); // 断线机头 红色 字体加大 -rq + ui->labeBreakHead->setFont(fontNormal_10); + ui->labeBreakHead->setAlignment(Qt::AlignLeft); + ui->labeBreakHead->setAlignment(Qt::AlignVCenter); + + ui->labelContentInfo->setStyleSheet(LABELWHITESTYLE); + ui->labelContentInfo->setFont(fontNormal_1); + ui->labelContentInfo->setAlignment(Qt::AlignLeft); + ui->labelContentInfo->setAlignment(Qt::AlignVCenter); + + ui->labelContentProcess->setStyleSheet(LABELNAVYBLUESTYLE); + ui->labelContentProcess->setFont(fontNormal_1); + ui->labelContentProcess->setAlignment(Qt::AlignLeft); + ui->labelContentProcess->setAlignment(Qt::AlignVCenter); + + ui->labelContentWarrant->setStyleSheet(LABELWHITESTYLE); + ui->labelContentWarrant->setFont(fontNormal_1); + ui->labelContentWarrant->setAlignment(Qt::AlignLeft); + ui->labelContentWarrant->setAlignment(Qt::AlignVCenter); + + ui->frameTwo->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonOk->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1")); + ui->buttonCancel->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1")); + ui->buttonForward->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonForward->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonForward->objectName())); + ui->buttonReverse->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonReverse->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonReverse->objectName())); + + ui->frameThree->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonRename->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonReplace->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonSkip->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonRename->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonRename->objectName())); + ui->buttonReplace->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonReplace->objectName())); + ui->buttonSkip->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonSkip->objectName())); + + ui->frameDetecBtn->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonDetectBegin->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonDetectBegin->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonDetectBegin->objectName())); + ui->buttonDetectEnd->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonDetectEnd->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonDetectEnd->objectName())); + ui->buttonDetectClose->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonDetectClose->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1")); + + ui->frameProcessBtn->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonRestart->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonRestart->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonRestart->objectName())); + ui->buttonUpdataCancel->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonUpdataCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1")); + + //设置可工作区域 + ui->frameWorkArea->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonX1->setFont(fontNormal_1); + ui->buttonX2->setFont(fontNormal_1); + ui->buttonY1->setFont(fontNormal_1); + ui->buttonY2->setFont(fontNormal_1); + + //主轴角度旋转 + ui->frameSpindleRotate->setStyleSheet(TRANSPARENTSTYLE); + ui->labelSpindleAngle->setStyleSheet(LABELWHITESTYLE); + ui->labelSpindleAngle->setFont(fontNormal_1); + ui->labelSpindleAngleUnit->setStyleSheet(LABELWHITESTYLE); + ui->labelSpindleAngleUnit->setFont(fontNormal_1); + ui->buttonSpindleAngleValue->setFont(fontNormal_1); + + //界面解密 + ui->frameHMIDecrypt->setStyleSheet(TRANSPARENTSTYLE); + ui->labelNetworkCardID->setStyleSheet(LABELWHITESTYLE); + ui->labelNetworkCardID->setFont(fontNormal_1); + ui->labelNetworkCardIDValue->setStyleSheet(LABELWHITESTYLE); + ui->labelNetworkCardIDValue->setFont(fontNormal_1); + ui->labelHMIPassword->setStyleSheet(LABELWHITESTYLE); + ui->labelHMIPassword->setFont(fontNormal_1); + ui->buttonHMIPassword->setFont(fontNormal_1); + ui->labelDecryptInfo->setStyleSheet(LABELWHITESTYLE); + ui->labelDecryptInfo->setFont(fontNormal_1); + ui->labelDecryptInfoValue->setStyleSheet(LABELWHITESTYLE); + ui->labelDecryptInfoValue->setFont(fontNormal_1); + + //修改一级密码 + ui->frameChangePassword->setStyleSheet(TRANSPARENTSTYLE); + ui->labelNewPassword->setStyleSheet(LABELWHITESTYLE); + ui->labelNewPassword->setFont(fontNormal_1); + ui->labelConfirmPassword->setStyleSheet(LABELWHITESTYLE); + ui->labelConfirmPassword->setFont(fontNormal_1); + ui->buttonNewPassword->setFont(fontNormal_1); + ui->buttonConfirmPassword->setFont(fontNormal_1); + + ui->frameWarrantBtn->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonWarrant->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonWarrant->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1")); + ui->buttonWarrantCancel->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn")); + ui->buttonWarrantCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1")); +} + +//设置标题 +void PromptDialog::setTitleStr(QString str) +{ + ui->labelTitle->setText(str); +} + +//设置断线机头字体颜色 +void PromptDialog::setStrColor(QString str) +{ + ui->frameProcess->hide(); + ui->labelContentInfo->setText(""); + ui->labelContentInfo->hide(); + ui->labelContentWarrant->setText(""); + ui->labelContentWarrant->hide(); + ui->labelContent->setText(""); + ui->labelContent->hide(); + ui->labeBreakHead->setText(str); + ui->labeBreakHead->show(); +} + +//设置显示内容 +void PromptDialog::setContentStr(QString str) +{ + ui->frameProcess->hide(); + ui->labelContentInfo->setText(""); + ui->labelContentInfo->hide(); + ui->labeBreakHead->setText("");//断线机头显示 + ui->labeBreakHead->hide(); + ui->labelContentWarrant->setText(""); + ui->labelContentWarrant->hide(); + ui->labelContent->setText(str); + ui->labelContent->show(); +} + +void PromptDialog::setContentProcessStr(QString str) +{ + ui->frameProcess->show(); + ui->labelContentInfo->setText(""); + ui->labelContentInfo->hide(); + ui->labeBreakHead->setText("");//断线机头显示 + ui->labeBreakHead->hide(); + ui->labelContent->setText(""); + ui->labelContent->hide(); + ui->labelContentWarrant->setText(""); + ui->labelContentWarrant->hide(); + ui->labelContentProcess->show(); + ui->labelContentProcess->setText(str); +} + +void PromptDialog::setContentInfoShow() +{ + ui->labelContent->hide(); + ui->labeBreakHead->hide(); + ui->frameProcess->hide(); + ui->labelContentWarrant->hide(); + ui->labelContentInfo->show(); + ui->labelContentInfo->raise(); +} + +void PromptDialog::setContentWarrantShow() +{ + ui->labelContent->hide(); + ui->labeBreakHead->hide(); + ui->frameProcess->hide(); + ui->labelContentInfo->hide(); + ui->labelContentWarrant->show(); +} + +void PromptDialog::setContentHMIDecryptShow(QString id) +{ + //将id中的冒号去掉 + QStringList strlist = id.split(":", QString::SkipEmptyParts); + QString nId; + nId.clear(); + for(int i = 0; i < strlist.size(); i++) + { + nId += strlist[i]; + } + ui->labelNetworkCardIDValue->setText(nId); + ui->buttonHMIPassword->setText(""); + + QDir apppath(qApp->applicationDirPath()); + QString HMIDecryptConfigfile; + HMIDecryptConfigfile = apppath.path() + apppath.separator() + "HMIDecryptConfig.ini"; + QSettings iniSetting(HMIDecryptConfigfile, QSettings::IniFormat); + int decryptFlag = iniSetting.value("HMIDecrypt/ifdecrypt").toInt(); + QFile iniFile(HMIDecryptConfigfile); + if(decryptFlag != 0 || !iniFile.exists())//等于1或者配置文件不存在 + { + ui->labelDecryptInfoValue->setText("HMI decrypted");//界面已解密 + } + else + { + ui->labelDecryptInfoValue->setText("HMI unresolved");//界面未解密 + } + + ui->buttonOk->setEnabled(false); +} + +void PromptDialog::setContentChangePasswordShow()//修改一级用户密码内容显示 +{ + ui->buttonNewPassword->setText(""); + ui->buttonConfirmPassword->setText(""); + ui->buttonOk->setEnabled(false); +} + +void PromptDialog::setValue(int progress) +{ + ui->progressBar->setValue(progress); +} + +void PromptDialog::setButtonUCancelStr(QString str) +{ + ui->buttonUpdataCancel->setText(str); +} + +void PromptDialog::setRange(int minimum, int maximum) +{ + ui->progressBar->setRange(minimum,maximum); +} + +QString PromptDialog::getNetworkCardID() +{ + return ui->labelNetworkCardIDValue->text(); +} + +QString PromptDialog::getInputPassword() +{ + return ui->buttonHMIPassword->text(); +} + +void PromptDialog::slotMCInfoChange() +{ + QString strInfo; + MCInfo info; + char softwareVerStr[32+1]; + char softwareTimeStr[32+1]; + + info = g_pMachine->getMcInfo(); + memcpy(softwareVerStr, info.softwareVerStr, 32); + memcpy(softwareTimeStr, info.buildInfoStr, 32); + softwareVerStr[32] = 0; + softwareTimeStr[32] = 0; + QString strBoardVer; + strBoardVer.sprintf("%s", softwareVerStr); + strInfo += tr("Board") + " " + strBoardVer + "\n"; + QString softwareBulid; + softwareBulid.sprintf("%s", softwareTimeStr); + + QString verInfo = "\n" + strInfo + "\r\n" + tr("Build Time:") + softwareBulid.right(softwareBulid.size() - 6);//编译时间: + ui->labelContentInfo->setText(verInfo); + + //连接多块主板也是从g_pMachine(第一块)获取软件授权信息 + MCStatus mcStatus; + mcStatus = g_pMachine->getMcStatus(); + + MCInfo infoID; + infoID = g_pMachine->getMcInfo(); + + QString IDStr(infoID.boardId); + if(IDStr.indexOf(":") != -1) + { + QStringList list = IDStr.split(":"); + IDStr = list.at(1); + } + + QString passwordStr(infoID.installment); + if(passwordStr.indexOf(":") != -1) + { + QStringList list = passwordStr.split(":"); + passwordStr = list.at(1); + } + + int time = mcStatus.workableTimer;//只在上电的时候读取 + QString timeStr; + if( time > TIMELIMITMIN && time < TIMELIMITMAX) + { + timeStr = (tr("Unlimited time")); // 无时间限制 + } + if(time <= 0) + { + timeStr = (tr("Time has run out")); // 时间已用完 + } + if(time > 0 && time < TIMELIMITMIN) + { + QString strDay; + QString strHour; + QString strSec; + + strDay = QString::number(time/(60 *24) , 10); + strHour = QString::number((time%(60 *24))/60 , 10) ; + strSec = QString::number(time%60 , 10); + + timeStr = strDay + " " + tr("Day") + " " + strHour + " " + tr("Hour") + " " + strSec + " " + tr("Minutes") ; // 天 小时 分钟 + } + + QString strBoardInfo; + strBoardInfo = QString(tr("ID: %1\n")).arg(IDStr); + strBoardInfo += QString(tr("Password: %1\n")).arg(passwordStr); + strBoardInfo += QString(tr("Time: %1")).arg(timeStr); + ui->labelContentWarrant->setText(strBoardInfo); +} + +void PromptDialog::on_buttonOk_clicked() +{ + if(m_funType == BTN_SPINDLE_ROTATE) + { + emit siSpindleRotate(m_spindleAngle); + } + else + { + done(1); + } +} + +void PromptDialog::on_buttonCancel_clicked() +{ + done(0); +} + +void PromptDialog::on_buttonRename_clicked() +{ + done(1); +} + +void PromptDialog::on_buttonReplace_clicked() +{ + done(2); +} + +void PromptDialog::on_buttonSkip_clicked() +{ + done(0); +} + +//重启 +void PromptDialog::on_buttonRestart_clicked() +{ +#ifdef Q_OS_WIN + qApp->exit(); +#endif + +#ifdef Q_OS_LINUX + system("reboot"); +#endif +} + +//升级中断 +void PromptDialog::on_buttonUpdataCancel_clicked() +{ + emit(siUpdataCancel()); + done(0); +} + +void PromptDialog::on_buttonWarrant_clicked() +{ + //输入框 + WordsInputDialog wordInputDlg; + wordInputDlg.clean(); + wordInputDlg.setTitleStr(tr("Warrant")); + wordInputDlg.setOldWordsStr(""); + if(wordInputDlg.exec() == 1) + { + QString textStr = wordInputDlg.getInputStr(); + //连接多块主板也是从g_pMachine(第一块)获取软件授权信息,所以解锁也是通过第一块主板 + g_pMachine->setMacKey(( unsigned char * ) textStr.toLatin1().data() ,textStr.toLatin1().size()); + done(1); + } +} + +void PromptDialog::on_buttonWarrantCancel_clicked() +{ + done(0); +} + +//开始检测 +void PromptDialog::on_buttonDetectBegin_clicked() +{ + if(m_funType == BTN_BOTTOM)//等于底线检测 + { + return; + } + if(m_funType == BTN_FACE)//等于面线检测 + { + return; + } +} + +//停止检测 +void PromptDialog::on_buttonDetectEnd_clicked() +{ + if(g_pMachine!= NULL) + { + g_pMachine->exitDetectTest(); + } +} + +//关闭检测窗体 +void PromptDialog::on_buttonDetectClose_clicked() +{ + if(g_pMachine != NULL) + { + g_pMachine->exitDetectTest(); + } + done(0); +} + +//界面解密ID号输入按钮 +void PromptDialog::on_buttonHMIPassword_clicked() +{ + //输入框 + WordsInputDialog wordInputDlg; + wordInputDlg.clean(); + wordInputDlg.setTitleStr(tr("HMI decrypt")); + wordInputDlg.setOldWordsStr(""); + if(wordInputDlg.exec() == 1) + { + QString textStr = wordInputDlg.getInputStr(); + ui->buttonHMIPassword->setText(textStr); + if(textStr.length() > 0) + { + ui->buttonOk->setEnabled(true); + } + } +} + +void PromptDialog::on_buttonSpindleAngleValue_clicked() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + int rslt; + NumerInputDialog ndlg(this); + ndlg.setTitleStr(tr("Spindle angle rotation"));//主轴角度旋转 + ndlg.setUnitStr(cod->toUnicode("°")); + ndlg.setValueAndRange(ui->buttonSpindleAngleValue->text().toInt()*100, 0, 36000, 2); + rslt = ndlg.exec(); + + if (rslt == 1)//输入弹窗点击了确认 + { + s32 val = ndlg.getValue(); + m_spindleAngle = val; + float angle = m_spindleAngle*0.01; + QString angleStr; + angleStr.sprintf("%.2f",angle); + ui->buttonSpindleAngleValue->setText(angleStr); + } +} + +//修改一级密码:新密码输入按钮 +void PromptDialog::on_buttonNewPassword_clicked() +{ + //密码输入框 + PassWordDialog passWordDlg; + passWordDlg.setTitleStr(tr("New Password input"));//设置新密码输入的标题 + if(passWordDlg.exec() == 1)//确认 + { + m_newPassword = passWordDlg.getInputStr();//获取输入框里的密码 + QString showStr(""); + for (int var = 0; var < m_newPassword.size(); var++) + { + showStr = showStr + "*"; + } + ui->buttonNewPassword->setText(showStr);//新密码框里显示获取的密码 + } +} +//修改一级密码:确认新密码输入按钮 +void PromptDialog::on_buttonConfirmPassword_clicked() +{ + //密码输入框 + PassWordDialog passWordDlg; + passWordDlg.setTitleStr(tr("Confirm Password input"));//设置确认密码输入的标题 + if(passWordDlg.exec() == 1)//确认 + { + m_confirmPassword = passWordDlg.getInputStr();//获取输入框里的密码 + QString showStr(""); + for (int var = 0; var < m_confirmPassword.size(); var++) + { + showStr = showStr + "*"; + } + ui->buttonConfirmPassword->setText(showStr);//确认密码框里显示获取的密码 + if(m_confirmPassword.length() > 0 ) + { + ui->buttonOk->setEnabled(true); + } + } + +} + +//主轴正转 +void PromptDialog::on_buttonForward_pressed() +{ + emit siSpindleAction(MT_MOVE_DIR_POSI); +} + +//主轴正转停止 +void PromptDialog::on_buttonForward_released() +{ + emit siSpindleAction(MT_MOVE_DIR_STOP); +} + +//主轴反转 +void PromptDialog::on_buttonReverse_pressed() +{ + emit siSpindleAction(MT_MOVE_DIR_NEGA); +} + +//主轴反转停止 +void PromptDialog::on_buttonReverse_released() +{ + emit siSpindleAction(MT_MOVE_DIR_STOP); +} + +void PromptDialog::on_buttonX1_pressed() +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(XY_MOVE_RIGHT, 2);//速度等级默认是2 + } +} + +void PromptDialog::on_buttonX1_released() +{ + if(g_pMachine != NULL) + { + g_pMachine->motoMove(XY_MOVE_RIGHT, MT_MOVE_DIR_STOP, 0); + } + m_area = 2; +} + +void PromptDialog::on_buttonX2_pressed() +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(XY_MOVE_LEFT, 2); + } +} + +void PromptDialog::on_buttonX2_released() +{ + if(g_pMachine != NULL) + { + g_pMachine->motoMove(XY_MOVE_LEFT, MT_MOVE_DIR_STOP, 0); + } + m_area = 1; +} + +void PromptDialog::on_buttonY1_pressed() +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(XY_MOVE_FRONT, 2); + } +} +//Y+ +void PromptDialog::on_buttonY1_released() +{ + if(g_pMachine != NULL) + { + g_pMachine->motoMove(XY_MOVE_FRONT, MT_MOVE_DIR_STOP, 0); + } + m_area = 4; +} + +void PromptDialog::on_buttonY2_pressed() +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(XY_MOVE_BACK, 2); + } +} +//Y- +void PromptDialog::on_buttonY2_released() +{ + if(g_pMachine != NULL) + { + g_pMachine->motoMove(XY_MOVE_BACK, MT_MOVE_DIR_STOP, 0); + } + m_area = 3; +} diff --git a/sharedviews/promptdialog.h b/sharedviews/promptdialog.h new file mode 100644 index 0000000..4ddb3a3 --- /dev/null +++ b/sharedviews/promptdialog.h @@ -0,0 +1,135 @@ +#ifndef PROMPTDIALOG_H +#define PROMPTDIALOG_H + +#include +#include +#include +#include +#include "wordsinputdialog.h" +#include "numerinputdialog.h" +#include "setcontrolstyle.h" +#include "sharedviews/passworddialog.h" + +#define NOODLES 1 +#define BOTTOM 2 +#define TIMELIMITMAX 2147483647 +#define TIMELIMITMIN 2147385345 + +namespace Ui { +class PromptDialog; +} + +class PromptDialog : public QDialog +{ + Q_OBJECT + +public: + explicit PromptDialog(QWidget *parent = 0); + ~PromptDialog(); + + enum BTN_SHOW + { + BTN_OK_CANCEL, //ok和cancel按钮 + BTN_OK, //ok按钮 + BTN_R_R_S, //重命名、替换、跳过 + BTN_RESTART, //重启按钮 + BTN_UCANCEL, //升级取消按钮 + BTN_WARRANT, //授权按钮 + BTN_BOTTOM, //底线检测 + BTN_FACE, //面线检测 + BTN_NONE, //无按钮 + BTN_P_NONE, //进度条模式下无按钮(文件导入导出) + BTN_HMI_DECRYPT, //界面解密 + BTN_CHANGE_PASSWORD, //修改一级密码 + BTN_SPINDLE_ROTATE, //主轴旋转 + BTN_WORK_AREA //设置可工作区域 + }; + +private: + Ui::PromptDialog *ui; + + QPoint m_btnOkPoint;//ok按钮位置 + QPoint m_btnCancelPoint;//cancel按钮位置 + + int m_funType;//功能类型 + + QString m_filePath; + + int m_spindleAngle;//主轴旋转角度值 + + int m_area;//xy正负位置 + QString m_newPassword;//获取新密码字符串 + QString m_confirmPassword;//获取确认新密码字符串 + + QString buttonStyle1; + QString buttonStyle2; + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006(); + void initControlStyle();//初始化窗体控件样式 + void refreshColorOrderHead();//刷新当前色序的机头工作号 + +public: + void initDialog(int sel = 0);//初始化窗体 + void setTitleStr(QString str);//设置标题 + void setStrColor(QString str);//设置底线面线断线机头显示字体的颜色 + void setContentStr(QString str);//设置显示内容 + void setContentProcessStr(QString str);//设置进度条显示内容 + void setContentInfoShow();//主板信息内容显示 + void setContentWarrantShow();//授权信息内容显示 + void setContentHMIDecryptShow(QString id);//界面解密网卡ID号显示 + void setContentChangePasswordShow();//修改一级用户密码内容显示 + void setValue(int progress); + void setButtonUCancelStr(QString str); + void setRange(int minimum, int maximum); + inline int getSpindleRotateAngle(){return m_spindleAngle;}//获取主轴旋转角度 + inline int getArea(){return m_area;} + inline QString getInputNewPassword(){return m_newPassword;}//获取新密码 + inline QString getInputConfirmPassword(){return m_confirmPassword;}//获取确认新密码 + + QString getNetworkCardID();//获取网卡ID + QString getInputPassword();//获取界面输入密码 + +signals: + void siUpdataCancel(); + void siSpindleAction(int action);//主轴动作(正转、反转、停止) + void siSpindleRotate(int angle);//主轴旋转角度 + +public slots: + void slotMCInfoChange(); + +private slots: +private slots: + void on_buttonOk_clicked(); + void on_buttonCancel_clicked(); + void on_buttonRename_clicked(); + void on_buttonReplace_clicked(); + void on_buttonSkip_clicked(); + void on_buttonRestart_clicked(); + void on_buttonUpdataCancel_clicked(); + void on_buttonWarrant_clicked(); + void on_buttonWarrantCancel_clicked(); + void on_buttonDetectBegin_clicked(); + void on_buttonDetectEnd_clicked(); + void on_buttonDetectClose_clicked(); + void on_buttonHMIPassword_clicked(); + void on_buttonSpindleAngleValue_clicked(); + void on_buttonNewPassword_clicked(); + void on_buttonConfirmPassword_clicked(); + void on_buttonForward_pressed(); + void on_buttonForward_released(); + void on_buttonReverse_pressed(); + void on_buttonReverse_released(); + void on_buttonX1_pressed(); + void on_buttonX1_released(); + void on_buttonX2_pressed(); + void on_buttonX2_released(); + void on_buttonY1_pressed(); + void on_buttonY1_released(); + void on_buttonY2_pressed(); + void on_buttonY2_released(); +}; + +#endif // PROMPTDIALOG_H diff --git a/sharedviews/promptdialog.ui b/sharedviews/promptdialog.ui new file mode 100644 index 0000000..51baead --- /dev/null +++ b/sharedviews/promptdialog.ui @@ -0,0 +1,1064 @@ + + + PromptDialog + + + + 0 + 0 + 546 + 325 + + + + Dialog + + + + + + + + 0 + 0 + 472 + 48 + + + + + + + Prompt + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 20 + 70 + 440 + 130 + + + + + 0 + 0 + + + + + 1000 + 200 + + + + border:0px; +background-color: rgb(240, 240, 240, 255); + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + 100 + 210 + 361 + 51 + + + + background-color: rgb(184, 184, 184); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 270 + 10 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 190 + 10 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 110 + 9 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 30 + 10 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + + 190 + 210 + 271 + 51 + + + + background-color: rgb(184, 184, 184); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 100 + 9 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 190 + 10 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 20 + 10 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + + 20 + 70 + 440 + 130 + + + + + 0 + 0 + + + + + 1000 + 200 + + + + border:0px; +background-color: rgb(240, 240, 240, 255); + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + 0 + 0 + 472 + 274 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 20 + 70 + 440 + 130 + + + + background-color: rgb(206, 206, 206); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 10 + 411 + 51 + + + + + 100 + 10 + + + + + 600 + 80 + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + 10 + 80 + 411 + 32 + + + + QProgressBar +{ + color: rgb(255, 255, 255); + border-radius: 5px; + border:0px; + background-color: qlineargradient(spread:pad, x1:0.97, y1:1, x2:1, y2:0, stop:0 rgba(163, 165, 165, 255), stop:1 rgba(214, 214, 214, 255)); +} + +QProgressBar::chunk +{ + background-color: rgb(170, 255, 127); + width: 20px; +} + +QProgressBar +{ + border-radius: 5px; + text-align: center; +} + + + 0 + + + + + + + 190 + 210 + 271 + 51 + + + + background-color: rgb(184, 184, 184); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 100 + 9 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 190 + 10 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + + 190 + 210 + 271 + 51 + + + + background-color: rgb(184, 184, 184); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 100 + 9 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 190 + 10 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + + 20 + 70 + 440 + 130 + + + + + 0 + 0 + + + + + 1000 + 200 + + + + border:0px; +background-color: rgb(240, 240, 240, 255); + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + 190 + 210 + 271 + 51 + + + + background-color: rgb(184, 184, 184); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 9 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 110 + 10 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 190 + 10 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + + 20 + 40 + 440 + 161 + + + + background-color: rgb(206, 206, 206); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 10 + 91 + 16 + + + + ID: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 20 + 50 + 91 + 16 + + + + Password: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 120 + 50 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + 120 + 10 + 71 + 16 + + + + ID + + + Qt::AlignCenter + + + + + + 120 + 100 + 71 + 16 + + + + DecryptInfo + + + Qt::AlignCenter + + + + + + 20 + 100 + 91 + 16 + + + + DecryptInfo: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 20 + 40 + 440 + 161 + + + + background-color: rgb(206, 206, 206); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 10 + 91 + 16 + + + + Spindle angle: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 120 + 10 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + 210 + 10 + 91 + 16 + + + + deg + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + 20 + 40 + 440 + 161 + + + + background-color: rgb(206, 206, 206); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 50 + 91 + 16 + + + + New Password: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 120 + 50 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + 20 + 100 + 91 + 16 + + + + Confirm Password: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 120 + 100 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + + 40 + 40 + 440 + 130 + + + + + 0 + 0 + + + + + 1000 + 200 + + + + border:0px; +background-color: rgb(240, 240, 240, 255); + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + 20 + 40 + 441 + 161 + + + + background-color: rgb(206, 206, 206); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 50 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + 20 + 80 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + 110 + 50 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + 110 + 80 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + frameBack + labelTitle + labelContent + frameThree + labelContentInfo + frameProcess + frameProcessBtn + frameWarrantBtn + labelContentWarrant + frameDetecBtn + frameHMIDecrypt + frameSpindleRotate + frameChangePassword + frameTwo + labeBreakHead + frameWorkArea + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/sensorinputwidget.cpp b/sharedviews/sensorinputwidget.cpp new file mode 100644 index 0000000..f8f0394 --- /dev/null +++ b/sharedviews/sensorinputwidget.cpp @@ -0,0 +1,590 @@ +#include "sensorinputwidget.h" +#include "ui_sensorinputwidget.h" + +SensorInputWidget::SensorInputWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::SensorInputWidget), + m_itemPerPage(16), + m_pGetSenserTimer(NULL) +{ + ui->setupUi(this); + + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + + m_mousePressX = 0; + m_mousePressY = 0; + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; + m_sensorsTypeIdx = -1; + + m_pGetSenserTimer = new QTimer(this); + connect(m_pGetSenserTimer, SIGNAL(timeout()), + this, SLOT(slotOnRefTimer())); + + initData(); + initControl(); + refreshUi(); +} + +SensorInputWidget::~SensorInputWidget() +{ + delete m_pGetSenserTimer; + delete ui; +} + +void SensorInputWidget::initData() +{ + m_curPage = 0; // 当前页 + m_allSensorItemList.clear(); + m_sensorItemList.clear(); + m_itemList.clear(); + m_sensorsDat.clear(); +} + +//初始化窗体控件,包括位置、尺寸、样式 +void SensorInputWidget::initControl() +{ + m_SensorBtnList.append(ui->button1); + m_SensorBtnList.append(ui->button2); + m_SensorBtnList.append(ui->button3); + m_SensorBtnList.append(ui->button4); + m_SensorBtnList.append(ui->button5); + ui->button6->setVisible(false); + ui->button7->setVisible(false); + ui->button8->setVisible(false); + + + if(g_emResolut == resolution1910)//1920x1080的分辨率每页显示8个条目 + { + ui->button6->setVisible(true); + ui->button7->setVisible(true); + ui->button8->setVisible(true); + m_SensorBtnList.append(ui->button6); + m_SensorBtnList.append(ui->button7); + m_SensorBtnList.append(ui->button8); + } + else if(g_emResolut == resolution1006)//1024x600的分辨率每页显示8个条目 + { + ui->button6->setVisible(true);//显示 + ui->button7->setVisible(true); + ui->button8->setVisible(true); + m_SensorBtnList.append(ui->button6); + m_SensorBtnList.append(ui->button7); + m_SensorBtnList.append(ui->button8); + } + + m_SensorBtnList.append(ui->button1_2); + m_SensorBtnList.append(ui->button2_2); + m_SensorBtnList.append(ui->button3_2); + m_SensorBtnList.append(ui->button4_2); + m_SensorBtnList.append(ui->button5_2); + ui->button6_2->setVisible(false); + ui->button7_2->setVisible(false); + ui->button8_2->setVisible(false); + + if(g_emResolut == resolution1910)//1920x1080的分辨率每页显示8个条目 + { + ui->button6_2->setVisible(true); + ui->button7_2->setVisible(true); + ui->button8_2->setVisible(true); + m_SensorBtnList.append(ui->button6_2); + m_SensorBtnList.append(ui->button7_2); + m_SensorBtnList.append(ui->button8_2); + } + else if(g_emResolut == resolution1006)//1024x600的分辨率每页显示8个条目 + { + ui->button6_2->setVisible(true); + ui->button7_2->setVisible(true); + ui->button8_2->setVisible(true); + m_SensorBtnList.append(ui->button6_2); + m_SensorBtnList.append(ui->button7_2); + m_SensorBtnList.append(ui->button8_2); + } + + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void SensorInputWidget::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + this->resize(1024*factoryX,600*factoryY); + ui->frameBack->setGeometry(0,0,1024*factoryX,600*factoryY); + ui->buttonTypeLogo->setGeometry(25*factoryX,30*factoryY,60*factoryX,60*factoryY); + ui->labelMainTitle->setGeometry(100*factoryX,30*factoryY,200*factoryX,24*factoryY); + ui->labelSubTitle->setGeometry(130*factoryX,64*factoryY,300*factoryX,21*factoryY); + + QRect rectName(30*factoryX,0,53*factoryX,53*factoryY); + QRect rectValue(55*factoryX,0,380*factoryX,53*factoryY); + for(int i = 0; i < 2; i++) + { + for(int j = 0; j < m_itemPerPage/2; j++) + { + m_SensorBtnList[i*(m_itemPerPage/2) + j]->setGeometry((140+i*340)*factoryX,(94+j*53)*factoryY,380*factoryX,53*factoryY); + m_SensorBtnList[i*(m_itemPerPage/2) + j]->initLeftNameRightValue(rectName,rectValue); + } + } + + ui->framePageBtn->setGeometry(700*factoryX,545*factoryY,600*factoryX,45*factoryY); + ui->labelPage->setGeometry(20*factoryX,550*factoryY,102*factoryX,45*factoryY); + ui->buttonPgUp->setGeometry(0,0,96*factoryX,40*factoryY); + ui->buttonPgDn->setGeometry(106*factoryX,0,96*factoryX,40*factoryY); + ui->buttonBack->setGeometry(212*factoryX,0,96*factoryX,40*factoryY); +} +//初始化窗体控件为1024x600分辨率 +void SensorInputWidget::initResolution1006() +{ + this->resize(1024,600); + ui->frameBack->setGeometry(0,0,1024,600); + ui->buttonTypeLogo->setGeometry(25,30,60,60); + ui->labelMainTitle->setGeometry(100,30,200,24); + ui->labelSubTitle->setGeometry(130,64,300,21); + + QRect rectName(30,0,53,53); + QRect rectValue(55,0,380,53); + for(int i = 0; i < 2; i++) + { + for(int j = 0; j < m_itemPerPage/2; j++) + { + m_SensorBtnList[i*(m_itemPerPage/2) + j]->setGeometry(140+i*340,94+j*53,380,53); + m_SensorBtnList[i*(m_itemPerPage/2) + j]->initLeftNameRightValue(rectName,rectValue); + } + } + + ui->framePageBtn->setGeometry(700,545,600,45); + ui->labelPage->setGeometry(20,550,102,45); + ui->buttonPgUp->setGeometry(0,0,96,40); + ui->buttonPgDn->setGeometry(106,0,96,40); + ui->buttonBack->setGeometry(212,0,96,40); +} + +//初始化窗体控件样式 +void SensorInputWidget::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //背景图 + QString frameBackImgPath = setControlStyle.getSharedStyleSheet(); + ui->frameBack->setStyleSheet(frameBackImgPath); + ui->labelMainTitle->setFont(fontBold_1); + ui->labelMainTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelSubTitle->setFont(fontNormal_1); + ui->labelSubTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelPage->setFont(fontNormal_1); + ui->labelPage->setStyleSheet(LABELWHITESTYLE); + + for(int i = 0; i < m_SensorBtnList.size(); i++) + { + m_SensorBtnList[i]->setEnabled(false); + m_SensorBtnList[i]->setLabelValueFont(fontNormal_1); + m_SensorBtnList[i]->setLabelNameFont(fontBold_1); + } + + //四个按钮样式表一样 + ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + + ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + + ui->buttonBack->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonBack->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonBack->objectName()),12); +} + +//设置类型图标 +void SensorInputWidget::setTypeLogo(QString tStyle) +{ + ui->buttonTypeLogo->setUnPreBtnLogo(tStyle); +} + +void SensorInputWidget::setMainTitle(QString title) +{ + ui->labelMainTitle->setText(title); +} + +//设置副title +void SensorInputWidget::setSubTitle(QString title) +{ + ui->labelSubTitle->setText(title); +} + +int SensorInputWidget::addSensorItems(QList itemList) +{ + m_allSensorItemList.append(itemList); + return (m_allSensorItemList.size() - itemList.size()); +} + +void SensorInputWidget::setMachine(Machine *pMc) +{ + g_pMachine = pMc; +} + +void SensorInputWidget::refreshUi() +{ +// QList itemList; +// itemList.clear(); + +#if(0)//测试用 + m_SensorBtnList[0]->setLabelValue("11111"); + m_SensorBtnList[0]->setLabelName("■"); +#endif + + if(m_itemPerPage <= 0) + { + return; + } + + if(m_sensorsTypeIdx == -1)//传感器信号不分类 + { + m_itemList.clear(); + m_itemList.append(m_sensorItemList);//根据下位机位图过滤的传感器信号列表放在itemList里 + } + else + { + getItemList(m_itemList); //根据不同主板加载的分类传感器信号 + } + + //----------- + int itemNum, pageNums; + itemNum = m_itemList.size(); + + //qDebug()<< "RefreshUi m_sensorItemList = "< pageNums) // 当前页 + { + m_curPage = pageNums; + } + if (m_curPage <= 1) + { + m_curPage = 1; + } + + // 刷新文本 + int i, itemidx; + itemidx = (m_curPage-1) * m_itemPerPage; + for (i = 0; i < m_itemPerPage; i++) + { + if (itemidx < itemNum) + { + if(m_itemList[itemidx].m_name.length() <= 0)//字符长度为空 + { + //QString str = "byte:" + QString::number(itemList[itemidx].m_byte_offset) + " bit:" + QString::number(m_sensorItemList[itemidx].m_bit_offset); + QString str = "byte:" + QString::number(m_itemList[itemidx].m_byte_offset,16).toUpper() + " bit:" + QString::number(m_itemList[itemidx].m_bit_offset); + qDebug()<<"字符长度为空"<setLabelValue(m_itemList.at(itemidx).m_name); + } + m_SensorBtnList.at(i)->show(); + } + else + { + m_SensorBtnList.at(i)->hide(); + } + itemidx++; + } + + // 刷新信号 + refreshSensors(); + + // 刷新按钮 + if (m_curPage <= 1) + { + ui->buttonPgUp->setEnabled(false); + } + else + { + ui->buttonPgUp->setEnabled(true); + } + if (m_curPage >= pageNums) + { + ui->buttonPgDn->setEnabled(false); + } + else + { + ui->buttonPgDn->setEnabled(true); + } + + if(pageNums == 0) + { + m_curPage = 0; + } + + // 页信息 + QString str = tr("pageNum: ") + QString("%1/%2").arg(m_curPage).arg(pageNums);//页数: + ui->labelPage->setText(str); +} + +void SensorInputWidget::refreshSensors() +{ + QTextCodec *cod = QTextCodec::codecForLocale(); + if(m_sensorsDat.size() <= 0) + { + return; + } + + //-------------------------- + int itemNum, pageNums; +// itemNum = m_sensorItemList.size();//m_sensorItemList + itemNum = m_itemList.size(); + pageNums = (itemNum+m_itemPerPage-1) / m_itemPerPage; + + if (m_curPage > pageNums) // 当前页 + { + m_curPage = pageNums; + } + if (m_curPage <= 1) + { + m_curPage = 1; + } + + // 刷新文本 + int i, itemidx; + itemidx = (m_curPage-1) * m_itemPerPage; + for (i = 0; i < m_itemPerPage; i++) + { + if (itemidx < itemNum) + { + //const SensorItem & item = m_sensorItemList.at(itemidx);//m_sensorItemList + const SensorItem & item = m_itemList.at(itemidx); + + int bytepos = item.m_byte_offset; + int bitinbyte = item.m_bit_offset; + + if ( bytepos >= 0 && + bitinbyte >= 0 && + bytepos < m_sensorsDat.size()) + { + u8 curbyte = m_sensorsDat.at(bytepos); + u8 mod = 0x01 << bitinbyte; + + if ((curbyte & mod) != 0) + { + m_SensorBtnList.at(i)->setLabelName(cod->toUnicode("■")); + } + else + { + m_SensorBtnList.at(i)->setLabelName(cod->toUnicode("□")); + } + } + else + { + m_SensorBtnList.at(i)->setText(""); + } + } + else + { + break; + } + itemidx++; + } +} + +void SensorInputWidget::getItemList(QList &ItemList) +{ + ItemList.clear(); + + for(int i = 0; i < m_sensorItemList.size(); i++) + { + int type = m_sensorItemList[i].m_type; + + if((type & m_sensorsTypeIdx) != 0 && (type != -1)) + { + ItemList.append(m_sensorItemList[i]);//筛选好的传感器信号,分类传感器信号 + } + } +} + +void SensorInputWidget::show() +{ + m_sensorsDat.clear(); + + if (g_pMachine != NULL) + { //如果没有传感器信号位图 + if (g_pMachine->isSensorBmpEn() == 0) + { + m_sensorItemList.clear(); + g_pMachine->getSensorEnBmpFromMachine();//读取传感器有效位图 + refreshUi(); + + qDebug("send GetSensorEnBmpFromMachine"); + } + } + + //emit(siEntrySensorScan()); + if (m_pGetSenserTimer != NULL) + { + m_pGetSenserTimer->start(500);//读取传感器信号 + } + + if (g_pMachine != NULL) + { + g_pMachine->entrySensorScan(); + } + + qDebug("SensorInputWidget::show"); + + QWidget::show(); +} + +void SensorInputWidget::hide() +{ + if (m_pGetSenserTimer != NULL) + { + m_pGetSenserTimer->stop(); + } + + //emit(siExitSensorScan()); + + if (g_pMachine != NULL) + { + g_pMachine->exitSensorScan(); + } + + qDebug("SensorInputWidget::hide"); + + QWidget::hide(); +} + +void SensorInputWidget::slotRefSensorBitmap(SensorsBitmap map) +{ + qDebug("SlotRefSensorBitmap"); + m_sensorItemList.clear(); + + if (g_pMachine != NULL) + { + if (g_pMachine->isSensorBmpEn() != 0) + { + QByteArray sensorsbmp; + sensorsbmp.resize(sizeof(SensorsBitmap)); + memcpy(sensorsbmp.data(), &map, sizeof(SensorsBitmap)); + + int ssize = m_allSensorItemList.size() ;//m_allSensorItemList 8192个 机型里的所有主板的传感器信号 + int fsize = sensorsbmp.size(); + int size = (ssize < fsize) ? ssize:fsize; + for (int i = 0; i < size; i++) + { + unsigned char fdat = sensorsbmp.at(i); + for (int j = 0; j < 8; j++) + { + const SensorItem & item = m_allSensorItemList.at( i*8 + j); + if ((fdat & 0x01) != 0) + { + m_sensorItemList.append(item);//根据下位机过滤好的传感器列表 + } + fdat >>= 1 ; + } + } + + qDebug("m_sensorItemList.size=%d", m_sensorItemList.size()); + refreshUi(); + } + } +} +//接收传感器状态改变的槽函数 +void SensorInputWidget::slotRefSensorsDat(SensorsBitmap dat) +{ + // 读取信号 + m_sensorsDat.clear(); + m_sensorsDat.resize(sizeof(SensorsBitmap)); + memcpy(m_sensorsDat.data(),&dat,sizeof(SensorsBitmap)); + + // 更新视图 + refreshSensors(); +} + +void SensorInputWidget::slotOnRefTimer() +{ + if (g_pMachine != NULL) + { + g_pMachine->getSensorsFromMachine(); // 读取一次信号 + } +} + +void SensorInputWidget::on_buttonPgUp_clicked() +{ + m_curPage--; + refreshUi(); +} + +void SensorInputWidget::on_buttonPgDn_clicked() +{ + m_curPage++; + refreshUi(); +} + +void SensorInputWidget::on_buttonBack_clicked() +{ + this->hide(); +} + +void SensorInputWidget::mousePressEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + m_mousePressX = e->x(); + m_mousePressY = e->y(); + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; + } +} + +void SensorInputWidget::mouseReleaseEvent(QMouseEvent *e) +{ + if ( e->button() == Qt::LeftButton) + { + m_mouseReleaseX = e->x(); + m_mouseReleaseY = e->y(); + } + + int width = this->width(); + int height = this->height(); + if ((m_mousePressX >= 0 && m_mousePressX <= 100) && + ((m_mousePressY >= (height - 100)) && m_mousePressY <= height) && + ((m_mouseReleaseX >= (width - 100)) && m_mouseReleaseX <= width) && + ((m_mouseReleaseY >= (height - 100)) && m_mouseReleaseY <= height)) + { + MainWidgetFunction mainFunction; + QString usbPath;//优盘路径 + usbPath = mainFunction.detectUsb();//优盘检测 + if(usbPath.length() <= 0) + { + //优盘不存在 + return; + } + else + { + QPixmap pixmap=QPixmap::grabWindow(this->winId(),0,0,this->width(),this->height());//截屏存放在pixmap + QString name_pc = usbPath + "EMB" + // + QDateTime::currentDateTime().toString("yyyyMMdd") +//获取时期时间 + +"_"+ + QDateTime::currentDateTime().toString("hhmmss") + ".png"; + + pixmap.save(name_pc,"png"); // 路径 + } + } + + m_mousePressX = 0; + m_mousePressY = 0; + m_mouseReleaseX = 0; + m_mouseReleaseY = 0; +} diff --git a/sharedviews/sensorinputwidget.h b/sharedviews/sensorinputwidget.h new file mode 100644 index 0000000..51aef76 --- /dev/null +++ b/sharedviews/sensorinputwidget.h @@ -0,0 +1,99 @@ +#ifndef SENSORINPUTWIDGET_H +#define SENSORINPUTWIDGET_H + +#include +#include +#include + +#include "items/sensoritem.h" +#include "setcontrolstyle.h" +#include "mybutton.h" +#include "mctype/mainwidgetfunction.h" +#include +#include + +namespace Ui { +class SensorInputWidget; +} + +class SensorInputWidget : public QWidget +{ + Q_OBJECT + +public: + explicit SensorInputWidget(QWidget *parent = 0); + ~SensorInputWidget(); + +private: + Ui::SensorInputWidget *ui; + +public: + void initData(); + void setTypeLogo(QString tStyle); + void setMainTitle(QString title); + void setSubTitle(QString title); + int addSensorItems(QList itemList); + void setMachine(Machine *pMc);//设置不同板卡号对应的不同Machine + +public: + void clear(); + +signals: + //void siEntrySensorScan(); + //void siExitSensorScan(); + +public slots: + void slotRefSensorBitmap(SensorsBitmap map); + void slotRefSensorsDat(SensorsBitmap dat); + +private slots: + void slotOnRefTimer(); + void on_buttonPgUp_clicked(); + void on_buttonPgDn_clicked(); + void on_buttonBack_clicked(); + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006();//初始化窗体控件为1024x600分辨率 + void initControlStyle();//初始化窗体控件样式 + +private: + void refreshUi(); + void refreshSensorBtn(); + void refreshSensors(); + +private: + int m_itemPerPage; + QString m_title; + int m_curPage; + QList m_allSensorItemList;//全部传感器信号列表 8196个 + QList m_sensorItemList;//根据下位机位图过滤的传感器信号列表 + QList m_itemList;//根据不同主板筛选传感器信号(20220418-rq) + QByteArray m_sensorsDat; + + QTimer * m_pGetSenserTimer; + QList m_SensorBtnList; + int m_sensorsTypeIdx; // 传感器板卡的索引 + +private: + void getItemList(QList & ItemList); + +public slots: + void show(); + void hide(); + + //鼠标事件 +protected: + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + +private: + int m_mousePressX; + int m_mousePressY; + int m_mouseReleaseX; + int m_mouseReleaseY; + +}; + +#endif // SENSORINPUTWIDGET_H diff --git a/sharedviews/sensorinputwidget.ui b/sharedviews/sensorinputwidget.ui new file mode 100644 index 0000000..2790274 --- /dev/null +++ b/sharedviews/sensorinputwidget.ui @@ -0,0 +1,520 @@ + + + SensorInputWidget + + + + 0 + 0 + 1024 + 600 + + + + Form + + + background-color: rgb(139, 139, 139); + + + + + 60 + 120 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 60 + 160 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 30 + 10 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + + + + 60 + 240 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 60 + 200 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 110 + 10 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Sensor + + + + + + 60 + 280 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 0 + 0 + 1024 + 600 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 60 + 80 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 40 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Sensor + + + + + + 20 + 570 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + PageNums: 1/1 + + + + + + 60 + 360 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 60 + 320 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 750 + 560 + 241 + 31 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 80 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 160 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 0 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + + 520 + 120 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 520 + 280 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 520 + 80 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 520 + 240 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 520 + 160 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 520 + 360 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 520 + 200 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 520 + 320 + 440 + 32 + + + + Qt::NoFocus + + + + + + + + + frameBack + buttonTypeLogo + labelMainTitle + labelSubTitle + labelPage + framePageBtn + button2 + button5 + button8 + button1 + button4 + button3 + button7 + button6 + button2_2 + button6_2 + button1_2 + button5_2 + button3_2 + button8_2 + button4_2 + button7_2 + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/setcontrolstyle.cpp b/sharedviews/setcontrolstyle.cpp new file mode 100644 index 0000000..3addffd --- /dev/null +++ b/sharedviews/setcontrolstyle.cpp @@ -0,0 +1,207 @@ +#include "setcontrolstyle.h" + +SetControlStyle::SetControlStyle(QObject *parent) : QObject(parent) +{ + m_uiName.clear(); +} + +void SetControlStyle::setUiName(QString uiName) +{ + m_uiName = uiName; +} + +QString SetControlStyle::getStyleSheet(QString controlName) +{ + //样式表格式 <分辨率><主题><窗体名称><图片名称> + //例如图片路径 :/images/MainWidget/ButtonConnect_logo.png + QString style; + style = "background-color: rgba(245, 245, 245, 0);color: rgb(255, 255, 255);border:0px;border-image:url(:/images/"; + + style += m_uiName + "/"; + style += controlName + "_logo.png);"; + + return style; +} + +QString SetControlStyle::getStyleSheet1(QString controlName) +{ + //样式表格式 <分辨率><主题><窗体名称><图片名称> + //例如图片路径 :/images/1920x1080/theme1/EmbMainWidget/ButtonConnect_logo.png + QString style; + style = "background-color: rgba(245, 245, 245, 0);color: rgb(255, 255, 255);border:0px;border-image:url(:/images/"; + + //分辨率 + QString str; + str.clear(); + switch (g_emResolut) + { + case resolution1910: + str = "_1910"; + break; + case resolution1006: + str = "_1006"; + break; + default: + break; + } + + style += m_uiName + "/"; + style += controlName + str + "_logo.png);"; + + return style; +} + +QString SetControlStyle::getBorderImageStyleSheet(QString controlName) +{ + //样式表格式 <分辨率><主题><窗体名称><图片名称> + //例如图片路径 :/images/1920x1080/theme1/EmbMainWidget/ButtonConnect_logo.png + QString style; + style = "background-color: rgba(245, 245, 245, 0);color: rgb(255, 255, 255);border:0px;border-image:url(:/images/"; + + //分辨率 + QString str; + str.clear(); + switch (g_emResolut) + { + case resolution1910: + str = "_1910"; + break; + case resolution1006: + str = "_1006"; + break; + default: + break; + } + + style += m_uiName + "/"; + style += controlName + str + "_logo.png);"; + + return style; +} + +QString SetControlStyle::getTopStyleSheet(QString controlName) +{ + //样式表格式 <分辨率><主题><窗体名称><图片名称> + //例如 :/images/1920x1080/theme1/EmbMainWidget/buttonPatternSet_logo + QString style = ":/images/"; + + style += m_uiName + "/"; + style += controlName + "_logo.png"; + + return style; +} + +QString SetControlStyle::getBottomStyleSheet(QString parentName) +{ + //样式表格式 <分辨率><主题><窗体名称><图片前缀> + //例如 :/images/EmbMainWidget/frameMainFunction + QString style = ":/images/"; + + style += m_uiName + "/"; + style += parentName; + + return style; +} + +QString SetControlStyle::getBottomStyleSheet1(QString parentName) +{ + //样式表格式 <分辨率><主题><窗体名称><图片前缀> + //例如 :/images/EmbMainWidget/frameMainFunction + QString style = ":/images/"; + + QString str; + str.clear(); + + switch (g_emResolut) + { + case resolution1910: + str = "1910_"; + break; + case resolution1006: + str = "1006_"; + break; + default: + break; + } + + style += m_uiName +"/" + str; + style += parentName; + + return style; +} + +QString SetControlStyle::getBtnStyleSheet(QString iconName) +{ + QString path = ":/images/"; + + path += m_uiName + "/"; + path += iconName; + + QString style = "QPushButton{"+QString(LABELNAVYBLUESTYLE)+"border-image: url(" + path + "_p0.png" + ");border:0px;}"; + style += "QPushButton:pressed{border-image: url(" + path + "_p1.png" + ");}"; + style += "QPushButton:disabled{border-image: url(" + path + "_p2.png" + ");}"; + + return style; +} + +QString SetControlStyle::getSharedStyleSheet() +{ + //样式表格式 <分辨率><主题><窗体名称><图片名称> + //例如图片路径 :/images/1920x1080/theme1/EmbMainWidget/ButtonConnect_logo.png + QString style; + style = "background-color: rgba(245, 245, 245, 0);color: rgb(255, 255, 255);border:0px;border-image:url(:/images/"; + + //分辨率 + QString str; + str.clear(); + switch (g_emResolut) + { + case resolution1910: + str = "_1910"; + break; + case resolution1006: + str = "_1006"; + break; + default: + break; + } + + style += "SharedIcon/WidgetFrameBack"+ str +"_logo.png);"; + + return style; +} + +QString SetControlStyle::getSharedTopStyleSheet(QString controlName) +{ + //样式表格式 <分辨率><主题><窗体名称><图片名称> + //例如 :/images/1920x1080/theme1/EmbMainWidget/buttonPatternSet_logo + QString style = ":/images/"; + style += "SharedIcon/"; + style += controlName + "_logo.png"; + + return style; +} + +QString SetControlStyle::getSharedBottomStyleSheet(QString parentName) +{ + //样式表格式 <分辨率><主题><窗体名称><图片前缀> + //例如 :/images/1920x1080/theme1/EmbMainWidget/frameMainFunction + QString style = ":/images/"; + style += "SharedIcon/"; + style += parentName; + + return style; +} + +QString SetControlStyle::getSharedBtnStyleSheet(QString iconName) +{ + QString path = ":/images/"; + path += "SharedIcon/"; + path += iconName; + + QString style = "QPushButton{"+QString(LABELNAVYBLUESTYLE)+"border-image: url(" + path + "_p0.png" + ");border:0px;}"; + style += "QPushButton:pressed{border-image: url(" + path + "_p1.png" + ");}"; + style += "QPushButton:disabled{border-image: url(" + path + "_p2.png" + ");}"; + + return style; +} diff --git a/sharedviews/setcontrolstyle.h b/sharedviews/setcontrolstyle.h new file mode 100644 index 0000000..f8493f3 --- /dev/null +++ b/sharedviews/setcontrolstyle.h @@ -0,0 +1,37 @@ +#ifndef SETCONTROLSTYLE_H +#define SETCONTROLSTYLE_H + +#include +#include +#include "main.h" + +class SetControlStyle : public QObject +{ + Q_OBJECT +public: + explicit SetControlStyle(QObject *parent = 0); + +private: + QString m_uiName;//窗体名称 + +public: + void setUiName(QString uiName);//设置窗体名称 + QString getStyleSheet(QString controlName);//获取普通按钮样式表 + QString getStyleSheet1(QString controlName);//获取样式表 + QString getBorderImageStyleSheet(QString controlName);//获取九宫格frame样式表 + QString getTopStyleSheet(QString controlName);//获取自定义按钮顶层样式表 + QString getBottomStyleSheet(QString parentName);//获取自定义按钮底层样式表 + QString getBottomStyleSheet1(QString parentName);//获取自定义按钮底层样式表 + QString getBtnStyleSheet(QString iconName);//获取普通按钮样式表(字符输入) + + QString getSharedStyleSheet();//获取普通按钮样式表 + QString getSharedTopStyleSheet(QString controlName);//获取自定义按钮顶层样式表 + QString getSharedBottomStyleSheet(QString parentName);//获取自定义按钮底层样式表 + QString getSharedBtnStyleSheet(QString iconName);//获取普通按钮样式表(字符输入) + +signals: + +public slots: +}; + +#endif // SETCONTROLSTYLE_H diff --git a/sharedviews/setworkarea.cpp b/sharedviews/setworkarea.cpp new file mode 100644 index 0000000..1df0d11 --- /dev/null +++ b/sharedviews/setworkarea.cpp @@ -0,0 +1,190 @@ +#include "setworkarea.h" +#include "ui_setworkarea.h" + +SetWorkArea::SetWorkArea(QWidget *parent) : + QWidget(parent), + ui(new Ui::SetWorkArea) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::NonModal );//用以设置窗口模态类型 ,ApplicationModal阻塞整个应用程序的所有窗口 + initWidget(); + initControl(); +} + +SetWorkArea::~SetWorkArea() +{ + delete ui; +} +void SetWorkArea::initWidget() +{ + m_headValue= 0; + m_area = 2; + ui->frameWorkArea->show(); + + //蓝色 + buttonStyle1 = "QPushButton{outline: none;color:rgb(10,10,10);background-color:rgb(0,151,226);border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;}"; + //白色 + buttonStyle2 = "QPushButton{outline: none;color:rgb(10,10,10);background-color:rgb(250,250,250);border:0px solid rgb(0,0,0);border-style:inset;border-radius:5px;}"; + ui->buttonX1->setText(tr("X +")); + ui->buttonX2->setText(tr("X -")); + ui->buttonY1->setText(tr("Y +")); + ui->buttonY2->setText(tr("Y -")); + + ui->buttonX1->setStyleSheet(buttonStyle1);//初始化默认都是白色,根据从主控上读上来的当前位置值,显示哪个是蓝色 + ui->buttonX2->setStyleSheet(buttonStyle2); + ui->buttonY1->setStyleSheet(buttonStyle2); + ui->buttonY2->setStyleSheet(buttonStyle2); +} + +void SetWorkArea::initControl() +{ + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + initControlStyle();//初始化窗体控件样式 +} +void SetWorkArea::initResolution1910() +{ + //上状态栏 + this->resize(896,497); + this->move((1920-this->width())/2,(1080-this->height())/2); + + ui->frameBack->setGeometry(0,0,946,564); + ui->labelTitle->setGeometry(40,2,754,56); + //设置可移动区域 + ui->frameWorkArea->setGeometry(40,78,904,340); + ui->buttonX1->setGeometry(300,110,160,58);//x+ + ui->buttonX2->setGeometry(10,110,160,58);//x- + ui->buttonY1->setGeometry(150,10,160,58);//y+ + ui->buttonY2->setGeometry(150,205,160,58);//y- + + ui->buttonOk->setGeometry(522,400,174,70); + ui->buttonCancel->setGeometry(704,400,174,70); +} +void SetWorkArea::initResolution1006() +{ + //上状态栏 + + this->resize(480,268); + this->move((1024-this->width())/2,(600-this->height())/2); + + ui->frameBack->setGeometry(0,0,508,304); + ui->labelTitle->setGeometry(5,-10,400,56); + + ui->frameWorkArea->setGeometry(40,58,440,161); + ui->buttonX1->setGeometry(170,60,70,38); + ui->buttonX2->setGeometry(10,60,70,38); + ui->buttonY1->setGeometry(90,10,70,38);//y+ + ui->buttonY2->setGeometry(90,120,70,38); + + ui->buttonOk->setGeometry(274,216,96,40); + ui->buttonCancel->setGeometry(380,216,96,40); +} +//初始化窗体控件样式 +void SetWorkArea::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //设置控件图标 + //背景图 + //ui->SetWorkArea->setStyleSheet(TRANSPARENTSTYLE); + // ui->frameWorkArea->setStyleSheet(TRANSPARENTSTYLE); + //ui->frameBack->setStyleSheet(TRANSPARENTSTYLE); + // this->setStyleSheet(LABELWHITESTYLE); + ui->frameBack->setStyleSheet(setControlStyle.getStyleSheet(this->objectName())); + ui->labelTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelTitle->setFont(fontNormal_1); + ui->labelTitle->setAlignment(Qt::AlignLeft); + ui->labelTitle->setAlignment(Qt::AlignVCenter); + //设置可工作区域 + ui->frameWorkArea->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonX1->setFont(fontNormal_1); + ui->buttonX2->setFont(fontNormal_1); + ui->buttonY1->setFont(fontNormal_1); + ui->buttonY2->setFont(fontNormal_1); + + ui->buttonOk->setWhiteBlueBottomStyle(); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1"),12); + ui->buttonCancel->setWhiteBlueBottomStyle(); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"),12); +} +//设置标题 +void SetWorkArea::setTitleStr(QString str) +{ + ui->labelTitle->setText(str); +} +void SetWorkArea::show() +{ + QWidget::show(); +} +void SetWorkArea::setHead(int m_head) +{ + m_headValue= m_head; +} +void SetWorkArea::on_buttonCancel_clicked() +{ + + this->hide(); +} + +void SetWorkArea::on_buttonOk_clicked() +{ + if(g_pMachine != NULL) + { + g_pMachine->manualAction(SET_WORK_AREA,m_headValue,m_area); + } + + //this->hide(); +} + +//X+ +void SetWorkArea::on_buttonX1_clicked() +{ + ui->buttonX1->setStyleSheet(buttonStyle1); + ui->buttonX2->setStyleSheet(buttonStyle2); + ui->buttonY1->setStyleSheet(buttonStyle2); + ui->buttonY2->setStyleSheet(buttonStyle2); + + m_area = 2; +} + +//Y+ +void SetWorkArea::on_buttonY1_clicked() +{ + ui->buttonX1->setStyleSheet(buttonStyle2); + ui->buttonX2->setStyleSheet(buttonStyle2); + ui->buttonY1->setStyleSheet(buttonStyle1); + ui->buttonY2->setStyleSheet(buttonStyle2); + m_area = 4; +} + +//Y- +void SetWorkArea::on_buttonY2_clicked() +{ + ui->buttonX1->setStyleSheet(buttonStyle2); + ui->buttonX2->setStyleSheet(buttonStyle2); + ui->buttonY1->setStyleSheet(buttonStyle2); + ui->buttonY2->setStyleSheet(buttonStyle1); + m_area = 3; +} + +void SetWorkArea::on_buttonX2_clicked() +{ + ui->buttonX1->setStyleSheet(buttonStyle2); + ui->buttonX2->setStyleSheet(buttonStyle1); + ui->buttonY1->setStyleSheet(buttonStyle2); + ui->buttonY2->setStyleSheet(buttonStyle2); + m_area =1; +} diff --git a/sharedviews/setworkarea.h b/sharedviews/setworkarea.h new file mode 100644 index 0000000..a3f721d --- /dev/null +++ b/sharedviews/setworkarea.h @@ -0,0 +1,63 @@ +#ifndef SETWORKAREA_H +#define SETWORKAREA_H + +#include +#include +#include +#include "promptdialog.h" +#include "mybutton.h" +#include "setcontrolstyle.h" +//#include "Include/datafiledst.h" +#include "datafile/datafiledst.h" +#include "datafile/datafiledsr.h" +#include "mctype/mainwidgetfunction.h" +#include +namespace Ui { +class SetWorkArea; +} + +class SetWorkArea : public QWidget +{ + Q_OBJECT + +public: + explicit SetWorkArea(QWidget *parent = 0); + ~SetWorkArea(); + +private slots: + void on_buttonCancel_clicked(); + + void on_buttonOk_clicked(); + + void on_buttonX1_clicked(); + + void on_buttonY1_clicked(); + + void on_buttonY2_clicked(); + + void on_buttonX2_clicked(); + +private: + Ui::SetWorkArea *ui; + +private: + int m_area; + int m_headValue; + + QString buttonStyle1; + QString buttonStyle2; +private: + void initWidget(); + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006();//初始化窗体控件为1024x600分辨率 + void initControlStyle();//初始化窗体控件样式 + +public: + inline int getArea(){return m_area;} + void setHead(int m_head); + void setTitleStr(QString str);//设置标题 + void show(); +}; + +#endif // SETWORKAREA_H diff --git a/sharedviews/setworkarea.ui b/sharedviews/setworkarea.ui new file mode 100644 index 0000000..2acbba7 --- /dev/null +++ b/sharedviews/setworkarea.ui @@ -0,0 +1,216 @@ + + + SetWorkArea + + + + 0 + 0 + 473 + 274 + + + + Form + + + outline:none;border:0px;background-color: rgba(255, 255, 255, 0); + + + + + 0 + 0 + 472 + 274 + + + + background-color: rgba(245, 245, 245, 0);color: rgb(255, 255, 255); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 40 + 40 + 440 + 161 + + + + background-color: rgb(206, 206, 206); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 50 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + 20 + 80 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + 110 + 50 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + 110 + 80 + 75 + 23 + + + + QPushButton +{ +background-color:rgba(250, 250, 250);color: rgb(80, 80, 80);border:0px;border-radius:5px; +} +QPushButton:pressed +{ +background-color: rgba(199, 226, 255); +} + + + + + + + + + + 10 + 10 + 472 + 48 + + + + + + + Prompt + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 350 + 250 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + 250 + 250 + 71 + 31 + + + + Qt::NoFocus + + + + + + + + + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/systemmanagedialog.cpp b/sharedviews/systemmanagedialog.cpp new file mode 100644 index 0000000..472ac41 --- /dev/null +++ b/sharedviews/systemmanagedialog.cpp @@ -0,0 +1,748 @@ +#include "systemmanagedialog.h" +#include "ui_systemmanagedialog.h" + +SystemManageDialog::SystemManageDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::SystemManageDialog), + m_itemPerPage(8) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + + this->move(0,0); + initDialog(); + initControl(); + + m_logType = 0; + + m_curConnectWifi.clear();//当前连接的wifi + m_curConnectWifiPass.clear();//当前连接的wifi密码 + m_curConnectMode = false;//当前连接的方式 + ui->labelCurIP->clear(); + + ui->buttonSetAutoIP->setEnabled(false); + ui->buttonSetStaticIP->setEnabled(false); +} + +SystemManageDialog::~SystemManageDialog() +{ + delete ui; +} + +//初始化窗体控件,包括位置、尺寸、样式 +void SystemManageDialog::initControl() +{ + m_itemBtnList.clear(); + m_itemBtnList.append(ui->button1); + m_itemBtnList.append(ui->button2); + m_itemBtnList.append(ui->button3); + m_itemBtnList.append(ui->button4); + m_itemBtnList.append(ui->button5); + ui->button6->setVisible(false);//隐藏 + ui->button7->setVisible(false); + ui->button8->setVisible(false); + + if(g_emResolut == resolution1910)//1920x1080的分辨率每页显示12个条目 + { + ui->button6->setVisible(true);//显示 + ui->button7->setVisible(true); + ui->button8->setVisible(true); + m_itemBtnList.append(ui->button6); + m_itemBtnList.append(ui->button7); + m_itemBtnList.append(ui->button8); + } + else if(g_emResolut == resolution1006)//1024x600的分辨率每页显示8个条目 + { + ui->button6->setVisible(true);//显示 + ui->button7->setVisible(true); + ui->button8->setVisible(true); + m_itemBtnList.append(ui->button6); + m_itemBtnList.append(ui->button7); + m_itemBtnList.append(ui->button8); + } + + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + break; + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void SystemManageDialog::initResolution1910() +{ + double factoryX = 1.875; //缩放比例系数 + double factoryY = 1.8; + + this->resize(1920,1080); + ui->frameBack->setGeometry(0,0,1920,1080); + ui->buttonTypeLogo->setGeometry(128,66,78,78); + ui->labelMainTitle->setGeometry(226,60,1000,48); + ui->labelSubTitle->setGeometry(302,112,1000,36); + + ui->frameRightUp->setGeometry(1700,92,300,72); + ui->buttonDelete->setGeometry(0,0,66,66); + ui->buttonSelectAll->setGeometry(0,0,66,66); + ui->buttonExport->setGeometry(80,0,66,66); + + ui->frameRightUpWIFI->setGeometry(1200,92,600,72); + ui->buttonRefresh->setGeometry(500,0,66,66); + ui->labelCurIP->setGeometry(0,0,500,66); + + ui->buttonChangeLog->setGeometry(10,0,66,66); + + for(int i = 0; i < m_itemPerPage; i++) + { + m_itemBtnList[i]->setGeometry(153*factoryX,(106 + i * 53)*factoryY,718*factoryX,53*factoryY); + } + + ui->framePageBtn->setGeometry(1120,990,800,70); + ui->labelPage->setGeometry(32,1008,200,40); + ui->labelExplain->setGeometry(240,960,660,110); + ui->buttonPgUp->setGeometry(0,0,168,70); + ui->buttonPgDn->setGeometry(200,0,168,70); + ui->buttonOk->setGeometry(400,0,168,70); + ui->buttonCancel->setGeometry(600,0,168,70); + + ui->framePageBtnWIFI->setGeometry(920,990,1000,70); + ui->buttonPgUpWIFI->setGeometry(0,0,168,70); + ui->buttonPgDnWIFI->setGeometry(200,0,168,70); + ui->buttonSetAutoIP->setGeometry(400,0,168,70); + ui->buttonSetStaticIP->setGeometry(600,0,168,70); + ui->buttonCancelWIFI->setGeometry(800,0,168,70); +} + +void SystemManageDialog::initResolution1006() +{ + this->resize(1024,600); + ui->frameBack->setGeometry(0,0,1024,600); + + ui->buttonTypeLogo->setGeometry(25,30,60,60); + ui->labelMainTitle->setGeometry(100,30,200,24); + ui->labelSubTitle->setGeometry(130,64,240,21); + + ui->frameRightUp->setGeometry(800,40,800,61); + ui->buttonDelete->setGeometry(150,0,50,50); + ui->buttonSelectAll->setGeometry(150,0,50,50); + ui->buttonExport->setGeometry(90,0,50,50); + + ui->frameRightUpWIFI->setGeometry(600,40,400,61); + ui->buttonRefresh->setGeometry(300,0,50,50); + ui->labelCurIP->setGeometry(0,0,300,50); + + ui->buttonChangeLog->setGeometry(20,0,50,50); + + for(int i = 0; i < m_itemPerPage; i++) + { + m_itemBtnList[i]->setGeometry(153,106 + i * 53,718,53); + } + + ui->framePageBtn->setGeometry(595,545,600,45); + ui->labelPage->setGeometry(20,550,102,45); + ui->labelExplain->setGeometry(130,538,350,50); + ui->buttonPgUp->setGeometry(0,0,96,40); + ui->buttonPgDn->setGeometry(106,0,96,40); + ui->buttonOk->setGeometry(212,0,96,40); + ui->buttonCancel->setGeometry(318,0,96,40); + + ui->framePageBtnWIFI->setGeometry(489,545,600,45); + ui->buttonPgUpWIFI->setGeometry(0,0,96,40); + ui->buttonPgDnWIFI->setGeometry(106,0,96,40); + ui->buttonSetAutoIP->setGeometry(212,0,96,40); + ui->buttonSetStaticIP->setGeometry(318,0,96,40); + ui->buttonCancelWIFI->setGeometry(424,0,96,40); +} + +//初始化窗体控件样式 +void SystemManageDialog::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //背景图 + QString frameBackImgPath = setControlStyle.getSharedStyleSheet(); + ui->frameBack->setStyleSheet(frameBackImgPath); + ui->labelMainTitle->setFont(fontBold_1); + ui->labelMainTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelSubTitle->setFont(fontNormal_1); + ui->labelSubTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelPage->setFont(fontNormal_1); + ui->labelPage->setStyleSheet(LABELWHITESTYLE); + ui->labelExplain->setFont(fontNormal_1); + ui->labelExplain->setStyleSheet(LABELWHITESTYLE); + + //右上方 + ui->frameRightUp->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonDelete->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonDelete->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonDelete->objectName())); + ui->buttonSelectAll->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonSelectAll->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonSelectAll->objectName())); + ui->buttonExport->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonExport->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonExport->objectName())); + ui->buttonChangeLog->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonChangeLog->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonChangeLog->objectName())); + + //右上方 + ui->frameRightUpWIFI->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonRefresh->setGreenGradientBottomStyle(BORDER_RADIUS1); + ui->buttonRefresh->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonChangeLog->objectName())); + ui->labelCurIP->setFont(fontNormal_1); + ui->labelCurIP->setStyleSheet(LABELWHITESTYLE); + + QString style = "QPushButton{border:0px;text-align:left;border-radius:7px;background-color:rgba(255, 255, 255, 0);color: rgb(255, 255, 255);}"; + style += "QPushButton:checked{background-color: rgba(255, 255, 255, 50);}"; + + for(int i = 0; i < m_itemBtnList.size(); i++) + { + m_itemBtnList[i]->setStyleSheet(style);//文本左对齐 + m_itemBtnList[i]->setFont(fontNormal_1); + } + + //四个按钮样式表一样 + ui->buttonPgUp->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUp->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + + ui->buttonPgDn->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDn->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + + ui->buttonOk->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()),12); + + ui->buttonCancel->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12); + + //WIFI + ui->framePageBtnWIFI->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonPgUpWIFI->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgUpWIFI->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgUp->objectName()),12); + + ui->buttonPgDnWIFI->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonPgDnWIFI->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonPgDn->objectName()),12); + + ui->buttonSetAutoIP->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonSetAutoIP->setFont(fontNormal_6); + + ui->buttonSetStaticIP->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonSetStaticIP->setFont(fontNormal_6); + + ui->buttonCancelWIFI->setOrangeGradientBottomStyle(BORDER_RADIUS2); + ui->buttonCancelWIFI->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12); +} + +void SystemManageDialog::refreshUi() +{ + int itemNum; + if (m_itemList.size() <= 0) + { + itemNum = 0; + + for (int i = 0; i < m_itemPerPage; i++) + { + m_itemBtnList.at(i)->hide(); + } + ui->labelPage->setText(tr("pageNum: 0/0"));//页数: 0/0 + ui->buttonPgUp->setEnabled(false); + ui->buttonPgDn->setEnabled(false); + ui->buttonOk->setEnabled(false); + + return; + } + else + { + itemNum = m_itemList.size(); + } + + m_pageNums = (itemNum + m_itemPerPage - 1)/m_itemPerPage;// 计算页数 + if (m_curPages > m_pageNums)// 当前页 + { + m_curPages = m_pageNums; + } + if (m_curPages <= 1 && itemNum != 0) + { + m_curPages = 1; + } + + int itemidx = (m_curPages - 1) * m_itemPerPage; + + for (int i = 0; i < m_itemPerPage; i++) + { + if (itemidx < itemNum) + { + //设置图标和文件夹名称 + m_itemBtnList[i]->setText(m_itemList.at(itemidx)); + m_itemBtnList.at(i)->show(); + + itemidx++; + } + else + { + m_itemBtnList.at(i)->hide(); + } + } + + // 翻页按钮 + if (m_curPages <= 1) + { + ui->buttonPgUp->setEnabled(false); + } + else + { + ui->buttonPgUp->setEnabled(true); + } + if (m_curPages >= m_pageNums) + { + ui->buttonPgDn->setEnabled(false); + } + else + { + ui->buttonPgDn->setEnabled(true); + } + + // 页信息 + if(m_pageNums == 0) + { + m_curPages = 0; + } + + QString str = tr("pageNum: ") + QString("%1/%2").arg(m_curPages).arg(m_pageNums);//页数: + ui->labelPage->setText(str); + + refreshCheckedPage(); +} + +void SystemManageDialog::refreshCheckedPage() +{ + if(m_selectedIdx == SELECT_NONE) + { + ui->buttonOk->setEnabled(false); + } + else + { + ui->buttonOk->setEnabled(true); + } + + if(m_selectedIdx == SELECT_ALL) + { + // 刷新页面中被选择的条目 + for(int var = 0; var < m_itemPerPage; var++) + { + // 条目被选中 + m_itemBtnList.at(var)->setCheckable(true); + m_itemBtnList.at(var)->setChecked(true); + } + return; + } + + // 刷新页面中被选择的条目 + for(int var = 0; var < m_itemPerPage; var++) + { + int idx = (m_curPages - 1) * m_itemPerPage + var; + if(m_selectedIdx == idx) + { + // 条目被选中 + m_itemBtnList.at(var)->setCheckable(true); + m_itemBtnList.at(var)->setChecked(true); + } + else + { + // 不被选中 + m_itemBtnList.at(var)->setChecked(false); + m_itemBtnList.at(var)->setCheckable(false); + } + } +} + +void SystemManageDialog::clickItem(int idx) +{ + m_selectedIdx = (m_curPages - 1) * m_itemPerPage + idx - 1; + refreshCheckedPage(); + QString wifiName = m_itemList[m_selectedIdx]; + if(m_curConnectWifi != wifiName) + { + ui->buttonSetAutoIP->setEnabled(true); + ui->buttonSetStaticIP->setEnabled(false); + } + else + { + ui->buttonSetAutoIP->setEnabled(false); + ui->buttonSetStaticIP->setEnabled(true); + } +} + +void SystemManageDialog::initDialog(s16 type) +{ + m_setType = type; + m_curPages = 1;//当前页数 + m_pageNums = 1;//总页数 + m_selectedIdx = SELECT_NONE;//被选中的条目 + m_itemList.clear(); + + if(type != 0) + { + ui->frameRightUpWIFI->show(); + ui->framePageBtnWIFI->show(); + ui->frameRightUp->hide(); + ui->framePageBtn->hide(); + ui->labelExplain->show(); + } + else + { + ui->frameRightUpWIFI->hide(); + ui->framePageBtnWIFI->hide(); + ui->frameRightUp->show(); + ui->framePageBtn->show(); + ui->labelExplain->hide(); + } +} + +//设置类型图标 +void SystemManageDialog::setTypeLogo(QString tStyle) +{ + ui->buttonTypeLogo->setUnPreBtnLogo(tStyle); +} + +//设置主title +void SystemManageDialog::setMainTitle(QString str) +{ + ui->labelMainTitle->setText(str); +} + +//设置副title +void SystemManageDialog::setSubTitle(QString str) +{ + ui->labelSubTitle->setText(str); +} + +void SystemManageDialog::addItem(QString str) +{ + m_itemList.append(str); +} + +void SystemManageDialog::addListError() +{ + m_itemList = g_pSettings->readToCsv(TYPE_ERROR);//读取 QStringList +} + +void SystemManageDialog::addListBreakage() +{ + m_itemList = g_pSettings->readToCsv(TYPE_BREAK);//读取 QStringList +} + +void SystemManageDialog::addListDebug() +{ + m_itemList = g_pSettings->readToCsv(TYPE_DEBUGINFO);//读取 QStringList +} + +int SystemManageDialog::exec(int type)//升级类型 +{ + ui->buttonDelete->setVisible(false); + ui->buttonSelectAll->setVisible(false); + ui->buttonExport->setVisible(false); + + ui->buttonChangeLog->setVisible(false); + + m_updateType = type; + + //当为外围板版本查询时,列表按钮和确定按钮不可按 + if(m_updateType < 0) + { + ui->buttonOk->setEnabled(false); + + for(int i = 0; i < m_itemBtnList.size(); i++) + { + m_itemBtnList[i]->setEnabled(false); + } + } + else + { + if(m_updateType == PRODUCTSTATIS) + { + ui->buttonDelete->setVisible(true); + ui->buttonOk->setEnabled(false); + + for(int i = 0; i < m_itemBtnList.size(); i++) + { + m_itemBtnList[i]->setEnabled(false); + } + } + else if(m_updateType == JOURNAL) + { + ui->buttonDelete->setVisible(false);//不可见 + ui->buttonOk->setEnabled(false); + ui->buttonExport->setVisible(true); + + ui->buttonChangeLog->setVisible(true); + + for(int i = 0; i < m_itemBtnList.size(); i++) + { + m_itemBtnList[i]->setEnabled(false); + } + } + else + { + ui->buttonOk->setEnabled(true); + + for(int i = 0; i < m_itemBtnList.size(); i++) + { + m_itemBtnList[i]->setEnabled(true); + } + } + } + + refreshUi(); + return QDialog::exec(); +} + +QString SystemManageDialog::getCurFile() +{ + QString fileName = m_itemList.at(m_selectedIdx); + return fileName; +} + +void SystemManageDialog::setWifiInfo(QString ip,QString ssid,QString psd,bool mode) +{ + ui->labelCurIP->setText(ip); + m_curConnectWifi = ssid; + m_curConnectWifiPass = psd; + m_curConnectMode = mode; +} + +void SystemManageDialog::setItemList(QStringList list) +{ + m_itemList.clear(); + m_itemList = list; +} + +void SystemManageDialog::on_buttonCancel_clicked() +{ + //超级用户密码权限,单次有效 + g_emUser = operate; + done(0); +} + +void SystemManageDialog::on_buttonOk_clicked() +{ + if(m_updateType == HMI_UPDATA)//界面升级 + { + //升级需要重新启动程序,是否重启进行升级? + qDebug()<<"HMI_UPDATA"; + + PromptDialog promptDlg(this); + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDlg.setTitleStr(tr("Prompt")); + + QString str; + str = tr("The upgrade needs to restart the program. Do you need to restart to upgrade?");//升级需要重新启动程序,是否重启进行升级? + promptDlg.setContentStr(str); + if(promptDlg.exec() != 1) + { + //done(0); + return; + } + } + done(1); +} + +void SystemManageDialog::on_buttonPgUp_clicked() +{ + m_curPages--; + refreshUi(); +} + +void SystemManageDialog::on_buttonPgDn_clicked() +{ + m_curPages++; + refreshUi(); +} + +void SystemManageDialog::on_button1_clicked() +{ + clickItem(1); +} + +void SystemManageDialog::on_button2_clicked() +{ + clickItem(2); +} + +void SystemManageDialog::on_button3_clicked() +{ + clickItem(3); +} + +void SystemManageDialog::on_button4_clicked() +{ + clickItem(4); +} + +void SystemManageDialog::on_button5_clicked() +{ + clickItem(5); +} + +void SystemManageDialog::on_button6_clicked() +{ + clickItem(6); +} + +void SystemManageDialog::on_button7_clicked() +{ + clickItem(7); +} + +void SystemManageDialog::on_button8_clicked() +{ + clickItem(8); +} + +void SystemManageDialog::on_buttonDelete_clicked() +{ + if(m_updateType == PRODUCTSTATIS)//等于生产统计 + { + PromptDialog promptDlg(this); + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDlg.setTitleStr(tr("Prompt")); + + QString str; + str = tr("Do you want to clear the production statistics?");//是否清空生产统计? + promptDlg.setContentStr(str); + if(promptDlg.exec() == 1) + { + emit siClearProductStatis(); + } + } + else if(m_updateType == JOURNAL) + { + PromptDialog promptDlg(this); + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDlg.setTitleStr(tr("Prompt")); + + QString str; + str = tr("Do you want to clear the journal?");//是否清空日志文件? + promptDlg.setContentStr(str); + if(promptDlg.exec() == 1) + { + emit siClearJournal(); + } + } +} + +void SystemManageDialog::on_buttonSelectAll_clicked() +{ + if(m_selectedIdx == SELECT_ALL) + { + m_selectedIdx = SELECT_NONE; + } + else + { + m_selectedIdx = SELECT_ALL; + } + refreshCheckedPage(); +} + +//导出csv文件 +void SystemManageDialog::on_buttonExport_clicked() +{ + if(m_updateType == JOURNAL)//等于日志文件 + { + PromptDialog promptDlg(this); + promptDlg.initDialog(PromptDialog::BTN_OK_CANCEL); + promptDlg.setTitleStr(tr("Prompt")); + + QString str; + str = tr("Do you want to export journal?");//是否导出日志文件? + promptDlg.setContentStr(str); + if(promptDlg.exec() == 1) + { + emit siCsvExport(m_logType); + } + } +} + +void SystemManageDialog::on_buttonChangeLog_clicked() +{ + //done(0); + //qDebug()<<"buttonChange_clicked" < TYPE_DEBUGINFO) + { + m_logType = 0; + } + + if(m_logType == TYPE_ERROR) + { + emit siCsvChangeErro(); + } + else if(m_logType == TYPE_BREAK) + { + emit siCsvChangeBrea(); + } + else if(m_logType == TYPE_DEBUGINFO) + { + emit siCsvChangeDebug(); + } + + refreshUi(); +} + +//刷新wifi +void SystemManageDialog::on_buttonRefresh_clicked() +{ + m_curPages = 1;//当前页数 + m_pageNums = 1;//总页数 + m_selectedIdx = SELECT_NONE;//被选中的条目 + emit siRefreshWifiList(); + refreshUi(); +} + +void SystemManageDialog::on_buttonPgUpWIFI_clicked() +{ + m_curPages--; + refreshUi(); +} + +void SystemManageDialog::on_buttonPgDnWIFI_clicked() +{ + m_curPages++; + refreshUi(); +} + +void SystemManageDialog::on_buttonSetAutoIP_clicked() +{ + if(m_selectedIdx < m_itemList.size() && m_selectedIdx >= 0) + { + QString ssid = m_itemList.at(m_selectedIdx); + emit siSetDynamicIP(ssid); + } +} + +void SystemManageDialog::on_buttonSetStaticIP_clicked() +{ + QString ssid = m_curConnectWifi; + QString psd = m_curConnectWifiPass; + QStringList ipList = ui->labelCurIP->text().split(".", QString::SkipEmptyParts); + QString ip; + ip.clear(); + if(ipList.size() >= 3) + { + ip = ipList[0]+"."+ipList[1]+"."+ipList[2]+"."; + } + + emit siSetStaticIP(ssid,psd,ip); +} + +void SystemManageDialog::on_buttonCancelWIFI_clicked() +{ + done(0); +} diff --git a/sharedviews/systemmanagedialog.h b/sharedviews/systemmanagedialog.h new file mode 100644 index 0000000..214a52a --- /dev/null +++ b/sharedviews/systemmanagedialog.h @@ -0,0 +1,108 @@ +#ifndef SYSTEMMANAGEDIALOG_H +#define SYSTEMMANAGEDIALOG_H + +#include +#include +#include "promptdialog.h" + +#include "setcontrolstyle.h" + +#define SELECT_NONE -2 //全不选 +#define SELECT_ALL -1 //全选 + +namespace Ui { +class SystemManageDialog; +} + +class SystemManageDialog : public QDialog +{ + Q_OBJECT + +public: + explicit SystemManageDialog(QWidget *parent = 0); + ~SystemManageDialog(); + +private: + Ui::SystemManageDialog *ui; + int m_itemPerPage;//界面每页条目数 + QList m_itemBtnList; + + int m_curPages;//当前页数 + int m_pageNums;//总页数 + int m_selectedIdx;//被选中的条目 + QStringList m_itemList; + + int m_updateType;//升级类型 + int m_logType;//日志类型 0:报错 1:断线 + s16 m_setType; + + QString m_curConnectWifi;//当前连接的wifi + QString m_curConnectWifiPass;//当前连接的wifi密码 + bool m_curConnectMode;//当前连接的方式 + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006(); + void initControlStyle();//初始化窗体控件样式 + + void refreshCheckedPage();//刷新条目选中状态 + void clickItem(int idx);//点击某一条目 + +public: + void initDialog(s16 type = 0); + void refreshUi(); + void setTypeLogo(QString tStyle);//设置类型图标 + void setMainTitle(QString str);//设置主title + void setSubTitle(QString str);//设置副title + + void addItem(QString str); + + void addListError();//读取错误日志CSV + void addListBreakage();//读取断线日志CSV + void addListDebug();//读取调试信息CSV + + int exec(int type = 0);//升级类型 + + QString getCurFile();//获取当前选中的文件 + inline int getCurIdx(){return m_selectedIdx;} + void setWifiInfo(QString ip,QString ssid,QString psd,bool mode); + void setItemList(QStringList list); + +signals: + void siClearProductStatis();//清空产量统计 + void siCsvExport(int logType);//导出csv文件 + void siClearJournal();//清空文件日志 + void siCsvChangeErro();//切换报错 + void siCsvChangeBrea();//切换断线 + void siCsvChangeDebug();//切换调试信息 + void siRefreshWifiList();//刷新wifi列表 + void siSetDynamicIP(QString);//设置动态IP + void siSetStaticIP(QString,QString,QString);//设置静态IP + +private slots: + void on_buttonCancel_clicked(); + void on_buttonOk_clicked(); + void on_buttonPgUp_clicked(); + void on_buttonPgDn_clicked(); + void on_button1_clicked(); + void on_button2_clicked(); + void on_button3_clicked(); + void on_button4_clicked(); + void on_button5_clicked(); + void on_button6_clicked(); + void on_button7_clicked(); + void on_button8_clicked(); + void on_buttonDelete_clicked(); + void on_buttonSelectAll_clicked(); + void on_buttonExport_clicked(); + void on_buttonChangeLog_clicked(); + void on_buttonRefresh_clicked(); + void on_buttonPgUpWIFI_clicked(); + void on_buttonPgDnWIFI_clicked(); + void on_buttonSetAutoIP_clicked(); + void on_buttonSetStaticIP_clicked(); + void on_buttonCancelWIFI_clicked(); +}; + +#endif // SYSTEMMANAGEDIALOG_H diff --git a/sharedviews/systemmanagedialog.ui b/sharedviews/systemmanagedialog.ui new file mode 100644 index 0000000..8cbea0b --- /dev/null +++ b/sharedviews/systemmanagedialog.ui @@ -0,0 +1,649 @@ + + + SystemManageDialog + + + + 0 + 0 + 1024 + 600 + + + + Dialog + + + background-color: rgb(120, 120, 120); + + + + + 0 + 0 + 1024 + 600 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 20 + 570 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + PageNums: 1/1 + + + + + + 140 + 280 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 360 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 320 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 80 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 680 + 560 + 321 + 31 + + + + background-color: rgba(255, 255, 255, 0); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 80 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 240 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 160 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 0 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + + 140 + 160 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 240 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 200 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 30 + 10 + 60 + 60 + + + + Qt::NoFocus + + + + + + + + + + + + 110 + 10 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Update + + + + + + 140 + 120 + 760 + 32 + + + + Qt::NoFocus + + + + + + + + + + + + 140 + 40 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + Update + + + + + + 680 + 10 + 321 + 61 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 250 + 20 + 41 + 40 + + + + Qt::NoFocus + + + + + + + + + 200 + 20 + 40 + 40 + + + + Qt::NoFocus + + + background-color: rgb(255, 255, 255); + + + + + + + + + 150 + 20 + 41 + 40 + + + + Qt::NoFocus + + + + + + + + + 100 + 20 + 41 + 40 + + + + Qt::NoFocus + + + + + + + + + + 680 + 10 + 321 + 61 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 250 + 20 + 41 + 40 + + + + Qt::NoFocus + + + + + + + + + 30 + 20 + 181 + 21 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + 192.168.2.196 + + + + + + + 600 + 560 + 401 + 31 + + + + background-color: rgb(118, 118, 118); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 80 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 240 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + StaticIP + + + + + + 160 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + DynamicIP + + + + + + 0 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + 320 + 0 + 75 + 23 + + + + Qt::NoFocus + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + + + + + + + + 160 + 560 + 421 + 31 + + + + + Arial + 8 + + + + background-color: rgba(255, 255, 255, 0); +color: rgb(255, 255, 255); + + + *Before setting the static IP, you need to first set the dynamic IP. After the dynamic IP is set, you need to return to this interface to continue setting the static IP + + + true + + + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/sharedviews/wordsinputdialog.cpp b/sharedviews/wordsinputdialog.cpp new file mode 100644 index 0000000..28e6090 --- /dev/null +++ b/sharedviews/wordsinputdialog.cpp @@ -0,0 +1,360 @@ +#include "wordsinputdialog.h" +#include "ui_wordsinputdialog.h" + +WordsInputDialog::WordsInputDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::WordsInputDialog) +{ + ui->setupUi(this); + setWindowFlags (Qt::Window | Qt::FramelessWindowHint); + setWindowModality(Qt::ApplicationModal); + setAttribute(Qt::WA_TranslucentBackground, true);//设置窗体背景透明 + + m_buttonWordList.clear(); + m_buttonWordList.append(ui->buttonLatterQ); + m_buttonWordList.append(ui->buttonLatterW); + m_buttonWordList.append(ui->buttonLatterE); + m_buttonWordList.append(ui->buttonLatterR); + m_buttonWordList.append(ui->buttonLatterT); + m_buttonWordList.append(ui->buttonLatterY); + m_buttonWordList.append(ui->buttonLatterU); + m_buttonWordList.append(ui->buttonLatterI); + m_buttonWordList.append(ui->buttonLatterO); + m_buttonWordList.append(ui->buttonLatterP); + m_buttonWordList.append(ui->buttonLatterA); + m_buttonWordList.append(ui->buttonLatterS); + m_buttonWordList.append(ui->buttonLatterD); + m_buttonWordList.append(ui->buttonLatterF); + m_buttonWordList.append(ui->buttonLatterG); + m_buttonWordList.append(ui->buttonLatterH); + m_buttonWordList.append(ui->buttonLatterJ); + m_buttonWordList.append(ui->buttonLatterK); + m_buttonWordList.append(ui->buttonLatterL); + m_buttonWordList.append(ui->buttonLatterZ); + m_buttonWordList.append(ui->buttonLatterX); + m_buttonWordList.append(ui->buttonLatterC); + m_buttonWordList.append(ui->buttonLatterV); + m_buttonWordList.append(ui->buttonLatterB); + m_buttonWordList.append(ui->buttonLatterN); + m_buttonWordList.append(ui->buttonLatterM); + + for(int var = 0; var < m_buttonWordList.size(); var++) + { + connect(m_buttonWordList.at(var), + SIGNAL(clicked()), + this, + SLOT(inputBtnClick()) + ); + } + + m_buttonNumberList.clear(); + m_buttonNumberList.append(ui->buttonNum1); + m_buttonNumberList.append(ui->buttonNum2); + m_buttonNumberList.append(ui->buttonNum3); + m_buttonNumberList.append(ui->buttonNum4); + m_buttonNumberList.append(ui->buttonNum5); + m_buttonNumberList.append(ui->buttonNum6); + m_buttonNumberList.append(ui->buttonNum7); + m_buttonNumberList.append(ui->buttonNum8); + m_buttonNumberList.append(ui->buttonNum9); + m_buttonNumberList.append(ui->buttonNum0); + for(int var = 0; var < m_buttonNumberList.size(); var++) + { + connect(m_buttonNumberList.at(var), + SIGNAL(clicked()), + this, + SLOT(inputBtnClick()) + ); + } + + m_shift = 1; + m_inputStr.clear(); + ui->labelNameNewWords->clear(); + ui->labelNameOldWords->clear(); + ui->buttonOk->setEnabled(false); + + initControl(); +} + +WordsInputDialog::~WordsInputDialog() +{ + delete ui; +} + +void WordsInputDialog::setInputStr(QString str) +{ + m_inputStr = m_inputStr + str; + ui->labelNameNewWords->setText(m_inputStr); + if(m_inputStr.length() > 0) + { + ui->buttonOk->setEnabled(true); + } +} + +//初始化窗体控件,包括位置、尺寸、样式 +void WordsInputDialog::initControl() +{ + //根据不同分辨率设置控件的位置和尺寸 + switch (g_emResolut) + { + case resolution1910: + initResolution1910(); + break; + case resolution1006: + initResolution1006(); + default: + this->resize(1920,1080); + break; + } + + initControlStyle();//初始化窗体控件样式 +} + +//初始化窗体控件为1920x1080分辨率 +void WordsInputDialog::initResolution1910() +{ + double factoryX = 1.875; + double factoryY = 1.8; + + this->resize(1024*factoryX,600*factoryY); + this->move((1920-this->width())/2,(1080-this->height())/2); + ui->frameBack->setGeometry(0*factoryX,0,1024*factoryX,600*factoryY); + ui->labelTitle->setGeometry(50*factoryX,55*factoryY,1024*factoryX,48*factoryY); + + ui->labelName->setGeometry(65*factoryX,148*factoryY,95*factoryX,33*factoryY); + ui->labelNameNewWords->setGeometry(194*factoryX,143*factoryY,554*factoryX,44*factoryY); + ui->labelNameOldWords->setGeometry(575*factoryX,147*factoryY,200*factoryX,44*factoryY); + + for(int i = 0; i < m_buttonNumberList.size(); i++) + { + m_buttonNumberList[i]->setGeometry((60+i*91)*factoryX,233*factoryY,67*factoryX,40*factoryY); + } + + int x = 0; + int y = 0; + int idx = 0; + for(int i = 0; i < m_buttonWordList.size(); i++) + { + if(m_buttonWordList[i]->text().toUpper() == "Q") + { + x = 60; + y = 295; + idx = i; + } + if(m_buttonWordList[i]->text().toUpper() == "A") + { + x =97; + y = 353; + idx = 0; + } + if(m_buttonWordList[i]->text().toUpper() == "Z") + { + x = 189; + y = 414; + idx = 0; + } + m_buttonWordList[i]->setGeometry((x+idx*91)*factoryX,y*factoryY,67*factoryX,40*factoryY); + idx++; + } + + ui->buttonShift->setGeometry(60*factoryX,414*factoryY,107*factoryX,40*factoryY); + ui->buttonBack->setGeometry(827*factoryX,414*factoryY,107*factoryX,40*factoryY); + ui->frameTwo->setGeometry(725*factoryX,472*factoryY,321*factoryX,51*factoryY); + ui->buttonOk->setGeometry(0,0,107*factoryX,40*factoryY); + ui->buttonCancel->setGeometry(135*factoryX,0,107*factoryX,40*factoryY); +} +//初始化窗体控件为1024x600分辨率 +void WordsInputDialog::initResolution1006() +{ + this->resize(1024,600); + this->move((1024-this->width())/2,(600-this->height())/2); + ui->frameBack->setGeometry(0,0,1024,600); + ui->labelTitle->setGeometry(50,55,1024,48); + + ui->labelName->setGeometry(65,148,95,33); + ui->labelNameNewWords->setGeometry(194,143,554,44); + ui->labelNameOldWords->setGeometry(575,147,200,44); + + for(int i = 0; i < m_buttonNumberList.size(); i++) + { + m_buttonNumberList[i]->setGeometry(60+i*91,233,67,40); + } + + int x = 0; + int y = 0; + int idx = 0; + for(int i = 0; i < m_buttonWordList.size(); i++) + { + if(m_buttonWordList[i]->text().toUpper() == "Q") + { + x = 60; + y = 295; + idx = i; + } + if(m_buttonWordList[i]->text().toUpper() == "A") + { + x =97; + y = 353; + idx = 0; + } + if(m_buttonWordList[i]->text().toUpper() == "Z") + { + x = 189; + y = 414; + idx = 0; + } + m_buttonWordList[i]->setGeometry(x+idx*91,y,67,40); + idx++; + } + ui->buttonShift->setGeometry(60,414,107,40); + ui->buttonBack->setGeometry(827,414,107,40); + ui->frameTwo->setGeometry(725,472,321,51); + ui->buttonOk->setGeometry(0,0,107,40); + ui->buttonCancel->setGeometry(135,0,107,40); +} + +//初始化窗体控件样式 +void WordsInputDialog::initControlStyle() +{ + SetControlStyle setControlStyle; + setControlStyle.setUiName(this->objectName()); + + //白蓝色渐变、灰蓝色渐变 + QString style = "QPushButton{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(255, 255, 255), stop:1 rgb(215, 243, 254));border-radius:5px;}"; + style += "QPushButton:pressed{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(217, 222, 224), stop:1 rgb(191,213,223));}"; + style += "QPushButton:disabled{background-color: qlineargradient(spread:pad, x1:0.5 y1:0, x2:0.5, y2:1, stop:0 rgb(230, 230, 230), stop:1 rgb(182,182,182));}"; + + for(int i = 0; i < m_buttonWordList.size(); i++) + { + m_buttonWordList[i]->setStyleSheet(style); + m_buttonWordList[i]->setFont(fontNormal_1); + } + + for(int i = 0; i < m_buttonNumberList.size(); i++) + { + m_buttonNumberList[i]->setStyleSheet(style); + m_buttonNumberList[i]->setFont(fontNormal_1); + } + + ui->frameBack->setStyleSheet(TRANSPARENTSTYLE); + ui->frameBack->setStyleSheet(setControlStyle.getStyleSheet(this->objectName())); + + ui->labelName->setStyleSheet(LABELWHITESTYLE); + ui->labelName->setFont(fontNormal_1); +// ui->labelName->setAlignment(Qt::AlignRight); +// ui->labelName->setAlignment(Qt::AlignVCenter); + + ui->labelTitle->setStyleSheet(LABELWHITESTYLE); + ui->labelTitle->setFont(fontNormal_1); + ui->labelTitle->setAlignment(Qt::AlignLeft); + ui->labelTitle->setAlignment(Qt::AlignVCenter); + + ui->labelNameNewWords->setStyleSheet(LABELWHITESTYLE); + ui->labelNameNewWords->setFont(fontNormal_1); + ui->labelNameNewWords->setAlignment(Qt::AlignLeft); + ui->labelNameNewWords->setAlignment(Qt::AlignVCenter); + + ui->labelNameOldWords->setStyleSheet(LABELWHITESTYLE); + ui->labelNameOldWords->setFont(fontNormal_1); + ui->labelNameOldWords->setAlignment(Qt::AlignLeft); + ui->labelNameOldWords->setAlignment(Qt::AlignVCenter); + + ui->buttonShift->setStyleSheet(style); + ui->buttonShift->setFont(fontNormal_1); + + ui->buttonBack->setStyleSheet(style); + ui->buttonBack->setFont(fontNormal_1); + + ui->frameTwo->setStyleSheet(TRANSPARENTSTYLE); + ui->buttonOk->setWhiteBlueBottomStyle(); + ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1"),12); + ui->buttonCancel->setWhiteBlueBottomStyle(); + ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"),12); +} + +void WordsInputDialog::setTitleStr(QString str) +{ + ui->labelTitle->setText(str); +} + +void WordsInputDialog::setOldWordsStr(QString str) +{ + ui->labelNameOldWords->setText(str); +} + +void WordsInputDialog::clean() +{ + m_inputStr.clear(); + ui->labelNameNewWords->clear(); + ui->buttonOk->setEnabled(false); +} + +void WordsInputDialog::wifiClean() +{ + m_inputStr.clear(); + ui->labelNameNewWords->clear(); + ui->buttonOk->setEnabled(true); +} + +QString WordsInputDialog::getInputStr() +{ + return m_inputStr; +} + +void WordsInputDialog::inputBtnClick() +{ + QPushButton *button = (QPushButton*) this->sender() ; + + if(button == NULL) + { + return; + } + QString str = button->text(); + setInputStr(str); +} + +void WordsInputDialog::on_buttonShift_clicked() +{ + m_shift = -1 * m_shift; + + for(int i = 0; i < m_buttonWordList.size(); i++) + { + if(m_shift == -1) + { + QString lostr=m_buttonWordList[i]->text().toLower(); + m_buttonWordList[i]->setText(lostr); + } + else if(m_shift == 1) + { + QString upstr=m_buttonWordList[i]->text().toUpper(); + m_buttonWordList[i]->setText(upstr); + } + } +} + +void WordsInputDialog::on_buttonBack_clicked() +{ + if(m_inputStr.length() <= 0) + { + return; + } + + m_inputStr = m_inputStr.remove(m_inputStr.length()-1,m_inputStr.length()); // 删除最后一位字符 + ui->labelNameNewWords->setText(m_inputStr); + + if(m_inputStr.length() <= 0) + { + ui->buttonOk->setEnabled(false); + } +} + +void WordsInputDialog::on_buttonOk_clicked() +{ + done(1); +} + +void WordsInputDialog::on_buttonCancel_clicked() +{ + clean(); + done(0); +} diff --git a/sharedviews/wordsinputdialog.h b/sharedviews/wordsinputdialog.h new file mode 100644 index 0000000..57489a6 --- /dev/null +++ b/sharedviews/wordsinputdialog.h @@ -0,0 +1,53 @@ +#ifndef WORDSINPUTDIALOG_H +#define WORDSINPUTDIALOG_H + +#include +#include "mybutton.h" +#include "setcontrolstyle.h" + +namespace Ui { +class WordsInputDialog; +} + +class WordsInputDialog : public QDialog +{ + Q_OBJECT + +public: + explicit WordsInputDialog(QWidget *parent = 0); + ~WordsInputDialog(); + +private: + Ui::WordsInputDialog *ui; + +private: + void setInputStr(QString str);//设置字符 + +private: + void initControl();//初始化窗体控件,包括位置、尺寸、样式 + void initResolution1910();//初始化窗体控件为1920x1080分辨率 + void initResolution1006();//初始化窗体控件为1024x600分辨率 + void initControlStyle();//初始化窗体控件样式 + +private: + QList m_buttonWordList; + QList m_buttonNumberList; + int m_shift; //-1:字母小写 1:字母大写 + QString m_inputStr;//输入的字符 + +public: + void setTitleStr(QString str);//设置标题 + void setOldWordsStr(QString str);//设置标题 + void clean(); + void wifiClean(); + QString getInputStr();//获取输入的字符 + +private slots: + void inputBtnClick(); + void on_buttonShift_clicked(); + void on_buttonBack_clicked(); + void on_buttonOk_clicked(); + void on_buttonCancel_clicked(); +}; + +#endif // WORDSINPUTDIALOG_H diff --git a/sharedviews/wordsinputdialog.ui b/sharedviews/wordsinputdialog.ui new file mode 100644 index 0000000..4222e35 --- /dev/null +++ b/sharedviews/wordsinputdialog.ui @@ -0,0 +1,1880 @@ + + + WordsInputDialog + + + + 0 + 0 + 1010 + 440 + + + + Dialog + + + + + 0 + 0 + 1024 + 48 + + + + background-color: rgb(0, 170, 255); + + + Words input + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 760 + 310 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + M + + + false + + + false + + + false + + + + + + 510 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 6 + + + false + + + false + + + false + + + + + + 208 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + E + + + false + + + false + + + false + + + + + + 610 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + U + + + false + + + false + + + false + + + + + + 760 + 250 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + K + + + false + + + false + + + false + + + + + + 107 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 2 + + + false + + + false + + + false + + + + + + 560 + 250 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + H + + + false + + + false + + + false + + + + + + 660 + 250 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + J + + + false + + + false + + + false + + + + + + 410 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + T + + + false + + + false + + + false + + + + + + 910 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + P + + + false + + + false + + + false + + + + + + 360 + 250 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + F + + + false + + + false + + + false + + + + + + 560 + 310 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + B + + + false + + + false + + + false + + + + + + 208 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 3 + + + false + + + false + + + false + + + + + + 7 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + Q + + + false + + + false + + + false + + + + + + 107 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + W + + + false + + + false + + + false + + + + + + 610 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 7 + + + false + + + false + + + false + + + + + + 160 + 250 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + S + + + false + + + false + + + false + + + + + + 58 + 250 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + A + + + false + + + false + + + false + + + + + + 360 + 310 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + C + + + false + + + false + + + false + + + + + + 910 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 0 + + + false + + + false + + + false + + + + + + 7 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 1 + + + false + + + false + + + false + + + + + + 10 + 70 + 181 + 44 + + + + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 710 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + I + + + false + + + false + + + false + + + + + + 200 + 70 + 581 + 44 + + + + font: 16pt "wqy-microhei"; +background-color: rgb(255, 255, 255); +border: 0px solid rgb(11 , 137 , 234); + + + + + + Qt::AlignCenter + + + + + + 510 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + Y + + + false + + + false + + + false + + + + + + 460 + 310 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + V + + + false + + + false + + + false + + + + + + 159 + 310 + 91 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + Z + + + false + + + false + + + false + + + + + + 309 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + R + + + false + + + false + + + false + + + + + + 860 + 310 + 130 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + + wqy-microhei + 16 + 50 + false + false + + + + Qt::NoFocus + + + + + + + + + false + + + false + + + false + + + + + + 810 + 190 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + O + + + false + + + false + + + false + + + + + + 410 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 5 + + + false + + + false + + + false + + + + + + 660 + 310 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + N + + + false + + + false + + + false + + + + + + 309 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 4 + + + false + + + false + + + false + + + + + + 710 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 8 + + + false + + + false + + + false + + + + + + 260 + 250 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + D + + + false + + + false + + + false + + + + + + 860 + 250 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + L + + + false + + + false + + + false + + + + + + 460 + 250 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + G + + + false + + + false + + + false + + + + + + 0 + 0 + 1010 + 440 + + + + + 30 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + buttonNum9 + buttonLatterM + buttonLatterO + buttonLatterA + buttonLatterT + buttonLatterU + buttonLatterJ + buttonLatterE + buttonLatterB + buttonNum0 + buttonNum8 + buttonLatterY + buttonNum5 + buttonLatterK + buttonLatterR + buttonNum2 + buttonNum1 + buttonLatterZ + buttonLatterF + buttonNum3 + buttonLatterL + buttonLatterW + buttonLatterQ + buttonLatterD + buttonLatterC + buttonShift + buttonLatterV + buttonNum6 + buttonLatterI + buttonLatterS + buttonNum4 + buttonBack + buttonLatterX + buttonLatterH + buttonNum7 + buttonLatterG + buttonLatterP + buttonLatterN + buttonShift + buttonLatterM + buttonLatterO + buttonLatterA + buttonLatterT + buttonLatterU + buttonLatterJ + buttonLatterE + buttonLatterB + buttonNum0 + buttonNum8 + buttonLatterY + buttonNum5 + buttonLatterK + buttonLatterR + buttonNum2 + buttonNum1 + buttonLatterZ + buttonLatterF + buttonNum3 + buttonLatterL + buttonLatterW + buttonLatterQ + buttonLatterD + buttonNum9 + buttonLatterC + buttonLatterV + buttonNum6 + buttonLatterI + buttonLatterS + buttonNum4 + buttonBack + buttonLatterX + buttonLatterH + buttonNum7 + buttonLatterG + buttonLatterP + buttonLatterN + + + + + 800 + 70 + 161 + 44 + + + + border:0px; + + + old + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 10 + 310 + 141 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + + wqy-microhei + 16 + 50 + false + false + + + + Qt::NoFocus + + + + + + + + + false + + + false + + + false + + + + + + 670 + 380 + 321 + 51 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 88 + 0 + 92 + 48 + + + + + 10 + 10 + + + + + 500 + 100 + + + + Qt::NoFocus + + + + + + + + + false + + + false + + + false + + + + + + 190 + 0 + 92 + 48 + + + + + 10 + 10 + + + + + 500 + 100 + + + + Qt::NoFocus + + + + + + + + + false + + + false + + + false + + + + + + + 260 + 310 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + X + + + false + + + false + + + false + + + + + + 810 + 130 + 92 + 50 + + + + + 30 + 10 + + + + + 500 + 200 + + + + Qt::NoFocus + + + + + + 9 + + + false + + + false + + + false + + + frameBack + labelTitle + buttonLatterM + buttonNum6 + buttonLatterE + buttonLatterU + buttonLatterK + buttonNum2 + buttonLatterH + buttonLatterJ + buttonLatterT + buttonLatterP + buttonLatterF + buttonLatterB + buttonNum3 + buttonLatterQ + buttonLatterW + buttonNum7 + buttonLatterS + buttonLatterA + buttonLatterC + buttonNum0 + buttonNum1 + labelName + buttonLatterI + labelNameNewWords + buttonLatterY + buttonLatterV + buttonLatterZ + buttonLatterR + buttonBack + buttonLatterO + buttonNum5 + buttonLatterN + buttonNum4 + buttonNum8 + buttonLatterD + buttonLatterL + buttonLatterG + labelNameOldWords + buttonShift + frameTwo + buttonLatterX + buttonNum9 + + + + MyButton + QPushButton +
sharedviews/mybutton.h
+
+
+ + +
diff --git a/spanish.qm b/spanish.qm new file mode 100644 index 0000000000000000000000000000000000000000..35211cc79c7002151c8d3093e149f2fccade2c6b GIT binary patch literal 13706 zcmc&)d2Afj8UJFh?<*mWLlP%U%oT_Yj!6)NsH$TVTAGkFPNFuTl=1GYJ<06MGP`Tn zp{0VVNmW$=S`eb8+(HFJ|A49uh(b6D5`q@Bsw!xpcM)e*f=a6*=i$I3aENHIj}kw7m8kQ#)Ue<& zqV7lViTm9jP(vEmOYWtH`!6S2`5HC0UrV%VGhKY{jYN(6Y3#cPh)(+!?X3G1QQJY< z`Qsb#+zxvDkWJM0JiYi!e4g^roUV5ph~~dNXKW3wPuMo+8}6+{Cq6Uh*Z&(L{8zW& z?mLMVe!FgB;Uz>}O?CV4d6G!8>mJ{L`4>0Tz4P=PL<9e*PaS>-<1DX#AoT%$f3N=G zNBf9QdZ+&I4?FSxk;Li$#pmg_C05*t`%SA7X&NP3c1OZoi*XhmNaW9Xf~fb4iQ76b z&k85;^vtP5^EwkR9{DSHcr@|yA29B!-zPr&<}Kjkyu^q5@Y(UBhL)KF;Hs@*?-lP7 zoq1)$fj4m7^Sj2?BXc0{^^H^4zE3pgrN){0j}o=pjSqbEDpAW*P4!a?A>H4ax}So) zCv9%p)%+gbf3xYqt5f)WVbg#9jd5DvZ{GF6ION>l{Op;-L}%^A=X#>EJDQ*0bC{_A zVDs}fe=cc0a?c^)xUQw)>&w6|wJiM*d@nuHvijBsf#=GW8`faFvu|&?{eqW>n!nQW zjP@4M&~VG!KXAd{_SX4lfR}kcZ$0Dub@;rjb>+=>5iK~>df(M~@bysZAFsL!JnU#| znK2;uVB3nrz}3C2&E8o@RR2cX)fRA_zNYPg)YmZYm2GdHi{DSash!UHJM`q0_R%j~ z1bi>IUpn|bqUEXf>(}>#&+oV2a`On$sn4}PanZAoe@**eUO6A@{BXz8YcO8#T^%>g z{SDryj(g@oj@Frud!O7-G&j@Pao%fCkDqp)@B-vL<($s(1Hj$*Sm(h@f#-}zy6FBS z@Q-$NKZ|irJFDyV-URNi?t17am^X32gz(qZV}xCFAz7qRl1zM>WK)V2Oj47xQe}lv0w&P}WOG_5=dDEWg*Rlo6 z5?^#Xr6nyrlf{*moWaeM;Wpu=d1J=(wrOX~Oc|T>Ad$FBCCCCBzirYHAl2}#fRPN`H3e>d&!8!ww;>lxK7+q;eA_LqyqQY*Dj$bO z@R2)QaHxuA>?PaCwf<7#Pr+%=P0)-`fD!B$Kv?yjNZvoEC7 z9Vx1(n{h2=-O-USZh#sihC+OaHVXaCLMK`KqYKK`lff_fq7BGJ&ciBnJQ+NzTE5eK zNz#1?3x`cts%rsDly#lF zkz`sFAQoel3bYqe$!S?~9RtIg`op#kTe_Rk*kdY2+6{3kt+e#@?C;nQ%6U`~KnK^s zlhUiQpU>jH4Wv5dd}K>UJU6~upALLh(t6JWst(_|thgovgH zUjdqO!}f@gAzp>A&&MYslmMsM#)O_Xrwq+9GiF|~K)a8@>D0sq-c@dBMJ2?(N79RV zh?$>J;I788=REUR0ZtK)BgYbP431M(4V}$aI&@A%W(RA3DZ5if#;{p=;bk?~$QN8& z^Vn7}{25_KY&%hBF5O;D9q@g`;xasOY$#imv+&G}r8F?IEtOh);Am>w)5_|2y&xWk zzR8FH((iF}4089`23}@XfwR)~8m4U1Uho zh*xQ~c{rZXhN?pwiUF+^C8#Xd9Dkt1s57lfyR3*gh3g#lq3jbTz;CLC$LBPIV`)w( zxR+d2Pdv0ySD*IX6`W_%Fojjc@ShfK1u~i1q(bJvYFIggy#gj>fEh-Z!gv1k43H&c z)X}?~RJojp`aJesn1Y(*3_YWbyN14p)9RE_Ol$GY(p6FQGOWyQ%)v8x?64Eyge@16 zfeU+Cd;q#{PatZf)63yAYZ7O+L8P0H zL?n>xa5+n0N5+|fOMebkqlt^1iAxkCEE5%BcmzhpHp$i*kig??QH--LQWEmp1u+U2 zh$bpzcDzh2yHbbFW``=4fsqFxYVk%R4T{kLbfKDgZQQVmS#?e^_g5oxOI9Z_A1|?& zIdRj17n&ECU2Twev8?5ewG=Zy!#&V2?!eNPmf+5zl4h4HatRf5*(wfTmQEW`(=DbD zP0@fA1u0q4`wXIBI1^Gu!OC<^#wDg933}x{ zsc&VKj6dt5O~vkAC?m~5dS%CX2h!**@S$EJ%#-lW61xKKZI(ADO4mTbDoOo)Py?G} zQ&0Hyf^BoQ4|iasjvK*mb!sb(P>59)*uiE;z$c;Ii#%grZRxyMtT}ZTwE`ETE0ui`^B`)kv(XqJyQY9MtmC(Nx~DSQ2G3 zZvSmmWQ*0Bu2CpnfnI${djb&QCa}VkH%7A6O0CpmS*-354!@hCK(V%l;jwDTE_*dB4zT;M_N6=NUyGZWh`;1c}=#Rcozv>ey z)T6RhD$6U?8ZhfjsdohUxn1^R0By#^zM#b^-ub1fJv_B5v* zcaLAeD@2IEzW5^+K={{Hjv1~=r>R01x}4m7uvf(ZMDm_2 nxOv^QwVXL&E6>Afh^n5v@)WF;m(RTlDg2RJ1bdoZ75M)Fw4*G@ literal 0 HcmV?d00001 diff --git a/spanish.ts b/spanish.ts new file mode 100644 index 0000000..b42ae1f --- /dev/null +++ b/spanish.ts @@ -0,0 +1,7072 @@ + + + + + BrokenLineDialog + + + Form + + + + + + 1 + + + + + Broken Line Prompt + + + + + ClothingMac + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + Template recognition device + + + + + No device:0;Bar code:1;Coding hole:2;Multiple files:3 + + + + + X frame sensor coordinates + + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Y frame sensor coordinates + + + + + Spindle parking sensor angle + + + + + Lift sensor coordinates + + + + + Angle of spindle hook sensor + + + + + Spindle jog parking angle + + + + + X movable area negative boundary + + + + + X movable area positive boundary + + + + + Y movable area negative boundary + + + + + Y movable area positive boundary + + + + + X Sewing area negative boundary + + + + + X Sewing area positive boundary + + + + + Y Sewing area negative boundary + + + + + Y Sewing area positive boundary + + + + + XY start stop speed + + + + + + + + + + + mm/s + + + + + XY zero running speed + + + + + XY simulate running speed + + + + + XY movement acceleration + + + + + + mm/s2 + + + + + XY brake acceleration + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + XY maximum moving speed + + + + + Spindle start stop speed + + + + + + + + + + + + + + + + + r/min + + + + + Spindle zero reset speed + + + + + Spindle running speed + + + + + Spindle running acceleration + + + + + + + r/ss + + + + + Spindle brake acceleration + + + + + sewing maximum speed + + + + + Spindle zeroing compensation angle + + + + + X gap compensation + + + + + Y gap compensation + + + + + Sewing main shaft working speed + + + + + Spindle cutting speed + + + + + Spindle needle return speed + + + + + Spindle start slow speed + + + + + Reverse equivalent spindle speed + + + + + Sewing frame movement mode + + + + + XY continuous:0;XY intermittent:1 + + + + + Sewing frame start angle + + + + + Sewing frame steadiness angle + + + + + Slow stitch at beginning + + + + + + + Needle + + + + + Needle action, thread loosen allowed + + + + + + + + + + + + + + + + + + + + + + Not allow:0;allowed:1 + + + + + Needle action,tight bobbin spring allowed + + + + + Needle action, catch upper thread allowed + + + + + Cut thread allowed + + + + + Do not trim:0;Automatic:1;Last trimming:2;Data trimming:3 + + + + + Trimmer cutting angle + + + + + Trimming completion angle + + + + + Thread cut, upper thread loosen allowed + + + + + Thread cut, tensile thread allowed + + + + + Thread cut, catch upper thread allowed + + + + + Thread cut, presser foot lift allowed + + + + + Stitch detect if thread broken + + + + + Thread brake detection, main shaft angle + + + + + Bobbin change reminder function + + + + + Not enabled: 0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bobbin thread length + + + + + Bobbin thread correction per stitch + + + + + Bobbin change as per sewed pieces + + + + + + times + + + + + Oiling mode selection + + + + + No oil:0;Oiling by time:1;Oiling by stitches:2;Oiling continously:3 + + + + + Oiling interval by needle stitch + + + + + Oiling interval by working time + + + + + + + s + + + + + Needle Oiling sustained time + + + + + Stop position selection after work complete + + + + + Current:0;Start:1;Anchor:2;Feeding:3;Offset:4 + + + + + Valid flag for offset point coordinates + + + + + + invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate valid symbol + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Delay after pneumatic frame off + + + + + Sewing acceleration + + + + + Trimming frame displacement + + + + + Automatic move to threading point allowed + + + + + Large presser foot action allowed + + + + + Sewing move head up down + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Software limit XY move allowed + + + + + Number of Needle hooks + + + + + Trimming frame direction + + + + + No:0;left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Early speed reduction + + + + + Delayed speed step + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Pneumatic frame off + + + + + + Penumatic frame on + + + + + ms + + + + + Loop work allowed + + + + + Shuttle Oiling sustained time + + + + + Sewing operation speed 1 + + + + + Sewing operation speed 2 + + + + + Sewing operation speed 3 + + + + + Change the sewing needle count value + + + + + Enable + Energìa potencial + + + + Disable + Eliminaciòn de energìa potencial + + + + JogP + marcha adelante + + + + JogN + Marcha atrás + + + + Zero + Puesta a cero + + + + Open + Abrir + + + + Close + Cerrar + + + + Up + + + + + Down + + + + + Extend + + + + + Back + + + + + Combine + + + + + Separate + + + + + X to move motor + + + + + Y to move motor + + + + + Spindle motor + + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + + + + + Frame + + + + + Big foot + + + + + Middle foot + + + + + Buckle the bottom line + + + + + Top and bottom lines + + + + + Lower scissors to cut thread + + + + + Sandwich line + + + + + Elastic thread + + + + + Elastic thread 2 + + + + + Laser control + + + + + Laser blow + + + + + Oil + + + + + Headlamp + + + + + Sewing Blow + + + + + Hookline ext + + + + + Hookline open and close + + + + + Sewing machine head lifting + + + + + Spindle clutch + + + + + Pen + + + + + All to zero + + + + + Needle shuttle reset + + + + + Back thread + + + + + Back offset + + + + + Back shuttle + + + + + Back work + + + + + Set anchor + + + + + Back anchor + + + + + + Back start + + + + + Forwrak or back + + + + + Bottom count reset + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + SoftwareSet + + + + + Authorization + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Select + + + + + Para + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + Botòn de inicio 1 + + + + Pause button 1 + Botòn de paro 1 + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ControlActionWidget + + + Form + + + + + Control action + 控制动作 + + + + + Control action < Auxiliary function + 控制动作 < 辅助功能 + + + + + PageNums: 1/1 + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PushButton + + + + + pageNum: + + + + + The machine is about to move, please pay attention to safety! + + + + + All to zero + + + + + DebugInfoDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + DebugInfo: + + + + + pageNum: 0/0 + + + + + pageNum: + + + + + FileSelectDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + pageNum: + + + + + FiveHeadPrecisionSewing + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + + + + + + + + + + + + + + + + + + + mm + + + + + Left + + + + + Front + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + Y Sewing area Negative boundary + + + + + sewing work speed + + + + + + r/min + + + + + Bobbin thread length + Bottom line length + + + + + Refueling method selection + + + + + Head 4 shuttle refueling + Refueling needles interval + + + + + Refueling duration + + + + + Production preset + + + + + Sewing machine head 2 - surface thread breakage inspection + Thread trimming moving frame direction + + + + + Pin 1 motor + + + + + Allow for needle starting and thread loosening + + + + + Allow for loose thread during thread cutting + + + + + Allow needle withdrawal during thread cutting + + + + + Automatically thread back points during sewing + + + + + Allow for loose lines when moving boxes + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + Shuttle 1 motor + + + + + Spindle 2 motor + + + + + Pin 2 motor + + + + + Shuttle 2 motor + + + + + Spindle 3 motor + + + + + Pin 3 motor + + + + + Shuttle 3 motor + + + + + Spindle 4 motor + + + + + Pin 4 motor + + + + + Spindle 5 motor + + + + + Pin 5 motor + + + + + Shuttle 5 motor + + + + + Head 1 Elastic thread + + + + + Head 2 Elastic thread + + + + + Head 3 Elastic thread + + + + + Head 4 Elastic thread + + + + + Head 5 Elastic thread + + + + + Head 1 blow + + + + + Head 2 blow + + + + + Head 3 blow + + + + + Head 4 blow + + + + + Head 5 blow + + + + + Head 1 trim + + + + + Head 2 trim + + + + + Head 3 trim + + + + + Head 4 trim + + + + + Head 5 trim + + + + + Head 1 needle refueling + + + + + Head 2 needle refueling + + + + + Head 3 needle refueling + + + + + Head 4 needle refueling + + + + + Head 5 needle refueling + + + + + Head 1 shuttle refueling + + + + + Head 2 shuttle refueling + + + + + Head 3 shuttle refueling + + + + + Head 5 shuttle refueling + + + + + Head 1 lifting + + + + + Head 2 lifting + + + + + Head 3 lifting + + + + + Head 4 lifting + + + + + Head 5 lifting + + + + + X Sewing area positive boundary + + + + + Y Sewing area positive boundary + + + + + Zero position coordinate of head 2 + + + + + Zero position coordinate of head 3 + + + + + Zero position coordinate of head 4 + + + + + Zero position coordinate of head 5 + + + + + Sewing motion frame method + + + + + Xy continuous moving box:0;Xy intermittent moving frame:1 + + + + + Thread cutting allowed + + + + + No. of stitch detect if thread broken + Number of thread breakage detection needles + + + + + Bobbin change reminder function + Change shuttle core reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + do not enable this feature:0;Count delay reminders by length:1;Count by number of pieces:2;Prompt immediately based on length:3 + + + + + Count of shuttle change pieces + + + + + Times + + + + + not refueling:0;Intermittent refueling according to worktime:1;Intermittent refueling according to the number of working stitches:2;Continuously refueling:3 + + + + + Interval between refueling stitches + + + + + + + second + + + + + Cutting and parting angle + + + + + Thread trimming completion angle + + + + + Software limit: xy movement + + + + + Automatic sewing speed regulation + Sewing speed reduction mode + + + + + Circular working function + + + + + Duration of shuttle refueling + + + + + Sewing and blowing time + + + + + Sewing hook angle + + + + + Continuous angle of sewing frame + + + + + Zero All + + + + + X to move motor + + + + + Y to move motor + + + + + Head moving motor + + + + + All spindle zero positions + + + + + Spindle 1 motor + Spindle motor + + + + + Shuttle 4 motor + Shuttle motor + + + + + Lock frame cylinder + + + + + Flap control + + + + + Barcode testing + + + + + AllSpleHook + AllSpindleJogs + + + + + Spindle thread cutting speed + + + + + Allowing for wire clamping during wire cutting + + + + + Number of stitches for surface thread clamping + + + + + Head 1 ThreadCuttingAction + + + + + Head 2 ThreadCuttingAction + + + + + Head 3 ThreadCuttingAction + + + + + Head 4 ThreadCuttingAction + + + + + Head 5 ThreadCuttingAction + + + + + Head 1 Clamp wire + + + + + Head 2 Clamp wire + + + + + Head 3 Clamp wire + + + + + Head 4 Clamp wire + + + + + Head 5 Clamp wire + + + + + MU_Canl + makeupCanl + + + + + Makeup1 + makeup1 + + + + + Makeup2 + makeup2 + + + + + Makeup3 + makeup3 + + + + + Makeup4 + makeup4 + + + + + Makeup5 + makeup5 + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + ThCutAct1 + + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Coordinate of threading point X + + + + + Coordinate of threading point Y + + + + + ThCutAct2 + + + + + ThCutAct3 + + + + + ThCutAct4 + + + + + ThCutAct5 + + + + + SetStart + + + + + ProcReset + + + + + Simulate + + + + + HeadLifting + + + + + GoFeedt + + + + + Back start + + + + + Select + + + + + X negative limit + + + + + Y negative limit + + + + + freedom from error + + + + + Not powered on + + + + + + Insufficient air pressure + + + + + + Safe Area Intervention + + + + + + The usage deadline has expired + + + + + Filling data error + + + + + + Working status not allowed + + + + + control error + + + + + Motion control chip version error + + + + + Waiting for button to lift timeout + + + + + FPGA reset error + + + + + Peripheral not ready + + + + + Transmission data error + + + + + Program version error + + + + + Production completed + + + + + forward limit + + + + + Reverse limit + + + + + Motion alarm + + + + + Motion limit + + + + + Exercise emergency stop + + + + + + Motion parameter error + + + + + + Machine parameter error + + + + + + Input parameter error + + + + + The file is correct + + + + + Waiting for files + + + + + Zero successfully + + + + + Zero error + + + + + + Coordinate system error + + + + + + Target position out of range + + + + + + X forward limit + + + + + + X reverse limit + + + + + + Y forward limit + + + + + + Y reverse limit + + + + + + No Data + + + + + data error + + + + + + Spindle not in zero position + + + + + + Rotary shuttle not in zero position + + + + + Needle shuttle out of sync + + + + + Rotation out of sync + + + + + The scissors are not returning to their original position + + + + + + Machine head not in high position + + + + + Machine head not in low position + + + + + Light curtain intervention + + + + + + Broken surface thread + + + + + Bottom line disconnection + + + + + + Head lifting timeout + + + + + + Replacing the shuttle core + + + + + Abnormal feeding pressure roller + + + + + Abnormal discharge pressure roller + + + + + Abnormal discharge and pressing + + + + + Tensioning device abnormal + + + + + Abnormal cloth clamping device + + + + + Edge cutting motor blocked + + + + + Cross cutting motor abnormality + + + + + Password set successfully + + + + + Password setting failed + + + + + Needle motor alarm + + + + + Shuttle motor alarm + + + + + X motor alarm + + + + + Y motor alarm + + + + + Needle motor reset failed + + + + + Shuttle motor reset failed + + + + + X motor reset failed + + + + + Y motor reset failed + + + + + Slave board communication timeout + + + + + X motor not in zero position + + + + + The safety door is not closed + + + + + The machine head is not in a safe area + + + + + Template not in place + + + + + Para + + + + + Starting angle of sewing frame + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + AllSpleJogs + + + + + N/S_Proof + + + + + AMShaftRun + + + + + Setting + + + + + Authorize + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + Botòn de inicio 1 + + + + Pause button 1 + Botòn de paro 1 + + + + Jog button 1 + + + + + Open frame button 1 + + + + + Manual operation button 1 + + + + + Be ready button 1 + + + + + Key button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + Template in position 1 + + + + + Template in position 2 + + + + + MOTOR_ALM1 + + + + + MOTOR_ALM9 + + + + + MOTOR_ALM17 + + + + + MOTOR_ALM25 + + + + + MOTOR_ALM33 + + + + + MOTOR_ALM41 + + + + + X zero position + + + + + Y zero position + + + + + X deceleration + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Sewing machine head 2 lifting upper limit + + + + + Sewing machine head 3 lifting upper limit + + + + + Sewing machine head 4 lifting upper limit + + + + + Lower lifting limit of sewing machine head 0 + + + + + Lower lifting limit of sewing machine head 1 + + + + + Lower lifting limit of sewing machine head 2 + + + + + Lower lifting limit of sewing machine head 3 + + + + + Moving up motor limit on head 1 + + + + + Moving down motor limit on head 1 + + + + + Sewing needle parking space 1 + + + + + Sewing needle parking space 2 + + + + + Sewing needle parking space 3 + + + + + Embroidery spindle zero position 9 + + + + + Embroidery spindle zero position 10 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing shuttle 2- parking space + + + + + Sewing shuttle 3- parking space + + + + + Sewing shuttle 4- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + Sewing machine head 3 - surface thread breakage inspection + + + + + Sewing machine head 4 - surface thread breakage inspection + + + + + Sewing thread trimming return 1 + + + + + Sewing thread trimming return 2 + + + + + Sewing thread trimming return 3 + + + + + Sewing thread trimming return 4 + + + + + GLOBAL + + + Language + + + + + Year + + + + + Month + + + + + Day + + + + + Hour + + + + + Minute + + + + + Second + + + + + Server IP settings + + + + + Server port settings + + + + + Local IP settings + + + + + Local port settings + + + + + Resolution + + + + + Communication method + + + + + Network:0;SerialPort:1 + + + + + Machine type + + + + + 001 McHighSingleQui:0;002 FiveHeadPrecisionSewing:1;003 ClothingMac:2;004 multineedlerotary:3 + + + + + Whether there is a Automatic shuttle change function + + + + + Is there a Richpeace logo + + + + + Product type + + + + + Chinese:0;English:1 + + + + + ProductNull: + + + + + Parameter is classified + + + + + HMI decrypt + + + + + Gateway connection method + + + + + Serial port:0; Network port:1 + Serial port1:0;Serial port2:1;Network port:2 + + + + + Input rack number + + + + + Network settings + + + + + Factory expects delivery time + + + + + Debugging progress + + + + + HeadSpacingSheetDialog + + + Dialog + + + + + PageNums: 0/0 + + + + + Sub title + + + + + Sub title < Title + + + + + pageNum: + + + + + PageNum: 0/0 + + + + + + + + Prompt + + + + + + USB flash drive is not detected! + + + + + Export successful + + + + + Import successful! + + + + + HighSingleQui + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + % + + + + + Step size + + + + + Reinforcement method + + + + + Tight locking:0;Reinforced locking:1 + + + + + Reinforcement needles + + + + + pin + + + + + Reinforcement frequency + + + + + Angle correction offset + + + + + Angle correction x positive + + + + + Angle correction x negative + + + + + Angle correction y positive + + + + + Angle correction y negative + + + + + Left + + + + + Front + + + + + Automatic shuttle changing device + + + + + + + + + + No:0;Have:1 + + + + + Infrared device + + + + + + + + + Normally closed:0;Normally open:1 + + + + + Pneumatic device + + + + + Power-on device + + + + + Safety door device + + + + + Manual and automatic button device + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + X Sewing area Positive margin + + + + + Y Sewing area Negative boundary + + + + + Y Sewing area Positive margin + + + + + Encoder coefficient molecule + + + + + Zero tangent distance + + + + + Feeding device + + + + + Crosscutting device + + + + + Cloth clamping device + + + + + Tensioning device + + + + + Edge cutting device + + + + + sewing work speed + + + + + + + + r/min + + + + + Spindle Back needle speed + + + + + Sewing moving frame + + + + + Continuous:0;Intermittent:1 + + + + + Sewing acceleration and deceleration mode + + + + + No acceleration or deceleration:0;Xy sine acceleration and deceleration:1 + + + + + Sewing machine head rotating manner + + + + + Continuous rotation:0;Xy intermittent rotation:1 + + + + + Sewing head deceleration mode + + + + + No acceleration or deceleration:0;Intermittent acceleration and deceleration:1 + + + + + + + + + + + Not allow:0;Allowed:1 + + + + + Cut lines allow + + + + + Equal ratio + + + + + Thread loosening is allowed during thread cutting + + + + + During thread cutting, the stay wire is allowed + + + + + Thread clamping is allowed during thread cutting + + + + + It is allowed to lift the presser foot during thread trimming + + + + + Lifting machine head thread cutting is allowed during thread cutting + + + + + The thread clamping of the lifting head is allowed during thread cutting + + + + + It is allowed to hook the thread at the foot of the presser during thread cutting + + + + + Needle withdrawal allowed during thread trimming + + + + + Buckle the thread allowed during thread trimming + + + + + Number of broken wires + + + + + + Needles + + + + + Change bobbin Reminder function + + + + + Not:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bottom line length + + + + + Number of shuttles + + + + + times + + + + + Refueling method selection + + + + + No:0; According to working hours:1; According to the number of working stitches:2; Persistent refueling:3 + + + + + Refueling needles interval + + + + + Refueling duration + + + + + + + s + + + + + Parking position selection after completion + + + + + Current:0;Starting:1;Anchor:2;Feeding:3;Offset:4 + + + + + Offset point coordinate valid flag + + + + + + Invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate effective mark + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Trimming frame displacement + + + + + Automatic threading back point is allowed during sewing + + + + + Lifting and lowering of frame crossing machine head in sewing room + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Frame moving and automatic frame pressing allowed + + + + + Allowed to move frame and thread + + + + + Software limit XY move allowed + + + + + Thread trimming moving frame direction + + + + + Fixed frame:0;Left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Auto Zero after power on + + + + + Automatic drawing is allowed + + + + + The opposite side is allowed when feeding + + + + + Allowing distribution during feeding + + + + + Medium cutting is allowed during feeding + + + + + During feeding, it is allowed to cut across the edge + + + + + The thread loosening is allowed when the head is lifting + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe input emergency door allowed + + + + + Manual and automatic safe input + + + + + Loop work allowed + + + + + Shuttle refueling duration + + + + + + Replace the punch count value + + + + + Starting angle of sewing frame + + + + + Trimming completion angle + + + + + Spindle parking sensor angle + + + + + Spindle thread cutting speed + + + + + Enable + Energìa potencial + + + + Disable + Eliminaciòn de energìa potencial + + + + JogP + marcha adelante + + + + JogN + Marcha atrás + + + + Zero + Puesta a cero + + + + Open + Abrir + + + + Close + Cerrar + + + + X to move motor + + + + + Y to move motor + + + + + Spindle motor + + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + + + + + Lower scissors to cut thread + + + + + Buckle the bottom line + + + + + Elastic thread + + + + + oil + + + + + headlamp + + + + + Sewing machine head lifting + + + + + Sandwich line + + + + + Shuttle changing device grabbing + + + + + Shuttle changer swing + + + + + Shuttle changer rotation + + + + + Sewing Blow + + + + + AllToZero + + + + + BackThread + + + + + BackOffset + + + + + BackZero + + + + + CountReset + + + + + OutputReset + + + + + NeedZeroPos + + + + + ShutZeroPos + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + SoftwareSet + + + + + Authorization + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Select + + + + + Para + + + + + Width + + + + + Height + + + + + Allow for needle starting and thread loosening + + + + + Needle and thread clamping allowed + + + + + Do not trim:0;Automatic thread trim:1;Finally trim:2;Data trim:3 + Do not trim: 0;Automatic thread trim:1;Finally trim:2;Data trim:3 + + + + + Sewing speed reduction mode + + + + + Auto:0;Param:1;Not:2 + + + + + Front_Back + + + + + N/S_Proof + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + Botòn de inicio 1 + + + + Pause button 1 + Botòn de paro 1 + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ImportHPGL + + + Encrypted file parsing error! + + + + + MainWidget + + + Richpeace Embroidery Control System + 富怡绣花控制系统 + + + + + XPlatForm-RP-HMI-L1910-V210713 + + + + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + PatternSet + + + + + Pattern + 花样设置 + + + + + Assist + 辅助功能 + + + + + ParaSet + 参数设定 + + + + + Shortcut + 快捷功能 + + + + + Main + 主界面 + + + + + 4999 + + + + + + + Not connected + Status:Not connected + 状态 + + + + + 2021/03/08 8:37:16 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + assist + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + shortcut + + + + + Forward or back + 快进快退 + + + + + + + + + + + + + + + + + + labelParaType + + + + + Init windows... + + + + + Init communication... + + + + + Richpeace Quilting Control System + + + + + Quilting Control System + + + + + FileName + + + + + Index + + + + + StartPoint + + + + + LocatePoint + + + + + Range + + + + + Position + + + + + Production + + + + + + Connected + Status:Connected + + + + + Connnecting... + Status:Connnecting... + + + + + Pattern selection + + + + + Pattern setting > Pattern selection + + + + + Sensor signal + + + + + Auxiliary function > Sensor signal + + + + + Control action + + + + + Auxiliary function > Control action + + + + + + Accessibility + + + + + Accessibility > Software setting + + + + + Accessibility > Network Manage + + + + + Time setting + + + + + Accessibility > Time setting + + + + + Spindle test + + + + + Accessibility > Spindle test + + + + + + + Root + + + + + + + Accessibility > Root + + + + + Pattern import + + + + + Pattern setting > Pattern import + + + + + Pattern export + + + + + Pattern setting > Pattern export + + + + + Pattern delete + + + + + Pattern setting > Pattern delete + + + + + Normal operation + + + + + Ready + Status:Ready + + + + + Working + Status: Working + + + + + Simulated sewing + + + + + Undefined error, + + + + + + Pattern para + + + + + Pattern setting > Head spacing + + + + + Pattern setting > Pattern para + + + + + Prompt + + + + + Loading patterns, please wait... + + + + + Setting workable area + + + + + + + Parameter setting + + + + + Limit parameter + + + + + Speed control parameters + + + + + Action settings + + + + + Operating parameters + + + + + Machine parameters + + + + + Parameter setting > + + + + + Parameter setting > Parameter setting + + + + + MainWidgetFunction + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Prompt + + + + + + + + USB flash drive is not detected! + + + + + The program is corrupted, please re-upgrade after replacing the program! + + + + + The file format is wrong, please select again! + + + + + File bytes are 0, please check the file! + + + + + + File size not match, invalid file! + + + + + Data check error, invalid file! + + + + + Parameters imported successfully! + + + + + File head not match, invalid file! + + + + + Parameter Import + + + + + Auxiliary Function > Parameter Import + + + + + + + + MC Upgrade + + + + + Auxiliary Function > MC Upgrade + + + + + + ssid is empty! + + + + + + Settings require screen restart to take effect! + + + + + IP input + + + + + Journal exported successfully! + + + + + Journal exported failed! + + + + + Password input * + + + + + Password input ** + + + + + Password input **** + + + + + Whether to exit the program? + + + + + HMI Upgrade + + + + + Auxiliary Function > HMI Upgrade + + + + + Parameters exported successfully! + + + + + All to zero + + + + + + + + + + + + + + + + + + + + + + + + + The machine is about to move, please pay attention to safety! + + + + + + All to reset + + + + + Whether to reset the output? + + + + + If all process to reset? + + + + + Spindle jog + + + + + Spindle rotate angle + + + + + Back work point + + + + + Back to origin + + + + + Set start point + Set embroidery point + + + + + + Whether to set the current point as the start point? + + + + + Back anchor point + + + + + Back embroidery point + + + + + Set offset point + + + + + Whether to set the current point as the offset point? + + + + + Back offset point + + + + + Border check + + + + + Trim + + + + + The machine is about to cut the thread, please pay attention to safety! + + + + + Failed to initialize wlan0! + + + + + Failed to search for WiFi list. Please try again later! + + + + + dynamic + + + + + static + + + + + Failed to obtain IP. Please check the settings! + + + + + WIFI + + + + + Auxiliary Function > WIFI + + + + + Lower cutter + + + + + The scissors are about to move, please pay attention to safety! + + + + + Simulate frame + + + + + Process reset + + + + + The machine is about to reset, please pay attention to safety! + + + + + The machine is about to oil! + + + + + Goto zero pos + + + + + Set work range + + + + + If automatically set work range? + + + + + Manual oil + + + + + Bottom line detection + + + + + Face line detection + + + + + Password input + + + + + Exit successfully! + + + + + Shuttle count reset + Shuttle change + + + + + The machine is about to change the shuttle automatically! + + + + + System info + + + + + Production statistics + + + + + Auxiliary Function > Production statistics + + + + + Error Log + + + + + Auxiliary Function > Error Log + + + + + Breakage Log + + + + + Auxiliary Function > Breakage Log + + + + + ErrorLog + + + + + Auxiliary Function > ErrorLog + + + + + No connection + + + + + Warrant + + + + + Setting workable area + + + + + Debug Info + + + + + Auxiliary Function >Debug Info + + + + + Is the bottom line count reset? + + + + + Are you sure to ManualSwitch? + + + + + Are you sure to AutoSwitch? + + + + + Total number of patterns processed: + + + + + Total number of embroidery: + + + + + Pattern name: + + + + + Pattern break line num: + + + + + Head + + + + + break line num: + + + + + Day + + + + + Hour + + + + + Minutes + + + + + The remaining available time of the machine is + + + + + Undefined error, + + + + + Failed to upgrade the main control system! + + + + + The main control system has been successed, waiting until machine restart + + + + + System will restart %1 s later + + + + + Main control system is being upgraded... + + + + + Failed to send data file! + + + + + The data file is send successfully! + + + + + Data file sending... + + + + + + + The password is wrong,please re-enter! + + + + + reset parameters password successfully logged in! + + + + + HMI decrypt + + + + + The interface program is licensed, and then take effect after restarting, please restart manually! + + + + + Password error, interface program authorization failed! + + + + + Is the version restored? + + + + + Modify the first level password + + + + + The two passwords are inconsistent! + + + + + Password reset complete! + + + + + Do you delete the configuration file? + + + + + The settings take effect after restarting the interface! + + + + + Import csv file successful! + + + + + Do you delete the csv file? + + + + + Reset succeeded! + + + + + Whether to enter debug mode? + + + + + whether to exit debug mode? + + + + + Please log in to super user again! + + + + + Is the pattern clear? + + + + + Delete complete! + + + + + Simulated sewing + + + + + Whether to switch working status + + + + + Manual thread cutting + + + + + makeup sewing + + + + + Head lifting and lowering + + + + + Head lifting + + + + + Set anchor point + + + + + Back shuttle pos + + + + + Needle shuttle adjust + + + + + Whether to shut down the computer? + + + + + Whether to set to change a shuttle automatically? + + + + + AllSpindleZeroPositions + + + + + AllSpindleHookLines + + + + + AllSpindleJogs + + + + + NeedleShuttleProofreading + + + + + AllMainShaftRun + + + + + McHeadDialog + + + Dialog + + + + + + + + + + + + PushButton + + + + + MultiNeedleRotary + + + HMI Configuration + + + + + Interface debug mode + + + + + Delete configure file + + + + + Machine parameters + + + + + Work parameters + + + + + startX + + + + + + + + mm + + + + + startrY + + + + + + + r/min + + + + + Sewing main shaft working speed + + + + + Main shaft zero reset speed + + + + + Main shaft running speed + + + + + + XY zero reset speed + + + + + + + + + mm/s + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + Work head selection 1 + + + + + + Not allow:0;allowed:1 + + + + + Work head selection 2 + + + + + Production preset + + + + + + No. of stitch detect if thread broken + + + + + Needle + + + + + + Bobbin thread length + + + + + Bobbin change reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe door allowed + + + + + X to move motor + + + + + Y to move motor + + + + + All spindle zero positions + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + Signal + + + + + Action + + + + + HMIUpgrade + + + + + MCUpgrade + + + + + ParaImport + + + + + ParaExport + + + + + Setting + + + + + Authorize + + + + + Network + + + + + Time + + + + + Version + + + + + Root + + + + + Para + + + + + Select + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + Botòn de inicio 1 + + + + Pause button 1 + Botòn de paro 1 + + + + Jog button 1 + + + + + Open frame button 1 + + + + + NumerInputDialog + + + Dialog + + + + + C + + + + + (0~3000)rmp + + + + + Number input + + + + + ← + + + + + ParameterSetDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + Sub title + + + + + Sub title < Title + + + + + Repetitions + + + + + + pageNum: + + + + + HMI Configuration + + + + + Root > HMI Configuration + + + + + IOT Configuration + + + + + Root > IOT Configuration + + + + + Network Settings + + + + + IOT Configuration > Network Settings + + + + + Machine parameters + + + + + Root > Machine parameters + + + + + Work parameters + + + + + Root > Work parameters + + + + + Repetitions : 0 + + + + + Server IP settings + + + + + Server Port settings + + + + + + Local IP settings + + + + + Local Port settings + + + + + Board IP settings + + + + + + + Root + + + + + + + Accessibility > Root + + + + + Board port settings + + + + + Local port settings + + + + + + + + + + Network error + + + + + Input + + + + + + + read parameter... + + + + + + + No connection + + + + + + + + + + + Prompt + + + + + + The settings take effect after restarting the interface! + + + + + + Network settings are completed, re-establish after reboot + + + + + The time setting is completed and will take effect after restart + + + + + Unreasonable time setting, please reset + + + + + Time setting failed, please reset + + + + + Connection mode changes, take effect after the reboot! + + + + + Whether to recover the default parameters for the board? + + + + + PassWordDialog + + + Dialog + + + + + Password + + + + + 9 + + + + + 1 + + + + + 2 + + + + + ← + + + + + 3 + + + + + 6 + + + + + 8 + + + + + C + + + + + 0 + + + + + 5 + + + + + 7 + + + + + 4 + + + + + Prompt + + + + + IP settings are unreasonable! + + + + + PatternManageWidget + + + Form + + + + + PageNums: 0/0 + + + + + Sub title < Title + + + + + Sub title + + + + + + 1000.0 + + + + + W + + + + + 500.0 + + + + + 999 + + + + + H + + + + + 1000000 + + + + + Y + + + + + X + + + + + 800.0 + + + + + dst + + + + + C + + + + + N + + + + + pageNum: + + + + + + + + + + Prompt + + + + + Over 1.28 million stitches, can not be imported! + + + + + Format error, can not be imported! + + + + + This file already exists! + + + + + Rename + + + + + Importing + + + + + Exporting + + + + + Import complete + + + + + Export complete + + + + + USB flash drive is not detected! + + + + + Whether to delete the pattern? + + + + + Operation screen + + + + + USB + + + + + + + Pattern Import + + + + + + + Pattern Import < Pattern setting + + + + + Pattern Export + + + + + Pattern Export < Pattern setting + + + + + new folder + + + + + This folder already exists! + + + + + PatternSelectWidget + + + Form + + + + + Name: + 花样名: + + + + + N + + + + + H + C + + + + + W + + + + + + X + + + + + + Y + + + + + Width + + + + + NeedleNum + + + + + Name + + + + + Height + + + + + Pattern Select + 花样选择 + + + + + Pattern Select < Pattern Setting + 花样选择 < 花样设置 + + + + + PageNums: 0/0 + + + + + PageNum: 0/0 + + + + + pageNum: + + + + + Prompt + + + + + The number of stitches of the selected pattern has reached the upper limit (2 million stitches), and it cannot be embroidered! + + + + + PromptDialog + + + Dialog + + + + + Prompt + + + + + ID: + + + + + Password: + 密码: + + + + + ID + + + + + DecryptInfo + + + + + DecryptInfo: + 解密信息: + + + + + Spindle angle: + 主轴角度: + + + + + deg + + + + + + New Password: + 密码: + + + + + Confirm Password: + 解密信息: + + + + + X + + + + + + X - + + + + + Y + + + + + + Y - + + + + + Board + + + + + Build Time: + + + + + Unlimited time + + + + + Time has run out + + + + + Day + + + + + Hour + + + + + Minutes + + + + + ID: %1 + + + + + + Password: %1 + + + + + + Time: %1 + + + + + Warrant + + + + + HMI decrypt + + + + + Spindle angle rotation + + + + + New Password input + + + + + Confirm Password input + + + + + QObject + + + (0x0002)Insufficient air pressure + Insufficient air pressure + + + + + (0x0003)safe area error + safe area error + + + + + (0x0004)Expiration of use + Expiration of use + + + + + (0x0005)Driver alarm + Driver alarm + + + + + (0x0006)Fill data error + Fill data error + + + + + (0x0007)Not allowed to work + Not allowed to work + + + + + (0x0008)Control error + Control error + + + + + (0x0009)Motion control chip version error + Motion control chip version error + + + + + (0x000A)Waiting for button to lift timeout + Waiting for button to lift timeout + + + + + (0x000B)FPGA Reset + FPGA Reset + + + + + (0x000C)Peripheral Device not ready + Peripheral Device not ready + + + + + (0x000D)Transmission data error + Transmission data error + + + + + (0x000E)Program version error + Program version error + + + + + (0x000F)Complete output + Complete output + + + + + (0x0010)Positive limit + Positive limit + + + + + (0x0011)Negative limit + Negative limit + + + + + (0x0012)Motion alarm + Motion alarm + + + + + (0x0013)Motion limit + Motion limit + + + + + (0x0014)Emergency stop + Emergency stop + + + + + (0x0015)Motion parameters error + Motion parameters error + + + + + (0x0016)Machine parameters error + Machine parameters error + + + + + (0x0017)Input parameters error + Input parameters error + + + + + (0x001A)Not in work status error + Not in work status error + + + + + (0x001B)Prohibited frame moving state + Prohibited frame moving state + + + + + (0x001F)Zero success + Zero success + + + + + (0x0020)Return to zero error + Return to zero error + + + + + (0x0021)Coordinate system error + Coordinate system error + + + + + (0x0022)Target position out of bounds + Target position out of bounds + + + + + (0x0023)X Positive limit + X Positive limit + + + + + (0x0024)X Negative limit + X Negative limit + + + + + (0x0025)Y Positive limit + Y Positive limit + + + + + (0x0026)Y Negative limit + Y Negative limit + + + + + (0x002B)Safety door error + + + + + (0x002C)Entering the light curtain 1 + Entering the light curtain 1 + + + + + (0x002D)Entering the light curtain 2 + Entering the light curtain 2 + + + + + (0x0040)None data + None data + + + + + (0x0041)Data error + Data error + + + + + (0x0042)Graphics out of range + Graphics out of range + + + + + (0x0050)Spindle is not in zero position + Spindle is not in zero position + + + + + (0x0051)Rotary hook is not in zero position + + + + + (0x0054)Scissors are not in position + Scissors are not in position + + + + + (0x0056)Nose not in low position + + + + + (0x0058)Thread is broken + Thread is broken + + + + + (0x0059)Bottom thread disconnected + Bottom thread disconnected + + + + + (0x005D)Execution command timed out + Execution command timed out + + + + + (0x005F)Head lifting timeout + + + + + (0x00F0)Change the bobbin + Change the bobbin + + + + + (0x00F1)Replace bobbin A + Replace bobbin A + + + + + (0x00F2)Replace bobbin B + Replace bobbin B + + + + + (0x00F3)The machine is in the state of replacing the bobbin + The machine is in the state of replacing the bobbin + + + + + (0x002E)Insufficient air pressure + + + + + Normal stop + (0x0100)Normal stop + + + + + Find zero success + (0x0101)Find zero success + + + + + work pause + (0x0102)work pause + + + + + End of work + (0x0103)End of work + + + + + Work done + (0x0104)Work done + + + + + Complete production + (0x0105)Complete production + + + + + (0x0106)Execute success + Execute success + + + + + (0x0107)Execute false + Execute false + + + + + (0x0108)wait file + wait file + + + + + (0x0109)change the bobbin + change the bobbin + + + + + (0x010A)Execute finish + Execute finish + + + + + (0x010B)Execute runnibng + Execute runnibng + + + + + Enable + Energìa potencial + + + + Disable + Eliminaciòn de energìa potencial + + + + JogP + marcha adelante + + + + JogN + Marcha atrás + + + + Turn + + + + + Zero + Puesta a cero + + + + Open + Abrir + + + + Close + Cerrar + + + + Ascending + + + + + descending + + + + + Trim + + + + + SensorInputWidget + + + Form + + + + + + Sensor + + + + + PageNums: 1/1 + + + + + pageNum: + + + + + SetWorkArea + + + Form + + + + + Prompt + + + + + X + + + + + + X - + + + + + Y + + + + + + Y - + + + + + SystemManageDialog + + + Dialog + + + + + PageNums: 1/1 + + + + + + Update + + + + + 192.168.2.196 + + + + + StaticIP + + + + + DynamicIP + + + + + *Before setting the static IP, you need to first set the dynamic IP. After the dynamic IP is set, you need to return to this interface to continue setting the static IP + 设置静态IP前需要先设置动态IP,动态IP设置完成后需要返回此界面继续设置静态IP + + + + + pageNum: 0/0 + + + + + pageNum: + + + + + + + + Prompt + + + + + The upgrade needs to restart the program. Do you need to restart to upgrade? + + + + + Do you want to clear the production statistics? + + + + + Do you want to clear the journal? + + + + + Do you want to export journal? + + + + + WordsInputDialog + + + Dialog + + + + + Words input + + + + + Name: + + + + + ← + + + + + old + + + + diff --git a/turkey.qm b/turkey.qm new file mode 100644 index 0000000000000000000000000000000000000000..bfa030a3a943c50fff6867843abd4519c063d059 GIT binary patch literal 186538 zcmd3P2Y6IP_x{|wE!j#Z6k(|XQbKP^?<5ci9YsR2Nfwf9NH#z~5D-LBEJ%?eQpEmQ z0L4mI1QbC~KSdNNqJpSY1%&^5W_Iu0a(A=&)Zg=mCwa5wPC0YtoHOT~nYsO~jD)?v zu3Y>{t?FCHu6h4xH^$l|GRE*T@>YRo4sew8iv_+mK;ZlFz~)Sn3<6*C3fyZ3wqVk0 z%YiL{+kmZrKLA@Z>2)ix4X_2UEpP;|9dHJ)J@6S|cl>-VFnuXU$?;!-ukRJOu}I*S zLSQe(bp3#R7@KgCqx42)fm;)RXmj419Hlod3Eb8Mn8KK0Jx6JK9x#SZ|;PjdT zpPVD`>9asQJMS1r>FeLow>ucCfOZl(TM8V3@xp6qj`&pY;#^O`dKo8L02(RUo>UQ3z&3(!(m zBrv{}K=TETk~~J>1KR~|8ZL0lNse;mbb$#I1U8u~aL#*7e|ZO{;4K25-@{S*%*_lH z!F!HT0;_ZuIN%O}L&kEHdR!3rZ3BTPX9+y}F-O_iNnnHL1SV}4_*h$kD^~%xp`Q5y ztKJrF-g(UhUOd84 zim$*7eIQS^jbMh%Elld;;3y9}!3;|>7@K}j;MH0jCG#$h^616PuonFA)ntxx!fs}G z>o3N>0$qU8f6Fn$*^5l-xsw^L%?9ti$&A)VF)v=>D9<>Be)+I2tlXg2;FQ zyz=8Qfj7%Blm1ii*H~uil8$-yy+G%k0!QrPD9x=Z@O!twpJjm;k~zxtdkCC;Q{b{k z1g^QnOxs*2e-ksmbcD%MCo}7x9T@AliP>J&Gqy9G+2al}HfuPuTY$5tu$r%a0N$<0 zYIUx`m{~6{(;)D-E*zyev%q<8v08`MGpXD~c3ZQCn73N@ac# zc;tJ5$L#`tevPACeUZTWZwTyoo4^Nb0+)AV{nE!VR%ruA>657fzp2OuYzBWk`y?Bf z?S@S3!BR)w!=xn%EOqY=CJ+694RJlsSew~w$bIv{&ku8y=QU;eP1&=H$@e|OiYGQ@(#-yB&ey3- zdTcy<YUF8KVqz)BYd4xYwQ z`evxWPe?7nib2m*z8e+eCJGJZyxF41r4@ zV}JCoi*fHF@S$hepZ{6I>b`OHobtDU3@YvwSi*D9%U4Sc@psFdIZKXmv_s#YVHG4}&f z&F3K3b{>*ySI4-wc~(lSb`h@|ORYS0ndImtb?NMa$?284J~o5N?c=0D`@rXW+DK!@ zE@D#EvQh@?!Pvq-q)Z!Zm=mu_?wl_fyL-OCUv_hpjCV=y@6(x-v|sX8`V9K^5ou=8 zDA*s1q(?LH+`jeFLv~mR39jdfmHOTKQ=WCXcjA>o(iL=U+?DR``yw z=dVjIoAJFj>v5Ept>-8=Z7sc)Ighbdf8i)Uc0+pmOX!{6eWmvo7BTkQkJ7e7nBSL= zag^e}k#<7Hvn|I3URf>eJO_R}Qcc=d8*-!5Xz9~y;QK0h(t&MyCVjX{I_$vwy!RLB z^GlG6GaS;1JOlLFFzF=W^v%*=MOztrXsmSeP#4C&JSFRTK)xFsvThY@sIt=p4m>Gv z*inws4_7$Kb@~gubCAHruLxZAtE@lw3X>)rk&PqQGB)gSj`GMa<+zp@&$>Hh^Br9= zpJxKQG1jCvusiT2AjYR@Szu4#WFYMPrbmFV9h-Fq!rpJT4%in<7L#n-R++KNM+Hu} zN4Do3V{ChUxlA9(hdqbnvP%y#7C&B~r6EUY`B9E?<;4P9ek+%K684g zdwh^g`c1mOg52xqHpaewM;_1}eA}b9oU&vt_YB_!-|zpYCSTAJgTm)6E$>+(*uT1kZUI$b}1K#x~ZIi<)LI zDQl)Y?e}p^F8`W5?T<8IE%}~K7hu;G$@h55GnRI%JpJ2UO#1VTBtU>?g_?bj+Ixx1bTjUP+mWC8e`8C%FiuF ze_Pe!C@mQvzt9eLMB_W<&E+9i!3Udj(eKws%kQrQpSC?waTv=#JTBl!zw6UOf8CVx47CzGCJ@|XAS#FBBb{9p51jD7f~{B;ww z>yI1qH?o9z<&nR84r_?xE#;H@K+mfKF@8^smH&v}$mEKj$bZ~5gs~k3@>NeA#@4UZ8CG6oa>xJZ;veh>xjR@_@y0pm zlZyfupVcLl1Dyx;)Fo`hJnBDGR|UF?*=7nHbd952{S$#5vjjfSN8s}5x~lV?kXH+J z)qljgqrxU#&FuAzUChwcesBwu2RH>jey6VP2WbE3J-T|Q8^QkiQP;30Er>iB)?t>5Xo>R*yqZnA+-ESG|u(tEcN)ciPQZ(QsY64_{>LjvBfS zOE3;?FY3B|Y-UV;N!Ok1wUId-r44uMdVv4f+qda@OP@2=sHH9?;}s_N?kjM?le*#S z$1u6?%K{%cq8o8`D3huU(z!cAuTC4T8xLE8m3xJwbgY8F)87gFtv*M2Y=7OmW0#!)hSrJMHfUd*2}x|zx67`s%RqZFT_n>7ObvGsP~dEiRjtWkJ<BX6&_%x-}WE!+!6o zTek;v-I=6Y|1Ih(*r9uc_-=ZtZiBZ2-e|tut-8HCz%Tpty8ZbWzoJClr%mww zf?2xHtaF*vJW2P>M$GH4pVA$bYJ!hX>yFavulDPXcUlGcuvvFzHtM^yQ+N5kis0wU zy1(jy?>`@|XKg@-%=3D~-X|E_w1%T}XsAA}*vr@>Z|dW&fG@0j_3`_^h5urtzUICj zOq#^>wIn^0=1$Ysn}+fRoYgm2Tbs$Z3=()ps=m?g513STo4#@NQ%tH{Ti46SRp4(5~vL(a6<^o6l#8KL?Oy8Qy9XL*ZJ3U|N1%1~`Uov*rM16N^ z*P|o!!>AukR_lk`AphMz>qiy$W2{y_5d2%Koc_)&mzbO=O-j=eAtsSeMzZ&vCZKuFJy}R`<4Lr%DDpT~YcKMXCmmk)@df#x!cP4P5N8szf2|Uo1quipo!23_=->Ui? zV@vMRzq`Q+pVWOol&k+p|NfORST7FK?*v~ncf5XAG5D_XlLC`>3QVoVQELB)z;7-I zJkdtrnFSo>8dn6~I#b|+0RmTS)bIP@2xDb-2&`6C;J~H=hknLU`mTz=Q{M~xWe-QW z);j_lelBp>I)P7oDR5O?{ecT7m|S%A#( zc4z&`)tlfCsK`b`fDAN z7FX6^sRjAaDNcXo;#J7iEBb5y!Fp#-zCn8OFq5WLFc??rur6t0h%bJGF>7s(a zwx4LQ>}$!SC!RA{m%Es>u7$w2Gdar53Jm2=ea@srv!U`n*azz#GgLlyn6Ya|3{__Q z481zhP`B=6Cfza6P;V#n{yi@mZk>bIopgpqyXP=z)GLPD*P9{tlMJ1|f?odf7DJai zF^}2|HT0))Tn`(Pb>A`Rg}#QA-Y+ng?l276zmBou!-k>#KVZ_(vW7dGzY06^fFZMZ z5$vR~hN7t+#*U^Kifzw8f3-FgXL#WhsVQ)3qQLjtagl_0(U+o@bgzV$_Yya zHZurp)z~m?+aboX-!#nqVJc&F1{xl68JN`fe#67$|9NYlVMWhwOd31Fu;N*aPnTwf zm7~z_%Et{WkM)L~R@1P?0QvZz!2&Pz0>VD}&+7s&JZD(DAM^f?T84G^4q@`3&4%Z1 zh5mR*GCaS;#n|MEhL;|MeE#n@hF9B4tr) zufe`qWcZ{}7xX9FaNs5QAr>4le6bemjF(akU!K?n|IH@Df6rBAtn(4W(fz=VCk#I% zz<$3q$?(HW*t@OU8ctsWpRd?%`03z4CO!L`;b-$$CRO;t@bjzRGWM&Nqh#7F@cs?4^aA_gzD(ka`KaPSvSFdrD ztThZ*L1*^hX~VVqzh%XN{L>je%Q$Wi+4F@Zm12t3z|qg?wXfsK5x zhkqtsFS=9Usuzrgg`Y6_ewQ(h#%W4fqkY>@Cf!!X=y-A_)|lRmSc&Ixs8{j6M52 z1Aopfz)eh=ooDQ~{2Y^7J!woT53K*1F?srYtlQr-4t&)BIlsj?dj02k-OhOT;UP?_ zc-=VGc;f`8yU-AV$8MS{jJlDxf@~kwj6BCZ+xCfuWUCK_1eJXnXed&j)0$^ znP8ms=oKbc-DsS20($S0gT|@tK!@aJ##t2~K);V0XEldhICY0{Rx0FN{}kh#d5{|~ z-(sBe3;JPv%{cGa4Cv3djSsjNq24PTy zO<@1B0v}x>aK&H7wYT12(xL^%=WoIfuzr~Fm2R*Ts!ulV*!2qf_l9xjsk<3_X`ONR zvzRw^els38{XLU)bBzbvLLRiaYCM!V81aRf#?OCP1o__0`1$o2OpY68JZc^Qf5IKc zV;x|J%-?1_cKSH%o$|)x&qFTMa~gk`a~}S%Q^ucY9endDM|sU0<1Z&M??~X;V_oJp z-S%Nc#D`ut-L~%}ba&Ole}-6dVaH)Nqef8da<2| z1Ke)v|2_2e;ku^&SGF?t{Ww$dt)QFzy1;~E0*5e;($ReaPu384Hix5J^BaK;k_9H+ zX&O))dbDD1)4*|0FxGVea3k!*LQ{IP&zRh8zbXCa3yf9k&rw>QVamJ*<30A2Dd#=t ztBLQJ?ir1KIW7pS+C|`iLjs4~6qx&8j?&Vn1%A6l;HicJf0@8hcAgN}aJs;hP68J$ z7x+|P)AWb?FzJUEILag56S$a}W?j1iJ>SuE-+y{w-Y+#hbRXz<@Q~@@FEC#B9WyPc zHW=%=>ZZrLLa$yvY+AMy^LzY@0-rfxT0Zs=lj>|YJ$)1N`thx%b<)@H%Q;Lh5dRIS zVtQpy8e^*)nl|i8VREH%ruTLof<0VpdjFS3;KTK%E$=|iH(zSn)?+Tlb&qNLADx&q zzPf2=GRE!m;ig^Bf?xZ7WBM>2a(76v>A>?95YLcJhporpAA8(%`0OaG|67?pzjZwP zM>9=dZrj1+Hu3k`hLTI(Z8om$MttJxy3!ElQX6= z)?>Np+A!jR@e&4bI>*%tk-!Iie|58mC^AT&Dw!?Ip{KC5*HvRDn^i|w( z)6FH|r#~0RNw2<$^~wG?(`T?V-ZI6N>wO#i%X{J~Uv(oM=n;4}jiaQ$8dv433?_H# z9#^$|9`xAYxM~MyGO2xyxH^+sA>L~cc*_!w^4J&R>Ziaizq41|tz%~}wxLQ~!(C$; z`^X*Fi2R8U#KkqHdN ze%#X=|HAk`7PtNs?22V01^)U`-1Gfhh@a`>UTF6Q{6kmbUeZA>yp|C6a-G5OBX1R$ zK0NN#PUW!P*%bHgvJFh0Q8#W2{3_BM7Pq|~`m1Xgw_^qL$(gEgAO6>l@70UjdwCP= zF+`$<$;CFi??n`SuwCBgTZ<~JvTq@6qh3% z;(i#1&t)m@T*68C->$@6x;Y>5gvN0<^T01XUyC{IR zZ(rdA*1>Rq<=Ce!%3r zo5w#}y#kXSDIfpby_hFYCUcaVT#kS46_jfn9{=)LwC~wt@jFIAF4*D(CLIwt=w6P} z_a6%Uc>+hdda}U!lLWRG-X+LvB@zzhOBHxp6A~#=Vcju09!m^H0!sVI#A&MGv_&-yHvN zD(q&D*}M^X4Tpa>+nviH&$^i_uj~&w*V{49S(sHED*SShq=~a%(rrPnQQ&95dL0|`L==Zw|K6Yo4g8nGNu)< z29xf33D}fLclQEz!u#(7!3THM24WuFxeWL%KL6C*jO?&eSIy1pTi_QyYi>0>i%A_G zG`GD1?AYGi*}fR^eY&~xPk3(Nx8^QshafN3nY(Up3cu!BfsY?G_a-_frJ4J_kjSKK z+s&ynAcv}V<0!4T%{=_%X2vFV6nJ?yM=AbZfe$8`N3=xwv%fNrCcNhXbJ|SMx9u8p z+Gl7-@loNp{*(xGbR$;TI9 zJ@;RZ5}Rv&(1SdYku%K?KK?oc%1`F`A7Ea0`b*#g2h8*TN`>Eh0Y_YQo*r5Ui(+vf8>>9L+2YQC}p`Ze*8z-PO0ls>D% zQSM)4zA>u^@_c|rehlNV=r@b*g+*xZ27xI<1rC3Rqx54(j&j|q0;iQ1xO9cUr(dub z=fl2eSg}Y zfE%)xz#NoMug|ySD8+5HSbAqN+3~u?GTa4hYq4ZOFWa|UER)lLy)Bk`@E_RrSu9Ht zFR=}>SPy>-zn($h?^7)aS8oOX^s`jcWiY9BdrNiXi^!c{u-sy4!KA+$Se*NwhCgJx zrOx<)jJ+_?(!#L<@t$-`O9uPkb-kq(V$yQiLzdg?_JF^&ho%1-(BZEFOVUt`bI+lc zAxRid=lhm1wc&@EyVWwb_D%SS<_etO&XPIK#U%4>mhtvmKlHa=Ma#_d(EnvKE%#@=i1kdIW!@3kdjnTl=IiTX z-aKe|c*u)P+SSPNNWvV%`|Oq{?nHgk8p|>(T8zw-j}d`c+c{|bg~cswCrAldb&Jm z*}ZcZ@>XsUc(y)ANx#jq_hF2C+utqwhIyHk=CvG1gWPTRmgUeo9m?xx`PTUX?6HHE zpQgYsmfziS&iEOVt~axscMd?DqYp>vv{&G-TR6&he`~q00eN%R43;Z3p{EZTEq_e} zo#s!o{Po@dCS?z@vZkk)T1(ZjJj0EFZZ^VHG;1PHL_N?HV*OMF4n4* zApZ*&TW?tkdETpmwa&`VA+I|EVHd9d&04oRFgr!yQx@xO?_Fe4@uSvejz^jF?qqAL z(`awTpVroEU{}2C!}DjX9TO(P-alsT_#Wt5V3-xV&)tX+<2|d%qnpypE!~u6$ zvoq&{|30*4?{Cedmd{(q59^8b+%AC$&j}o06qx!UN9pJyfhWEfc(w&cx#ntt4XOz2 z|B1jy{}i}#taZXd(53e#An5V>JJwul2I%*fHSddhSiij^u&PnufE5CV?BXbWd%wVw zX9WI|$WeAaE3jc7fdg*{TsT_bQ)X-41(d&dyfyD?RrqIaS|`>VkGRw4)`@jbGwJq~ z)`^W^Pn>_yTJRk(ae}po==J7S>lC6-{f^ctduAan{E>AE(W#ZwTKqD`Idi3T+OoFD zW34an+G89g>rCtP5Av`+=xm*lkMXFn)H-7h>gjmKI^*npjODy+om&}xj+(Os4ywaZ znm$tCPt^pT_i&UOzb$a}N7lIs^xStGrTb70UQ0hs7kGX@N4ZHkfopEF&ixg3NUmgk z&^;G%xg*wx>a~P^yKY^0U=-}ikF3jf?`O<1#k!oygrqqWLsukd#VWQlrh$I zm)2rFzHEJF7WC|zVb+(B+a&Gz#QI7%(5L!M>+8SSvF_bsedBsFCjG~5ee)0K?e{*j zZZ12ANew*K&Bd+YpO|fZ%RC=(mz~zPf9}lWR_WIFSFK^}ize1BUo1y_ZGd&pYLru< zp1>Ms1g1PLaD>cJIyPS5kJAPI{v}7bUR8mOn+TkKQs9%@1g>si{cOPZjO|Uc{vw4Pp&#n?|@T7TMf67kO|)?c?> zMI2(Q^}Gam-|$E4`T30?pXXRFo+w0|;(+y%V>pw0{~+*@R@Tc@{+rvae>`tPynUPX z>L&2dh#@w)3gT9CvIKrzM&R{&93@*%feRkA$um&@D|rGh#&MJ%TW2#-yDoRLInuW? z_HI*~oyJju7AVUz2`g7 zclB-kH-Rs{TFOy+=QG;?%N!=Btg(%L0P&6S9c*L90cXBp8}|#=5lyezGEUmz@4RWt zlzTFH)?{1O-Z!A9p0#D)y%GMO+ieqm%76}s#OZCe;&$&bIsJ88@d#k{HCu5uFmsr#cnUDDtF8C};DlAS;wOQH588^K2j>4^ zD}D<&<&drTBjBW_wtE_kLjLn<+l+dc->DDVX7oOdIOsDRrE|w^v;Me<{FCFhd2bwK z?7+vidD}ZN>B0532b%5&AKfl+{;ReJAAsF=WIjjftG2d>y1WR#z;m{T&%wUib%Uea z=nLDz@%xcq*3!28sl80vUcN9ol#f$x1NaL;^> zazZ14&Fctk{k`qEMd?^~T5T`xLpxKZ*)|Tk6?Xm)wvX1p&Mtr+hL}%=_cBh$K<*L1`9sH5G#9r?B2k=90x0inz zbe&+dCyf3T>+i|-DnItaI^a)x)lRS*p8nllt;x^O_ZfEQkL{87dDLEqzMuPo{nqXS zm^`$Fy+M~7kh4aCzkkV5io4U^X!qxcx7V?^r0=`7*gM+SFzMq=d-tI`u@1d%?@sS$ zr`!9E!@O|!v-fWcduZaL_LMfekhikcKKMN3+2Eu0VP4ofPu^`G{=j-BOx2o7jFQM{=0Wts9kFei4W(H%E zQte|pjvCiK$Lnbh=W`V>zq&i>Sdtj4vPR%*{T%fcZb!axq2pHU>tSE)aWt+1{;&P0 zqcJ^SJlb(P;iNYmUGCZrJ#xU&$B1>tq9u-0#AW1yk&aR8;9p5=;7F&}o;Mxt{|v#p zajL`pDzN%xf%m@1QTpyvfxotQkQ|k^FXJdTo#H5@=O?docy)uAoMd%O9}2m!s>pF4 zz3;u@c*s=|ezsd23wFHI9C6HajW{2 zW6jY;@Y^hLtfS{$^&QXhIKy$rb8mzH+kN49ndp+y-m#HB&n@eCqYu_Qx;)2QiSQS- zTjzK?^%Ux10?)q7Q8J`D-tAr?#=UqioLcbqTx zI`s7s#|3J~xLJOMf@$vaRd5*y>rUV6V2LqQLk@F4w*`fv-@jipIrJC zoSkM)r^RVu8O+TlFgHGPvO;`XjL!=3(?MyOt(z;$o#)JRxiWHG9imnvvvlP#se9C~ zRzkerjkcuYcLC~dfPHKY18OyQ&rUPd|Qi4jcb!oyE>J_yoW|o9H3W<`+ zBl=#Rg50Q2wE<_K-*_?)t#snAG>nPh2PbBw6TPYF`|LEhXB;cS>msEFdmmR?hO@bI z0G~n5zfo6<80%^gQ(cv$#Hj5y#nRve?Lq{Q^{Z8}AC_t)#-K@Az&fB4 ziL6rWAN`^P{&ox;Qka6y>F7I~$~w zFiT}tsMIQ@M(sCMsA`Y~phA#PNOetiHb^b8I(s?s1}W;SouJZd8Xi;J1u+AXWj zDFw9;Huiur5h;}CE%4+7Q;5G6M*G36KMhzwi9HpX`&F!y-Hw_@av24Qh|x&LZzt3_ zJqhyzgU^Ru$T4N4>U8%6w!?Y5vun{5caA%)pxBuSxk7BivCaju-GJ+`Wq1t`R@$*A4ZMmV7%4F+i% z#%3ITlVF3r%*TqRX#x5{S`F_jV^q1TyTF+bo35~^z=c0NUY9a1wjQorPmbH`Donx@ z=4*;!8f=gm#s*H-2~9{rRb+dTp-l`+mQW9F3sM8Sf^oe38)%Z!981@n9H-agoa!p@ z5TP`hP{C)Ck@;Kb6YFXLwys6qY)^rEYMP(BG>Wi;>C>PS($Ipy+6~=vJcV3VX*^Vh z8=?gyk6_M1gDH)+`6QB=6WKQZib0KiwRIoX_LO6Cu=~2(I8XHCmVyl&+R=8&anqeZRMHxpn>zy*g*gf7>>5)yM5 zgCGVZ4}ZBK+ew%P@@du7e0Lt)EY5KSX%k$~`01GI1<~eU1Eu8CAP5@92}|W?qmfg6 z5++bAR`=IYP?VQPu7Mb8aca~e7Wz~1&4-{IOH-M&7TC) zkT@&?2aDg@6)N2+^rjVfooVnI6nZ`R&S>>oSx=CiSQi7JjH4;lTj27hXGdsk1$eAT z{gK4(3f{-$4d}ONh&wk51C#^rTnE1vqE6wgQWcIolrLp9IIavEhVOGxh6)2s7Sk}u z0-wR9@n9pi8|@R^Ajnp-uyG8>lr34(=s^ON_vKvfJJD!D9DNT)wz`tk=jJwxB)`o5 zZwGweK;Mt_KtB+a?4Kge@8qV-5mJatBPWPOHXikzq!WEk7Pb($^omp>y~2A61C)cc z;UTAhvk)^n$DQlu^V!}jC(R4*R)NP2k6JOeoD!h_Nrq4nPLA9!7Qhhk-S|om&k;Xq zmC?p$;N_qr>IB1bn$HB1*aJ~I*o_+jq}0fBrHWan;@tGlx!$g{0_R{77tSFrv24_; zxMYJ#>#3>%YuyZ3O+u9fOMU})Jx1#Azh(Dmwbo8H2A6<*9w=jM>ftUV2WX@=R)=Wt z`joV=4T*oqI)n37DaF{6dr>15B1V=p?*#mKIct*NQ0163b{dT%lU`xP0NyFzi_|@2 zSr$|Q_>nxgk?Q*AEIchT#$@7YJ@^mWcv{6rHS#nch-T$!J&?#(6*)o1Ihmy-R%q!( z;~B65VAmDqD3|2U^g5G0UQYp;(X@7tG25yX0>WI%m?gk1I}YIzPo^{7A2P~@+n%c*tx8K}#A+8%3M*Et z018;qDv1mVCtv=Su$V|m^I`>&7oy^|if#a>F4rY}21(P{L?H0<80&l8fi%Z3t-Vec*}V}doyzUpk|^!u7GORfL<*-UYK9MJ zpygV2NI}{pSd)sTiOBOY7_nM?i_MDFdh(w#W3|d|jDty?U_)BMUdLbAV9HR9t;l;t zPB=!8KP%TW$%S7K@R0<2ZJ4JqmpL-FGBqu4t*%8ey|uos+TJacesbHpMWo&(vQ$iC znt2l-CvrGTk(Elaf|i~t_X>}O8r3z!BRIq}3jRPIjWPC48rZFC5;v(^V11R%O{6R+ zSz7#E=L16a7lnFgfV@0JPC?gJ_^%dQmi&aSJg+;Qe4EW%wfftow~kVJ>#)+>`P_lD zA`wIg^y%e6)(KaIF!+SbCNZk^z|svesw<*%zBpANWlB>zElFqqh^^Jq%c!NNc-(p3 zunx2ditPtCSQMFs=8}KOU-V4X^miaa6~c+3C>yxG@8k+t`_C!o|@cMUFC-ntPwZ3 z^C0hp!9}`4SJr5$P$yKg8xxs~Pha>MBv*&Y%84oH8b%K4I>{I?3Z{lo8$!dALJ4$H zS3r;_whjSUI#CsB57fDOzc6C#V{JQQS!$~ zllb$;$Yw{6$c=<5qfTyHm&& zhKKpAq9r+ZZ}R!17Gvw>$st9L=&d(9j0ly$yJ?JqFeI%!ctz2CHAyP27d$S7?x|sY zsjfPJ@TeGWzv5LZw<8-6p`46?1*H4JYLBguazTYqabX1!>xxMy=t*f~YAfPc6(FYoXOioZDEitHCj+tu>O>4Vp=}dS1aFDMo%t${O+BJ`9U;ALi|xB5PiiJ@Jq!L!yVIztZmz#wu{ zhX2aLj=p(ruX8eD>z>JlO`A3iEvG(WTa?sI%SDk@#qCe7Wyq3-X-3^q$}8J9FTcp^ zEP#%n9RTnghnAR#5^1%P4Ks&Q703#w7^MeR7G?NQdnvbz!iTw3k5YD(zJ-*E0cT~J zbFe!-JKsfVFFBqpo}F)FLFy71hgc> zQ-r7)n1E6lh0*L%LZYFaZxiBt3~WG<%Qu(^3JIzPR7_rYXXL7kP^5v`QE^FFaTOuk zHMC74dxJ8BDTPkek+!6?{6beGn~Sm!g`-*+g<`o*I~ddw;*(sN-X2(phG}c{>FXGB z;nX5_3Vhl`PY(@WIdnnIMVuXJM~c>bRow`}trQT_4oXcZo8(DP%W?Ki@rM$_mIj?* z4wF?OR<<;af+a(&HI)}NQSME|y8gXoNSUM}Pfi*#Qhh0oVZ%|0FX8?6H!Z7Z5u(m& zt3Tb!Tbv)pKmW`6ANgB(MQJ(FmaHOu({fTEfI5UNNyuMG zZV$eQSKVchePYVxku?P7rd@dAThuhQnz941Qw$ES#Ewa61zE0w@EWRWB+-+qpBgZI z4FigD!e?$f%v_SbOS{0JM=AsVUMA}m9G2(kPm)kJm)xuC>n z6r&)M@v={GiBE*-80bi=OzE0DHI=p)rsp7M)Sc-T8GnJ2q$=+qIpwKNLNZ0k#iep6 zg2+5Vor7}`J-E%@T#<)ym35h7ltFR?;!iP{m1VB!%o`x_m( z>wNm#+>%#6#2J<1dEtpGeFB$H%C_Z^%W~3vceBE z+~asr8fyN3pZD>DBTaiNH4X%!ty$_C+L-FXsyr-i5sR!fMG&$%rPRVa;`BdieO0yI zBJ{SCRu0gw*uKm+5Qx`dio7n`7`Qa*3k?@Jzoi_?hKD=a`sbfpYgO=77Ig{KxD?p} z>eO*4;!<0jwHMv?zmB%jC}Es!t5?yBjO4`T*?_h6p_%AlzGV2b{R$NK_4LUa;nghDh^RjZqJFR zMR3?L*nq*9_$#2i_OK?GCP9X@pkLvt6aiOGE^y^x+#*;cf4_>dAytHTqc%mfxD7=v zRG6s3o&sy}h*=Pe*;C!QMc9`RL5Y^*o8bH*_2B4|B^A-N9G7N%iT2lvoJwJ&)7c}m z|ArO=T6D9DvbaeSHY^G7x6ojdK=9|{2ZszDKDO~C<%g9}S1EzklES*h0swR&-;K!1 zR|nDVD@`QlhZR;;DJ(eGFVMKMMB!s{ABpaW^eP&j>j8@afAxcLgXz zl1TbvkwgwHN-F8#ODs{}Yl-*N=vY-=Zgb?3@IP80jfDTvvV%r|ELwM|0cs*JMc0G# z>x`5^&^(MMqSKIiP-3Ai!V2xchJx#9lQiY95HU#ni3m6u<9zoypHhK63Kn^mp@Whm zt+!IJF(`C*Q(zX2*3d_By9dM`S`E)eCJc-v`sJb(eHwQ8dp)`E_@_Gyvyt9SK>(iB z6tw9-&<^hac@KA-Pi#@gkyZgBkRO{~5l_-89x2~=r5yxuYBXdVMFIj(8VIbke$Xa> zh*c;IU00(5CG$U0B@M7y9mxk=CQ?du$<@@-s0Ka~P&iT@^|`x-+^gIL9Eny+M`~-- zP>2vc4$q2IMWv9uCK76axv25O-QH|X52TTe#IUM+(e)#-<1BP-SlTW9*1!mi@2s=_ zpmVex{o2nEm-!CUQ0Rm0{2@E?wVp-f5*?e0T9MwPJR7)KEc~fbZxstKBBt$C;g3b# z{iN}AHT6a58tsVZJKV#+9^0m*@aO)qElJ@;$F?~r{JB!?($RXn6nk{SA2;*0bO{^H z!yk)vpLzI`v2Rfhe>S#V8sX3VQ+qVROaA9}XoQztS{daCh%M&8%O0bc(tNBmM~`S0 z5c}aHnvefm+i*22i)A0K=7Xh{u9~I%bGu_Ti;qcuYd-l8?vK?hKdOq*ej=Kd(0n2` zMWOlVKc*`*OaHg`uWD8rn~u_av{Y&;LJ6hNRGKAJ_pK%=C5c->uy4cnzgY)+aGGj? zy7^7Bte6y^=997NKFxY6`SccoEJSr6OBb9Jz!PhH;ce#&_z3b~}aVi@+y}lKe*}h9^~uGxNj& ze&T!=`kVIk&{=sD6H$&kQ|hh}RJXH}dcF(a+@sa~9;IkZZ>;etCx`s8XabtTPrnH` z2&_R^1F%U7XYTs_2!;NUgpHi<IE2#v}`@DzE1zC75_%KMa}@>Glhr7%;Xa(_@m-R+G$TBQ*c zLPrCUY<_%0Xw|U}gL>$s-xZd^=|#aJa*c^(Rh}=VG@@2$BT|JQOi5AViLaq8qLZXz z9SQoTasXTuhH!?p#CJqov>7x)qahIvWkuC=CTENR1%*J>!L^bUnrtorTYiet@Mx3tbEL4tH3~fvTI!sm2L=4!l5WqTR z#cuJCtpKGjC-_{p(C1~=T_LQv!6Nh;zQzn7-cgJeF(3#MD%R@l_ z<1v9~yOYRd4R1m>@r0ln<^tu;2Jbn-$>w=t$5dXHZ_80=F*pv1N5<4?PKot2rC<#y zG@*h*4ge1?h^#x2h9~j|#StvmQIHxRw{QVSXFumS|D zi5M%nErOFsLbE98e09V|dDq`Dd?ee zYZO#{=yW7aCpK;cPRJ@K({~uCqGwZ!aU}^q3pKQcy1x8-lDUD0ko-{g$ z0`>B3DTRt)o}A|PMxgsY7T5?KgmO^LWFL1$Pso(RlvJ2YPd-sCqLfnhB>Th;l#@7K zKeQ1t8=zDw4bZBwwDZ;CbCqCYwq_4%1UO?zn+fYiv1OIk*h_Y~Q0A`xp01GGSf!YF zUol1bTAiz;8j6^vFeOkPnxs5!qf4dIqZy90G^Ue(c^(w}D%|^svXm@fwXA{pt~@90 z=yF2cXtgHxvMTVhC~h4fgSComip(`_l&(pq+huKK6~I;NgamcXkDLK&!r#%8nt zWuo-nL_Qm2<7ze1&(wjgAf*gY6vj?~AzzkC5*yT_xZ_G!W`(daot^m2N}=8DrrBNJ z(uixcNLQ;U-%&_XPpi_f_p}H`jN)fCvKM@1`$-j$|A*at$O%=M#IL8dN=+)MRDRD; zaLp0iSpmbt-B5tl<@ZQywX0H)A_$ihU@b1r!=4QaCRu&oat;9Vgnbo}m*8rk ztw2t=CY9mxZ)T(umash1Dx!W+OCeB{>vU)ZMD`)yh8kWZ4sXIn8Lc8~2Nfw|!ZbIc z7Ux!O%LwIPy82OF(v!VP2b1~E;Z)k?@YBjugj4gy^^g0*{8i9Yy2>kAAoT6iNeyBl989wECV9)PsO6 zw#q<37IN0dw5A=lzWXCWhw7j3_ErAi{-7NA7A5WR4!nJngDEv6L#q8xeWt_9$H=uy7!E2nlnoxgDhmk!O3b30*QB zQn-W)RKuY>TO*te{O?5K;(vns>i8=OAAqQwA1u?uRR``C;`1j}+c0V5bLY|KTiO&x zKC1}xTA7mN{f9BAs~b&UZV4BHhR)&OJ!TU^yo{u+!rdB`{ri+-aBAGnxi#{61+mpw z)n6l2dkmEZcPchtjp!5^rhYGKWKWHm>o$t-sh49J24mNOW+Ff*%@dvmVBGyjT*lVI zI_e=$0Txclt<|nS146++EU^tjEwz6CaKu2X6wTfT)-JqK%EAV7A-49^4R23u?4eB% z65M`*#5N$I1c{A#Y9QHLjg$wUiyjy$*GGzsX9N`x7HS9mXstkLBozDBzF0=2REQ;} z*aR9P#TB_zm70N7ON5(dLgh(yHI*IJ)80Te1gJ(TY$e9|f_Jw>5RL({4{Vy`TUnHK zj;3&=umyz>L_&)QTa>JvurXZNCZvkg+x5b`PNx8qJdgR#iqIndNtbQ8RNpSF=&i2d z^P6gEpg`AJLMq+QMotSJV)|zaEh7qzUKkyyMdlktcuLq2sc@}-Kcq8K!oo_B$9+hNgV48y7d89Z}O=`PFD&hO#lZG7l}hmD4r`O5pfiD7U4BQC-^;8!<6 zZwbqVyX%D!kKK7id5FapdiZ5jigyx+KjR8Bw^uVxR5F3+;tKz@82|qgXym^|pl(5S zc;J$kcq#C5R&gLWT|kEeh`}|K8$~CqsA0jzG|u_HH5W}W9AU|CYjtL)6*|Yc;NZ)0 z<&o#im7zIWl>+V@R9Gs&TVgFKf2KNjBaoLJCMoA!|3w;Utg$k!$_&lRaAjiUj*}J( z3OogkwU(E31PR}jj-u3Hsc;I3b%vYR$s8(-RBg9XR_o7%&BL&Yi@#Olw^B&OL-Qu&Mex(d`L>#?4lolv z4BJVIHZmKbGR6q4Z|EVY)ghKgX!6(X_)-d&uwLaL*d{PcQ&w`o@<`40*Nr6wODV)iXRB%Cl?C}NZ8>x+c?v9=A-+Q_L#INFcW@O3 z+`$!E1bH3AL5sdq{4q0Wc9N#0^h|Z&YM8ruaIbnUG#DLcMmx$8I-dZ+NBql)f z3H|;+J>Ol|1*yS2D+g0iC|@UQz|Fi2yhB$#rOlLtVcb~|ui zeWZG;)1dIAKB`w3lVlvwf>||n&0YCr3w}E!QehOnigIS1GPYLVP3c^B6F)^N@c;VC z_DJm*!;knyR36oAP?4`frWc8!&I)0wb;UUZ zlv=}Yv_}pM9Y-LJuIL<*PC+x`me3N!`Kcw9fid_$ykj;Jng6e|>OtNq*!qx$3nBcI z5sSo-te{AZ9T$r@!wAzlb~ji1C2awq%>l?qFi8)?%|oM}o)gt#Q#3md|n&iyEn8d(ad!}VK~5FXeOtLqZTdaGu$hfh!k zzGT9-(J&W+kGK;P!2QWOopV-8m?(+zw$cMzB4MN}_P4T(W%gQcmb0$nVl zM%asaUH?v16}760+O5VQB3U}bS7gZ1Y9#RP!XOeVq;v3kGI=Ut$%Gq-B^=46@bh7V zN{=u=9)4qA$pb_i|6{ywPw5B0?~d|pJ^aSKXoHf#`JMPn2SsZKWssAR`|4X!k-qR*=5 z7Ig;C{`LivBbD4PXfFcEweZXHNS^sG1oOGi0(>3Slohv#B#S%XoXW0>NHr%0)trnW zQ}f8wgWRaEzAM?4Ue;7Z{Vq|H5Og)(v#m73Cd)`2*&EE>uF<-IbI2w69XkimE2 zDeGyaTQ;RzxNMLon@1}5&amZK#8?a1Pb3_JH^7Xv|AY+4u-qYhCQcJo{hO1!=eVKF z2KM(~{2jc*A#DOCiZhdpHz9f&bhuqJ@|PB1!<(k?vNgTp4?Z^05%7 z+s&v2`B2!{NE=lSi_1JIDn=KShHl?eC9xfsmC}|EUwAhfM`plX#n(J24vuH6l!c4g zzb{8*Pl>}`DYcmt5!tQ<(0g=Op;qK4)P=1MWz8OG-ZU{vJ|8gXJt-~6jU)HmIVF)i zsHLc%f^i~rLN^GAC<0~eQ@X3xUa1PacB%+rjyy`b_N7-x8s$j$YDW4#vdww*!l)rL znw%Damo=-TDAR*y?9p9E`INdBmE9<`=i9pkL{GtP;_`@4T8p45QGj+*ieMB;PSw{@ z&$o+6WGeAlf}laBJFAFtYiTzd2o%}t0kbp{n#S)iC*#EL))s%!9iL(f&{&9DK*iw% zA$s07b~K87R~As&l@-+D2EG;}`!^H*Q|{EmmM0i3nAmi=B<%}B%cC~>-`Tnpi4%GR zxgH{KloGeB(gr$`kCEIE4swme=yB+R$dcGdGk^xkCy|nQ*)$xn8wb@W0^nEGrLYVB z>AnZFq6C9M;|^F%6pEA56rdn*bkiXru*b1l4NVn-bK}}a@RF^EGE`Zth6A0z9lkxP zL`{w=u*z`Z-qjK`Ih~L}?&x6c%=Zv*3aWCe9N#)tSj0~-$;6&Qu~RV8M5v2vP{`&a zRqxLZk8JUm$HlR@g^somD6=}6_G%NXy`t&_vDTzLm1<|I^ukSEP{6e75gNgnLF%bQ zO*F>0kRo{(a2P21ND`NN%eU6zwb&pO;2-1P2sVZM0aNl?2M2Z=sjVx@&nigEaB*p! zi%5o&N+F~|ROL~hi|ZUHYyWbaT%8ck+*Tn*&A@-vthMv)dIhfWYVvNR(Y+IF=?_-( zUZKb0_FXda=%#S88G?7ds^M))SO}+K_`cT$y+~z`D@GWEwuL(rl_Z38T558llsITP zp-rVF5+*C1AnZgi0ayIu9n#l)8z6uG?;AX|dDAHhh3(LM$7OnU?ZX)(K z84VU!KS9I7b}Qoa{(Cl>Xfj=H{696B_6CGYDl!q2+nf~}xI*ZL&1_ui9Bsb;-|iBP z#PwCtMY1==$@xLPE2V3e-W~{*EKdOvFQWCRDmN4YueBk0z^|NA%ChmYrn(9|aPmZT zsZz*P*|-ND36nocnfzkZfP;)8_4V&vw;HKb|1p4Mp9Wfx+?rR~Xy`-pCK~nnm1K$X z$sLn5s?=JM*BWYGMr%a^Uk2xM%F~KSu>+Jc9lT7JvY|U-X+bf?c)H_UNkWT6%NcOa z`6m}-FnWyi7N1xPcE!+{0%A8l1=4Af(mKwiA*277(+RqW)?(2;AWs=!(JUy zuC&fpgm$z82O@Pc4l65uSFb`+<)+?9kF_3Dd%j@=M8a>0iW>^;#6r zFef$4e_TFV$oIMPJ?^+F7+1kWZQw9IW7L~KgJb2i7Q>RkXRoREf|4W=t2D8$7EL0} zLnTcOXq+95%jNfxIz8^3s7+}X;s)l)uc(|0ftZG7F8-j#2VR zCH-@vBcS^geJxVb@p9l#jY@?UP$p{bxLBvqI*l?s{ReIEEqkC$D2vwe*M_4fvMGVQ z(09^ShP#js(aDHfbEHe*NJxlmI2z_a*MT!qeJ-9G8oj!v0hxV)0S%#}1k00k9$IOF zuTtEuRY>j$46WBwP(t6Fs7&0bOirU5I2H=Lt@iQLK%u6e)b zQ8~C76@{+jRA+R#B;5byOollelS4WIVk^Za1QZ+dU^b2DV+gb9gXXL`wiKH_5sQ!R!iel#Z$Jr_ zA#Mqti0Ps!?(<({l;Ci05s-;amKjY!(gz-}@O4Z^N`Vr)1{6zHA#-(c5@{|SJyrVlfh;;?q$r1PjE^L9#bGL{NmQ~}DKC=y{8to}C{g}K4KW55g^x$=Lj*%kAr^9N z>CSkv(W1?r`aFJ2fea_S{tQcyE8K2tBF~xSYiDLp0i zmTsXbch&rd)A+Y;75MIXEy1LzoHLfBQGtIUsudI0=p9BTG%8+8>0=?H*K|?`s2Q_czKh0|agAs^bs8KO*h*TR zO$`{$Dgo^foBq*`Ot{sfj%&YC(j;s+N}!0+l9(wnm4{ey9HR)}fMeYdd4Bf@aTpn% z!m~-P9uGp{^d314NGbVOP3l61c#<2`niLfKx`G}4ZBwxM0?Azd4N__{0(l`20m!9= zKT-$XQ+=UY9=?c5={C|Br6-||4>7vY$D0GkslIVWPgdR z8)Q_A4U5E1>K+PICUzZ`W-CR7pvuyCa9k}?IUy$x2_n(=WQ+?4+KQMBwV8&V;#biP zqtXs_-4s_rJ~EDTgrm_H-1UcfX#V&%>qXK-!yvWAb_VjR6M3o0blV~EqBDShgXgb5 z^CmC`#GN~Q=cy{C8>Ap)NE!P1ex3}RO3oZl7LrxKpi!AG){QB)6rYog^H?;s*a-1N znv|u}6hg1+X_&r6!a}$x`LH_8n z!H*V*(^4ZfurZd=l&D1R7jdd?V3dRARk51KqBO7kpdy@Zi(4^7ZWdqlMr<8C8su}J z{aa2R36AFIDL>eqm0e0tPt=l8r@F|is8M>!uAY+0Z=ujdv-}c$J+YTxLA1YgE*VjL z>0B~ZL`9|c$@qsk!XlpgIMh9*Wqh^7xRm!7o(gT`KPTqt1`^ORnt6}7cm;oICy9?udQ zBhDe9fgvkItX;%_72=h8;s_bvJk`KIq)G$I`_F#~2&Y9ObpmFA2dp8CeBt^J_LAFE z-MK~B0q+u?>}Z8mfEh&&4_a0!=9JPjYbtsVA5%UBy`mLUm*3zp39S-^5z(oAfhk)7 zZtBz=+A=j92cndiHytD`EdCV95|R^ZAmA8F5@H2^c`+p*hBRfen@(1xY=dZ&5yp~8 z;iiBtEz;EN)4&jrB{jBvu9G14)zmi{IE@Pccr7GAz>(lQ;t$HOs)utD#DY-7yeT0> zJu{mYR`fn4R)}3t+!ux#;J{ayBGK1Q{{jku7*%;S{(sHAO>k9Lwk9Yr1}wk^j7e-` zd~9QkNWhX17_ghPK$fu+u!^5FI9}w-E9pwQiFB{(Udb4D^&50_yr@ABGCDeXP*G7) z!ya~Ybo8j^FQP|1s!@;LB!@Mt=z$};zi+Lxf6mX|=bWo6zkC_?v++H9t-bcz>wm4C zblEkA1U^Su7b$rx*Yw%ac;yz{Z=GOLg?PeA0| zNn=wFS4bS`Ds%6(v990cgB~AAnPL&R?p*w1kmn9zt>&06*)TeDQT@Dg%hRb|C_5X z+gTut0>CuOFlZ6DLFq^=hN*bBn2znjNZSGO=oU2q;*x#G(Rp2@?G+S5Z9^ zgbp12p<0V1rtJ~3VL6Z#JxA>>x_K^2JI@y0V@kHzo77%eLF7EqM_AIk4h?3BZ?3;q z%~agCKjo@cC>>p9py?Y!KstV2gmSGSx^?2I}YV z4^*(rp^Umf?d#x zC1K2R{j--9rG`|ul*LS}-B&w*)N*5%JEH|jr=y3z`OKcxVwhwU)>`WI z``eqyJz64QL1Tp*owo_sipRa>z72yzP&ZrFZTOTfv_@HIY5H%(@=w)&VXT`b0!Ii+ z?#=S&r$oHpX7dbDY5j;4i##;A#m7O@>6eBRv9TBzZlq>g63vc|Mw}W>7YJq$8GTbTPK1Cm^Pn$B)o#_&3cs@Lp<}u;W4TGw@)r%_b@G zoh}LsIBpIs80Clsq)AHqkDSmG+$5F`doghtWO8?muuaqP3n*st1?nGc_WYY1+y%#vVy1kTq z!NME|odz=~#)TLUKkl;+QA5BnL2!8N_c+HsP8~|pikf|oE4nSG@lO0BM9hq&`UT;E zUqotUTO)NaAQBLsG*6y9x}B`7w+3s;a=(M|1&~#2Ez^F+lp>sF}ek($wq;G?E~-=rBUpEjAHMb zOKQidrI}__N5E3o>mG=P<6(Z)IFf(qP0cjhR5g$N9ekUe#uOP*5GhSLl|HJQ6^K)L zw4o8!*u02QPNh-BFlS{NQU5AdRk3J@J)~Hi zj>SL;&BY<>gl2>;9^-CHGP%Od(c+<@tI`#VJf@t~Cm#AnO$I+)X<(AC*(8w$ADu+DQljJ6`p)c&)Tyjl4(`*xYzJN6f-AU72{&Xw2Cjz1`_Lwa0pN+BpJ7bKf)=h%lyUQ_Cg2l&DVwd|1$+^kW${PYmiFv_i~KPf z`58+%wuR$zgc{t+AKz=zzgcx~^EKVcx*p!UFN}BH(_xZzJj#se^6L4?i<1-F^@;o2 z>sy`MGna{cC&&u&g#i+};D&E6I{ zGAmQVI*Sej#pQn7>8mL>?XUR9~1Dd?JFDbRAmomwa53 z#TC?(v!Ik%;rzSTm7L_!c+^|jdclkWZlWnL45KvP0Hq%Qn(-XT z`g&y7nJ>jQpzzu=NM)&P2(-6A3TAJef6VX5pp#6ui%CnwFW3oNFGKA{lM?Q(<(_>s zoFWTkY^ekM@rrh{h4;Cuvnj%0Zw5y&X!)cwRhmyKnpN9KU5v5<8&!swqZY4r9& zgE%JAY0nz2&3$(3ZMq1K{akKA^}UXjCL^vT=ITdGt4xHM?FYSi+S2eZe&=b~HacE0)8$fCYMImAIYP{nc z{`jCo9TDNR=i@)~8vgEAd#N>y!UF^Z*TmCU#Z_e*4AWTUa?|W(wwyH-ERFUrwzhdt z1W-3xb7su7r(OC1(f?I+&vB?vveH`Ycb4)ViR(*q!2+OW)JBgWy+CS}AgwnCajax z=SN_Z*~Q0o!UAL6@lzQlEFDJpsI|)ZIw}$*7NJAy9C*37z4TniqJ`HuZWW{r6x&q} z`(feu#_9)a!>EiqX>L(?jX^xh?Fv_XujicY(dnByDeHEtkCy1~JIkx>EqM%>uPi`I z;2JWUM{T?a;&Hx;&hscQUOadk8Po@O@Rwvb9$5NTCYi`;NS%EBS1i3K%QJVwq8>>m z0(3br_c&7(#LJoHc?Z$t0D};|+E~<0R6!VrQ=jIZ?V;@B3)eA1a3qY`yh9~T33&0z zBbJbu%Bn?i_D`~>rXvSfP-`6v{IjdsJAi%Qi|Fy3AgfDJuD6EW)HqgHlrfo6L~en7 zT%z1jyy+RgA#+yhoq;}z$$|^MyP)Bfa?Tll)c)7ooo>~ka;}U^xVufbvnpSnZTa<3 z-a9sFDXVFWHy`xU!B4?_M<6p%{w3~VGu2T{OavGHRr3--EPlnbL=cC6v8+T8qhCEK z5ya$ZK0RVN-pfA(zaBn?5Lt4_NPcj|b9io-5(lw!7)55#)iA;6Ac(qg?y^{PaM7b_ z;BeO1+4g8`(6Id5jK}B449kBmLTDj1=b80q5+zd?rwZSKFAshN7eAE?4p<+;E?5@B z3NCjKQ3(zqSwkgF8<=r$SAsqTP8p>`qHWjI419Nx^)?;+7g|UB-F^ItmZOVpY*G05 zVP|P=v(0XbC+l1N)}V((L;^j81UCXqX#qOzg&<;$LlnW4hK*1J7d+#v(y^PMLKjJ9bUgqS+rS(JCHjm}+%Vt3|PEQPjX$Fr?YZzAko^@EP>Iy^kp1v;cFpKW2y1KS#KtoA_96sh$TrB4{9-swheNj2bS%>h5F0r=a>9c$`Ha}HWO z$*XCe%Jv=sw>0=|kp?|H?<02##q7ujx@W#aC$amyuIHE)GuMiki*N(esFXu1p1zqu zx6xVzp-tSXB(5ZJKu%T*no)(66%2T~L zYsV0q-yvdakWeUdu^jhN9GSr;dRs$8TB*h*rw^M5C{^jcRatU7wq9;x?3ZD&8gl9` zTmg1=u|sl83QLQ|M99h^v#I0YTZbRa$@BF?7>Ar2ScMA{1M;3ED5;a+8HuWA8kS;K z%g(u11G5m7!Uh*gakn^0uU*>|{GkRO^(a&mt6J32cNa4}l;iWfCGcjt^EzhVAB%g= ztv(v-`ttU$s*qN@Z$Ew=@Kj|jfvsG83}IgsBc5X?F8-l&d4aSzC#8}-Y!V;8}%%ds8LX& z)N(x0L^KrnAkVaoEr9DKhab=(8N|2ky)n|fjz`T5LtY-a6r1y)-%9E2yxEuoT_)v9 z9OjHSYOr*`fG*fi^NZx0P(J;n~oT{m3RQ7R)fk z010N-I54NLABVnMPiNH!WpC!(;)Z&C2l>M}3@O9#CC(h&8YE5B<@G9r$EsA+J6Yhr zj)uwst)rkGR_=6ob@fS>29329AKc;-2O+lMEO-qY=i_SZI&(&s8C{?WROf3>XYt#K zg5sMbQB-kjh*ZqYe7A^BrKVb_fa{ZiVL2~`QGrd8!^Tr5aYZ&?f)dkt46Brg?4ww4?FLlvtOkfr1#&*#GrVdwfx zhMu+k{^rWPK@BohG11hYFaS@x{g76u?lo) zf{3Psy;sfxjoG->MpKE!%LxnCj?9qN0S%kIk24k5UZGXC5Mp0jp~W?p@l=@Sn}6T)cXH~py*&O5QVqL|hQJ64=#rGNK+38m^d zc~x+$f{-c#K@sok&AT}+yxM@)GVhJT0yL$Z!^a8>$bLmVuMJQrMvBlY@ydY2& z_F{fkvVooWf?rhZ#W*2xZ!ig9Rp}B|NzIs~h`Fb}jxn;Ket7eC1yN#HM}+cieAo?4%CXFZWri(Bb( z?5m$Pdwgcr4ucHA;ixXxi0n%T%~-kK>_d0&e`6lw3$4atBz=CB-2**vdU?HNlUge2 z!Nm@Xb#fDY0F!f%r0i168%zqfaS%^Vgz#l;!tUW)yqj5!jRiO?#yQ;r3T2&R%Lc{cpY$$?|O!d!{SxxgmkT07?ai*ULK004~ zr^h);Jd4NaV>--9`V?hNENn-}ovgGU1w~bGrbD52O43mxS|n)()nRD5=w0U9;L-v3 z)I16@YEJ#FaO(D^$rubnT3;uP8s8#$^B509;R~e}Y++(}#w$Md4NBo_*{$PvB8fGR z{*b|a-}Y7?gv1h)NIE&e_uz+Irr4Ur04at^gKk!^CeJA;CV2PXJACPbjH_X=_ze! z4GK2oT+<_5k{EBG)I?rhFH0P+1TDlHakDH*Mq%4 zPo+R=cq|!>-T{tyOtczDEq66I`buOJd7(sUI7~_?WZjgb6^MG)$~BiEX>>K%x(a^WI^0-n&tdWY2 zKdpugvUUbkCX1X0CL5~&re%vkV5L#P6S@}{o{I$pIs2&GFVP#J0YUvc$eQ1S0}_q_ z{y7e!gka@igIM)*{yaYx8i*!8k#@f{DJMY~X-#Sl5PIC250m|>@3b7)r!=a4lVI}^t%b1X%}=*<*v9m|M{ zK0<*Uq}VmCUoi7gil0e{H&yfX@!g4<4`NwU$w#oPRPyiUC{#zq)0~dMtWxfIm~~Zq z4Ce5v{d|rBLn-zcYP+e}ujG*5salWiqn=tnU4l_9r5*zvlLj%R{y`p@Mk;++jPeCB znAa=P*+?NT-5!rZQlUqX$cfA*B8UXd4xGqegU0Hdo^O3*6#;R@t=cx)q>k&$$v`*G01Zt%CcdFl)g>in&NRIF$WbrRa2Qwtb6q+wLr zlWggE`cXPPXfl!0tTpbW9wJPP4uQzj$Pt+y4w31RBXVUpM6Qe+k(uETnHf1ESBFF7 z>fZ_?*BT%)zvqv*jBZd_cF>!e_^XnJTgKJpPyrSi@Xwhaptr+6b@{fl)>2*U{giBR zf(@QbXBr8E0GD3kxjnQ!gglu#$ZP^!HkTVl=A1=FBGYaVq2RScbodtJMoJHc8g-Bi zUsv3K=zb2`=(Mtd6>E8PFgvidIOz2k6C~J{w)(w|)@oNLA>*JC4w{%xeZL?222J$Gvbes%`wIq6!|30##1ny=y5jy-a`YDon2U$bn=w54_ zVfAgKU0PN|xpOV&ShI$P8)yI}dVK#&#W%BKu?Z6`b^~kZymXs2PA+!)3{Pdt zG?^!)@08$&ht+wM9bHcNpMU= zyS&=~_R5cpN?Rqxlhks%zhV_spuuxuvZf2aLI>En3Ntw^P98RIjiA={IUaN0f=eLN zr4o#p-(JT=rq*H?PnWgi1~s8m5%N4=%53fke>Ek)T8>D4{%Tr&6*isu zn=A60qK}s~wE4@K6lPfF@>f^oS1~(@zq%&Bid&5Q-DlP-eDI|EqP@O;bMo{1?ZMj3 zsm~>g+V0<+{#=Kt-MsR-oo;(`=5vju-n{y`>odH0?eoVv&+F!AA*YJ3ADRKfnyYrx z&h|bDHcLECKXZ5Aw*_}POXBPkTXWt#hq~AhwLn6sR^4C-(OPwIPa7f{N(Q@1lC@};4XUM8f+AgXF8p6bQZp)G;()#$riGYoJU!_sRVRCX3&Ped z>}5|%9xZT6G77d%n&mwfzL!8AP7!dECtyK7xxcW_er-$jWL$FP_Ir2b+okS-z~ zth8jCQcTkV0}UYYoe4ap-0NNvBQ3X$kT_q6;!C+K)t8`W)5#U*6h|EpnKVwz|2d9W z=79afEtZW@4Em-1#*8l3!=wz5qP%71sQaN}OY0CpZ^rQsRdj$sT_3|cKIsNYouZEG z6<`BJ9buq#syeD}zB9{hIKZ;-yV*VR($%Olh-;ciE&$@&SS>|dk{m7#$_$1_C|_pq zei(^p+2EhzC!f10MH$0@Q}F>8<{#wddv)|584RC8Jo*C&Y7{!17slt+D>jtT^I$sb zIVGKCkW){S`@J9A8!+hVb(YNth|FTxgi~?x-m()<(J{5y0S`hERrQx$E(JvvbG>C9 zgcF!2M6AW`={*aiNnhE88qo6Gbg}>`%0w3h#7ph$1J$xrWRjEaj!ZoE7~+km%sg%2 zl;YiHXJvK&@Oe{1FW(${D(79}&6&Gcmx8UzIrH^{dDjev9hXM;xdEEFB}r@=aEP=L{&IEOmW}?o6%toz|L>) zV^L}qPG<`^d3lj4#2%!GJ-|f|CkL7%^-&%vFYI3zCmvX^=6VQ1oyp^*;oSP@grf&# zY+QA21zt*nly&i`tKaJK_J?`$Y+KL03Z-ju*L^9X?YklN&AV);o;6k|6fSuR*H$Q$ zBy|E!iKr)RjpG5efpr~7?p84(hB(e&)tT^!dY4+=&n`8z`r{Fy(m_R#G5 zdh)oJ82SVjt@pV6>j-@=;(^szE8svEU5UG0VdcAA>PY@lKWh zlK+lVNXEXvU$fXdS%lpx{PQ0zW%*OD< zi%O_ANYmeoh2VPi9m39<1x>rC*IKVb(?;vnAZcX1N|NGfMa5g;G@$6I%p5-{;KdQb zsIkZO3Zm%|<{BTn2M%D;#m$@BH;+6`AEmRDm=8 z5O}i^jXny`Sv@|fDlaU0%q==-Z*jat1m9aRd?94B9M3dU7k7d(K}zE6PCh6AZE#X& z_DrT%iB~KuW^iH_$dQG9ZwU`GClA}$S!7qq*#9F$(oh_|A>L$$i#1($(=K@kOD=EA z<-8eLkPmpLrlG3q@-F5hsJvc3dDL0$wsh7+ zfC=iYcO+eJAnQfY`yz&3?Sp?W1FpfLlccHnY)QIb^IQ?6X;f(HlcjrPm(blh{HV9G z^`eD0yyI7^{)$KKiq-dOzJTYfoV*S!Q7-g#$$b81>9w|$N%F88Q2MmwGngvgkjwQm zs7C9R_u-<2aP$f4oL8W{mXmhB-|JtDoWf!BZ<43816B6_p)=Ul9Cm<%&-mW~i(EL% z;&Mb+N+0ryAi`&uBs+_(^u2i0tG9ctzC8YU+zKYJfxa^@=FPe6mq6wlh{7;C9g`K4 zZx)jD@WosUt$w?(`fc0P+Lh>h0`0^sIS+vnk7h-=JbzOm%LuAEu+OBH1bcdEaZ~hY z8!HVKCwShtvj*+6w1q5+bk&l~q5V9CG1x+kY+b4esDBWk!|}=79llzNl__jZwLN#W z=Iw1$&d1kZG@Se@{P*vyq3V7eA-y}jb%?_>FJkm#l-dt7*olr8)9J_-f=6mWq0+a^`5ti}KS#rq4Fw6URkG$#r|5q5Tre)f2mxc#< z{#1U&b7D6H1+XckQu~5VCB*~NzBKx&^_Y)yel#;nTIa63%m1piCbUn;X>H`8xFz); zNq`n&*5t+y>?ZN#a<_{H0_MRsddux(X|2^=Z4WL=g-p_3S>a==trapSqu2fRVz0OL zL5xLVL;#ee-^k{o8=iw*xA51%%VO?VArM=N5A7-){K}7=aM9ae-M^hQW+2X-DZ@iM zSy&6i^QD36ZuJRQA(E{3mYyRwsxP01t~PrK%Yf*W;o(tRnL?wo5da_S(C7!-8;dwD zq%~KNA4gWNG^HxJd4RU-#xC6Nq0z0X!is#0iL(;*DM5aSdE-5V42)X z9<;Y!^!m?fBGFNZ9@5DQ4SA@hZX6fsLLK5N=LvFe^bHNHWSY03P7_uNeP`* z(Z}zn6Pz|{Y2}kCLx$*evv zV5SZS)u0%0#+1DF0{5_8g-L;H<43jH^FGA1-9yQKLQ^cn-W9`>CC6t z<1hG-Qh<3|aw_*qeqIuCQtSAR!GcgjOQ4dH$Wq?uKlcz;9n_Guv76hz-;O;5>6q+R zC3pvZhhADD%QzXs*ewvZz6t(u9<9cf+uzk9-9y2YA?E)K64L--xr+#0{27Uvjrrxt z_nyJCvB&V|TKE~m&`$;b9$2X_Mf|86VO-b3Hc7D^$`pRE1B9Kq{20W|n#=DRq}&w# z^*UB_J$$lOZN!4J*YZ?~Pb1^@ZY|=dQLEvufFW5xqhK?}q}aV$XxsoED- zDMgwYAK%u(h4loCVbO`LzHSDSX2Q1~r~DJB!Z`tmZ2}jYS;9Yu%qPPskNd43+x-Db zp=#Lhb9Klf(fB$9Ihh{K_jDoZsiLz$faM3GjIg_S&<#^v`q&&T`C8liGPio(64OSQ zTE=_|S*-awlsy3#mOWfHRssd-GEJ{N+FrzH2~yDFl= zkE>SyHw7mzN#GWX`Di7wi~LA)tRZMgvPZV@#$O=T8Qy-3OMVD$ zR(V7NHgqQ_N*I4*QU68!^E%AAEog5Qc>IOdchab%G4A?AKX~jTztTdfB|HqgXw`zC z!4YZpEo3+*GGNJxGkYY!K(MofI@U;fEd+P2M^9cua#D8QY`>p8>GrX=p1gjRIl20~ zeh>(xsrjL?RvWJaqng<2Ux_vTS{Ka8z?{bNJ4>UFzh7(PDj*QrOWJJo@gi&1R{33w zWB!mkkIelAEbVk4WWhx)l6KmNu>?0qL)e_APiv3j`)3csvv~}+R44Hgo2wp0@PEsA z5%hTC>4i1uis8KSPw0T>5Q{1p5te_3io;~Ux^>Thd+oG)cC!QN!+Uwd2cx0g^| zi*v%|M=Gs_&Q4D&CM(El@IP5+XUUoEQR@898S0SLo&99YaWcK`)|lj@q6=fP>XvB! zTC?enJ?D2o0lL|m>4_5HKbGDsWfLA&8n(#gpmu{vs)%vBIWZ8ghib4XpC}>z$5KL= z=t@4lW#Uddy%|-To*iz}H4lFcW{a2N#c}WUey%s)kE8{oN5_X7%F-+$?Ld)~+I+b1 zd~t=>o+@bJW7wrh>cwf(N2j)x0bL&xEiP~&=`Lc7Fkn;Ig#nZ)$>v@JSMc3O6-?(*f!vE7VIdUgeB*_GA3mMpXe1Eiv)X5)4K z3l3`8tJl~&HfiDQndJKAzjEQ%JrZ&)|CKAG-IEs4mO;GYAYKVWbcMBhq@K1M;#IfS z)$m%^+^?>Mf92)~>`7by%do%h*18^E>xTQ)jqtDTxL@4~{c4B=d?~3u_=^Sh%0K_( zUqavxqq=!g{&(49jr~)TlarT)Ki*8^H1}IwTr#h+`E~oHd~cy0;J5fcLJWR9j+qer z%m@1F)k>J-sKPFMcD?em{bM)yKa1ikH*Ux&1<~6(mOrZCPx0VP@!@9CGipdspnFL% zi^Ch~GtMUU6eSmiITeA>*}-4gCjD_;mOevt#b{M-aI;@ZT{i~@ux8N9B8p>Nc>j+W za{C5LuXN=@RsgfUL5k#(rB*lTB8jnxScN;`m&z5k13Nk+hau{G{{;U%^|j*4cbTplZZ$DIfFY|`shNw`yaNutqqCy2G^x&xD7L( z7rKMLkl?d4&W4PGOMF;d0?UzQ9v7A@j~54*J_nh})ZVfr`N(q#Y+yPg+_Uk+Txj?0 z$7=|4uCOh;wN8`pCF50ttwCHMo=?Fr$bd44v{*g{=v@WWTZiS{2-JzOCm`2t;Led$ znjm&3_R5n-x1+2)Z9gBtmt*(%68_>pQ!Kc_6$~RG;|u}eh?8J(7RI4AW4Yf!6E;Xi zy`k;G)k@=g%NTpUk0Pm$f@xNZP9&o?>Fg)`TV40@jORWsW7ac=tRQx^sS-v!-5}rW z9ee7KeHuk}@7Oc<(`V72?gt;j^|e2LWm)SQgJ_(vm)2up`}ugc{Q@C5vQQLkeeW%Z zNYQmMKYb)qv^~>wKa9kSp1yiz@?u6y6+XC_`lu|%HW5u$<}*$1W_%_gF+ot z@A%wNSmodt8#f^O?RU08EO^FY1F*3CVX&~BgknMLzuPu5(1Sp3qNGGeg=h^cjmMWD zua;xe&|*}>FK?!NXIX$t0v){D>(6)k*=tt7@dTpNBtZwdf!$$*Kac?R_(*H{^3nUfjVW?YLqTeFY34iZNdr~8h*&SX4ZT{_R~#&PStvC!|}vTeP* zk91*gInFLME#boPoXN56EN(vTyT07uBcnX~4b%5Ow$|gwoX;#OjyD$N9+{G(xv4!Y zZm;9I{P(Sw@s-IA$+E0NH{hdOyln=Qh26Z*R3&ue`DDt#@|T6F|*o>Vw6+a z6KWU#mCD|Ua;{2YOoKoRnJJu!Ra#Q)S*8E*7)D*!Hf{`1qJkROfq9u?AodA50#my$ zS!)fD{zn-&-?6}_+cJc2y|aO|^!e#z14RvN=`rg}T$EY|{6~aI(kO{dL*#7U0;^p> zvmp1UhB~=kcdB_mCT^L&6=TOrzQa%0fq46+DDS9bxG1UL;_Bo!jYOz}O}aXjcu3Y) z=8G=x>t80z89X0vsJ7%qwr6qbBV$WjX!->Yo)N$QL>Yq zO&Z@xJ@_2|2m6a+fIN|2Z4=sKnux(ZGBzE{^J723C3uN$Bq#ok{m|=eJmj2|kfqC)JYtJQm@O|~_npkTe+3nwAz-Zfw!u-ejvA+$ZY=I`5q$`lXTnASQB_nS zs@jO6s=Tyk9|-r5(xgd6rN(|4RWthkbz+QB-9Lk8IFtlySZYn)K{c6H#31pz)P~Mk zL7XyKZf&)U{#n}Y_c>CKPjLNIzWe`U>^rn3s8-w({Yg+8UaGEIR@9Y4FXZRX~%Q1(v0E2=lCB(W$GwcICAM-ROoki);s9Y{OB z>i6XznrkohUv6%F(_QJ6Z|!3JRlN-!_SOw-Y>0$%anHx$0p#j#EDxLcKgF+@aLIio z(m{J)e4+mu>$e7B={#M!64NUxP&rl)NeA<3Z$@=I8jrjm= z$K8jP9EaqyfqYhe)bF^jKn@j%D(^j{Wfk~*+v-mhiF-C%i0%mnk0~8iY=v1?CM?J5 zARMz6{^w%D`|kF(C9GQnz7H)2b9V8)-^`V-xt~AtNcze*a{)>o)?b1iAA4rb0sKDs zcxt?S^`nq6<)O~k?kA5nq3%LP#9>ff4F{+fyNv_)JKb$G`jP=I(Bv%(g)LW2o^FFGe<6M2U*{-B34^t-T# z0?Quu_URCM&Fm`h)p1Xd-OQaQB3N3V6gkx|@DK`>nHK0#dGb*d7yvXIK!3XVo@Nna zgC$igtM;)>Ct3%vyofR_wmY&Ej8++g23*&S1uMUm;|s_&#V%z? zLTS2Q6Xr&x!NTHmR9Yt_P_o@kdfU=sTg2q35n9qX?2C?rT!3s=P8o)@%4~3F+8sty zg|(;47rBK*yc*@I|6``SMyy$lc!1}z~)LL4QL%Tb@ z3U=*%kNcf~S$RULd1zW|#lCdb+Yb*s=|1mb;&J)bIdGYrmHAfCNl~!tU?P^R!#OGu zo=P%ZDH7bFNr%5QO6#I5uRrNZsEolgoN+mRr$nr7fjl&l)vw|qxn&M~-|F{U-2h`9 zl)PUucFFEz-_s{Isep~*_59OCEoT3FU)8By}V~S~IlII9xD0n(e z_g`-VPlTk)*W8CS-R;}^G;rhggCfb8hvc&mlKM-x^H-jQHeNRHHn<%-OSft}&;0E? z3vA~sD8^<_Mu#`jSEy)2saN?q{uEJacOuK})pF`F57vc8)w93d*9jWwrL$>^H}oLX z$V=en%24+4Is0-1UY9{*Y_pK^bc@ETch;ew^&36~nRf2V*tMpvY5w~e@Iv_<952al zL+okwgT?HvIW1+tL<<=k)Rt;^PKE9Jwzn$PgT*b-P{})~{JG>ji$8xIw~c~5 zosMhw{M!9H6;?77#NRJMCmB580{F^Y}ug9fpo@8IiXH4kOhvSuagR0 zF9|-*L5HsDun6`9fU(rm``FXu^0_PLD}H`@?Dx10lF|~J2i7fc;Ys}H9o)f3YnXqu zWUQY2^>t=l-qOzxFn`O~V*TxIR~iX7kykG#%u%?dl%U2Oc9En5NTCd@HJHa{R1G9W zVx1cMMyELAvgiO6hEaVEKO*ngCx~!v*(h}$zktxr|12_2yogzRn0WE`C(Tb}z z@$J7Ov)jluqr$`5N5@6xz^+H^!k0YN$|Ck<*$qB|fF37W&)U)2p%r#ZX@ua_Q5~Ug z8!M2|LZee7AqcgUN$BGds+16jsA36z6jLvukLoFz(AOiJ#75Cjyn75j^Zsr_2GONv zoeR^COx)0ZrwWHdWHs41T4s>dOM0DjBwzWm_4HV1*NwDUc##G=EwspKQHvx4L*Xu4 zFG(~@ltT;1xFqZC?y4rrL#vI$v1hamh0ONb!#X5eM|@LwLcrNv-?n1nuwnbg;M(2ZW$M)!0K2Qr5`pnD@s=xolQ}?d@X~b^ve-i6Q%1%O^Na^Vs=F7 z7xj#Y(oaWbL6ojuPtTWr+DORDL*m{O&`kK0kDpL~H*(@7MY>QIGg8Gp~h0all2Y>o5eDBC!I zhc!b|5e9z(!+RYzt6|AjRWM1;{tKdAN_1%73Mj~sJ8c1zpz$;=s$ z4>KTV1Y~x=vAjeDP|VAye#mC_^vw&>fz(08pQXUtip0zWg0Y>neI1V?K%*4UxR^oX zs-WSwmYRK|HrONa2?cOPAinkOgm#e11w9=&ji>%@qi>?tpGTMkmJr-?w}Q#(Jlpx#JjrP&n6zAgaNh2 zy%)@%_7c`e7ASf-v+L{W!Fu7tz)s&%AlE0-pkjb;7BkD=kmc`UpMFj>lWzbxR(fsX zFBag?6KC`VY%P>A30`uTc7M1D-4lw^jfwj`c_#%)D|x_gX|1!F;M^J44xss`44Sio zCJNe8b4SZ+bik)MeOHjisvvE((0GVn?VztP`@DETk({0QzSWVTot$!)YEqohdS_)z za@}biM22ayXLVb!oJV!b*T^=-iVlt|%-a+53t!JB56v{n%-Xjz6u2X6{}Xohqa2kM zJhEPyMw{|JgDxy0Ps@D09>$Lp-kphscE7WUNsI`M&9#5*Ah*Sy7U^^^Fygfg0&_$l z^$0ZSV@}?HXF-o&SNOgHotr>~MR%~#8OU)*u3+}Qeaz->!k7P1llk1&y=5e zpzkTruO?8Qk96Qh1)F6-&I`!+!+QisY2bP{QxP+di?@LqXY`qaRW>z$lsQpfR&w$W z2r89OY;+W@XV4`S<1O+09? zBKHwo*XQvmScqIVFED0Bx0T8GscCch%Vm6ab=92t)jhRksiGQW>WW#toF=|OFg2!1 zGQT>XcG7^Oig*1xj@ZIVPXOw0qupO^cb8tGJ*+48W#)YS8#{#|OQaNe)EBMAX`bbJ zOE1sVRkJ@gn>rvceG_DAOqJz*0C&cIUC@a#+_i}`w1n0d*El)4k1#CdRY2(xrgeeOue1 zz4`ib3WZlZREpuggxqQ1$t)wum6llvI)227ZApMbP(y%=xW)-t>^|1L-=^?d>nwKg zC`z(I+N1X1N68?w(X(*#eIYi5c7CF$o+EeWCmy!9w(-~p^y$xBzuW}#*@!PcbM@at`m;Bm z4JkCar2Q2C%nDW0R9nVIdVi*;Ae2oDN-}sk*lKSCfIsl~XxfT7?NFs)cJ+NqNbP^6 zNly|>V-f8k`DYmSmIQjH)6)}=TaX=K=(IMLN`g&7i@oixJ}s7^^kfDdm5ZE)u?cGU z`hva%EdW*9@vLeG zzDAu+g&tv)?7(wxQVLze`W1Wd^~W^k-;pD;LX}tEr6rw%;IqJodLq}YK*iu3$es;N zQBwL8@AR$A*{GSGg-p2SiAu7d+Qby{eyx`pC(|&&)0eNFw_mbPtsq2}GXPc2&8E|| z-O{XjrPE5K#?f-@99zvex>^^j1#VQ_Rw!g_L-jDHZ%;geo4fTgS;j4`burZr4wR+< z7y;(}YdW};A9PRp_F|sZQ@Jzo6+8SXUD*zvscF%`Y35#L#e^8ep+Xs8qK)xcZ$FC7 zTnrnDgk`YF@~2wN!v;L2zZx>&ab--!QD(`fFj3}4qZKIoID?K-R)<;8d{Uvp z2|one9If9fT2m7of6;%Lto3@&%}BCJ)b3_bQ`M*Z%jOqS!L(`knmIkJlJDAk7#1z2`dHG9#XR=k6+|z*2qERn)4TEEGTf zs0#DyjfvYmL5VM zC(_x5g+!^Mga&~oUQgdd)*#ANi0Gf%C=X@q3Ij@^#SzOxImfc;l*ynqpFvA)bB;eT z2h0piHjWjKR;fjOb$)`qV-lPa%?0>n@hLy3$?3g3fH{yt4^_JbG&o((ez{bLK0&}1rEX& zyYp#0<{56ohTI1VIfj`vqDfos6Z~5dWuFT)HZwnCxL}jaSYo$*n>i5Ujf5ai1G2XG z$2c&BeKiZaXr*O$twKJ$>nniGsVOxeU&}(43GW%kSM|bl*!-A=WkPUg>O=i33sok@ zXP{>Ht6ozGZh|;j?Ndf>L+`qtvP_}RK+c}BDx5InYdmFfQEJfoMi#crw$H$JSDvw5 zqsloOCmV&~TO_KKexc+abA6!Vt4&Q_OBD<*S0D`I`KK=hIlRlLO5#nXwWsbi)$3>QE1Q>tLufFP3C*(wqC3GubW9+$3>}SP5E11r!@_y?O_7)nB2iSw&f>cQ zButiv-kwe_<*tiT0f+z@GqBC)IPn3mOv27e`}g@E8Ez8UuEY*@G$43&x)x+<13m?n z9)LrIM^YvwBzt{jaw>;_yr@?=g6XlE>9dl%^`=drZT5T1+qNkt!|=ybkCsNF<{@3( z!lAEVi^CQv&8wfvM5?_ru($5mJnUDsSwoWd)Yt#sR z6jZfeza|1=8NrjnNo)5UFVa9-F;o|5L?bIR$0f_M$%@3nDv|NS$F$`@@<85z>GEl< zRqvJu7CY@)9Y95dAwbQpTt&D=mJ0h76Cxj2r~Z7pzyc9E973Z2k6{*0uv8mW47w=% zKGIKL_-&}2zT}7HE$x9H7CYJtKfETLBlN~~u7cVzJQ2F6RFJ~y`0rH8_7>Vxnw(wi z>fM8PP927kV`zAhf1s1TwBFjlV4Brr=_UR!otlp0c=7l}?@?#DodzI<#1D~pV%1a# z2U7_{T&)8S`ANsxD7OrjV~NFc*5b+95+X$GSQI2tXvi-*Ryvo|pqjK+5Tr)0rEDx^ z#4^P1ihs|Ub|hqxcn0y}e+iNG^8&gSDOSp?v=;lFB`uAUz0^eX7K|cNm<4btl|eu4 zwWgErI+giYG64K=U?VS9yW{sOr^ z*1!VSbMNu_15~n=5*n2%cKV#W)9(%N5;4NyX->TAcyDH}@=#26-a?i8Dj;o8HEE@C zC!G=!*!ymE*#yAV>9YxZ+PKpuu+HduZ2|ylb=w5K9bvys07A6mCiG3L=O*w?y{?(H_YvW;4d0yv)lZEKIl2&^%ZHlx7W zwR(yJ-`4E{3Vd#gp%~0z<|)!O^{CKB6Iio;dv9QY8oeulFYi@y=YJO4Z`O+_NQsgd zG+v7UjT(E`-h48k_4cgOUSCcYWCEImdjd$*YoQ5zJgO#|!1CuK1sUc3-HB|~$Dp&? z)yG}}5K5a~0>6#4y#&5!YAC)27v}HpFa7-^?M10J5OW{wmSK_uQ^z35ebU$v$$dXM z10=U_EyE-C%?J&S+{#fyBmdi&fsy;|8Q-}T7s%_qA9HOUNA9J5tTn}R3)QnwavzP% zGRdu5&osz=)JR1azHOkIbKj0cCFj<>km>o&wt#xkjEs7C7cz$W!6bk=E!tEc(6Y&a zsH?GapSjtl*75V%%+w!+*lb6NK8H#T{ha%vo=VJpG%8h?TXuAvq`8H6+C!RKu2hlc zeiMz1uC);x?JT3PI-Sj!FU_|PCRt18(7aUC%dB0p?x9DyMUIcnqWY)2ZWR-uw;7Ti!dR$Zz)8 z56kf7a(ktUNWr+74LQ8#_bMv(2MXRaJcy`B%ER!+~ zF*+67G1#Ybz2s$Y8<~Byu_KATWM8duX;!J@!b8U>F&2&rVHJCe;=ug9*~eeqmyCGm z`%?(U>I)PhLXS&fVDlvCB4kY9KP)xJa;T5J@l3YQN{lZBF9EX{qMc(RUns|LMp zXX#&Uch;HOxWBaP>Cdw^VQ12x$k!QMO=^+iKa8FhF|(13YMN{x$_^g2z|gVV$1%hg z{^PLuDInm+6)HlxafPgSvaI>rS#Lz4$yeemx&ux{uapW z<4j(rV|x?#SWZ14u)@-UHO-Jx@ve&ak(01MPG&Ns`bK7RqEoDw7k4~F_3!y{@>FhCQ{7MsZI*SnI{QOEFpn`EZL ztK3E@4@+Qm_6M~Yi~9TmgWOzH{DMtBHk;$!&-XY(1rHMS&=$^0taNCqR5|GQ(l8#A zP4Tege>(@22jQl*h9RD>gvf9TO4Tf+-;_Yw=;`eIFr517|L_{SS^*FSdo3u~bA<+A z2fB2Bm5Ml*(tAe=04{0S0W?V}HWynll`A;p9X_dkvigva9h4y_PvxiV<#L*SWz>J~~WB#-h^As|0ieY{UWUTJ<{%sy# znQ@@S6_?WT3V$p~7}vim#Z|53Xk7{LWZA1WMAD3i(RVU}Z(jx+h>0srPc;Y}=1D)y zu6|M%N`>`gF!b#u)>0V9l3Q$p(l>R&l$yy@!#u*?F-DsWNcbl+N$C;PM5g4B3MS3<32LzG1Nui?3`QzT#-{c|VBHrEhzkDq1WIfmH{0(Y3`d07Fh= zV68iFwRn9J#_PMyb~hbs(5tWm=qyu%>78Ts1bG=#o-CZ#4V+~e<`g$>Co{|CBK^Dw z!DD~RfRSNX^$dc$O`!n;iVX?m;Q!NJk;Au}Jy(iFa!E@kZ8=t)2*aZF3&_Lbfd*)4 z1*fS>jH5N3p_Z5Z0LVZuvZc#=hAt{ORT9-C$F&GtIy4MJfaQRNXFPe~+#GDUFzUe6 zGh2N2CVA1h4>-yP8a!nos|z0ENm;3Xr4GZJ!WdWr2ijAio4Yp7UK(bFjl=0KlITR)PzOUS$MP3_6fNR#p6|r)_Gewyl$|3lSN$PV&#kgg5*}3DB(VMvK<7WbkiRvRLr%8SuvQrBzeYeq+WUzwIIh*32n| ze>x98KQSgu0Gf|^@J-_2XAJ1xX8K-F1L|L>3*3|4wp6W#e_pR@Eliw|6|jXt+?Hu{ zbdwn7%}10N0j0=dE<2E)@JMqeeKHGeHSMGWL6#KWEes=aH;M?0CFsZS;(N&vgd8+g z=?MvYD^C09X!NSCELeyl<41f<`iN){#Zun&X!L=P6tbBT>KPfCbhcplG*dYVJe|t< z#KUNVbL#W|E{v`NQHDLf`gl#--j~AJo`E|~+Vf?CiGxIv{ zT>jiPT0eC*wl~=2)|P{1VP&)l0b8B@d@d)+oZbR)S}#DG`u!hC;@Ys4v{E@A)IB&2m%?PP=pg zl}{##gH7H@H|nQ?PouxqH9TP54|OgJ!rX40zsyx*jtn^|}4B>V+|X>8k`)xL+l zp1dj==HFWtF%~lzq4eCm%YEjd|C%>zcUJtsRa|h^>VgdK;at558I~+>ajZqd+NxXi zV1SbSwLWQc}x4~UoqE_{FF@Ma+adX`0 zYDmjY<43)tey%XF4r5T=0Ou?=i{1W#M_Y)1FIA)yFE`S+&P_js)$!)lQkuWC>6VHh z@q9CIl|p$UghoTTJRDwO`5eQmiHN?{m|mG7O_mux2-3+&>p15&Gs}$q>6>Nm1u>|u z(`&}0E@l&A(uyEWGiKnE2yx3H#0=BB%A^Lb=1fYwc8^JkS2HG^u9?AY#-zj}Uq%{Y z(rLtNs)|XQF{umSg_yJ=V%LmGuMEwkS9X<24PMQelz8nPlM=6HOnRjzlU~b6biZII z9~xkmk9gci8PT$pT>4N}wq7nIM`w1G zMGaofS(JF~9*YvMW-L0hD=bPp>apm|$XWDiC5y^P^|~zjTmpR>_$v!HT}@e(8R9Mc zb20TDV$rL+%Ay9Z<}6CQc8^7gS2Gs9T9ZYase0m3SJht~Ig?(iWKx;EKPo0=6Y+5N z=(SyCQiE4>CM90G$E3uo8IxYC$)wFxJ@Kd~N3V^XML(-#(a+-kVOG^w$C+%~_Oq?H-E~uVyUzSxpwr%F!wljd%!)dYyM6d-SuBGwJn8CcQpNCcQp1lV0Cd zCN+39XHw#|drV5anlb71p_sHvxDb!J%KrMune;{_linC5lQIE1oU*^Mt4wO}YR;s@ zYxkIxcr|0v8@s}!Wr^#MB)w6CNk=~={}QL2*sy*&fj*NNuHRbm?M_nF@U?hi`5I?= zzD;WZfgI-5x8woCETWwMQ_;^{fADSCKp*9ljaa|#$B)Y=YBVWq-Dwvz(@d*45k6JJ zXT({Ov4Owbd)?=NWpU~Uu64J)ibJZ`06jDIM4W6EwAjoWz|Dz^u8q(I7v0HTHwdOl zHA9UViD4%Ab;lTo@u)YpG5kFz*0Fh-b2Zq(xG5JS^mVv*nXL%ZLLE98rDo&%N2sPbl3RMsHL zwG5oHV6drpEw6F-AcZJ0PwHHo)u!Fcz%Se_skCig_5NN4t7e5!XG;1Z%4j{l&dS~z zB(82QIqw}N$*hwpo{vpfj(N)gQ;>M-{Y6E2X?0so7Vb;bSW7h@cs2&P-_ZxC!nfd5 zXmq&U&ymci@c302;UMxb%6rE)EOL7`;s}+FTMaKA8C@R!XdEoDG4?66kV`DTy0P); zpdyRxz8l#6$agY^J`C@5PjLC7>Q$LxAE(Fbcu!5MCu!!o5v}|C?H}==b^POZQs3T9 z#A8uO_L-oggQd0h2HuGOX{o(w-UkZrSRFfBJX9Pk_%m5U}PINqwY|!vHXt$D6Z(H^it#?Yp9- zd&q!)ZN1l8{bnPb1Xucdz#hlhY6r(ni}-$YWK^Jh5T8*9`X6<=v5zvi9o!^oFeora z7M1d}^Pa=DAou!j0J^H{!wI@jF>_Jg{o{g1<=^EsJ#Ut3T{hXT--H+9{7Y)V4R80a zK4@*UZ-&1)E|pl%@s(a8d~M17N^f08t(K#`_k+K7chae^_gGS26#r zv(+Bpow)YY%#6%Lte$Wd{Itn{v*052r*8$9*r_u!`jJjSRR1L>1_hD&+ZY%WL~q#H zHsSnigONKU$0{5P3u09agaxrW4`bPHme|4YnIMc&&7KJY*saksL4bAMa0!0g_%)Z{ zN)Lvf*y0cGvU6LkCTTEECWzbL)-;(Qnt%J_Qi7vDKb~Uil8ZGYH?j*M{2;OC86kt3@#=tK^#GLk0Z;OfKm5C@l|KxxU- zI&~Q8&4(OM)_|XCHCG0aYu0KQF`3J|{L1SOm&qtMY3IZsNM+bi$2}cLNaZ%;6Xms$i5d@8{4j(kq zPj?tJa`5ZD*j_>lUE)`CG7ZkNV|=joXIPsU&S1T>19P20YjIt|@ literal 0 HcmV?d00001 diff --git a/turkey.ts b/turkey.ts new file mode 100644 index 0000000..0429a45 --- /dev/null +++ b/turkey.ts @@ -0,0 +1,7008 @@ + + + + + BrokenLineDialog + + + Form + + + + + + 1 + 1 + + + + Broken Line Prompt + + + + + ClothingMac + + + HMI Configuration + Arayüz yapılandırması + + + + Interface debug mode + Arayüz ayıklama modu + + + + Delete configure file + Yapılandırma dosyasını sil + + + + Machine parameters + Makine parametreleri + + + + Work parameters + Çalışma parametreleri + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + Template recognition device + + + + + No device:0;Bar code:1;Coding hole:2;Multiple files:3 + + + + + X frame sensor coordinates + + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + mm + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Y frame sensor coordinates + + + + + Spindle parking sensor angle + + + + + Lift sensor coordinates + + + + + Angle of spindle hook sensor + + + + + Spindle jog parking angle + + + + + X movable area negative boundary + + + + + X movable area positive boundary + + + + + Y movable area negative boundary + + + + + Y movable area positive boundary + + + + + X Sewing area negative boundary + + + + + X Sewing area positive boundary + + + + + Y Sewing area negative boundary + + + + + Y Sewing area positive boundary + + + + + XY start stop speed + + + + + + + + + + + mm/s + + + + + XY zero running speed + + + + + XY simulate running speed + + + + + XY movement acceleration + + + + + + mm/s2 + + + + + XY brake acceleration + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + XY maximum moving speed + + + + + Spindle start stop speed + + + + + + + + + + + + + + + + + r/min + + + + + Spindle zero reset speed + + + + + Spindle running speed + + + + + Spindle running acceleration + + + + + + + r/ss + + + + + Spindle brake acceleration + + + + + sewing maximum speed + + + + + Spindle zeroing compensation angle + + + + + X gap compensation + + + + + Y gap compensation + + + + + Sewing main shaft working speed + + + + + Spindle cutting speed + + + + + Spindle needle return speed + + + + + Spindle start slow speed + + + + + Reverse equivalent spindle speed + + + + + Sewing frame movement mode + + + + + XY continuous:0;XY intermittent:1 + + + + + Sewing frame start angle + + + + + Sewing frame steadiness angle + + + + + Slow stitch at beginning + + + + + + + Needle + + + + + Needle action, thread loosen allowed + + + + + + + + + + + + + + + + + + + + + + Not allow:0;allowed:1 + + + + + Needle action,tight bobbin spring allowed + + + + + Needle action, catch upper thread allowed + + + + + Cut thread allowed + + + + + Do not trim:0;Automatic:1;Last trimming:2;Data trimming:3 + + + + + Trimmer cutting angle + + + + + Trimming completion angle + + + + + Thread cut, upper thread loosen allowed + + + + + Thread cut, tensile thread allowed + + + + + Thread cut, catch upper thread allowed + + + + + Thread cut, presser foot lift allowed + + + + + Stitch detect if thread broken + + + + + Thread brake detection, main shaft angle + + + + + Bobbin change reminder function + + + + + Not enabled: 0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bobbin thread length + + + + + Bobbin thread correction per stitch + + + + + Bobbin change as per sewed pieces + + + + + + times + + + + + Oiling mode selection + + + + + No oil:0;Oiling by time:1;Oiling by stitches:2;Oiling continously:3 + + + + + Oiling interval by needle stitch + + + + + Oiling interval by working time + + + + + + + s + + + + + Needle Oiling sustained time + + + + + Stop position selection after work complete + + + + + Current:0;Start:1;Anchor:2;Feeding:3;Offset:4 + + + + + Valid flag for offset point coordinates + + + + + + invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate valid symbol + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Delay after pneumatic frame off + + + + + Sewing acceleration + + + + + Trimming frame displacement + + + + + Automatic move to threading point allowed + + + + + Large presser foot action allowed + + + + + Sewing move head up down + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Software limit XY move allowed + + + + + Number of Needle hooks + + + + + Trimming frame direction + + + + + No:0;left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Early speed reduction + + + + + Delayed speed step + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Pneumatic frame off + + + + + + Penumatic frame on + + + + + ms + + + + + Loop work allowed + + + + + Shuttle Oiling sustained time + + + + + Sewing operation speed 1 + + + + + Sewing operation speed 2 + + + + + Sewing operation speed 3 + + + + + Change the sewing needle count value + + + + + Enable + Etkinleştirmek + + + + Disable + Arızalı + + + + JogP + İleri + + + + JogN + Tersi + + + + Zero + + + + + Open + + + + + Close + Kapatma + + + + Up + + + + + Down + + + + + Extend + + + + + Back + + + + + Combine + + + + + Separate + + + + + X to move motor + X yönü hareketli motor + + + + Y to move motor + Y hareketli motor + + + + Spindle motor + Mil motoru + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + kaldırma motoru + + + + Frame + + + + + Big foot + + + + + Middle foot + + + + + Buckle the bottom line + + + + + Top and bottom lines + + + + + Lower scissors to cut thread + + + + + Sandwich line + + + + + Elastic thread + + + + + Elastic thread 2 + + + + + Laser control + + + + + Laser blow + + + + + Oil + + + + + Headlamp + + + + + Sewing Blow + + + + + Hookline ext + + + + + Hookline open and close + + + + + Sewing machine head lifting + Dikiş kafası kaldırma + + + + Spindle clutch + + + + + Pen + + + + + All to zero + Yardımcı fonksiyon > Parametre Dışa Aktarma + + + + Needle shuttle reset + + + + + Back thread + + + + + Back offset + + + + + Back shuttle + + + + + Back work + + + + + Set anchor + + + + + Back anchor + + + + + + Back start + + + + + Forwrak or back + + + + + Bottom count reset + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Signal + + + + + Action + + + + + HMIUpgrade + Arayüz + + + + MCUpgrade + kontrol + + + + ParaImport + içeaktarma + + + + ParaExport + dışaaktarm + + + + SoftwareSet + Yazılım + + + + Authorization + Lisanslama + + + + Network + yönetimi + + + + Time + + + + + Version + Versiyon + + + + Root + Süper kullanıcı + + + + Select + + + + + Para + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + Başlat düğmesi 1 + + + + Pause button 1 + Duraklatma düğmesi 1 + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ControlActionWidget + + + Form + Liste + + + + Control action + 控制动作 + kontrol eylemi + + + + Control action < Auxiliary function + 控制动作 < 辅助功能 + Kontrol Eylemleri < Yardımcı Fonksiyonlar + + + + PageNums: 1/1 + Sayfalar: 1/1 + + + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PushButton + buton + + + + pageNum: + buton: + + + + The machine is about to move, please pay attention to safety! + Makine hareket etmek üzere, lütfen güvenliğe dikkat edin! + + + + All to zero + Yardımcı fonksiyon > Parametre Dışa Aktarma + + + + DebugInfoDialog + + + Dialog + + + + + PageNums: 1/1 + Sayfalar: 1/1 + + + + DebugInfo: + + + + + pageNum: 0/0 + Sayfalar: 0/0 + + + + pageNum: + + + + + FileSelectDialog + + + Dialog + + + + + PageNums: 1/1 + Sayfalar: 1/1 + + + + pageNum: + + + + + FiveHeadPrecisionSewing + + + HMI Configuration + Arayüz yapılandırması + + + + Interface debug mode + Arayüz ayıklama modu + + + + Delete configure file + Yapılandırma dosyasını sil + + + + Machine parameters + Makine parametreleri + + + + Work parameters + Çalışma parametreleri + + + + + + + + + + + + + + + + + + + + + + mm + mm + + + + Left + + + + + Front + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + Y Sewing area Negative boundary + + + + + sewing work speed + + + + + + r/min + + + + + Bobbin thread length + Bottom line length + + + + + Refueling method selection + + + + + Head 4 shuttle refueling + Refueling needles interval + + + + + Refueling duration + + + + + Production preset + + + + + Sewing machine head 2 - surface thread breakage inspection + Thread trimming moving frame direction + + + + + Pin 1 motor + + + + + Allow for needle starting and thread loosening + + + + + Allow for loose thread during thread cutting + + + + + Allow needle withdrawal during thread cutting + + + + + Cutting and parting angle + + + + + Thread trimming completion angle + + + + + Automatically thread back points during sewing + + + + + Allow for loose lines when moving boxes + + + + + Continuous angle of sewing frame + + + + + Zero All + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + Shuttle 1 motor + + + + + Spindle 2 motor + + + + + Pin 2 motor + + + + + Shuttle 2 motor + + + + + Spindle 3 motor + + + + + Pin 3 motor + + + + + Shuttle 3 motor + + + + + Spindle 4 motor + + + + + Pin 4 motor + + + + + Spindle 5 motor + + + + + Pin 5 motor + + + + + Shuttle 5 motor + + + + + Head 1 Elastic thread + + + + + Head 2 Elastic thread + + + + + Head 3 Elastic thread + + + + + Head 4 Elastic thread + + + + + Head 5 Elastic thread + + + + + Head 1 blow + + + + + Head 2 blow + + + + + Head 3 blow + + + + + Head 4 blow + + + + + Head 5 blow + + + + + Head 1 trim + + + + + Head 2 trim + + + + + Head 3 trim + + + + + Head 4 trim + + + + + Head 5 trim + + + + + Head 1 needle refueling + + + + + Head 2 needle refueling + + + + + Head 3 needle refueling + + + + + Head 4 needle refueling + + + + + Head 5 needle refueling + + + + + Head 1 shuttle refueling + + + + + Head 2 shuttle refueling + + + + + Head 3 shuttle refueling + + + + + Head 5 shuttle refueling + + + + + Head 1 lifting + + + + + Head 2 lifting + + + + + Head 3 lifting + + + + + Head 4 lifting + + + + + Head 5 lifting + + + + + Spindle thread cutting speed + + + + + Allowing for wire clamping during wire cutting + + + + + Number of stitches for surface thread clamping + + + + + Head 1 ThreadCuttingAction + + + + + Head 2 ThreadCuttingAction + + + + + Head 3 ThreadCuttingAction + + + + + Head 4 ThreadCuttingAction + + + + + Head 5 ThreadCuttingAction + + + + + Head 1 Clamp wire + + + + + Head 2 Clamp wire + + + + + Head 3 Clamp wire + + + + + Head 4 Clamp wire + + + + + Head 5 Clamp wire + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + AllSpleJogs + + + + + N/S_Proof + + + + + MU_Canl + makeupCanl + + + + + Makeup1 + makeup1 + + + + + Makeup2 + makeup2 + + + + + Makeup3 + makeup3 + + + + + Makeup4 + makeup4 + + + + + Makeup5 + makeup5 + + + + + AMShaftRun + + + + + Setting + + + + + Authorize + + + + + ThCutAct1 + + + + + AnchorX + + + + + AnchorY + + + + + startX + + + + + startrY + + + + + Coordinate of threading point X + + + + + Coordinate of threading point Y + + + + + ThCutAct2 + + + + + ThCutAct3 + + + + + ThCutAct4 + + + + + ThCutAct5 + + + + + SetStart + + + + + ProcReset + + + + + Simulate + + + + + HeadLifting + + + + + GoFeedt + + + + + Back start + + + + + X negative limit + + + + + Y negative limit + + + + + freedom from error + + + + + Not powered on + + + + + + Insufficient air pressure + + + + + + Safe Area Intervention + + + + + + The usage deadline has expired + + + + + Filling data error + + + + + + Working status not allowed + + + + + control error + + + + + Motion control chip version error + + + + + Waiting for button to lift timeout + + + + + FPGA reset error + + + + + Peripheral not ready + + + + + Transmission data error + + + + + Program version error + + + + + Production completed + + + + + forward limit + + + + + Reverse limit + + + + + Motion alarm + + + + + Motion limit + + + + + Exercise emergency stop + + + + + + Motion parameter error + + + + + + Machine parameter error + + + + + + Input parameter error + + + + + The file is correct + + + + + Waiting for files + + + + + Zero successfully + + + + + Zero error + + + + + + Coordinate system error + + + + + + Target position out of range + + + + + + X forward limit + + + + + + X reverse limit + + + + + + Y forward limit + + + + + + Y reverse limit + + + + + + No Data + + + + + data error + + + + + + Spindle not in zero position + + + + + + Rotary shuttle not in zero position + + + + + Needle shuttle out of sync + + + + + Rotation out of sync + + + + + The scissors are not returning to their original position + + + + + + Machine head not in high position + + + + + Machine head not in low position + + + + + Light curtain intervention + + + + + + Broken surface thread + + + + + Bottom line disconnection + + + + + + Head lifting timeout + + + + + + Replacing the shuttle core + + + + + Abnormal feeding pressure roller + + + + + Abnormal discharge pressure roller + + + + + Abnormal discharge and pressing + + + + + Tensioning device abnormal + + + + + Abnormal cloth clamping device + + + + + Edge cutting motor blocked + + + + + Cross cutting motor abnormality + + + + + Password set successfully + + + + + Password setting failed + + + + + Needle motor alarm + + + + + Shuttle motor alarm + + + + + X motor alarm + + + + + Y motor alarm + + + + + Needle motor reset failed + + + + + Shuttle motor reset failed + + + + + X motor reset failed + + + + + Y motor reset failed + + + + + Slave board communication timeout + + + + + X motor not in zero position + + + + + The safety door is not closed + + + + + The machine head is not in a safe area + + + + + Template not in place + + + + + X Sewing area positive boundary + + + + + Y Sewing area positive boundary + + + + + Zero position coordinate of head 2 + + + + + Zero position coordinate of head 3 + + + + + Zero position coordinate of head 4 + + + + + Zero position coordinate of head 5 + + + + + Xy continuous moving box:0;Xy intermittent moving frame:1 + + + + + Thread cutting allowed + + + + + No. of stitch detect if thread broken + Number of thread breakage detection needles + + + + + Bobbin change reminder function + Change shuttle core reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + do not enable this feature:0;Count delay reminders by length:1;Count by number of pieces:2;Prompt immediately based on length:3 + + + + + Count of shuttle change pieces + + + + + Times + + + + + not refueling:0;Intermittent refueling according to worktime:1;Intermittent refueling according to the number of working stitches:2;Continuously refueling:3 + + + + + Interval between refueling stitches + + + + + + + second + + + + + Software limit: xy movement + + + + + Automatic sewing speed regulation + Sewing speed reduction mode + + + + + Circular working function + + + + + Duration of shuttle refueling + + + + + Sewing and blowing time + + + + + X to move motor + X yönü hareketli motor + + + + Y to move motor + Y hareketli motor + + + + Head moving motor + + + + + Spindle 1 motor + Spindle motor + Mil motoru + + + + Shuttle 4 motor + Shuttle motor + + + + + Lock frame cylinder + + + + + Flap control + + + + + Barcode testing + + + + + Signal + + + + + Action + + + + + HMIUpgrade + Arayüz + + + + MCUpgrade + kontrol + + + + ParaImport + içeaktarma + + + + ParaExport + dışaaktarm + + + + Network + yönetimi + + + + Time + + + + + Version + Versiyon + + + + Root + Süper kullanıcı + + + + Select + + + + + Para + + + + + Sewing motion frame method + + + + + Starting angle of sewing frame + + + + + Sewing hook angle + + + + + All spindle zero positions + + + + + AllSpleHook + AllSpindleJogs + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + Başlat düğmesi 1 + + + + Pause button 1 + Duraklatma düğmesi 1 + + + + Jog button 1 + + + + + Open frame button 1 + + + + + Manual operation button 1 + + + + + Be ready button 1 + + + + + Key button 1 + + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + Template in position 1 + + + + + Template in position 2 + + + + + MOTOR_ALM1 + + + + + MOTOR_ALM9 + + + + + MOTOR_ALM17 + + + + + MOTOR_ALM25 + + + + + MOTOR_ALM33 + + + + + MOTOR_ALM41 + + + + + X zero position + + + + + Y zero position + + + + + X deceleration + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Sewing machine head 2 lifting upper limit + + + + + Sewing machine head 3 lifting upper limit + + + + + Sewing machine head 4 lifting upper limit + + + + + Lower lifting limit of sewing machine head 0 + + + + + Lower lifting limit of sewing machine head 1 + + + + + Lower lifting limit of sewing machine head 2 + + + + + Lower lifting limit of sewing machine head 3 + + + + + Moving up motor limit on head 1 + + + + + Moving down motor limit on head 1 + + + + + Sewing needle parking space 1 + + + + + Sewing needle parking space 2 + + + + + Sewing needle parking space 3 + + + + + Embroidery spindle zero position 9 + + + + + Embroidery spindle zero position 10 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing shuttle 2- parking space + + + + + Sewing shuttle 3- parking space + + + + + Sewing shuttle 4- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + Sewing machine head 3 - surface thread breakage inspection + + + + + Sewing machine head 4 - surface thread breakage inspection + + + + + Sewing thread trimming return 1 + + + + + Sewing thread trimming return 2 + + + + + Sewing thread trimming return 3 + + + + + Sewing thread trimming return 4 + + + + + GLOBAL + + + Language + Dil + + + + Year + Yıl + + + + Month + Ay + + + + Day + Gün + + + + Hour + Saat + + + + + Minute + Dakika + + + + Second + Saniye + + + + Server IP settings + Sunucu IP ayarları + + + + Chinese:0;English:1 + + + + + Server port settings + Sunucu bağlantı noktası ayarları + + + + Local IP settings + Sunucu bağlantı noktası ayarları + + + + Local port settings + Yerel bağlantı noktası ayarları + + + + Resolution + Çözünürlük + + + + Communication method + İletişim yöntemi + + + + Network:0;SerialPort:1 + Ethernet bağlantı noktası: 0; Seri bağlantı noktası: 1 + + + + Machine type + Makine tipi + + + + 001 McHighSingleQui:0;002 FiveHeadPrecisionSewing:1;003 ClothingMac:2;004 multineedlerotary:3 + + + + + Product type + Ürün tipi + + + + ProductNull: + Yok: + + + + Whether there is a Automatic shuttle change function + Otomatik mekik değiştirme işlevi var mı + + + + Is there a Richpeace logo + Richpeace logosu var mı + + + + Parameter is classified + Parametrelerin kategorilerde gösterildi mi + + + + HMI decrypt + Arayüz şifre çözme + + + + Gateway connection method + Ağ geçidi bağlantı yöntemi + + + + Serial port:0; Network port:1 + Seri bağlantı noktası: 0; Ethernet bağlantı noktası: 1 + + + + Input rack number + Raf numarası girişi + + + + Network settings + Ağ ayarları + + + + Factory expects delivery time + Fabrika tahmini teslim süresi + + + + Debugging progress + Fabrika tahmini teslim süresi + + + + HeadSpacingSheetDialog + + + Dialog + + + + + PageNums: 0/0 + Sayfalar: 0/0 + + + + Sub title + + + + + Sub title < Title + + + + + pageNum: + + + + + PageNum: 0/0 + Sayfalar: 0/0 + + + + + + + Prompt + İpucu + + + + + USB flash drive is not detected! + USB sürücüsü algılanmadı! + + + + Export successful + + + + + Import successful! + + + + + HighSingleQui + + + HMI Configuration + Arayüz yapılandırması + + + + Interface debug mode + Arayüz ayıklama modu + + + + Delete configure file + Yapılandırma dosyasını sil + + + + Machine parameters + Makine parametreleri + + + + Work parameters + Çalışma parametreleri + + + + Flip style + + + + + normalP:0;nRight90P:1;nRight180P:2;nRight270P:3;mirrorP:4;mRight90P:5;mRight180P:6;mRight270P:7 + + + + + Rotation angle + + + + + + + + + + + + + + + + + + + + + + + + + + + mm + % + mm + + + + Step size + + + + + Reinforcement method + + + + + Tight locking:0;Reinforced locking:1 + + + + + Reinforcement needles + + + + + pin + + + + + Reinforcement frequency + + + + + Angle correction offset + + + + + Angle correction x positive + + + + + Angle correction x negative + + + + + Angle correction y positive + + + + + Angle correction y negative + + + + + Left + + + + + Front + + + + + Automatic shuttle changing device + + + + + + + + + + No:0;Have:1 + + + + + Infrared device + + + + + + + + + Normally closed:0;Normally open:1 + + + + + Pneumatic device + + + + + Power-on device + + + + + Safety door device + + + + + Manual and automatic button device + + + + + X movable area positive boundary + + + + + Y movable area positive boundary + + + + + X Sewing area Negative boundary + + + + + X Sewing area Positive margin + + + + + Y Sewing area Negative boundary + + + + + Y Sewing area Positive margin + + + + + Encoder coefficient molecule + + + + + Zero tangent distance + + + + + Feeding device + + + + + Crosscutting device + + + + + Cloth clamping device + + + + + Tensioning device + + + + + Edge cutting device + + + + + sewing work speed + + + + + + + + r/min + + + + + Spindle Back needle speed + + + + + Sewing moving frame + + + + + Continuous:0;Intermittent:1 + + + + + Sewing acceleration and deceleration mode + + + + + No acceleration or deceleration:0;Xy sine acceleration and deceleration:1 + + + + + Sewing machine head rotating manner + + + + + Continuous rotation:0;Xy intermittent rotation:1 + + + + + Sewing head deceleration mode + + + + + No acceleration or deceleration:0;Intermittent acceleration and deceleration:1 + + + + + + + + + + + Not allow:0;Allowed:1 + + + + + Cut lines allow + + + + + Equal ratio + + + + + Thread loosening is allowed during thread cutting + + + + + During thread cutting, the stay wire is allowed + + + + + Thread clamping is allowed during thread cutting + + + + + It is allowed to lift the presser foot during thread trimming + + + + + Lifting machine head thread cutting is allowed during thread cutting + + + + + The thread clamping of the lifting head is allowed during thread cutting + + + + + It is allowed to hook the thread at the foot of the presser during thread cutting + + + + + Needle withdrawal allowed during thread trimming + + + + + Buckle the thread allowed during thread trimming + + + + + Number of broken wires + + + + + + Needles + + + + + Change bobbin Reminder function + + + + + Not:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Bottom line length + + + + + Number of shuttles + + + + + times + + + + + Refueling method selection + + + + + No:0; According to working hours:1; According to the number of working stitches:2; Persistent refueling:3 + + + + + Refueling needles interval + + + + + Refueling duration + + + + + + + s + + + + + Parking position selection after completion + + + + + Current:0;Starting:1;Anchor:2;Feeding:3;Offset:4 + + + + + Offset point coordinate valid flag + + + + + + Invalid:0;X is valid:1;Y is valid:2;XY is valid:3 + + + + + Offset point coordinate X + + + + + Offset point coordinate Y + + + + + Threading point coordinate effective mark + + + + + Threading point coordinates X + + + + + Threading point coordinates Y + + + + + Production preset + + + + + Trimming frame displacement + + + + + Automatic threading back point is allowed during sewing + + + + + Lifting and lowering of frame crossing machine head in sewing room + + + + + Moving basket Loose line + + + + + Moving basket Clamp line + + + + + Frame moving and automatic frame pressing allowed + + + + + Allowed to move frame and thread + + + + + Software limit XY move allowed + + + + + Thread trimming moving frame direction + + + + + Fixed frame:0;Left:1;Forward:2;Right:3;Backward:4 + + + + + Spindle corner speed + + + + + Minimum speed deviation angle + + + + + Auto Zero after power on + + + + + Automatic drawing is allowed + + + + + The opposite side is allowed when feeding + + + + + Allowing distribution during feeding + + + + + Medium cutting is allowed during feeding + + + + + During feeding, it is allowed to cut across the edge + + + + + The thread loosening is allowed when the head is lifting + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe input emergency door allowed + + + + + Manual and automatic safe input + + + + + Loop work allowed + + + + + Shuttle refueling duration + + + + + + Replace the punch count value + + + + + Starting angle of sewing frame + + + + + Trimming completion angle + + + + + Spindle parking sensor angle + + + + + Spindle thread cutting speed + + + + + Enable + Etkinleştirmek + + + + Disable + Arızalı + + + + JogP + İleri + + + + JogN + Tersi + + + + Zero + + + + + Open + + + + + Close + Kapatma + + + + X to move motor + X yönü hareketli motor + + + + Y to move motor + Y hareketli motor + + + + Spindle motor + Mil motoru + + + + Needle motor + + + + + Shuttle motor + + + + + Lifting motor + kaldırma motoru + + + + Lower scissors to cut thread + + + + + Buckle the bottom line + + + + + Elastic thread + + + + + oil + + + + + headlamp + + + + + Sewing machine head lifting + Dikiş kafası kaldırma + + + + Sandwich line + + + + + Shuttle changing device grabbing + + + + + Shuttle changer swing + + + + + Shuttle changer rotation + + + + + Sewing Blow + + + + + AllToZero + + + + + BackThread + + + + + BackOffset + + + + + BackZero + + + + + CountReset + + + + + OutputReset + + + + + NeedZeroPos + + + + + ShutZeroPos + + + + + Signal + + + + + Action + + + + + HMIUpgrade + Arayüz + + + + MCUpgrade + kontrol + + + + ParaImport + içeaktarma + + + + ParaExport + dışaaktarm + + + + SoftwareSet + Yazılım + + + + Authorization + Lisanslama + + + + Network + yönetimi + + + + Time + + + + + Version + Versiyon + + + + Root + Süper kullanıcı + + + + Select + + + + + Para + + + + + Width + Genişlik + + + + Height + Yüksek + + + + Allow for needle starting and thread loosening + + + + + Needle and thread clamping allowed + + + + + Do not trim:0;Automatic thread trim:1;Finally trim:2;Data trim:3 + Do not trim: 0;Automatic thread trim:1;Finally trim:2;Data trim:3 + + + + + Sewing speed reduction mode + + + + + Auto:0;Param:1;Not:2 + + + + + Front_Back + + + + + N/S_Proof + + + + + HeadLifting + + + + + ThreadCut + + + + + ProcessReset + + + + + Simulated + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + Başlat düğmesi 1 + + + + Pause button 1 + Duraklatma düğmesi 1 + + + + Air pressure detection 1 + + + + + Security input 1 + + + + + X zero position + + + + + Y deceleration + + + + + X positive limit + + + + + Y positive limit + + + + + Sewing machine head 1 lifting upper limit + + + + + Lower lifting limit of sewing machine head 1 + + + + + Sewing spindle 1 needle - parking space + + + + + Sewing shuttle 1- parking space + + + + + Sewing machine head 1 - surface thread breakage inspection + + + + + ImportHPGL + + + Encrypted file parsing error! + + + + + MainWidget + + + Richpeace Embroidery Control System + 富怡绣花控制系统 + Richpeace Nakış Kontrol Sistemi + + + + XPlatForm-RP-HMI-L1910-V210713 + XPlatForm-RP-HMI-L1910-V210713 + + + + Pattern + 花样设置 + Desen ayarı + + + + Assist + 辅助功能 + EkIşlev + + + + ParaSet + 参数设定 + Parametre ayarı + + + + Shortcut + 快捷功能 + Kısayol işlevi + + + + Main + 主界面 + AnaArayüz + + + + + + + + + + + + + + + + + TextLabel + + + + + 4999 + 4999 + + + + + + Not connected + 状态 + bağlı değil + + + + 2021/03/08 8:37:16 + 2021/03/08 8:37:16 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + assist + Yardımcı fonksiyon + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + shortcut + Kısayol işlevi + + + + + + + + + + + + + + + + + PatternSet + Desen ayarı + + + + Forward or back + 快进快退 + Hızlı ileri ve geri + + + + + + + + + + + + + + + + + labelParaType + + + + + Init windows... + Formu başlat... + + + + Init communication... + İletişimi başlat... + + + + Richpeace Quilting Control System + + + + + Quilting Control System + + + + + FileName + + + + + Index + + + + + StartPoint + + + + + LocatePoint + + + + + Range + + + + + Position + + + + + Production + + + + + + Connected + bağlı + + + + Connnecting... + Bağlanıyor... + + + + Pattern selection + Desen seçimi + + + + Pattern setting > Pattern selection + Desen Ayarları > Desen Seçimi + + + + Sensor signal + Sensör sinyali + + + + Auxiliary function > Sensor signal + Yardımcı fonksiyon > Sensör Sinyalleri + + + + Control action + Kontrol eylemi + + + + Auxiliary function > Control action + Yardımcı fonksiyon> Kontrol Eylemleri + + + + + Accessibility + Ulaşılabilirlik + + + + Accessibility > Software setting + Yardımcı fonksiyon > Yazılım Ayarları + + + + Accessibility > Network Manage + Yardımcı fonksiyon > Ağ Yönetimi + + + + Time setting + Zaman ayarı + + + + Accessibility > Time setting + Yardımcı fonksiyon > Zaman Ayarları + + + + Spindle test + Mil taşlama makinesi + + + + Accessibility > Spindle test + Yardımcı Fonksiyonlar > Mil taşlama makinesi + + + + + + Root + Süper kullanıcı + + + + + + Accessibility > Root + Yardımcı fonksiyon > Süper Kullanıcı + + + + Pattern import + Desen içe aktarma + + + + Pattern setting > Pattern import + Desen Ayarları > Desen İçe Aktarma + + + + Pattern export + Desen dışa aktarma + + + + Pattern setting > Pattern export + Desen Ayarları > Desen Dışa Aktarma + + + + Pattern delete + Desen silme + + + + Pattern setting > Pattern delete + Desen Ayarları > Desen Silme + + + + Normal operation + + + + + Ready + hazır + + + + Working + işte + + + + Simulated sewing + + + + + Undefined error, + tanımsız hata, + + + + + Pattern para + Desen parametreleri + + + + Pattern setting > Head spacing + + + + + Pattern setting > Pattern para + Desen Ayarları > Desen Parametreleri + + + + Prompt + İpucu + + + + Loading patterns, please wait... + Desen yükleniyor, lütfen bekleyin... + + + + Setting workable area + + + + + + + Parameter setting + Parametre ayarları + + + + Limit parameter + Sınır parametresi + + + + Speed control parameters + Hız parametresi + + + + Action settings + Eylem ayarları + + + + Operating parameters + Operasyon parametreleri + + + + Machine parameters + Makine parametreleri + + + + Parameter setting > + Parametre ayarları + + + + Parameter setting > Parameter setting + Parametre Ayarı > Parametre Ayarı + + + + MainWidgetFunction + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Prompt + İpucu + + + + + + + USB flash drive is not detected! + USB sürücüsü algılanmadı! + + + + The program is corrupted, please re-upgrade after replacing the program! + + + + + The file format is wrong, please select again! + Dosya biçimi hatası, lütfen tekrar seçiniz! + + + + File bytes are 0, please check the file! + Dosya baytları 0, lütfen dosyayı kontrol edin! + + + + + File size not match, invalid file! + Dosya boyutu uyumsuzluğu, geçersiz parametre dosyası! + + + + Data check error, invalid file! + Veri doğrulama hatası, geçersiz parametre dosyası! + + + + Parameters imported successfully! + Parametreler başarıyla içe aktarıldı! + + + + File head not match, invalid file! + Dosya başlığı uyuşmazlığı, geçersiz parametre dosyası! + + + + Failed to initialize wlan0! + + + + + Failed to search for WiFi list. Please try again later! + + + + + dynamic + + + + + static + + + + + Failed to obtain IP. Please check the settings! + + + + + Parameter Import + Parametre içe aktarma + + + + Auxiliary Function > Parameter Import + Yardımcı fonksiyon > Parametre İçe Aktarma + + + + + + + MC Upgrade + Ana kontrol yükseltmesi + + + + Auxiliary Function > MC Upgrade + Yardımcı fonksiyon > Ana Yükseltme + + + + WIFI + + + + + Auxiliary Function > WIFI + + + + + Error Log + + + + + Auxiliary Function > Error Log + + + + + Breakage Log + + + + + Auxiliary Function > Breakage Log + + + + + ErrorLog + + + + + Auxiliary Function > ErrorLog + + + + + + ssid is empty! + + + + + + Settings require screen restart to take effect! + + + + + IP input + + + + + Whether to exit the program? + Programdan çıkılsın mı? + + + + AllSpindleZeroPositions + + + + + AllSpindleHookLines + + + + + AllSpindleJogs + + + + + NeedleShuttleProofreading + + + + + AllMainShaftRun + + + + + HMI Upgrade + Arayüz yükseltme + + + + Auxiliary Function > HMI Upgrade + Yardımcı fonksiyon > Kullanıcı Arayüzü Yükseltmesi + + + + Parameters exported successfully! + Parametreler başarıyla dışa aktarıldı! + + + + All to zero + Yardımcı fonksiyon > Parametre Dışa Aktarma + + + + + + + + + + + + + + + + + + + + + + + + The machine is about to move, please pay attention to safety! + Makine hareket etmek üzere, lütfen güvenliğe dikkat edin! + + + + + All to reset + İşlem sıfırlama + + + + Whether to reset the output? + Üretim miktarı ayarlansın mı? + + + + If all process to reset? + Tüm işlemler sıfırlandı mı? + + + + Spindle jog + + + + + Spindle rotate angle + Mil dönüş açısı + + + + Back work point + İşe geri dön + + + + Back to origin + Aslı noktaya geri dön + + + + Set start point + Set embroidery point + Nakış noktasını ayarlayın + + + + + Whether to set the current point as the start point? + Geçerli nokta nakış başlangıç noktası olarak ayarlansın mı? + + + + Back anchor point + Bağlantı noktasına geri dön + + + + Back embroidery point + Nakış noktasına geri dön + + + + Set offset point + + + + + Whether to set the current point as the offset point? + Geçerli nokta ofset noktası olarak ayarlansın mı? + + + + Back offset point + Ofset noktasına geri dön + + + + Border check + Kenar kontrolü + + + + Trim + Kırpma + + + + The machine is about to cut the thread, please pay attention to safety! + Makine ipliği kesmek üzere, lütfen güvenliğe dikkat edin! + + + + Lower cutter + Alt iplik kesme + + + + The scissors are about to move, please pay attention to safety! + Makas hareket etmek üzere, lütfen güvenliğe dikkat edin! + + + + Simulate frame + Boş kenarlık + + + + Process reset + İşlem sıfırlama + + + + The machine is about to reset, please pay attention to safety! + Makine işlemi sıfırlamak üzere, lütfen güvenliğe dikkat edin! + + + + Manual oil + Manuel yakıt ikmali + + + + The machine is about to oil! + Makine yakıt ikmali yapmak üzere! + + + + Shuttle count reset + Mekik arama sayısı sıfırlama + + + + The machine is about to change the shuttle automatically! + Makine mekiği otomatik olarak değiştirmek üzere! + + + + Goto zero pos + Çerçeve sıfır + + + + Set work range + İşin kapsamını ayarlayın + + + + If automatically set work range? + İşin kapsamı otomatik olarak belirleniyor mu? + + + + Bottom line detection + Alt ip algılama + + + + Face line detection + Üst iplik algılama + + + + Exit successfully! + Başarıyla çıkın! + + + + System info + Versiyon bilgisi + + + + Production statistics + Üretim İstatistikleri + + + + Auxiliary Function > Production statistics + Yardımcı fonksiyon > Üretim İstatistikleri + + + + No connection + Bağlı değil + + + + Warrant + Yetki vermek + + + + Is the bottom line count reset? + Alt ip sayısı sıfırlandı mı? + + + + Password input + + + + + Are you sure to ManualSwitch? + + + + + Setting workable area + + + + + Debug Info + + + + + Auxiliary Function >Debug Info + + + + + Are you sure to AutoSwitch? + Çalışma durumunu otomatik olarak değiştirir mi? + + + + Total number of patterns processed: + Toplam işlenen desen sayısı: + + + + Total number of embroidery: + Toplam nakış dikişi sayısı: + + + + Pattern name: + Desen adı: + + + + Pattern break line num: + Desen ipi kesme sayısı: + + + + Head + Makine kafası + + + + break line num: + Bağlantı (yada İp) kesme sayısı: + + + + Day + Gün + + + + Hour + Saat + + + + Minutes + Dakika + + + + The remaining available time of the machine is + Makinenin kalan kullanılabilir süresi + + + + Undefined error, + Tanımsız hata, + + + + Failed to upgrade the main control system! + Ana kontrol sistemi yükseltmesi başarısız oldu! + + + + The main control system has been successed, waiting until machine restart + Ana kontrol sistemi başarıyla yükseltildi, lütfen makinenin yeniden başlatılmasını bekleyin + + + + System will restart %1 s later + Sistem %1 saniye içinde yeniden başlatılacak + + + + Main control system is being upgraded... + Ana kontrol sistemi yükseltiliyor... + + + + Failed to send data file! + Veri dosyası gönderilemedi! + + + + The data file is send successfully! + Veri dosyası başarıyla gönderildi! + + + + Data file sending... + Veri dosyası gönderiliyor... + + + + Journal exported successfully! + + + + + Journal exported failed! + + + + + Password input * + Şifre girişi ※ + + + + Password input ** + Şifre girişi ※※ + + + + Password input **** + + + + + + + The password is wrong,please re-enter! + Şifre yanlış, lütfen şifreyi tekrar giriniz! + + + + reset parameters password successfully logged in! + + + + + HMI decrypt + Arayüz şifre çözme + + + + The interface program is licensed, and then take effect after restarting, please restart manually! + Arayüz programı yetkilendirmesi başarılı ve yeniden başlattıktan sonra etkili olacak, lütfen manuel olarak yeniden başlatın! + + + + Password error, interface program authorization failed! + Yanlış şifre, arayüz programı yetkilendirmesi başarısız oldu! + + + + Is the version restored? + Sürüm geri yüklendi mi? + + + + Modify the first level password + Birincil şifreyi değiştir + + + + The two passwords are inconsistent! + Yeni şifre ve onaylanan şifre eşleşmiyor! + + + + Password reset complete! + Şifre sıfırlama tamamlandı! + + + + Do you delete the configuration file? + Yapılandırma dosyası silinsin mi? + + + + The settings take effect after restarting the interface! + Arayüz yeniden başlatıldıktan sonra ayarlar geçerli olacaktır! + + + + Import csv file successful! + + + + + Do you delete the csv file? + + + + + Reset succeeded! + + + + + Whether to enter debug mode? + Hata ayıklama moduna girilsin mi? + + + + whether to exit debug mode? + Hata ayıklama modundan çıkılsın mı? + + + + Please log in to super user again! + + + + + Is the pattern clear? + Makine kafa kartı veri yolu algılama? + + + + Delete complete! + Silme tamamlandı! + + + + Simulated sewing + + + + + Whether to switch working status + + + + + Manual thread cutting + + + + + makeup sewing + + + + + Head lifting and lowering + + + + + Head lifting + + + + + Set anchor point + + + + + Back shuttle pos + + + + + Needle shuttle adjust + + + + + Whether to shut down the computer? + + + + + Whether to set to change a shuttle automatically? + Mekiği otomatik olarak değiştirmeye ayarlı mı? + + + + McHeadDialog + + + Dialog + + + + + + + + + + + + PushButton + buton + + + + MultiNeedleRotary + + + HMI Configuration + Arayüz yapılandırması + + + + Interface debug mode + Arayüz ayıklama modu + + + + Delete configure file + Yapılandırma dosyasını sil + + + + Machine parameters + Makine parametreleri + + + + Work parameters + Çalışma parametreleri + + + + startX + + + + + + + + mm + mm + + + + startrY + + + + + + + r/min + + + + + Sewing main shaft working speed + + + + + Main shaft zero reset speed + + + + + Main shaft running speed + + + + + + XY zero reset speed + + + + + + + + + mm/s + + + + + XY manual movement speed 1 + + + + + XY manual movement speed 2 + + + + + XY manual movement speed 3 + + + + + Work head selection 1 + + + + + + Not allow:0;allowed:1 + + + + + Work head selection 2 + + + + + Production preset + + + + + + No. of stitch detect if thread broken + + + + + Needle + + + + + + Bobbin thread length + + + + + Bobbin change reminder function + + + + + Not enabled:0;Delay reminder by length:1;Count by number of slices:2;Immediately reminder by length:3 + + + + + Secure input light curtain allows + + + + + Safety input pressure allowed + + + + + Safe input power-on signal allowed + + + + + Safe door allowed + + + + + X to move motor + X yönü hareketli motor + + + + Y to move motor + Y hareketli motor + + + + All spindle zero positions + + + + + All Spindle Hook Lines positions + + + + + All spindle jogs positions + + + + + All_Zero + + + + + Front_Back + + + + + AllSpleZero + + + + + Signal + + + + + Action + + + + + HMIUpgrade + Arayüz + + + + MCUpgrade + kontrol + + + + ParaImport + içeaktarma + + + + ParaExport + dışaaktarm + + + + Setting + + + + + Authorize + + + + + Network + yönetimi + + + + Time + + + + + Version + Versiyon + + + + Root + Süper kullanıcı + + + + Para + + + + + Select + + + + + Import + + + + + Export + + + + + Delete + + + + + OperatPara + + + + + ActionSet + + + + + SpeedPara + + + + + LimitPara + + + + + MCPara + + + + + Start button 1 + Başlat düğmesi 1 + + + + Pause button 1 + Duraklatma düğmesi 1 + + + + Jog button 1 + + + + + Open frame button 1 + + + + + NumerInputDialog + + + Dialog + İletişim kutusu + + + + C + C + + + + (0~3000)rmp + (0~3000)rmp + + + + Number input + Dijital giriş + + + + ← + + + + + ParameterSetDialog + + + Dialog + İletişim kutusu + + + + PageNums: 1/1 + Sayfalar: 1/1 + + + + Sub title + Alt başlık + + + + Sub title < Title + Alt başlık < başlık + + + + Repetitions + + + + + + pageNum: + Sayfalar: + + + + HMI Configuration + Arayüz yapılandırması + + + + Root > HMI Configuration + Süper Kullanıcı > Arayüz Yapılandırması + + + + IOT Configuration + Nesnelerin interneti (IoT) yapılandırması + + + + Root > IOT Configuration + Süper Kullanıcı > IoT Yapılandırması + + + + Network Settings + Ağ ayarları + + + + IOT Configuration > Network Settings + Nesnelerin interneti (IoT) Yapılandırması > Ağ Ayarları + + + + Machine parameters + Makine parametreleri + + + + Root > Machine parameters + Süper Kullanıcı > Makine Parametreleri + + + + + + + + + Network error + Ağ hatası + + + + + + read parameter... + Parametreler okunuyor... + + + + + + No connection + Bağlı değil + + + + Work parameters + Çalışma parametreleri + + + + Root > Work parameters + Süper Kullanıcı > İş Parametreleri + + + + Repetitions : 0 + + + + + Server IP settings + Sunucu IP ayarları + + + + Server Port settings + Sunucu bağlantı noktası ayarları + + + + + Local IP settings + Yerel IP ayarları + + + + Local Port settings + Yerel bağlantı noktası ayarları + + + + Board IP settings + Anakart IP ayarları + + + + + + Root + Süper kullanıcı + + + + + + Accessibility > Root + Yardımcı fonksiyon > Süper Kullanıcı + + + + Board port settings + Anakart Bağlantı Noktası Ayarları + + + + Local port settings + Yerel uç bağlantı noktası ayarları + + + + + + + + + + Prompt + İpucu + + + + + The settings take effect after restarting the interface! + Arayüz yeniden başlatıldıktan sonra ayarlar geçerli olacaktır! + + + + + Network settings are completed, re-establish after reboot + Ağ ayarı tamamlandı ve yeniden başlattıktan sonra bağlantının yeniden kurulması gerekiyor + + + + The time setting is completed and will take effect after restart + Zaman ayarı tamamlandı ve yeniden başlattıktan sonra geçerli olacak + + + + Unreasonable time setting, please reset + Zaman ayarı mantıksız, lütfen sıfırlayın + + + + Time setting failed, please reset + Zaman ayarı başarısız oldu, lütfen sıfırlayın + + + + Connection mode changes, take effect after the reboot! + Bağlantı yöntemi değiştirildi ve arayüz yeniden başlatıldıktan sonra geçerli olacak! + + + + Input + + + + + Whether to recover the default parameters for the board? + Anakart varsayılan parametrelerine geri yüklesin mi? + + + + PassWordDialog + + + Dialog + İletişim kutusu + + + + Password + şifre + + + + 9 + 9 + + + + 1 + 1 + + + + 2 + 2 + + + + ← + + + + + 3 + 3 + + + + 6 + 6 + + + + 8 + 8 + + + + C + C + + + + 0 + 0 + + + + 5 + 5 + + + + 7 + 7 + + + + 4 + 4 + + + + Prompt + İpucu + + + + IP settings are unreasonable! + + + + + PatternManageWidget + + + Form + Liste + + + + PageNums: 0/0 + Sayfalar: 0/0 + + + + Sub title < Title + Sub title < Title + + + + Sub title + Sub title + + + + + 1000.0 + 1000.0 + + + + W + W + + + + 500.0 + 500.0 + + + + 999 + 999 + + + + H + H + + + + 1000000 + 1000000 + + + + Y + Y + + + + X + X + + + + 800.0 + 800.0 + + + + dst + dst + + + + C + C + + + + N + N + + + + pageNum: + Sayfalar: + + + + + + + + + Prompt + İpucu + + + + Over 1.28 million stitches, can not be imported! + + + + + Format error, can not be imported! + Biçim hatası, içe aktarılamıyor! + + + + This file already exists! + Bu dosya zaten var! + + + + Rename + Yeniden isimlendirmek + + + + Importing + İçe aktarılıyor + + + + Exporting + Dışa aktarılıyor + + + + Import complete + İçe aktarma tamamlandı + + + + Export complete + Dışa aktarma tamamlandı + + + + USB flash drive is not detected! + USB sürücüsü algılanmadı! + + + + Whether to delete the pattern? + Deseni silmek istiyor musunuz? + + + + Operation screen + İşlem ekranı + + + + USB + USB bellek + + + + + + Pattern Import + Desen içe aktarma + + + + + + Pattern Import < Pattern setting + Desen İçe Aktarma < Desen Ayarları + + + + Pattern Export + Desen dışa aktarılıyor + + + + Pattern Export < Pattern setting + Desen Dışa Aktarma < Desen Ayarları + + + + new folder + Yeni dosya + + + + This folder already exists! + Bu klasör zaten var! + + + + PatternSelectWidget + + + Form + Form + + + + Name: + 花样名: + Desen adı: + + + + N + N + + + + H + C + C + + + + W + W + + + + + X + X + + + + + Y + Y + + + + Width + Genişlik + + + + NeedleNum + İğne mili sayısı + + + + Name + isim + + + + Height + Yüksek + + + + Pattern Select + 花样选择 + Desen seçimi + + + + Pattern Select < Pattern Setting + 花样选择 < 花样设置 + Desen seçimi < Desen ayarı + + + + PageNums: 0/0 + Sayfalar: 0/0 + + + + PageNum: 0/0 + Sayfalar: 0/0 + + + + pageNum: + Sayfalar: + + + + Prompt + İpucu + + + + The number of stitches of the selected pattern has reached the upper limit (2 million stitches), and it cannot be embroidered! + Seçilen desendeki ilmek sayısı üst sınıra (2 milyon ilmek) ulaştı, bu nedenle nakışa izin verilmiyor! + + + + PromptDialog + + + Dialog + İletişim kutusu + + + + Prompt + İpucu + + + + ID: + ID: + + + + Password: + 密码: + şifre: + + + + ID + ID + + + + DecryptInfo + Şifre çözme bilgileri + + + + DecryptInfo: + 解密信息: + Şifre çözme bilgileri: + + + + Spindle angle: + 主轴角度: + Mil açısı: + + + + deg + + kapsam; derece;açı + + + + New Password: + 密码: + Yeni Şifre: + + + + Confirm Password: + 解密信息: + Şifreyi Onayla: + + + + X + + X + + + + + X - + X - + + + + Y + + Y + + + + + Y - + Y - + + + + Board + Anakart + + + + Build Time: + + + + + Unlimited time + Zaman sınırı yok + + + + Time has run out + zaman doldu + + + + Day + Gün + + + + Hour + Saat + + + + Minutes + dakika + + + + ID: %1 + + ID: %1 + + + + Password: %1 + + Şifre: %1 + + + + Time: %1 + Saat: %1 + + + + Warrant + Yetki vermek + + + + HMI decrypt + Arayüz şifre çözme + + + + Spindle angle rotation + Mil açısı dönüşü + + + + New Password input + Yeni şifre belirle + + + + Confirm Password input + Yeni şifreyi onaylayın + + + + QObject + + + (0x0002)Insufficient air pressure + (0x0002) Yetersiz hava basıncı + + + + (0x0003)safe area error + (0x0003) Güvenli alan müdahalesi + + + + (0x0004)Expiration of use + (0x0004) Kullanım süresi sınırı sona erdi + + + + (0x0005)Driver alarm + (0x0005) sürücü alarmı + + + + (0x0006)Fill data error + (0x0006) Veri doldurma hatası + + + + (0x0007)Not allowed to work + (0x0007) Çalışma durumuna izin verilmiyor + + + + (0x0008)Control error + (0x0008) Kontrol hatası + + + + (0x0009)Motion control chip version error + (0x0009) Hareket kontrol çipinin yanlış versiyonu + + + + (0x000A)Waiting for button to lift timeout + (0x000A) Düğme kaldırma için bekleme zaman aşımı + + + + (0x000B)FPGA Reset + (0x000B) FPGA sıfırlama + + + + (0x000C)Peripheral Device not ready + (0x000C) Çevre birimi hazır değil + + + + (0x000D)Transmission data error + (0x000D) İletim veri hatası + + + + (0x000E)Program version error + (0x000E) Program sürüm hatası + + + + (0x000F)Complete output + (0x000F) Üretim miktarı tamam + + + + (0x0010)Positive limit + (0x0010) Pozitif sınır + + + + (0x0011)Negative limit + (0x0011) Ters sınır + + + + (0x0012)Motion alarm + (0x0012) Hareket Alarmı + + + + (0x0013)Motion limit + (0x0013) Hareket sınırı + + + + (0x0014)Emergency stop + (0x0014) Hareket acil durdurma + + + + (0x0015)Motion parameters error + (0x0015) hareket parametre hatası + + + + (0x0016)Machine parameters error + (0x0016) Makine parametre hatası + + + + (0x0017)Input parameters error + (0x0017) Giriş parametresi hatası + + + + (0x001A)Not in work status error + (0x001A) Çalışamaz + + + + (0x001B)Prohibited frame moving state + (0x001B) Çerçeve taşıma durumunu devre dışı bırak + + + + (0x001F)Zero success + (0x001F) Başarıyla sıfırlandı + + + + (0x0020)Return to zero error + (0x0020) Sıfır hata + + + + (0x0021)Coordinate system error + (0x0021) Koordinat sistemi hatası + + + + (0x0022)Target position out of bounds + (0x0022) Hedef konum sınırların dışında + + + + (0x0023)X Positive limit + (0x0023) X pozitif limit + + + + (0x0024)X Negative limit + (0x0024) X ters limit + + + + (0x0025)Y Positive limit + (0x0025) Y pozitif limit + + + + (0x0026)Y Negative limit + (0x0026) Y ters limiti + + + + (0x002B)Safety door error + (0x002B) Açık kapak alarmı, güvenlik kapısı hatası + + + + (0x002C)Entering the light curtain 1 + (0x002C) Işık perdesi 1 müdahale ediyor + + + + (0x002D)Entering the light curtain 2 + (0x002D) Işık perdesi 2 müdahale ediyor + + + + (0x0040)None data + (0x0040) Veri yok + + + + (0x0041)Data error + (0x0041) Veri hatası + + + + (0x0042)Graphics out of range + (0x0042) Grafik aralık dışında + + + + (0x0050)Spindle is not in zero position + (0x0050) İş mili sıfır konumunda değil + + + + (0x0051)Rotary hook is not in zero position + (0x0051) Döner kanca sıfır konumunda değil + + + + (0x0054)Scissors are not in position + (0x0054) Makas dönüş konumunda değil + + + + (0x0056)Nose not in low position + (0x0056) Burun düşük konumda değil + + + + (0x0058)Thread is broken + (0x0058) İp kesilmesi + + + + (0x0059)Bottom thread disconnected + (0x0059) Alt ip kesildi + + + + (0x005D)Execution command timed out + (0x005D) Yürütme komutu zaman aşımına uğradı + + + + (0x005F)Head lifting timeout + (0x005F) burun kaldırma zaman aşımı + + + + (0x00F0)Change the bobbin + (0x00F0) Bobini değiştirin + + + + (0x00F1)Replace bobbin A + (0x00F1) A bobinini değiştirin + + + + (0x00F2)Replace bobbin B + (0x00F2) B bobini değiştirin + + + + (0x00F3)The machine is in the state of replacing the bobbin + (0x00F3) Makine bobin değiştirme durumunda + + + + (0x002E)Insufficient air pressure + (0x002E) Yetersiz hava basıncı + + + + Normal stop + Normal durma + + + + Find zero success + Sıfır başarı + + + + work pause + iş askıya alındı + + + + End of work + İş bitimi + + + + Work done + iş bitti + + + + Complete production + Üretim miktarı tamamlandı + + + + (0x0106)Execute success + (0x0106) Başarıyla yürütüldü + + + + (0x0107)Execute false + (0x0107) Yürütme başarısız oldu + + + + (0x0108)wait file + (0x0108) Dosya bekleniyor + + + + (0x0109)change the bobbin + (0x0109) Masurayı değiştirin + + + + (0x010A)Execute finish + (0x010A) Yürütme tamamlandı + + + + (0x010B)Execute runnibng + (0x010B) Yürütme sırasında + + + + Enable + Etkinleştirmek + + + + Disable + Arızalı + + + + JogP + İleri + + + + JogN + Tersi + + + + Turn + + + + + Zero + + + + + Open + + + + + Close + Kapatma + + + + Ascending + + + + + descending + + + + + Trim + Kırpma + + + + SensorInputWidget + + + Form + Form + + + + + Sensor + Sensör sinyali + + + + PageNums: 1/1 + Sayfalar: 1/1 + + + + pageNum: + Sayfalar: + + + + SetWorkArea + + + Form + Form + + + + Prompt + İpucu + + + + X + + X + + + + + X - + X - + + + + Y + + Y + + + + + Y - + Y - + + + + SystemManageDialog + + + Dialog + İletişim kutusu + + + + PageNums: 1/1 + Sayfalar: 1/1 + + + + + Update + Yükselt + + + + 192.168.2.196 + 192.168.2.196 + + + + StaticIP + + + + + DynamicIP + + + + + *Before setting the static IP, you need to first set the dynamic IP. After the dynamic IP is set, you need to return to this interface to continue setting the static IP + 设置静态IP前需要先设置动态IP,动态IP设置完成后需要返回此界面继续设置静态IP + + + + + pageNum: 0/0 + Sayfalar: 0/0 + + + + pageNum: + Sayfalar: + + + + + + + Prompt + İpucu + + + + The upgrade needs to restart the program. Do you need to restart to upgrade? + Yükseltme, programın yeniden başlatılmasını gerektiriyor. Yükseltmeyi yeniden başlatmak istiyor musunuz? + + + + Do you want to clear the production statistics? + Üretim istatistiklerini temizle? + + + + Do you want to clear the journal? + + + + + Do you want to export journal? + + + + + WordsInputDialog + + + Dialog + İletişim kutusu + + + + Words input + Karakter girişi + + + + Name: + İsim: + + + + ← + + + + + old + Eski isim + + +