프로젝트

일반

사용자정보

개정판 99b45b60

ID99b45b60b15466cdcc0078206155a5132bd3a414
상위 5a6b546b
하위 b15c1200

gaqhf 이(가) 6년 이상 전에 추가함

new issue #579: FluidCode Form

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
1129 1129
        return res
1130 1130
    
1131 1131
    '''
1132
        @brief      get Fluid Code
1133
        @author     kyouho
1134
        @date       2018.07.03
1135
    '''
1136
    def getFluidCodeData(self):
1137
        from FluidCodeData import FluidCodeData
1138
        result = []
1139

  
1140
        try:
1141
            # Creates or opens a file called mydb with a SQLite3 DB
1142
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1143
            conn = sqlite3.connect(dbPath)
1144
            # Get a cursor object
1145
            cursor = conn.cursor()
1146

  
1147
            sql = 'select uid, code, description from FluidCode'
1148
            cursor.execute(sql)
1149
            rows = cursor.fetchall()
1150
            for row in rows:
1151
                data = FluidCodeData(row[0], row[1], row[2])
1152
                result.append(data)
1153
            # Catch the exception
1154
        except Exception as ex:
1155
            # Roll back any change if something goes wrong
1156
            conn.rollback()
1157
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1158
        finally:
1159
            # Close the db connection
1160
            conn.close()
1161

  
1162
        return result
1163

  
1164
    '''
1165
        @brief      set Fluid Code
1166
        @author     kyouho
1167
        @date       2018.07.03
1168
    '''
1169
    def setFluidCodeData(self, addDataList, removeDataList):
1170
        try:
1171
            # Creates or opens a file called mydb with a SQLite3 DB
1172
            dbPath = os.path.join(self.getCurrentProject().getDbFilePath(), 'ITI_PID.db')
1173
            conn = sqlite3.connect(dbPath)
1174
            # Get a cursor object
1175
            cursor = conn.cursor()
1176

  
1177
            for data in addDataList:
1178
                uid = data.uid
1179
                if not uid:
1180
                    print(uid)
1181
                    sql = "insert or replace into FluidCode(UID, CODE, DESCRIPTION) values(lower(hex(randomblob(16))), '{}', '{}')".format(data.code, data.description)
1182
                else:
1183
                    sql = "update FluidCode SET CODE='{}', DESCRIPTION='{}' WHERE UID = '{}'".format(data.code, data.description, data.uid)
1184
                cursor.execute(sql)
1185

  
1186
            for data in removeDataList:
1187
                uid = data.uid
1188
                if uid:
1189
                    print('remove UID : ' + uid)
1190
                    sql = "delete from FluidCode where UID = '{}'".format(uid)
1191
                    cursor.execute(sql)
1192

  
1193
            conn.commit()
1194
        
1195
        # Catch the exception
1196
        except Exception as ex:
1197
            # Roll back any change if something goes wrong
1198
            conn.rollback()
1199
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
1200
        finally:
1201
            # Close the db connection
1202
            conn.close()
