Browse Source

fix bug change tab checked cams

Alex Sidorov 1 year ago
parent
commit
414fa7e45f

+ 0 - 68
docs/template_propusk_back_four.html

@@ -1,68 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
-    <meta charset="UTF-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Document</title>
-</head>
-
-<body style="padding: 0; margin: 0; font-size: 12pt">
-    {% for _ in range(2) %}
-    <table >
-        <tbody>
-            <tr>
-                <td><b>Временный пропуск №:</b> {{ id_propusk }}</td>
-                <td rowspan="5">
-                    <img src="{{ face }}" height="200" width="300"/>
-                </td>
-            </tr>
-            <tr>
-                <td><b>Дата выдачи:</b> {{ date_from }}</td>
-                <td></td>
-            </tr>
-            <tr>
-                <td><b>Действителен до:</b> {{ date_to }}</td>
-            </tr>
-            <tr>
-                <td><b>Выдал:</b> {{ personal }}</td>
-            </tr>
-            <tr>
-                <td>
-                    <p style="font-size: 12pt;">__________________________________</p>
-                    <p style="font-size: 10pt !important;">&nbsp;&nbsp;Подпись сотрудника бюро пропусков</p>
-                    <p style="font-size: 10pt !important;">&nbsp;&nbsp;Печать</p>
-                </td>
-                <td></td>
-                
-            </tr>
-            <tr height="200" width="300">
-                <td><b>Место выдачи:</b>{{ place }}</td>
-                <td rowspan="6">
-                    <img src="{{ document }}" height="200" width="300" />
-                </td>
-            </tr>
-            <tr>
-                <td><b>Принимающий:</b></td>
-            </tr>
-            <tr>
-                <td>{{ receiving_man }}</td>
-            </tr>
-            <tr>
-                <td><b>Цель визита:</b></td>
-            </tr>
-            <tr> 
-                <td>{{ purpose_visite }}</td></tr>
-            <tr>
-                <td><b>Время выхода: __________________</b></td>
-            </tr>
-        </tbody>
-    </table>
-    <br>
-    <hr>
-    <br>
-    {% endfor %}
-</body>
-
-</html>

+ 0 - 38
docs/template_propusk_back_three.html

@@ -1,38 +0,0 @@
-<html lang="ru">
-
-<head>
-    <meta charset="UTF-8">
-    <style>
-        * {
-            margin: 0;
-            padding: 0;
-        }
-    </style>
-</head>
-
-<body>
-    {% for _ in range(2) %}
-    <table>
-        <tr>
-            <td colspan="2">
-                <img src="{{ face_photo }}" width="600" height="300"/>
-            </td>
-        </tr>
-        <tr>
-            <td><b>Временный пропуск №:</b> {{ id_propusk }}</td>
-            <td><b>Место выдачи:</b> {{ place }}</td>
-        </tr>
-        <tr>
-            <td><b>Дата выдачи:</b> {{ date_from }}</td>
-            <td><b>Принимающий:</b><br> {{ receiving_man }}</td>
-        </tr>
-        <tr>
-            <td><b>Действителен до:</b> {{ date_to }}</td>
-            <td><b>Цель визита:</b><br> {{ purpose_visite }}</td>
-        </tr>
-    </table>
-    <hr />
-    {% endfor %}
-</body>
-
-</html>

+ 0 - 61
docs/template_propusk_back_two.html

