-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
4790 lines (4161 loc) · 178 KB
/
Copy pathindex.html
File metadata and controls
4790 lines (4161 loc) · 178 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
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Reductor booleano y generador Ladder Logic para PLC, en un único archivo HTML.">
<title>Ladder Logic Reducer</title>
<style>
/*
* ============================================================================
* SECCIÓN 1: CONFIGURACIÓN VISUAL GLOBAL
* ============================================================================
* QUÉ hace:
* Define todos los valores visuales reutilizables mediante variables CSS.
*
* POR QUÉ se hace así:
* Centralizar colores, radios, sombras y tamaños evita valores "mágicos"
* repartidos por la hoja de estilos y permite cambiar el aspecto completo
* desde un único lugar.
*
* CÓMO modificarlo:
* Cambia únicamente las variables de :root. El resto del CSS consume
* estas variables, por lo que no es necesario buscar colores uno por uno.
*/
:root {
--color-fondo: #07111f;
--color-fondo-secundario: #0b1630;
--color-panel: #111c38;
--color-panel-secundario: #172344;
--color-texto: #eef4ff;
--color-texto-suave: #aab7d8;
--color-acento: #72a7ff;
--color-acento-fuerte: #3b82f6;
--color-correcto: #36c995;
--color-advertencia: #f5a524;
--color-error: #ef5b5b;
--color-borde: #2c3b67;
--color-cable: #e8efff;
--color-carril: #9cc0ff;
--radio-panel: 18px;
--radio-control: 11px;
--sombra-panel: 0 16px 42px rgba(0, 0, 0, 0.20);
--ancho-maximo: 1680px;
--fuente-normal: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
--fuente-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
* {
box-sizing: border-box;
}
html {
color-scheme: dark;
}
body {
margin: 0;
min-height: 100vh;
background:
radial-gradient(circle at top right, rgba(59, 130, 246, 0.10), transparent 36rem),
linear-gradient(180deg, var(--color-fondo), var(--color-fondo-secundario));
color: var(--color-texto);
font-family: var(--fuente-normal);
}
header.encabezado-principal {
position: sticky;
top: 0;
z-index: 20;
padding: 18px 24px;
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
background: rgba(5, 12, 27, 0.88);
backdrop-filter: blur(12px);
}
.encabezado-contenido {
max-width: var(--ancho-maximo);
margin: 0 auto;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
}
h1 {
margin: 0 0 7px;
font-size: clamp(1.25rem, 2vw, 1.65rem);
}
.subtitulo {
max-width: 1050px;
margin: 0;
color: var(--color-texto-suave);
line-height: 1.5;
}
.acciones-encabezado {
display: flex;
align-items: center;
gap: 10px;
flex-shrink: 0;
}
main {
width: min(100%, var(--ancho-maximo));
margin: 0 auto;
padding: 18px 24px 36px;
display: grid;
gap: 16px;
}
.rejilla-superior {
display: grid;
grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
gap: 16px;
align-items: start;
}
.panel {
min-width: 0;
padding: 16px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: var(--radio-panel);
background: linear-gradient(180deg, rgba(17, 28, 56, 0.98), rgba(10, 19, 39, 0.98));
box-shadow: var(--sombra-panel);
}
.panel h2 {
margin: 0 0 12px;
font-size: 1.08rem;
}
.controles {
display: grid;
grid-template-columns: repeat(3, minmax(150px, 1fr));
gap: 10px;
align-items: end;
}
.control-grupo,
.controles > div {
min-width: 0;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
label {
display: block;
margin-bottom: 6px;
color: var(--color-texto-suave);
font-size: 0.84rem;
}
input[type="number"],
input[type="text"],
textarea,
select {
width: 100%;
padding: 10px 11px;
border: 1px solid var(--color-borde);
border-radius: var(--radio-control);
outline: none;
background: #0a142b;
color: var(--color-texto);
font: inherit;
}
input:focus,
textarea:focus,
select:focus {
border-color: var(--color-acento);
box-shadow: 0 0 0 3px rgba(114, 167, 255, 0.14);
}
input[type="number"],
input[type="text"],
select {
min-height: 42px;
padding: 10px 11px;
font-family: var(--fuente-normal);
font-size: 0.95rem;
font-weight: 500;
line-height: 1.2;
text-align: left;
}
input[readonly] {
color: var(--color-texto-suave);
cursor: default;
background: #0c1730;
}
body.procesando {
cursor: progress;
}
body.procesando button {
pointer-events: none;
}
textarea {
min-height: 156px;
resize: vertical;
font-family: var(--fuente-mono);
line-height: 1.45;
}
button {
appearance: none;
min-height: 39px;
padding: 9px 13px;
border: 0;
border-radius: var(--radio-control);
cursor: pointer;
background: linear-gradient(180deg, #4a91ff, #2f6ed8);
color: white;
font-weight: 750;
box-shadow: 0 7px 18px rgba(47, 110, 216, 0.22);
}
button:hover:not(:disabled) {
filter: brightness(1.08);
}
button:disabled {
opacity: 0.48;
cursor: not-allowed;
}
button.secundario {
background: linear-gradient(180deg, #293859, #1c2948);
border: 1px solid rgba(255, 255, 255, 0.07);
box-shadow: none;
}
button.advertencia {
background: linear-gradient(180deg, #f3a51f, #d9850f);
box-shadow: 0 7px 18px rgba(217, 133, 15, 0.18);
}
.fila-botones {
display: flex;
flex-wrap: wrap;
gap: 9px;
margin-top: 12px;
}
.selector-idioma {
display: flex;
align-items: center;
gap: 8px;
padding: 7px 9px;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 12px;
background: #0a142b;
}
.selector-idioma label {
margin: 0;
white-space: nowrap;
}
.selector-idioma select {
width: auto;
min-width: 112px;
padding: 7px 9px;
}
.contenedor-tabla {
max-height: 58vh;
margin-top: 14px;
overflow: auto;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 14px;
background: #081123;
}
table {
width: max-content;
min-width: 100%;
border-collapse: collapse;
font-family: var(--fuente-mono);
font-size: 0.88rem;
}
th,
td {
padding: 0;
border-right: 1px solid rgba(255, 255, 255, 0.05);
border-bottom: 1px solid rgba(255, 255, 255, 0.07);
text-align: center;
}
th {
position: sticky;
top: 0;
z-index: 2;
min-width: 70px;
padding: 9px 7px;
background: #111d39;
color: #e3ecff;
}
th.columna-entrada {
background: #12203d;
}
th.columna-salida {
background: #173229;
color: #d8ffed;
}
td.columna-salida {
background: rgba(54, 201, 149, 0.035);
}
th.inicio-salidas,
td.inicio-salidas {
border-left: 3px solid rgba(54, 201, 149, 0.55);
}
th:first-child,
td:first-child {
position: sticky;
left: 0;
z-index: 3;
min-width: 48px;
background: #101a34;
font-weight: 800;
}
.celda-logica {
width: 68px;
padding: 9px 4px;
border: 0;
outline: 0;
background: transparent;
color: var(--color-texto);
text-align: center;
font: inherit;
text-transform: uppercase;
}
.nota {
margin: 10px 0 0;
color: var(--color-texto-suave);
font-size: 0.83rem;
line-height: 1.5;
}
.estado {
padding: 12px 13px;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 13px;
background: #081123;
line-height: 1.5;
}
.estado.correcto {
border-color: rgba(54, 201, 149, 0.42);
}
.estado.advertencia {
border-color: rgba(245, 165, 36, 0.42);
}
.estado.error {
border-color: rgba(239, 91, 91, 0.48);
}
.kpis {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 9px;
margin-top: 14px;
}
.kpi {
padding: 11px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 12px;
background: #081123;
}
.kpi-etiqueta {
color: var(--color-texto-suave);
font-size: 0.78rem;
}
.kpi-valor {
margin-top: 6px;
font-size: 1.12rem;
font-weight: 850;
}
.bloque-resultado {
display: grid;
min-width: 0;
gap: 16px;
margin-top: 14px;
}
.bloque-resultado > *,
.ladder-contenedor > *,
.rung-tarjeta,
.svg-scroll,
.resultado-detalle,
.lista-mapeo {
min-width: 0;
max-width: 100%;
}
.svg-scroll {
width: 100%;
}
.resultado-detalle {
margin-top: 0;
background: #081123;
}
.resultado-detalle > summary {
color: #cfe0ff;
}
.resultado-detalle pre {
margin-top: 10px;
}
.expresiones-destacadas {
padding: 14px 16px;
border: 1px solid rgba(114, 167, 255, 0.18);
border-radius: 13px;
background: linear-gradient(180deg, rgba(16, 32, 64, 0.92), rgba(8, 17, 35, 0.96));
font-size: 0.93rem;
line-height: 1.65;
}
.titulo-seccion {
margin-bottom: 6px;
color: #cfe0ff;
font-size: 0.91rem;
font-weight: 700;
}
pre {
margin: 0;
padding: 13px;
overflow: auto;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 13px;
background: #081123;
color: #edf3ff;
font-family: var(--fuente-mono);
line-height: 1.45;
white-space: pre-wrap;
word-break: break-word;
}
.lista-mapeo {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 9px;
margin-top: 10px;
}
.mapeo {
padding: 9px 11px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 11px;
background: #081123;
font-family: var(--fuente-mono);
font-size: 0.84rem;
}
details {
margin-top: 14px;
padding: 10px 12px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 12px;
background: #081123;
}
summary {
cursor: pointer;
font-weight: 750;
}
.panel-interpretacion h3 {
margin: 0;
padding-bottom: 10px;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
color: #dce8ff;
}
.ladder-contenedor {
display: grid;
gap: 12px;
}
.rung-tarjeta {
padding: 12px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 13px;
background: #07101f;
}
.rung-cabecera {
display: flex;
justify-content: space-between;
gap: 10px;
margin-bottom: 8px;
}
.rung-titulo {
font-weight: 800;
}
.rung-meta {
color: var(--color-texto-suave);
font-family: var(--fuente-mono);
font-size: 0.79rem;
}
.rung-expresion {
margin: 0 0 8px;
color: #cdd9f4;
font-family: var(--fuente-mono);
font-size: 0.85rem;
}
.svg-scroll {
overflow: auto;
padding: 8px;
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 11px;
background:
repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 26px),
repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 26px),
#06101d;
}
.ladder-svg {
display: block;
font-family: var(--fuente-normal);
}
.ladder-svg .cable,
.ladder-svg .carril,
.ladder-svg .contacto,
.ladder-svg .bobina {
fill: none;
stroke: var(--color-cable);
stroke-width: 2.2;
stroke-linecap: round;
stroke-linejoin: round;
}
.ladder-svg .carril {
stroke: var(--color-carril);
stroke-width: 2.5;
}
.ladder-svg text {
fill: #dce7ff;
font-size: 12px;
font-weight: 700;
}
.modal-fondo {
position: fixed;
inset: 0;
z-index: 50;
display: none;
place-items: center;
padding: 24px;
background: rgba(2, 7, 18, 0.76);
}
.modal-fondo.visible {
display: grid;
}
.modal {
width: min(460px, 100%);
padding: 18px;
border: 1px solid rgba(255, 255, 255, 0.09);
border-radius: 16px;
background: #101b37;
box-shadow: 0 25px 70px rgba(0, 0, 0, 0.42);
}
.modal h3 {
margin-top: 0;
}
@media (max-width: 1100px) {
.rejilla-superior {
grid-template-columns: 1fr;
}
}
@media (max-width: 780px) {
.encabezado-contenido {
flex-direction: column;
}
.acciones-encabezado {
width: 100%;
justify-content: flex-end;
}
.controles {
grid-template-columns: repeat(2, minmax(120px, 1fr));
}
.kpis {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<!--
============================================================================
SECCIÓN 2: DATOS / ESTADO - ESTRUCTURA HTML
============================================================================
QUÉ hace:
Define únicamente la interfaz y los puntos donde JavaScript renderiza datos.
POR QUÉ se hace así:
La estructura visual permanece declarativa y la lógica se mantiene en clases
y funciones JavaScript separadas.
CÓMO modificarlo:
Puedes cambiar textos, orden de paneles o añadir controles manteniendo los ID.
Si cambias un ID, actualiza también REFERENCIAS_UI en JavaScript.
-->
<header class="encabezado-principal">
<div class="encabezado-contenido">
<div>
<h1 id="tituloApp">Reductor booleano → Ladder Logic</h1>
<p id="subtituloApp" class="subtitulo">
Captura o importa una tabla lógica, valida su consistencia, minimiza cada salida y genera lógica Ladder.
</p>
</div>
<div class="acciones-encabezado">
<div class="selector-idioma">
<label id="etiquetaIdioma" for="selectorIdioma">Idioma</label>
<select id="selectorIdioma">
<option value="es">Español</option>
<option value="en">English</option>
<option value="it">Italiano</option>
</select>
</div>
<button id="botonAcerca" type="button" class="secundario">Acerca de</button>
</div>
</div>
</header>
<div id="modalAcerca" class="modal-fondo" aria-hidden="true">
<section class="modal" role="dialog" aria-modal="true" aria-labelledby="tituloAcerca">
<h3 id="tituloAcerca">Acerca de</h3>
<pre id="textoAcerca"></pre>
<div class="fila-botones">
<button id="botonCerrarAcerca" type="button" class="secundario">Cerrar</button>
</div>
</section>
</div>
<main>
<div class="rejilla-superior">
<section class="panel">
<h2 id="tituloTabla">1) Tabla lógica</h2>
<div class="controles">
<div>
<label id="etiquetaEntradas" for="numeroEntradas">Entradas</label>
<input id="numeroEntradas" type="number" min="1" max="40" value="4">
</div>
<div>
<label id="etiquetaSalidas" for="numeroSalidas">Salidas</label>
<input id="numeroSalidas" type="number" min="1" max="20" value="2">
</div>
<div>
<label id="etiquetaFilas" for="numeroFilas">Filas iniciales</label>
<input id="numeroFilas" type="number" min="1" max="2000" value="8">
</div>
<div class="control-grupo">
<label id="etiquetaModo" for="modoIndustrial">Interpretación</label>
<input id="modoIndustrial" type="text" value="Industrial flexible" readonly>
</div>
<div class="control-grupo">
<label id="etiquetaPrefijoEntrada" for="prefijoEntrada">Nemotécnico de entradas</label>
<input id="prefijoEntrada" type="text" value="E" autocomplete="off" inputmode="text">
</div>
<div class="control-grupo">
<label id="etiquetaPrefijoSalida" for="prefijoSalida">Nemotécnico de salidas</label>
<input id="prefijoSalida" type="text" value="S" autocomplete="off" inputmode="text">
</div>
</div>
<p id="reglaPrefijos" class="nota">
Los nemotécnicos pueden ser cualquier letra. Entrada y salida deben usar letras diferentes.
</p>
<div class="fila-botones">
<button id="botonDimensiones">Aplicar dimensiones</button>
<button id="botonAgregarFila" class="secundario">Agregar fila</button>
<button id="botonQuitarFila" class="secundario">Quitar última fila</button>
<button id="botonEjemplo" class="secundario">Cargar ejemplo</button>
<button id="botonRestablecer" class="advertencia">Restablecer</button>
</div>
<div class="contenedor-tabla">
<table id="tablaVerdad"></table>
</div>
<p id="notaTabla" class="nota">
Entradas: 1, 0, X o vacío. Salidas: 1 o 0. X/vacío significa Don't Care.
</p>
</section>
<section class="panel">
<h2 id="tituloImportacion">2) Importación y acciones</h2>
<label id="etiquetaPegar" for="areaPegado">Pegar tabla TSV / Excel / LibreOffice</label>
<textarea id="areaPegado" placeholder="E1 E2 E3 S1 0 0 X 0 0 1 X 1"></textarea>
<div class="fila-botones">
<button id="botonImportar">Importar tabla</button>
<button id="botonExportarTabla" class="secundario">Descargar TSV</button>
<button id="botonAnalizar">Minimizar y generar Ladder</button>
<button id="botonDescargarTxt" class="secundario" disabled>Descargar TXT</button>
<button id="botonDescargarLd" class="secundario" disabled>Descargar LD</button>
</div>
<details>
<summary id="tituloNotasTecnicas">Notas técnicas</summary>
<div id="notasTecnicas" class="nota"></div>
</details>
</section>
</div>
<section class="panel">
<h2 id="tituloResultado">3) Resultado</h2>
<div id="areaEstado" class="estado advertencia">Aún no se ha ejecutado el análisis.</div>
<div class="kpis">
<div class="kpi">
<div id="kpiModoEtiqueta" class="kpi-etiqueta">Modo</div>
<div id="kpiModo" class="kpi-valor">—</div>
</div>
<div class="kpi">
<div id="kpiRungsEtiqueta" class="kpi-etiqueta">Rungs</div>
<div id="kpiRungs" class="kpi-valor">—</div>
</div>
<div class="kpi">
<div id="kpiContactosEtiqueta" class="kpi-etiqueta">Contactos</div>
<div id="kpiContactos" class="kpi-valor">—</div>
</div>
</div>
<div class="bloque-resultado">
<div>
<div id="tituloExpresiones" class="titulo-seccion">Expresiones booleanas minimizadas</div>
<pre id="preExpresiones" class="expresiones-destacadas">—</pre>
</div>
<details class="resultado-detalle">
<summary id="tituloAscii">Ladder ASCII simplificado</summary>
<pre id="preAscii">—</pre>
</details>
<div>
<div id="tituloVisual" class="titulo-seccion">Ladder visual</div>
<div id="areaLadderVisual" class="ladder-contenedor">
<div class="estado">—</div>
</div>
</div>
<details class="resultado-detalle">
<summary id="tituloLd">Contenido del archivo .LD</summary>
<pre id="preLd">—</pre>
</details>
<div>
<div id="tituloConsistencia" class="titulo-seccion">Consistencia y mapeo E/S</div>
<div id="areaConsistencia" class="estado">—</div>
<div id="areaMapeo" class="lista-mapeo"></div>
</div>
</div>
</section>
</main>
<script>
"use strict";
/*
* ============================================================================
* SECCIÓN 1: CONFIGURACIÓN GLOBAL
* ============================================================================
* QUÉ hace:
* Centraliza límites, metadatos, textos y parámetros técnicos.
*
* POR QUÉ se hace así:
* Evita números y textos "mágicos" dentro de funciones. Cualquier ajuste
* habitual se realiza desde este objeto sin alterar la lógica.
*
* CÓMO modificarlo:
* Cambia VERSION, AUTOR, límites o prefijos aquí. Si agregas un idioma,
* añade su diccionario completo dentro de TRADUCCIONES.
*/
const CONFIG = Object.freeze({
VERSION: "V4.1",
AUTOR: "Raymundo Ortiz",
MAX_ENTRADAS: 40,
MAX_SALIDAS: 20,
MAX_FILAS: 2000,
ENTRADAS_INICIALES: 4,
SALIDAS_INICIALES: 2,
FILAS_INICIALES: 8,
PREFIJOS_POR_IDIOMA: Object.freeze({
es: Object.freeze({ entrada: "E", salida: "S" }),
en: Object.freeze({ entrada: "I", salida: "O" }),
it: Object.freeze({ entrada: "E", salida: "A" })
}),
NOMBRE_ARCHIVO_TSV: "tabla_logica.tsv",
NOMBRE_ARCHIVO_TXT: "ladder_logic.txt",
NOMBRE_ARCHIVO_LD: "ladder_logic.ld",
ANCHO_CONTACTO_SVG: 112,
ANCHO_BOBINA_SVG: 100,
QM_MAX_VARIABLES: 12,
QM_MAX_PRIMOS: 2400,
QM_MAX_ESTADOS: 4096,
QM_MAX_PRODUCTOS_PETRICK: 50000,
ESPRESSO_MAX_ITERACIONES: 18,
HEURISTICA_MAX_CANDIDATOS: 3000,
HEURISTICA_MAX_PARES_POR_ITERACION: 150000,
HEURISTICA_MAX_NODOS_CONTENCION: 120000,
VERIFICACION_MAX_NODOS: 750000,
FACTORIZACION_MAX_CANDIDATOS_GENERADOS: 2000,
FACTORIZACION_MAX_INTERSECCION: 10,
FACTORIZACION_CANDIDATOS_NIVEL_INICIAL: 30,
FACTORIZACION_CANDIDATOS_NIVEL_PROFUNDO: 12,
MAX_AUXILIARES_COMPARTIDOS: 12,
MAX_CANDIDATOS_COMPARTIDOS_POR_SALIDA: 1500,
MAX_INTERSECCIONES_COMPARTIDAS: 6000,
MAX_PARES_INTERSECCION_COMPARTIDA: 200000,
MAX_CANDIDATOS_COMPARTIDOS: 3000,
PREFIJO_RELE_AUXILIAR: "M",
COSTO_LADDER: Object.freeze({
contacto: 100,
rama: 28,
profundidad: 16,
termino: 8,
releAuxiliar: 110
})
});
/*
* ============================================================================
* SECCIÓN 2: DATOS / ESTADO
* ============================================================================
* QUÉ hace:
* Mantiene los datos editables y el último resultado calculado.
*
* POR QUÉ se hace así:
* La interfaz puede redibujarse sin perder la fuente de verdad de la app.
* La lógica de minimización recibe datos simples y no depende del DOM.
*
* CÓMO modificarlo:
* Para cambiar la configuración inicial, edita CONFIG. Para precargar
* datos propios, cambia DATOS_PERSONALES y llama a cargarDatosIniciales().
*/
// ← MODIFICA AQUÍ: cambia este objeto con tus datos personales.
const DATOS_PERSONALES = {
autorVisible: CONFIG.AUTOR
};
const ESTADO_APP = {
numeroEntradas: CONFIG.ENTRADAS_INICIALES,
numeroSalidas: CONFIG.SALIDAS_INICIALES,
prefijoEntrada: "E",
prefijoSalida: "S",
prefijosPersonalizados: false,
etiquetasEntradas: [],
etiquetasSalidas: [],
filas: [],
ultimoResultado: null,
idioma: "es",
procesando: false
};
/*
* Traducciones visibles de la interfaz.
* Para mantener el código legible, solo se traducen textos de UI y mensajes;
* los nombres técnicos importados de señales nunca se alteran.
*/
const TRADUCCIONES = {
es: {
tituloApp: "Reductor booleano → Ladder Logic",
subtituloApp: "Captura o importa una tabla lógica, valida su consistencia, minimiza cada salida y genera lógica Ladder.",
idioma: "Idioma",
acerca: "Acerca de",
cerrar: "Cerrar",
tituloTabla: "1) Tabla lógica",
entradas: "Entradas",
salidas: "Salidas",
filas: "Filas iniciales",
interpretacion: "Interpretación",
prefijoEntrada: "Nemotécnico de entradas",
prefijoSalida: "Nemotécnico de salidas",
reglaPrefijos: "Los nemotécnicos pueden ser cualquier letra individual (por ejemplo E/S, X/Y o Ñ/Q). Entrada y salida deben usar letras diferentes.",
prefijosIguales: "El nemotécnico de entrada y el de salida deben ser diferentes.",
industrial: "Industrial flexible",
aplicar: "Aplicar dimensiones",
agregarFila: "Agregar fila",
quitarFila: "Quitar última fila",
ejemplo: "Cargar ejemplo",
restablecer: "Restablecer",
notaTabla: "Entradas: 1, 0, X o vacío. Salidas: 1 o 0. X/vacío significa Don't Care. Los nemotécnicos de entrada y salida pueden ser cualquier letra, siempre que sean diferentes.",
importacion: "2) Importación y acciones",
pegar: "Pegar tabla TSV / Excel / LibreOffice",
importar: "Importar tabla",
exportarTabla: "Descargar TSV",
analizar: "Minimizar y generar Ladder",
descargarTxt: "Descargar TXT",
descargarLd: "Descargar LD",
modo: "Modo",
rungs: "Rungs",
contactos: "Contactos",
notas: "Notas técnicas",
notasTexto: "<b>Industrial flexible:</b> cada salida se minimiza usando únicamente las filas donde dicha salida vale 1. Las filas con salida 0 no se consideran prohibiciones globales. Después de minimizar cada salida, la aplicación detecta factores comunes completos entre salidas y crea relés auxiliares solo cuando reducen el costo Ladder total.",
resultado: "3) Resultado",
sinAnalisis: "Aún no se ha ejecutado el análisis.",
expresiones: "Expresiones booleanas minimizadas",
ascii: "Ladder ASCII simplificado",
visual: "Ladder visual",
ld: "Contenido del archivo .LD",
consistencia: "Consistencia y mapeo E/S",
tablaVacia: "La tabla no contiene filas válidas.",
dimensionesInvalidas: "Las dimensiones solicitadas están fuera de los límites permitidos.",
importacionCorrecta: "Tabla importada correctamente.",
importacionError: "No fue posible importar la tabla.",
valorEntradaInvalido: "Entrada inválida",
valorSalidaInvalido: "Salida inválida",
version: "Versión",
autor: "Autor",
industrialCorto: "Industrial",
},
en: {
tituloApp: "Boolean Reducer → Ladder Logic",
subtituloApp: "Capture or import a logic table, validate consistency, minimize each output and generate Ladder logic.",
idioma: "Language",
acerca: "About",
cerrar: "Close",
tituloTabla: "1) Logic table",
entradas: "Inputs",
salidas: "Outputs",
filas: "Initial rows",
interpretacion: "Interpretation",
prefijoEntrada: "Input mnemonic",
prefijoSalida: "Output mnemonic",
reglaPrefijos: "Mnemonics may use any single letter (for example I/O, X/Y or Ñ/Q). Input and output must use different letters.",
prefijosIguales: "Input and output mnemonics must be different.",
industrial: "Flexible industrial",
aplicar: "Apply dimensions",
agregarFila: "Add row",
quitarFila: "Remove last row",
ejemplo: "Load example",
restablecer: "Reset",
notaTabla: "Inputs: 1, 0, X or blank. Outputs: 1 or 0. X/blank means Don't Care. Input and output mnemonics may use any letter, provided they are different.",
importacion: "2) Import and actions",
pegar: "Paste TSV / Excel / LibreOffice table",
importar: "Import table",
exportarTabla: "Download TSV",
analizar: "Minimize and generate Ladder",
descargarTxt: "Download TXT",
descargarLd: "Download LD",
modo: "Mode",
rungs: "Rungs",
contactos: "Contacts",
notas: "Technical notes",
notasTexto: "<b>Flexible industrial:</b> each output is minimized using only rows where that output equals 1. Rows with output 0 are not treated as global prohibitions. After minimizing each output, the application detects complete common factors across outputs and creates auxiliary relays only when they reduce total Ladder cost.",
resultado: "3) Result",
sinAnalisis: "Analysis has not been run yet.",
expresiones: "Minimized Boolean expressions",
ascii: "Simplified ASCII Ladder",