1203

  
1204
    '''
1132 1205
        @brief      get equipment data list
1133 1206
        @author     humkyung
1134 1207
        @date       2018.05.03
DTI_PID/DTI_PID/DTI_PID.pyproj
4 4
    <SchemaVersion>2.0</SchemaVersion>
5 5
    <ProjectGuid>7c2e55a3-2b16-4b4f-867f-f16e2ef6f2f0</ProjectGuid>
6 6
    <ProjectHome>.</ProjectHome>
7
    <StartupFile>SymbolGenerator.py</StartupFile>
7
    <StartupFile>App.py</StartupFile>
8 8
    <SearchPath>
9 9
    </SearchPath>
10 10
    <WorkingDirectory>.</WorkingDirectory>
......
18 18
    <InterpreterArguments>
19 19
    </InterpreterArguments>
20 20
    <EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
21
    <InterpreterId>Global|PythonCore|3.6</InterpreterId>
21 22
  </PropertyGroup>
22 23
  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
23 24
    <DebugSymbols>true</DebugSymbols>
......
28 29
    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
29 30
  </PropertyGroup>
30 31
  <ItemGroup>
32
    <Compile Include="App.py" />
33
    <Compile Include="AppDocData.py" />
31 34
    <Compile Include="AreaOcrTestmodule.py">
32 35
      <SubType>Code</SubType>
33 36
    </Compile>
......
37 40
    <Compile Include="azure_ocr_module.py">
38 41
      <SubType>Code</SubType>
39 42
    </Compile>
43
    <Compile Include="ConfigurationAreaDialog.py" />
44
    <Compile Include="ConfigurationDialog.py" />
45
    <Compile Include="Configuration_Area_UI.py" />
46
    <Compile Include="Configuration_UI.py" />
47
    <Compile Include="ConnectAttr_UI.py" />
40 48
    <Compile Include="DTI_PID.py" />
49
    <Compile Include="DTI_PID_rc.py" />
41 50
    <Compile Include="DTI_PID_UI.py" />
51
    <Compile Include="FluidCodeData.py" />
52
    <Compile Include="EquipmentData.py" />
53
    <Compile Include="Equipment_Data_List_UI.py" />
54
    <Compile Include="FluidCodeDialog.py" />
55
    <Compile Include="FluidCode_UI.py" />
56
    <Compile Include="Instrument_Data_List_UI.py" />
57
    <Compile Include="LineDetector.py" />
58
    <Compile Include="LineNoTracer.py" />
59
    <Compile Include="Line_Data_List_UI.py" />
60
    <Compile Include="MainWindow.py" />
61
    <Compile Include="NominalPipeSizeDialog.py" />
62
    <Compile Include="NominalPipeSize_UI.py" />
42 63
    <Compile Include="potrace.py" />
64
    <Compile Include="Project.py" />
65
    <Compile Include="ProjectDialog.py" />
66
    <Compile Include="ProjectSelectionDialog.py" />
43 67
    <Compile Include="QcImageViewer.py">
44 68
      <SubType>Code</SubType>
45 69
    </Compile>
70
    <Compile Include="QConnectAttrDialog.py" />
71
    <Compile Include="QDirTreeWidget.py" />
72
    <Compile Include="QEquipmentDataListDialog.py" />
73
    <Compile Include="QInstrumentDataListDialog.py" />
74
    <Compile Include="QLineDataListDialog.py" />
75
    <Compile Include="QOcrResultDialog.py" />
76
    <Compile Include="QPropertyTableWidget.py" />
77
    <Compile Include="QRecognitionDialog.py" />
78
    <Compile Include="QResultPropertyTableWidget.py" />
79
    <Compile Include="QResultTreeWidget.py" />
80
    <Compile Include="QSymbolDisplayDialog.py" />
81
    <Compile Include="QSymbolEditorDialog.py" />
46 82
    <Compile Include="QtImageViewer.py">
47 83
      <SubType>Code</SubType>
48 84
    </Compile>
49 85
    <Compile Include="Recognition_UI.py" />
50
    <Compile Include="SG_DbHelper.py">
51
      <SubType>Code</SubType>
52
    </Compile>
86
    <Compile Include="SingletonInstance.py" />
53 87
    <Compile Include="symbol.py">
54 88
      <SubType>Code</SubType>
55 89
    </Compile>
56 90
    <Compile Include="SymbolBase.py">
57 91
      <SubType>Code</SubType>
58 92
    </Compile>
59
    <Compile Include="SymbolGenerator.py">
60
      <SubType>Code</SubType>
61
    </Compile>
62 93
    <Compile Include="tesseract_ocr_module.py">
63 94
      <SubType>Code</SubType>
64 95
    </Compile>
65 96
    <Compile Include="TextInfo.py">
66 97
      <SubType>Code</SubType>
67 98
    </Compile>
99
    <Compile Include="TextItemFactory.py" />
100
    <Compile Include="UI_OcrResultDialog.py" />
101
    <Compile Include="UI_ProjectDialog.py" />
102
    <Compile Include="UI_SymbolDisplay.py" />
103
    <Compile Include="UI_SymbolEditor.py" />
104
    <Compile Include="wxDTIPID.py" />
68 105
    <Compile Include="XmlGenerator.py">
69 106
      <SubType>Code</SubType>
70 107
    </Compile>
71 108
  </ItemGroup>
109
  <ItemGroup>
110
    <InterpreterReference Include="Global|PythonCore|3.6" />
111
  </ItemGroup>
72 112
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
73 113
  <!-- Uncomment the CoreCompile target to enable the Build command in
74 114
       Visual Studio and specify your pre- and post-build commands in
DTI_PID/DTI_PID/FluidCodeDialog.py
14 14
        @brief  constructor
15 15
        @author humkyung
16 16
        @date   2018.07.03
17
        @history    2018.07.03  kyouho      Add getFluidCodeData logic
17 18
    '''