@@ -1,61 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
-    <meta charset="UTF-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>{{ id_propusk }}</title>
-</head>
-
-<body style="padding: 0; margin: 0; font-size: 12pt">
-    {% for _ in range(2) %}
-    <table>
-        <tbody>
-            <tr>
-                <td colspan="2">
-                    <b>Временный пропуск КБГУ №:</b> {{ id_propusk }}
-                    <br>
-                    <b>Дата выдачи:</b> {{ date_from }}
-                    <br>
-                    <b>Действителен до:</b> {{ date_to }}
-                    <br><br>
-                    _______________________________________
-                    <br />Подпись сотрудника бюро пропусков
-                    <br>
-                    <b>Выдал:</b> {{ personal }}
-                    <br>
-                    <b>Принимающий:</b> {{ receiving_man }}
-                    <br>
-                    <b>Цель визита:</b> {{ purpose_visite }}
-                    <br>
-                    <b>Время выхода: __________________</b>
-                </td>
-                <td rowspan="2">
-                    <img src="file:/home/asidorov/project/propusk/test2.jpg" height="650" width="400" />
-                </td>
-            </tr>
-            <tr>
-                <td>
-                    <div style="border: 1px solid #000" width="350" height="300" align="center">
-                        <b>Используйте этот <br> QR-код для прохода <br> через турникет</b>
-                        <br>
-                        <img src="file:/{{qrcode}}" height="300" width="300">
-                    </div>
-
-                </td>
-                <td>
-                    <img src="file:/home/asidorov/project/propusk/test2.jpg"
-                        height="400" width="300">
-                </td>
-            </tr>
-        </tbody>
-    </table>
-    <br>
-    <div>
-            --------------------------------------------------------------------------------------- линия разрыва ----------------------------------------------------------------------------------------
-    </div>
-    {% endfor %}
-</body>
-
-</html>

+ 3 - 0
module/cam/IPCam.py

@@ -72,6 +72,9 @@ class IPCam(Thread):
         cv2.destroyAllWindows()
         cv2.destroyAllWindows()
         self.join()
         self.join()
 
 
+    def __del__(self) -> None:
+        self.stop_cam()
+        
     def cupture_image(self, qLabel: QLabel) -> str:
     def cupture_image(self, qLabel: QLabel) -> str:
         name_file = create_filename()
         name_file = create_filename()
         qLabel.setPixmap(self.__scaled_img)
         qLabel.setPixmap(self.__scaled_img)

+ 9 - 8
widgets/PCamChecked.py

@@ -2,13 +2,14 @@
 from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QComboBox, QPushButton, QMessageBox
 from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLineEdit, QComboBox, QPushButton, QMessageBox
 from widgets.PStackedWidget import PStackedWidget
 from widgets.PStackedWidget import PStackedWidget
 from module.cam import IPCam, USBCam, get_list_name_cam
 from module.cam import IPCam, USBCam, get_list_name_cam
-
+from logger import logger
 
 
 class PCamChecked(QWidget):
 class PCamChecked(QWidget):
     def __init__(self, parent=None, mode: str = 'video') -> None:
     def __init__(self, parent=None, mode: str = 'video') -> None:
         super().__init__(parent)
         super().__init__(parent)
 
 
         self.__mode = mode
         self.__mode = mode
+        self.__wwc = None
         
         
         self.vLayout = QVBoxLayout(self)
         self.vLayout = QVBoxLayout(self)
         self.vLayout.setObjectName(u'vLayout')
         self.vLayout.setObjectName(u'vLayout')
@@ -39,7 +40,7 @@ class PCamChecked(QWidget):
         self.btn_stop = QPushButton(self)
         self.btn_stop = QPushButton(self)
         self.btn_stop.setObjectName('btn_stop')
         self.btn_stop.setObjectName('btn_stop')
         self.btn_stop.setText('Остановить')
         self.btn_stop.setText('Остановить')
-        self.btn_stop.clicked.connect(self.__stop_cam)
+        self.btn_stop.clicked.connect(self.stop_cam)
         self.hLayout.addWidget(self.btn_stop)
         self.hLayout.addWidget(self.btn_stop)
 
 
         self.vLayout.addLayout(self.hLayout)
         self.vLayout.addLayout(self.hLayout)
@@ -53,26 +54,26 @@ class PCamChecked(QWidget):
             case _: return None
             case _: return None
 
 
     def __start_cam(self) -> None:
     def __start_cam(self) -> None:
