-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwritePDF.py
More file actions
917 lines (840 loc) · 56.4 KB
/
writePDF.py
File metadata and controls
917 lines (840 loc) · 56.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
import os
import asyncio
from pathlib import Path
from string import Template
import aiofiles
import shutil
import datetime
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.scrollview import ScrollView
from kivy.uix.label import Label
from kivy.uix.filechooser import FileChooserIconView
from kivy.uix.spinner import Spinner
from kivy.uix.filechooser import FileChooserIconView
from kivy.uix.popup import Popup
from kivy.uix.image import Image
from kivy.uix.camera import Camera
from kivy.core.window import Window
from PIL import Image as PilImage
from kivy.lang import Builder
from kivy.utils import platform
from jnius import autoclass
from main_menu import MainMenu
from carac_affaire import CaracAffaire
from choix_categorie import ChoixCategorie
from local_machine import LocalMachine
from treuils import Treuils
from cabestan import Cabestan
from appareil_gouverne import AppareilGouverne
from app_data import AppData
from connexion import Connexion
from new_user import NewUser
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.colors import HexColor
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Image, Paragraph, Spacer, PageBreak
from reportlab.lib.styles import getSampleStyleSheet
from android.permissions import request_permissions, Permission
from android.storage import primary_external_storage_path
Context = autoclass('android.content.Context')
Environment = autoclass('android.os.Environment')
current_activity = autoclass('org.kivy.android.PythonActivity').mActivity
app_storage_path = current_activity.getExternalFilesDir(None).getAbsolutePath()
class pdfWriter:
"""
Classe du générateur de PDF
"""
def __init__(self):
self.app_data = AppData()
self.page_width, self.page_height = letter
self.PAGE_WIDTH, PAGE_HEIGHT = A4
self.MARGIN_LEFT = 40
self.MARGIN_TOP = PAGE_HEIGHT - 60
self.LINE_HEIGHT = 20
self.HEADER_COLOR = HexColor("#cbcefb")
self.TEXT_COLOR = HexColor("#000000")
self.media_path = os.path.join(app_storage_path, 'media')
self.sign_path = os.path.join(app_storage_path, 'signatures')
self.pdf_path = os.path.join(app_storage_path, 'pdf')
self.filename = f"{datetime.date.today()}_{self.app_data.case_number}.pdf"
self.doc = SimpleDocTemplate(os.path.join('./build/', self.filename), pagesize=A4)
# self.doc = SimpleDocTemplate(os.path.join(self.build_path, self.filename), pagesize=A4)
os.makedirs(self.pdf_path, exist_ok=True)
def draw_picture(self, path, x, y, width, height, leftbottom=False):
"""
Dessine une image sur le document
Args:
path: chemin de l'image
x: position en x du coin inférieur gauche
y: position en y du coin inférieur gauche
width: largeur de l'image
height: hauteur de l'image
leftbottom: position défaut (Default value = False)
Returns:
Image: image dessinée
"""
img = Image(path, width, height)
if leftbottom == True:
img.hAlign = 'LEFT' # Optionnel, permet d'aligner l'image à gauche
img.vAlign = 'BOTTOM' # Optionnel, permet d'aligner l'image en bas
img.wrapOn(self.doc, self.page_width, self.page_height) # Le wrap ajuste l'image selon la taille du document
# Retourne l'image sans utiliser `drawOn`, mais l'ajoute directement aux éléments
return img
def show_popup(self, message):
"""
Affiche un popup
Args:
message: message à afficher
Returns:
None
"""
layout = BoxLayout(orientation='vertical')
label = Label(text=message, color=(1,1,1,1))
dismiss_button = Button(text='Fermer')
layout.add_widget(label)
layout.add_widget(dismiss_button)
popup = Popup(title='Information', content=layout, size_hint=(0.8, 0.4))
dismiss_button.bind(on_press=popup.dismiss)
popup.open()
def write_pdf(self):
"""
Construit le PDF élément par élément puis l'enregistre
"""
try:
os.makedirs("./build/pdf", exist_ok=True)
except Exception as e:
self.show_popup(f"Erreur lors de la création du dossier de build : {e}")
try:
elements = []
# --------------------------------------------------------------------------
# Page de garde
img = self.draw_picture(path="bopp.png", x=self.page_width - 600, y=self.page_height - 290, width=170, height=170, leftbottom=True)
elements.append(img)
styles = getSampleStyleSheet()
title_style = styles['Title']
title_paragraph = Paragraph(f"{self.app_data.intervention_type}", title_style)
elements.append(title_paragraph)
elements.append(Spacer(1, 30))
data = [
["Affaire", f"{self.app_data.case_number}"],
["NB", f"{self.app_data.nb_field}"],
["Navire", f"{self.app_data.boat_name}"],
["Nom", f"{self.app_data.client_name}"],
["Chantier", f"{self.app_data.site_name}"],
["Armement", f"{self.app_data.armement}"]
]
# data = [
# ["Affaire", f"{self.app_data.case_number}"],
# ["NB", f"{self.app_data.nb_field}"],
# ["Navire", f"{self.app_data.boat_name}"],
# ["Nom", f"{self.app_data.client_name}"],
# ["Chantier", f"{self.app_data.site_name}"]
# ]
elements.append(Table(data, colWidths=[150, 150], rowHeights=40, style=[
('BOX', (0, 0), (-1, -1), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 16),
('FONTNAME', (0, 0), (0, -1), 'Helvetica-Bold'),
('FONTNAME', (1, 0), (1, -1), 'Helvetica'),
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
# ('BACKGROUND', (0, 0), (-1, 0), self.HEADER_COLOR),
# ('TEXTCOLOR', (0, 0), (-1, -1), self.TEXT_COLOR),
('ALIGN', (0, 0), (0, -1), 'LEFT'),
('ALIGN', (1, 0), (1, -1), 'CENTER')
]))
elements.append(Spacer(1, 100))
data = [
["BOPP", "", "Chantier", "", "Armement", ""],
["Nom", f"{self.app_data.BOPP_name}", "Nom", f"{self.app_data.chantier_name}", "Nom", f"{self.app_data.armement_name}"],
["Date", f"{self.app_data.BOPP_date}", "Date", f"{self.app_data.chantier_date}", "Date", f"{self.app_data.armement_date}"],
["Visa", f"{self.app_data.BOPP_visa}", "Visa", f"{self.app_data.chantier_visa}", "Visa", f"{self.app_data.armement_visa}"]
]
# data = [
# ["BOPP", "", "Chantier", "", "Armement", ""],
# ["Nom", "", "Nom", "", "Nom", ""],
# ["Date", "", "Date", "", "Date", ""],
# ["Visa", "", "Visa", "", "Visa", ""]
# ]
elements.append(Table(data, colWidths=[70, 70], rowHeights=20, style=[
('BOX', (0, 0), (-1, -1), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 11),
('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),
('FONTNAME', (1, 0), (1, -1), 'Helvetica'),
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
# ('BACKGROUND', (0, 0), (-1, 0), self.HEADER_COLOR),
# ('TEXTCOLOR', (0, 0), (-1, -1), self.TEXT_COLOR),
('ALIGN', (0, 0), (0, -1), 'LEFT')
]))
elements.append(PageBreak())
# --------------------------------------------------------------------------
# Local Machine
if (
self.app_data.Lm_schema_synoptique != "" or
self.app_data.Lm_schema_electrique != "" or
self.app_data.Lm_schema_bornier != "" or
self.app_data.Lm_schema_cablage != "" or
self.app_data.Lm_releves_rincages_circuits != "" or
self.app_data.Lm_as_niveau_bas_NB1 != "" or
self.app_data.Lm_as_temperature_haute_TH1 != "" or
self.app_data.Lm_as_controle_ARU != "" or
self.app_data.Lm_as_alarme_hydraulique_voyant_defaut != "" or
self.app_data.Lm_pompe_principale_45_100_verif_plein_huile != "" or
self.app_data.Lm_pompe_principale_45_100_sens_rotation != "" or
self.app_data.Lm_pompe_principale_45_100_embrayage_pompe != "" or
self.app_data.Lm_pompe_principale_45_100_pression_HP != "" or
self.app_data.Lm_pompe_principale_45_100_stand_by != "" or
self.app_data.Lm_pompe_principale_HPR165_38_verif_plein_huile != "" or
self.app_data.Lm_pompe_principale_HPR165_38_sens_rotation != "" or
self.app_data.Lm_pompe_principale_HPR165_38_embrayage_pompe != "" or
self.app_data.Lm_pompe_principale_HPR165_38_pression_HP != "" or
self.app_data.Lm_pompe_principale_HPR165_38_stand_by != "" or
self.app_data.Lm_groupe_secours_pompe_45_sens_rotation != "" or
self.app_data.Lm_groupe_secours_pompe_45_calage != "" or
self.app_data.Lm_groupe_secours_pompe_45_serrage != "" or
self.app_data.Lm_groupe_secours_pompe_45_verif_plein_huile != "" or
self.app_data.Lm_groupe_secours_pompe_45_marche_arret_moteur != "" or
self.app_data.Lm_groupe_secours_pompe_45_pression_HP != "" or
self.app_data.Lm_groupe_secours_pompe_45_stand_by != "" or
self.app_data.Lm_groupe_secours_pompe_45_courant_demarrage != "" or
self.app_data.Lm_groupe_secours_pompe_45_courant_service != "" or
self.app_data.Lm_reglage_limiteur_pression_REP10 != "" or
self.app_data.Lm_reglage_pressostat_retour != "" or
self.app_data.Lm_reglage_reducteur_pression_REP13 != "" or
self.app_data.Lm_reglage_reducteur_pression_grue_REP16 != "" or
self.app_data.Lm_fonctionnement_sys_refrigeration_embrayage != ""
):
section_style = styles['Title']
title_paragraph = Paragraph("Local Machine", section_style)
elements.append(title_paragraph)
data = [
["ESSAIS A REALISER", "Valeurs BE", "Valeurs Intervenant"],
["Vérification conformité hydraulique", "", ""],
["Schémas synoptiques", f"{self.app_data.Lm_schema_synoptique}", f"{self.app_data.int_Lm_schema_synoptique}"],
["Schémas électriques", f"{self.app_data.Lm_schema_electrique}", f"{self.app_data.int_Lm_schema_electrique}"],
["Schéma bornier", f"{self.app_data.Lm_schema_bornier}", f"{self.app_data.int_Lm_schema_bornier}"],
["Schéma câblage", f"{self.app_data.Lm_schema_cablage}", f"{self.app_data.int_Lm_schema_cablage}"],
["Relevé des rinçages circuits", f"{self.app_data.Lm_releves_rincages_circuits}", f"{self.app_data.int_Lm_releves_rincages_circuits}"],
["", "", ""],
["Alarmes et sécurités", "", ""],
["Niveau bas NB1", f"{self.app_data.Lm_as_niveau_bas_NB1}", f"{self.app_data.int_Lm_as_niveau_bas_NB1}"],
["Température haute TH1", f"{self.app_data.Lm_as_temperature_haute_TH1}", f"{self.app_data.int_Lm_as_temperature_haute_TH1}"],
["Contrôles des ARU", f"{self.app_data.Lm_as_controle_ARU}", f"{self.app_data.int_Lm_as_controle_ARU}"],
["Alarme hydraulique voyant et défaut", f"{self.app_data.Lm_as_alarme_hydraulique_voyant_defaut}", f"{self.app_data.int_Lm_as_alarme_hydraulique_voyant_defaut}"],
["", "", ""],
["Pompe principale série 45/100", "", ""],
["Vérification plein d'huile", f"{self.app_data.Lm_pompe_principale_45_100_verif_plein_huile}", f"{self.app_data.int_Lm_pompe_principale_45_100_verif_plein_huile}"],
["Sens de rotation", f"{self.app_data.Lm_pompe_principale_45_100_sens_rotation}", f"{self.app_data.int_Lm_pompe_principale_45_100_sens_rotation}"],
["Embrayage / débrayage pompe", f"{self.app_data.Lm_pompe_principale_45_100_embrayage_pompe}", f"{self.app_data.int_Lm_pompe_principale_45_100_embrayage_pompe}"],
["Pression HP pompe", f"{self.app_data.Lm_pompe_principale_45_100_pression_HP}", f"{self.app_data.int_Lm_pompe_principale_45_100_pression_HP}"],
["Stand-by pompe", f"{self.app_data.Lm_pompe_principale_45_100_stand_by}", f"{self.app_data.int_Lm_pompe_principale_45_100_stand_by}"],
["", "", ""],
["Pompe principale série HPR165_38", "", ""],
["Vérification plein d'huile", f"{self.app_data.Lm_pompe_principale_HPR165_38_verif_plein_huile}", f"{self.app_data.int_Lm_pompe_principale_HPR165_38_verif_plein_huile}"],
["Sens de rotation", f"{self.app_data.Lm_pompe_principale_HPR165_38_sens_rotation}", f"{self.app_data.int_Lm_pompe_principale_HPR165_38_sens_rotation}"],
["Embrayage / débrayage pompe", f"{self.app_data.Lm_pompe_principale_HPR165_38_embrayage_pompe}", f"{self.app_data.int_Lm_pompe_principale_HPR165_38_embrayage_pompe}"],
["Pression HP pompe", f"{self.app_data.Lm_pompe_principale_HPR165_38_pression_HP}", f"{self.app_data.int_Lm_pompe_principale_HPR165_38_pression_HP}"],
["Stand-by pompe", f"{self.app_data.Lm_pompe_principale_HPR165_38_stand_by}", f"{self.app_data.int_Lm_pompe_principale_HPR165_38_stand_by}"],
["", "", ""],
["Groupe de secours 11kW - pompe série 45", "", ""],
["Sens de rotation", f"{self.app_data.Lm_groupe_secours_pompe_45_sens_rotation}", f"{self.app_data.int_Lm_groupe_secours_pompe_45_sens_rotation}"],
["Calage cylindrée", f"{self.app_data.Lm_groupe_secours_pompe_45_calage}", f"{self.app_data.int_Lm_groupe_secours_pompe_45_calage}"],
["Serrage", f"{self.app_data.Lm_groupe_secours_pompe_45_serrage}", f"{self.app_data.int_Lm_groupe_secours_pompe_45_serrage}"],
["Vérification plein d'huile", f"{self.app_data.Lm_groupe_secours_pompe_45_verif_plein_huile}", f"{self.app_data.int_Lm_groupe_secours_pompe_45_verif_plein_huile}"],
["Marche/Arrêt moteur", f"{self.app_data.Lm_groupe_secours_pompe_45_marche_arret_moteur}", f"{self.app_data.int_Lm_groupe_secours_pompe_45_marche_arret_moteur}"],
["Pression HP pompe", f"{self.app_data.Lm_groupe_secours_pompe_45_pression_HP}", f"{self.app_data.int_Lm_groupe_secours_pompe_45_pression_HP}"],
["Stand-by pompe", f"{self.app_data.Lm_groupe_secours_pompe_45_stand_by}", f"{self.app_data.int_Lm_groupe_secours_pompe_45_stand_by}"],
["Courant de démarrage", f"{self.app_data.Lm_groupe_secours_pompe_45_courant_demarrage}", f"{self.app_data.int_Lm_groupe_secours_pompe_45_courant_demarrage}"],
["Courant de service", f"{self.app_data.Lm_groupe_secours_pompe_45_courant_service}", f"{self.app_data.int_Lm_groupe_secours_pompe_45_courant_service}"],
["", "", ""],
["Réglage limiteur de pression retour REP.10", f"{self.app_data.Lm_reglage_limiteur_pression_REP10}", f"{self.app_data.int_Lm_reglage_limiteur_pression_REP10}"],
["", "", ""],
["Réglage pressostat retour PR", f"{self.app_data.Lm_reglage_pressostat_retour}", f"{self.app_data.int_Lm_reglage_pressostat_retour}"],
["", "", ""],
["Réglage réducteur de pression REP.13", f"{self.app_data.Lm_reglage_reducteur_pression_REP13}", f"{self.app_data.int_Lm_reglage_reducteur_pression_REP13}"],
["", "", ""],
["Réglage réducteur de pression grue REP.16", f"{self.app_data.Lm_reglage_reducteur_pression_grue_REP16}", f"{self.app_data.int_Lm_reglage_reducteur_pression_grue_REP16}"],
["", "", ""],
["Fonctionnement du système de réfrigération", "", ""],
["Dès l'embrayage de la pompe principale", f"{self.app_data.Lm_fonctionnement_sys_refrigeration_embrayage}", f"{self.app_data.int_Lm_fonctionnement_sys_refrigeration_embrayage}"],
["", "", ""]
]
elements.append(Table(data, rowHeights=14, style=[('GRID', (0, 0), (-1, -1), 1, colors.black),
('BACKGROUND', (0, 0), (2, 0), colors.lightblue),
('FONTNAME', (0, 0), (2, 0), 'Helvetica-Bold'),
('SPAN', (0, 1), (2, 1)),
('SPAN', (0, 7), (2, 7)),
('SPAN', (0, 8), (2, 8)),
('SPAN', (0, 13), (2, 13)),
('SPAN', (0, 14), (2, 14)),
('SPAN', (0, 20), (2, 20)),
('SPAN', (0, 21), (2, 21)),
('SPAN', (0, 27), (2, 27)),
('SPAN', (0, 28), (2, 28)),
('SPAN', (0, 38), (2, 38)),
('SPAN', (0, 40), (2, 40)),
('SPAN', (0, 42), (2, 42)),
('SPAN', (0, 44), (2, 44)),
('SPAN', (0, 46), (2, 46)),
('SPAN', (0, 47), (2, 47)),
('SPAN', (0, 49), (2, 49)),
('FONTNAME', (0, 1), (2, 1), 'Helvetica-Bold'),
('FONTNAME', (0, 8), (2, 8), 'Helvetica-Bold'),
('FONTNAME', (0, 14), (2, 14), 'Helvetica-Bold'),
('FONTNAME', (0, 21), (2, 21), 'Helvetica-Bold'),
('FONTNAME', (0, 28), (2, 28), 'Helvetica-Bold'),
('FONTNAME', (0, 47), (2, 47), 'Helvetica-Bold'),
('ALIGN', (0, 2), (0, 6), 'RIGHT'),
('ALIGN', (0, 9), (0, 12), 'RIGHT'),
('ALIGN', (0, 15), (0, 19), 'RIGHT'),
('ALIGN', (0, 22), (0, 27), 'RIGHT'),
('ALIGN', (0, 29), (0, 37), 'RIGHT'),
('ALIGN', (0, 48), (0, 48), 'RIGHT'),
('VALIGN', (0, 0), (2, 55), 'MIDDLE'),
('FONTSIZE', (0, 0), (2, 55), 8)
])
)
elements.append(PageBreak())
# --------------------------------------------------------------------------
# Treuil
if (
self.app_data.TPH125_0_traction_premiere_couche_statique != "" or
self.app_data.TPH125_0_traction_premiere_couche_dynamique != "" or
self.app_data.TPH125_0_pression != "" or
self.app_data.TPH125_0_vitesse_rotation_PV != "" or
self.app_data.TPH125_0_vitesse_rotation_GV != "" or
self.app_data.TPH125_0_debit != "" or
self.app_data.TPH125_0_essai_file_vire != "" or
self.app_data.TPH125_0_essai_freinage != "" or
self.app_data.TPH125_0_selection_PV_GV != "" or
self.app_data.TPH50_0_traction_premiere_couche_statique != "" or
self.app_data.TPH50_0_traction_premiere_couche_dynamique != "" or
self.app_data.TPH50_0_pression != "" or
self.app_data.TPH50_0_vitesse_rotation_PV != "" or
self.app_data.TPH50_0_vitesse_rotation_GV != "" or
self.app_data.TPH50_0_debit != "" or
self.app_data.TPH50_0_essai_file_vire != "" or
self.app_data.TPH50_0_essai_freinage != "" or
self.app_data.TPH50_0_selection_PV_GV != ""
):
section_style = styles['Title']
title_paragraph = Paragraph("Treuil", section_style)
elements.append(title_paragraph)
data = [
["ESSAIS A REALISER", "Valeurs BE", "Valeurs Intervenant"],
["Treuil double TPH 125-0 - Bobine Diam.610", "", ""],
["150m de chaîne DN30", "", ""],
["Traction à la première couche statique", f"{self.app_data.TPH125_0_traction_premiere_couche_statique}", f"{self.app_data.int_TPH125_0_traction_premiere_couche_statique}"],
["Traction à la première couche dynamique", f"{self.app_data.TPH125_0_traction_premiere_couche_dynamique}", f"{self.app_data.int_TPH125_0_traction_premiere_couche_dynamique}"],
["Pression ΔP", f"{self.app_data.TPH125_0_pression}", f"{self.app_data.int_TPH125_0_pression}"],
["", "", ""],
["Vitesse de rotation PV", f"{self.app_data.TPH125_0_vitesse_rotation_PV}", f"{self.app_data.int_TPH125_0_vitesse_rotation_PV}"],
["Vitesse de rotation GV", f"{self.app_data.TPH125_0_vitesse_rotation_GV}", f"{self.app_data.int_TPH125_0_vitesse_rotation_GV}"],
["Débit", f"{self.app_data.TPH125_0_debit}", f"{self.app_data.int_TPH125_0_debit}"],
["", "", ""],
["Essais file-vire", f"{self.app_data.TPH125_0_essai_file_vire}", f"{self.app_data.int_TPH125_0_essai_file_vire}"],
["Essais freinage", f"{self.app_data.TPH125_0_essai_freinage}", f"{self.app_data.int_TPH125_0_essai_freinage}"],
["", "", ""],
["Sélection PV ou GV", f"{self.app_data.TPH125_0_selection_PV_GV}", f"{self.app_data.int_TPH125_0_selection_PV_GV}"],
["", "", ""],
["Treuil double TPH 50-2 - Bobine Diam.292", "", ""],
["200m de câble acier diam.20 + 150m de câble textile diam.30", "", ""],
["Traction à la première couche statique", f"{self.app_data.TPH50_0_traction_premiere_couche_statique}", f"{self.app_data.int_TPH50_0_traction_premiere_couche_statique}"],
["Traction à la première couche dynamique", f"{self.app_data.TPH50_0_traction_premiere_couche_dynamique}", f"{self.app_data.int_TPH50_0_traction_premiere_couche_dynamique}"],
["Pression ΔP", f"{self.app_data.TPH50_0_pression}", f"{self.app_data.int_TPH50_0_pression}"],
["", "", ""],
["Vitesse de rotation PV", f"{self.app_data.TPH50_0_vitesse_rotation_PV}", f"{self.app_data.int_TPH50_0_vitesse_rotation_PV}"],
["Vitesse de rotation GV", f"{self.app_data.TPH50_0_vitesse_rotation_GV}", f"{self.app_data.int_TPH50_0_vitesse_rotation_GV}"],
["Débit", f"{self.app_data.TPH50_0_debit}", f"{self.app_data.int_TPH50_0_debit}"],
["", "", ""],
["Essais file-vire", f"{self.app_data.TPH50_0_essai_file_vire}", f"{self.app_data.int_TPH50_0_essai_file_vire}"],
["Essais freinage", f"{self.app_data.TPH50_0_essai_freinage}", f"{self.app_data.int_TPH50_0_essai_freinage}"],
["", "", ""],
["Sélection PV ou GV", f"{self.app_data.TPH50_0_selection_PV_GV}", f"{self.app_data.int_TPH50_0_selection_PV_GV}"],
["", "", ""]
]
elements.append(Table(data, rowHeights=15, style=[
('GRID', (0, 0), (2, 0), 1, colors.black),
('BOX', (0, 0), (-1, -1), 1, colors.black),
('BOX', (0, 1), (2, 2), 1, colors.black),
('GRID', (0, 3), (2, 5), 1, colors.black),
('GRID', (0, 7), (2, 9), 1, colors.black),
('GRID', (0, 11), (2, 12), 1, colors.black),
('GRID', (0, 14), (2, 14), 1, colors.black),
('BOX', (0, 16), (2, 17), 1, colors.black),
('GRID', (0, 18), (2, 20), 1, colors.black),
('GRID', (0, 22), (2, 24), 1, colors.black),
('GRID', (0, 26), (2, 27), 1, colors.black),
('GRID', (0, 29), (2, 29), 1, colors.black),
('FONTNAME', (0, 0), (2, 0), 'Helvetica-Bold'),
('BACKGROUND', (0, 0), (2, 0), colors.lightblue),
('SPAN', (0, 1), (2, 1)),
('SPAN', (0, 2), (2, 2)),
('SPAN', (0, 16), (2, 16)),
('SPAN', (0, 17), (2, 17)),
('FONTNAME', (0, 1), (2, 1), 'Helvetica-Bold'),
('FONTNAME', (0, 2), (2, 2), 'Helvetica-Oblique'),
('FONTNAME', (0, 16), (2, 16), 'Helvetica-Bold'),
('FONTNAME', (0, 17), (2, 17), 'Helvetica-Oblique'),
('ALIGN', (0, 3), (0, 5), 'RIGHT'),
('ALIGN', (0, 7), (0, 14), 'RIGHT'),
('ALIGN', (0, 18), (0, 30), 'RIGHT'),
('FONTSIZE', (0, 0), (2, len(data) - 1), 8)
])
)
elements.append(PageBreak())
# --------------------------------------------------------------------------
# Cabestan
if (
self.app_data.Cb_5T_traction_statique != "" or
self.app_data.Cb_5T_traction_dynamique != "" or
self.app_data.Cb_5T_pression != "" or
self.app_data.Cb_5T_vitesse_rotation != "" or
self.app_data.Cb_5T_debit != "" or
self.app_data.Cb_5T_essai_file_vire != "" or
self.app_data.Cb_5T_freinage != "" or
self.app_data.Cb_3T_traction_statique != "" or
self.app_data.Cb_3T_traction_dynamique != "" or
self.app_data.Cb_3T_pression != "" or
self.app_data.Cb_3T_vitesse_rotation != "" or
self.app_data.Cb_3T_debit != "" or
self.app_data.Cb_3T_essai_file_vire != "" or
self.app_data.Cb_3T_freinage != ""
):
section_style = styles['Title']
title_paragraph = Paragraph("Cabestan", section_style)
elements.append(title_paragraph)
data = [
["ESSAIS A REALISER", "Valeurs BE", "Valeurs Intervenant"],
["Cabestan 5T", "", ""],
["Traction statique", f"{self.app_data.Cb_5T_traction_statique}", f"{self.app_data.int_Cb_5T_traction_statique}"],
["Traction dynamique", f"{self.app_data.Cb_5T_traction_dynamique}", f"{self.app_data.int_Cb_5T_traction_dynamique}"],
["Pression ΔP", f"{self.app_data.Cb_5T_pression}", f"{self.app_data.int_Cb_5T_pression}"],
["", "", ""],
["Vitesse de rotation", f"{self.app_data.Cb_5T_vitesse_rotation}", f"{self.app_data.int_Cb_5T_vitesse_rotation}"],
["Débit", f"{self.app_data.Cb_5T_debit}", f"{self.app_data.int_Cb_5T_debit}"],
["", "", ""],
["Essais file-vire", f"{self.app_data.Cb_5T_essai_file_vire}", f"{self.app_data.int_Cb_5T_essai_file_vire}"],
["Freinage - défreinage moteur", f"{self.app_data.Cb_5T_freinage}", f"{self.app_data.int_Cb_5T_freinage}"],
["", "", ""],
["", "", ""],
["", "", ""],
["", "", ""],
["Cabestan 3T", "", ""],
["Traction statique", f"{self.app_data.Cb_3T_traction_statique}", f"{self.app_data.int_Cb_3T_traction_statique}"],
["Traction dynamique", f"{self.app_data.Cb_3T_traction_dynamique}", f"{self.app_data.int_Cb_3T_traction_dynamique}"],
["Pression ΔP", f"{self.app_data.Cb_3T_pression}", f"{self.app_data.int_Cb_3T_pression}"],
["", "", ""],
["Vitesse de rotation", f"{self.app_data.Cb_3T_vitesse_rotation}", f"{self.app_data.int_Cb_3T_vitesse_rotation}"],
["Débit", f"{self.app_data.Cb_3T_debit}", f"{self.app_data.int_Cb_3T_debit}"],
["", "", ""],
["Essais file-vire", f"{self.app_data.Cb_3T_essai_file_vire}", f"{self.app_data.int_Cb_3T_essai_file_vire}"],
["Freinage - défreinage moteur", f"{self.app_data.Cb_3T_freinage}", f"{self.app_data.int_Cb_3T_freinage}"],
["", "", ""],
["Sélection PV ou GV", "", ""],
["", "", ""],
["", "", ""],
["", "", ""],
["", "", ""]
]
elements.append(Table(data, rowHeights=15, style=[('GRID', (0, 0), (2, 0), 1, colors.black),
('BOX', (0, 0), (-1, -1), 1, colors.black),
('GRID', (0, 2), (2, 10), 1, colors.black),
('GRID', (0, 11), (2, 12), 1, colors.black),
('GRID', (0, 14), (2, 14), 1, colors.black),
('GRID', (0, 16), (2, 32), 1, colors.black),
('FONTNAME', (0, 0), (2, 0), 'Helvetica-Bold'),
('BACKGROUND', (0, 0), (2, 0), colors.lightblue),
('SPAN', (0, 1), (2, 1)),
('SPAN', (0, 5), (2, 5)),
('SPAN', (0, 8), (2, 8)),
('SPAN', (0, 11), (2, 14)),
('SPAN', (0, 19), (2, 19)),
('SPAN', (0, 22), (2, 22)),
('SPAN', (0, 25), (2, 25)),
('SPAN', (0, 27), (2, 30)),
('FONTNAME', (0, 1), (2, 1), 'Helvetica-Bold'),
('FONTNAME', (0, 15), (2, 15), 'Helvetica-Bold'),
('ALIGN', (0, 2), (0, 10), 'RIGHT'),
('ALIGN', (0, 16), (0, 27), 'RIGHT'),
('FONTSIZE', (0, 0), (2, 27), 8)
])
)
elements.append(PageBreak())
# --------------------------------------------------------------------------
# Appareil Gouverne 1
if (
self.app_data.AAG_schema_synoptique != "" or
self.app_data.AAG_schema_electrique != "" or
self.app_data.AAG_schema_bornier != "" or
self.app_data.AAG_schema_cablage != "" or
self.app_data.AAG_releves_rincages_circuits != "" or
self.app_data.AAG_as_niveau_bas_NB1 != "" or
self.app_data.AAG_as_controle_ARU != "" or
self.app_data.AAG_as_alarme_hydraulique_voyant_defaut != "" or
self.app_data.AAG_verif_zero_mecanique_safran != "" or
self.app_data.AAG_verif_zero_mecanique_recepteur != "" or
self.app_data.AAG_verif_positionnement_transmetteur_BOPP != "" or
self.app_data.AAG_controle_puissance != "" or
self.app_data.AAG_controle_frequence != "" or
self.app_data.AAG_controle_commande != "" or
self.app_data.AAG_controle_presence_24VDC != "" or
self.app_data.AAG_as_defauts_puissance != "" or
self.app_data.AAG_as_defauts_moteur != "" or
self.app_data.AAG_as_defauts_commande != "" or
self.app_data.AAG_as_niveau_bas != "" or
self.app_data.AAG_as_test_lampes != "" or
self.app_data.AAG_as_controle_ARU2 != "" or
self.app_data.AAG_signalisation_defauts != "" or
self.app_data.AAG_APG_pompe_double_sens_rotation != "" or
self.app_data.AAG_APG_pompe_double_marche_arret_moteur != "" or
self.app_data.AAG_APG_pompe_double_courant_demarrage != "" or
self.app_data.AAG_APG_pompe_double_courant_service != "" or
self.app_data.AAG_RTRIB_reglage_limiteur_pression_centrale != "" or
self.app_data.AAG_RTRIB_reglage_limiteur_pression_double_en_ligne != "" or
self.app_data.AAG_RTRIB_controle_vitesses_recepteur_moteur != "" or
self.app_data.AAG_RTRIB_controle_vitesses_recepteur_pompe != "" or
self.app_data.AAG_RTRIB_controle_vitesses_recepteur_reglage_Pmax != "" or
self.app_data.AAG_RTRIB_controle_fin_course_electrique_arret_electros != "" or
self.app_data.AAG_RTRIB_controle_fin_course_electrique_PX1 != "" or
self.app_data.AAG_RTRIB_controle_fin_course_electrique_PX2 != "" or
self.app_data.AAG_RTRIB_controle_fonctionnement_indicateurs_angle_passerelle != "" or
self.app_data.AAG_RTRIB_controle_fonctionnement_indicateurs_angle_local_barre != "" or
self.app_data.AAG_RBAB_reglage_limiteur_pression_centrale != "" or
self.app_data.AAG_RBAB_reglage_limiteur_pression_double_en_ligne != "" or
self.app_data.AAG_RBAB_controle_vitesses_recepteur_moteur != "" or
self.app_data.AAG_RBAB_controle_vitesses_recepteur_pompe != "" or
self.app_data.AAG_RBAB_controle_vitesses_recepteur_reglage_Pmax != "" or
self.app_data.AAG_RBAB_controle_fin_course_electrique_arret_electros != "" or
self.app_data.AAG_RBAB_controle_fin_course_electrique_PX1 != "" or
self.app_data.AAG_RBAB_controle_fin_course_electrique_PX2 != "" or
self.app_data.AAG_RBAB_controle_fonctionnement_indicateurs_angle_passerelle != "" or
self.app_data.AAG_RBAB_controle_fonctionnement_indicateurs_angle_local_barre != ""
):
section_style = styles['Title']
title_paragraph = Paragraph("Appareil Gouverne 1", section_style)
elements.append(title_paragraph)
data = [
["ESSAIS A REALISER", "Valeurs BE", "Valeurs Intervenant"],
["Vérification conformité hydraulique", "", ""],
["Schémas synoptiques", f"{self.app_data.AAG_schema_synoptique}", f"{self.app_data.int_AAG_schema_synoptique}"],
["Schémas électriques", f"{self.app_data.AAG_schema_electrique}", f"{self.app_data.int_AAG_schema_electrique}"],
["Schéma bornier", f"{self.app_data.AAG_schema_bornier}", f"{self.app_data.int_AAG_schema_bornier}"],
["Schéma câblage", f"{self.app_data.AAG_schema_cablage}", f"{self.app_data.int_AAG_schema_cablage}"],
["Relevé des rinçages circuits", f"{self.app_data.AAG_releves_rincages_circuits}", f"{self.app_data.int_AAG_releves_rincages_circuits}"],
["", "", ""],
["Alarmes et sécurités", "", ""],
["Niveau bas NB1", f"{self.app_data.AAG_as_niveau_bas_NB1}", f"{self.app_data.int_AAG_as_niveau_bas_NB1}"],
["Contrôles des ARU", f"{self.app_data.AAG_as_controle_ARU}", f"{self.app_data.int_AAG_as_controle_ARU}"],
["Alarme hydraulique voyant et défaut", f"{self.app_data.AAG_as_alarme_hydraulique_voyant_defaut}", f"{self.app_data.int_AAG_as_alarme_hydraulique_voyant_defaut}"],
["", "", ""],
["Vérification du zéro mécanique safran", f"{self.app_data.AAG_verif_zero_mecanique_safran}", f"{self.app_data.int_AAG_verif_zero_mecanique_safran}"],
["Vérification du zéro mécanique du transmetteur", f"{self.app_data.AAG_verif_zero_mecanique_recepteur}", f"{self.app_data.int_AAG_verif_zero_mecanique_recepteur}"],
["Vérification du positionnement du transmetteur BOPP", f"{self.app_data.AAG_verif_positionnement_transmetteur_BOPP}", f"{self.app_data.int_AAG_verif_positionnement_transmetteur_BOPP}"],
["", "", ""],
["Contrôle des tensions/fréquences", "", ""],
["Puissance", f"{self.app_data.AAG_controle_puissance}", f"{self.app_data.int_AAG_controle_puissance}"],
["Fréquence", f"{self.app_data.AAG_controle_frequence}", f"{self.app_data.int_AAG_controle_frequence}"],
["Commande", f"{self.app_data.AAG_controle_commande}", f"{self.app_data.int_AAG_controle_commande}"],
["Présence 24 VDC secours batterie", f"{self.app_data.AAG_controle_presence_24VDC}", f"{self.app_data.int_AAG_controle_presence_24VDC}"],
["", "", ""],
["Alarmes et sécurités", "", ""],
["Défauts de puissance", f"{self.app_data.AAG_as_defauts_puissance}", f"{self.app_data.int_AAG_as_defauts_puissance}"],
["Défauts moteur", f"{self.app_data.AAG_as_defauts_moteur}", f"{self.app_data.int_AAG_as_defauts_moteur}"],
["Défauts commande", f"{self.app_data.AAG_as_defauts_commande}", f"{self.app_data.int_AAG_as_defauts_commande}"],
["Niveau bas", f"{self.app_data.AAG_as_niveau_bas}", f"{self.app_data.int_AAG_as_niveau_bas}"],
["Test lampes", f"{self.app_data.AAG_as_test_lampes}", f"{self.app_data.int_AAG_as_test_lampes}"],
["Contrôle des ARU", f"{self.app_data.AAG_as_controle_ARU2}", f"{self.app_data.int_AAG_as_controle_ARU2}"],
["", "", ""],
["Signalisation visuelle et sonore des défauts sur coffret \n et sur platine passerelle", f"{self.app_data.AAG_signalisation_defauts}", f"{self.app_data.int_AAG_signalisation_defauts}"],
["", "", ""],
["", "", ""],
["Groupe APG 1,5 kW - pompe double 1,2 + 1,cm3/tr", "", ""],
["Sens de rotation", f"{self.app_data.AAG_APG_pompe_double_sens_rotation}", f"{self.app_data.int_AAG_APG_pompe_double_sens_rotation}"],
["MARCHE / ARRET moteur", f"{self.app_data.AAG_APG_pompe_double_marche_arret_moteur}", f"{self.app_data.int_AAG_APG_pompe_double_marche_arret_moteur}"],
["Courant de démarrage", f"{self.app_data.AAG_APG_pompe_double_courant_demarrage}", f"{self.app_data.int_AAG_APG_pompe_double_courant_demarrage}"],
["Courant de service", f"{self.app_data.AAG_APG_pompe_double_courant_service}", f"{self.app_data.int_AAG_APG_pompe_double_courant_service}"],
["", "", ""],
["", "", ""],
["", "", ""],
["", "", ""],
["", "", ""],
["", "", ""]
]
elements.append(Table(data, rowHeights=14, style=[('GRID', (0, 0), (-1, -1), 1, colors.black),
('BACKGROUND', (0, 0), (2, 0), colors.lightblue),
('FONTNAME', (0, 0), (2, 0), 'Helvetica-Bold'),
('SPAN', (0, 1), (2, 1)),
('SPAN', (0, 7), (2, 7)),
('SPAN', (0, 8), (2, 8)),
('SPAN', (0, 12), (2, 12)),
('SPAN', (0, 16), (2, 16)),
('SPAN', (0, 22), (2, 22)),
('SPAN', (0, 23), (2, 23)),
('SPAN', (0, 30), (2, 30)),
('SPAN', (0, 31), (0, 32)),
('SPAN', (1, 31), (1, 32)),
('SPAN', (2, 31), (2, 32)),
('SPAN', (0, 33), (2, 33)),
('SPAN', (0, 39), (2, 44)),
('FONTNAME', (0, 1), (2, 1), 'Helvetica-Bold'),
('FONTNAME', (0, 8), (2, 8), 'Helvetica-Bold'),
('FONTNAME', (0, 23), (2, 23), 'Helvetica-Bold'),
('FONTNAME', (0, 34), (2, 34), 'Helvetica-Bold'),
('ALIGN', (0, 2), (0, 6), 'RIGHT'),
('ALIGN', (0, 9), (0, 21), 'RIGHT'),
('ALIGN', (0, 24), (0, 33), 'RIGHT'),
('ALIGN', (0, 35), (0, 48), 'RIGHT'),
('VALIGN', (0, 0), (2, 55), 'MIDDLE'),
('FONTSIZE', (0, 0), (2, 55), 8)
])
)
elements.append(PageBreak())
# --------------------------------------------------------------------------
# Appareil Gouverne 2
section_style = styles['Title']
title_paragraph = Paragraph("Appareil Gouverne 2", section_style)
elements.append(title_paragraph)
data = [
["ESSAIS A REALISER", "Valeurs BE", "Valeurs Intervenant"],
["RECEPTEUR TRIBORD", "", ""],
["Réglage limiteur de pression sur centrale", f"{self.app_data.AAG_RTRIB_reglage_limiteur_pression_centrale}", f"{self.app_data.int_AAG_RTRIB_reglage_limiteur_pression_centrale}"],
["Réglage limiteur de pression en ligne", f"{self.app_data.AAG_RTRIB_reglage_limiteur_pression_double_en_ligne}", f"{self.app_data.int_AAG_RTRIB_reglage_limiteur_pression_double_en_ligne}"],
["", "", ""],
["Contrôle des vitesses régulateur tribord", "", ""],
["Moteur seul", f"{self.app_data.AAG_RTRIB_controle_vitesses_recepteur_moteur}", f"{self.app_data.int_AAG_RTRIB_controle_vitesses_recepteur_moteur}"],
["Pompe manuelle (secours)", f"{self.app_data.AAG_RTRIB_controle_vitesses_recepteur_pompe}", f"{self.app_data.int_AAG_RTRIB_controle_vitesses_recepteur_pompe}"],
["Réglage de la pression maximale de fonctionnement", f"{self.app_data.AAG_RTRIB_controle_vitesses_recepteur_reglage_Pmax}", f"{self.app_data.int_AAG_RTRIB_controle_vitesses_recepteur_reglage_Pmax}"],
["", "", ""],
["Contrôle des fins de courses électriques Bd / Td", "", ""],
["Arrêt des électros par capteurs inductifs (réglage)", f"{self.app_data.AAG_RTRIB_controle_fin_course_electrique_arret_electros}", f"{self.app_data.int_AAG_RTRIB_controle_fin_course_electrique_arret_electros}"],
["PX1 : FdC BD", f"{self.app_data.AAG_RTRIB_controle_fin_course_electrique_PX1}", f"{self.app_data.int_AAG_RTRIB_controle_fin_course_electrique_PX1}"],
["PX2 : FdC TD", f"{self.app_data.AAG_RTRIB_controle_fin_course_electrique_PX2}", f"{self.app_data.int_AAG_RTRIB_controle_fin_course_electrique_PX2}"],
["", "", ""],
["Contrôle de fonctionnement des indicateurs d'angle de barre", "", ""],
["Angle de passerelle", f"{self.app_data.AAG_RTRIB_controle_fonctionnement_indicateurs_angle_passerelle}", f"{self.app_data.int_AAG_RTRIB_controle_fonctionnement_indicateurs_angle_passerelle}"],
["Angle local barre", f"{self.app_data.AAG_RTRIB_controle_fonctionnement_indicateurs_angle_local_barre}", f"{self.app_data.int_AAG_RTRIB_controle_fonctionnement_indicateurs_angle_local_barre}"],
["", "", ""],
["RECEPTEUR BABORD", "", ""],
["Réglage limiteur de pression sur centrale", f"{self.app_data.AAG_RBAB_reglage_limiteur_pression_centrale}", f"{self.app_data.int_AAG_RBAB_reglage_limiteur_pression_centrale}"],
["Réglage limiteur de pression en ligne", f"{self.app_data.AAG_RBAB_reglage_limiteur_pression_double_en_ligne}", f"{self.app_data.int_AAG_RBAB_reglage_limiteur_pression_double_en_ligne}"],
["", "", ""],
["Contrôle des vitesses régulateur tribord", "", ""],
["Moteur seul", f"{self.app_data.AAG_RBAB_controle_vitesses_recepteur_moteur}", f"{self.app_data.int_AAG_RBAB_controle_vitesses_recepteur_moteur}"],
["Pompe manuelle (secours)", f"{self.app_data.AAG_RBAB_controle_vitesses_recepteur_pompe}", f"{self.app_data.int_AAG_RBAB_controle_vitesses_recepteur_pompe}"],
["Réglage de la pression maximale de fonctionnement", f"{self.app_data.AAG_RBAB_controle_vitesses_recepteur_reglage_Pmax}", f"{self.app_data.int_AAG_RBAB_controle_vitesses_recepteur_reglage_Pmax}"],
["", "", ""],
["Contrôle des fins de courses électriques Bd / Td", "", ""],
["Arrêt des électros par capteurs inductifs (réglage)", f"{self.app_data.AAG_RBAB_controle_fin_course_electrique_arret_electros}", f"{self.app_data.int_AAG_RBAB_controle_fin_course_electrique_arret_electros}"],
["PX1 : FdC BD", f"{self.app_data.AAG_RBAB_controle_fin_course_electrique_PX1}", f"{self.app_data.int_AAG_RBAB_controle_fin_course_electrique_PX1}"],
["PX2 : FdC TD", f"{self.app_data.AAG_RBAB_controle_fin_course_electrique_PX2}", f"{self.app_data.int_AAG_RBAB_controle_fin_course_electrique_PX2}"],
["", "", ""],
["Contrôle de fonctionnement des indicateurs d'angle de barre", "", ""],
["Angle de passerelle", f"{self.app_data.AAG_RBAB_controle_fonctionnement_indicateurs_angle_passerelle}", f"{self.app_data.int_AAG_RBAB_controle_fonctionnement_indicateurs_angle_passerelle}"],
["Angle local barre", f"{self.app_data.AAG_RBAB_controle_fonctionnement_indicateurs_angle_local_barre}", f"{self.app_data.int_AAG_RBAB_controle_fonctionnement_indicateurs_angle_local_barre}"],
]
elements.append(Table(data, rowHeights=14, style=[('GRID', (0, 0), (-1, -1), 1, colors.black),
('BACKGROUND', (0, 0), (2, 0), colors.lightblue),
('FONTNAME', (0, 0), (2, 0), 'Helvetica-Bold'),
('SPAN', (0, 1), (2, 1)),
('SPAN', (0, 5), (2, 5)),
('SPAN', (0, 4), (2, 4)),
('SPAN', (0, 9), (2, 9)),
('SPAN', (0, 10), (2, 10)),
('SPAN', (0, 14), (2, 14)),
('SPAN', (0, 15), (2, 15)),
('SPAN', (0, 18), (2, 18)),
('SPAN', (0, 19), (2, 19)),
('SPAN', (0, 22), (2, 22)),
('SPAN', (0, 23), (2, 23)),
('SPAN', (0, 27), (2, 27)),
('SPAN', (0, 28), (2, 28)),
('SPAN', (0, 32), (2, 32)),
('SPAN', (0, 33), (2, 33)),
('SPAN', (0, 33), (2, 33)),
('SPAN', (0, 39), (2, 44)),
('FONTNAME', (0, 1), (2, 1), 'Helvetica-Bold'),
('FONTNAME', (0, 5), (2, 5), 'Helvetica-Bold'),
('FONTNAME', (0, 10), (2, 10), 'Helvetica-Bold'),
('FONTNAME', (0, 15), (2, 15), 'Helvetica-Bold'),
('FONTNAME', (0, 19), (2, 19), 'Helvetica-Bold'),
('FONTNAME', (0, 23), (2, 23), 'Helvetica-Bold'),
('FONTNAME', (0, 28), (2, 28), 'Helvetica-Bold'),
('FONTNAME', (0, 33), (2, 33), 'Helvetica-Bold'),
('ALIGN', (0, 2), (0, 4), 'RIGHT'),
('ALIGN', (0, 11), (0, 14), 'RIGHT'),
('ALIGN', (0, 16), (0, 18), 'RIGHT'),
('ALIGN', (0, 20), (0, 22), 'RIGHT'),
('ALIGN', (0, 24), (0, 27), 'RIGHT'),
('ALIGN', (0, 29), (0, 32), 'RIGHT'),
('ALIGN', (0, 34), (0, 36), 'RIGHT'),
('VALIGN', (0, 0), (2, 55), 'MIDDLE'),
('FONTSIZE', (0, 0), (2, 55), 8)
])
)
elements.append(PageBreak())
#--------------------------------------------------------------------------
# Infos supplémentaires
section_style = styles['Title']
title_paragraph = Paragraph("Récapitulatif", section_style)
elements.append(title_paragraph)
data = [
["Récapitulatif des événements de l'intervention"],
["Matériel remplacé", ""],
["Pièces changées", f"{self.app_data.int_pieces_changees}"],
["Pièces cassées", f"{self.app_data.int_pieces_cassees}"],
["", ""],
["Temps d'intervention", ""],
["Temps passé", f"{self.app_data.int_temps_passe}"],
["Temps mort", f"{self.app_data.int_temps_mort}"],
["", ""],
["Commentaires :", ""],
["", f"{self.app_data.int_commentaires}"],
["", ""],
["", ""],
["", ""],
["", ""],
["", ""],
["", ""],
["", ""]
]
elements.append(Table(data, rowHeights=15, style=[('GRID', (0, 0), (-1, -1), 1, colors.black),
('SPAN', (0, 0), (1, 0)),
('SPAN', (0, 1), (1, 1)),
('SPAN', (0, 4), (1, 4)),
('SPAN', (0, 5), (1, 5)),
('SPAN', (0, 8), (1, 8)),
('SPAN', (0, 9), (1, 9)),
('SPAN', (0, 10), (1, 17)),
('FONTNAME', (0, 0), (1, 0), 'Helvetica-Bold'),
('FONTNAME', (0, 1), (1, 1), 'Helvetica-Bold'),
('FONTNAME', (0, 5), (1, 5), 'Helvetica-Bold'),
('FONTNAME', (0, 8), (1, 8), 'Helvetica-Bold'),
('FONTNAME', (0, 9), (1, 9), 'Helvetica-Bold'),
('BACKGROUND', (0, 0), (1, 0), colors.lightblue),
('FONTSIZE', (0, 0), (1, 27), 8)
])
)
elements.append(Spacer(1, 20))
section_style = styles['Title']
title_paragraph = Paragraph("Signatures", section_style)
elements.append(title_paragraph)
# rep_sign = './signatures'
# rep_sign = '/signatures'
# if os.path.isdir(rep_sign):
if os.path.isdir(self.sign_path):
# if os.listdir(rep_sign):
if os.listdir(self.sign_path):
sign_style = styles['Heading1']
# sign_int = './signatures/signature_int.png'
# sign_int = '/signatures/signature_int.png'
sign_int = os.path.join(self.sign_path,'signature_int.png')
# sign_client = './signatures/signature_client.png'
# sign_client = '/signatures/signature_client.png'
sign_client = os.path.join(self.sign_path,'signature_client.png')
try:
img_width = 150
img_height = 50
margin = 10
page_width, page_height = A4
x_start = (page_width - (3 * img_width + 2 * margin)) / 2
y_start = page_height - 100
sign_paragraph = Paragraph("Signature intervenant : ", sign_style)
elements.append(sign_paragraph)
img = self.draw_picture(
path=sign_int,
x=x_start,
y=y_start,
width=img_width,
height=img_height
)
elements.append(img)
elements.append(Spacer(1, 10))
sign_paragraph = Paragraph("Signature client : ", sign_style)
elements.append(sign_paragraph)
img = self.draw_picture(
path=sign_client,
x=x_start,
y=y_start - img_height - margin,
width=img_width,
height=img_height
)
elements.append(img)
except Exception as e:
self.show_popup(f"Problème avec l'ajout des signatures : {e}")
elements.append(PageBreak())
# --------------------------------------------------------------------------
# Galerie de photos
if self.app_data.is_galerie:
section_style = styles['Title']
title_paragraph = Paragraph("Galerie de photos", section_style)
elements.append(title_paragraph)
elements.append(Spacer(1, 50))
# images = [f for f in os.listdir('./media') if f.endswith('.png')]
images = [f for f in os.listdir(self.media_path) if f.endswith('.png')]
# Dimensions des images
img_width = 400
img_height = 150
margin = 10
page_width, page_height = A4
x_start = (page_width - (3 * img_width + 2 * margin)) / 2
y_start = page_height - 100
x_positions = [x_start, x_start + img_width + margin, x_start + 2 * (img_width + margin)]
y_position = y_start
images_on_page = 0
for img in images:
try:
# Calcule la position en fonction du nombre d'images sur la page
x_position = x_positions[images_on_page % 3]
img = self.draw_picture(
# path=f"./media/{img_path}",
# path=f"{self.media_path}/{img}",
path= os.path.join(self.media_path,img),
x=x_position,
y=y_position,
width=img_width,
height=img_height
)
elements.append(img)
elements.append(Spacer(1, 10))
images_on_page += 1
# Passe à la ligne suivante après 3 images
if images_on_page % 3 == 0:
y_position -= img_height + margin
# Saut de page si on dépasse la hauteur de la page
if y_position - img_height < 50:
elements.append(PageBreak())
y_position = y_start
images_on_page = 0
except Exception as e:
self.show_popup(f"Problème avec l'ajout des images : {e}")
#--------------------------------------------------------------------------
# Fin du document
self.doc.build(elements)
self.show_popup(f"Le fichier PDF a été créé avec succès !")
except Exception as e:
self.show_popup(f"Erreur lors de la création du fichier PDF : {e}")
# Déplacer le fichier PDF vers le dossier Documents
documents_path = Path('/storage/emulated/0/Documents')
try:
# shutil.move(os.path.join(self.build_path, self.filename), os.path.join(documents_path, self.filename))
shutil.move(os.path.join('./build/',self.filename), os.path.join(documents_path, self.filename))
self.show_popup(f"Le fichier PDF a été déplacé dans le dossier Documents.")
except Exception as e:
self.show_popup(f"Erreur lors du déplacement du fichier : {e}")
try:
shutil.move(os.path.join('./build/',self.filename), os.path.join(self.pdf_path, self.filename))
self.show_popup(f"Le fichier PDF a été déplacé dans le dossier PDF.")
except Exception as e:
self.show_popup(f"Erreur lors du déplacement du fichier : {e}")
def execute(self):
"""
Génère le fichier PDF
"""
# app_data = AppData()
# app_data.save_data()
self.write_pdf()