18 19
    def __init__(self, parent):
19 20
        QDialog.__init__(self, parent)
20 21

  
21 22
        self.ui = FluidCode_UI.Ui_DialogFluidCode()
22 23
        self.ui.setupUi(self)
23
        self.ui.tableWidgetFluidCode.setHorizontalHeaderLabels(['Code', 'Desc.'])
24
        self.ui.tableWidgetFluidCode.setRowCount(5)
24

  
25
        docData = AppDocData.instance()
26
        fluidCodes = docData.getFluidCodeData()
27
        
28
        self.ui.tableWidgetFluidCode.setColumnCount(3)
29
        self.ui.tableWidgetFluidCode.setHorizontalHeaderLabels(['uid', 'Code', 'Desc.'])
25 30
        
31
        self.ui.tableWidgetFluidCode.setRowCount(len(fluidCodes))
26 32
        self.ui.tableWidgetFluidCode.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
27

  
33
        
34
        row = 0
35
        for fluidCode in fluidCodes:
36
            self.ui.tableWidgetFluidCode.setItem(row, 0, QTableWidgetItem(fluidCode.uid))
37
            self.ui.tableWidgetFluidCode.setItem(row, 1, QTableWidgetItem(fluidCode.code))
38
            self.ui.tableWidgetFluidCode.setItem(row, 2, QTableWidgetItem(fluidCode.description))
39
            row += 1
28 40
    '''
29 41
        @brief  save fluid codes to sqlite
30
        @author humkyung
31
        @date   2018.07.03    
42
        @author humkyungS
43
        @date   2018.07.03
44
        @history    2018.07.03 kyouho 
32 45
    '''
33 46
    def accept(self):
47
        from FluidCodeData import FluidCodeData
48
        table = self.ui.tableWidgetFluidCode
49
        removeFluidCode = []
50
        fluidCodes = []
51

  
34 52
        try:
35
            pass
53
            rowCount = table.rowCount()
54
            for row in range(rowCount):
55
                
56
                isHide = table.isRowHidden(row)
57
                
58
                uid = table.item(row, 0)
59
                codeItem = table.item(row, 1)
60
                descriptionItem = table.item(row, 2)
61
                data = FluidCodeData(uid.text() ,codeItem.text(), descriptionItem.text())
62

  
63
                if isHide:
64
                    removeFluidCode.append(data)
65
                else:
66
                    fluidCodes.append(data)
67

  
68
            docData = AppDocData.instance()
69
            docData.setFluidCodeData(fluidCodes, removeFluidCode)
70
        
36 71
        except Exception as ex:
37 72
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
38

  
39
        QDialog.accept(self)
73
            
74
        
75
        QDialog.accept(self)

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)