-        
         match self.__mode:
         match self.__mode:
             case 'video':
             case 'video':
                 self.pStackedWidget.to_video()
                 self.pStackedWidget.to_video()
                 self.__wwc = USBCam(self.pStackedWidget.video,
                 self.__wwc = USBCam(self.pStackedWidget.video,
                                     self.line_cam.currentText())
                                     self.line_cam.currentText())
                 self.__wwc.start_cam()
                 self.__wwc.start_cam()
+                logger.info("Start USB cam")
             case 'snapshot':
             case 'snapshot':
                 self.pStackedWidget.to_video()
                 self.pStackedWidget.to_video()
                 self.__wwc = IPCam()
                 self.__wwc = IPCam()
                 self.__wwc.qLabel = self.pStackedWidget.video
                 self.__wwc.qLabel = self.pStackedWidget.video
                 self.__wwc.lnk_connect = self.line_cam.text()
                 self.__wwc.lnk_connect = self.line_cam.text()
                 self.__wwc.start()
                 self.__wwc.start()
+                logger.info("Start IP cam")
                     
                     
             case _: return None
             case _: return None
 
 
-    def __stop_cam(self):
+    def stop_cam(self):
+        logger.info("Stop cam")
         self.__wwc.stop_cam()
         self.__wwc.stop_cam()
-        del self.__wwc
+        self.__wwc = None
         self.pStackedWidget.to_image()
         self.pStackedWidget.to_image()
-        
-    def __del__(self) -> None:
-        self.__stop_cam
+        

+ 8 - 3
window/DialogSettingCam.py

@@ -8,6 +8,7 @@ from widgets import create_widget_cam_shecked
 from logger import logger
 from logger import logger
 
 
 
 
+
 class SettingCam(QDialog, Ui_DialogSettingCam):
 class SettingCam(QDialog, Ui_DialogSettingCam):
     def __init__(self, parent=None) -> None:
     def __init__(self, parent=None) -> None:
         super(SettingCam, self).__init__(parent)
         super(SettingCam, self).__init__(parent)
@@ -39,7 +40,7 @@ class SettingCam(QDialog, Ui_DialogSettingCam):
         logger.info(F'Change cams to {self.__mode}')
         logger.info(F'Change cams to {self.__mode}')
 
 
     @Slot()
     @Slot()
-    def __recreate_widget(self, select_mode: str = 'video') -> None:
+    def __recreate_widget(self, select_mode: str = 'video') -> None:            
         self.__del_widget()
         self.__del_widget()
         if self.tabWidget.currentIndex() == 0:
         if self.tabWidget.currentIndex() == 0:
             self.widget = create_widget_cam_shecked(mode=select_mode,
             self.widget = create_widget_cam_shecked(mode=select_mode,
@@ -54,10 +55,15 @@ class SettingCam(QDialog, Ui_DialogSettingCam):
 
 
 
 
     def __del_widget(self) -> None:
     def __del_widget(self) -> None:
+        try:
+            self.widget.stop_cam()
+        except AttributeError as er:
+            logger.error(er)
+            
         if self.widget is not None:
         if self.widget is not None:
             self.verticalLayout.removeWidget(self.widget)
             self.verticalLayout.removeWidget(self.widget)
             self.verticalLayout_3.removeWidget(self.widget)
             self.verticalLayout_3.removeWidget(self.widget)
-
+        
         self.widget = None
         self.widget = None
 
 
     def __load_cams_from_db(self):
     def __load_cams_from_db(self):
@@ -66,7 +72,6 @@ class SettingCam(QDialog, Ui_DialogSettingCam):
                 cam_setting.c.type == self.tabWidget.currentIndex()
                 cam_setting.c.type == self.tabWidget.currentIndex()
             )).fetchone()
             )).fetchone()
             if result:
             if result:
-                print(result)
                 self.__mode = result.mode
                 self.__mode = result.mode
                 self.__recreate_widget(self.__mode)
                 self.__recreate_widget(self.__mode)
                 match self.__mode:
                 match self.__mode: