plc/PLC_RUN.CPP
2021-09-08 21:32:30 +02:00

1424 lines
51 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <dos.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <alloc.h>
#include <conio.h>
#include <stdlib.h>
#include <graphics.h>
#include "..\..\..\jd_lib\f_lib\make_bot.h" // Fuciones de MAKE_BOTON
#include "PLC.H"
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
struct Make_Boton {
unsigned int Up, Left, Down, Right;
unsigned char Cdf, Cb1, Cb2;
unsigned char Ab, Pb;
unsigned char Isc, Sc;
};
extern struct Make_Boton far *Botones; // Puntero a estructura
extern void Imprime_Boton_i(struct Make_Boton Bot_Imp);
extern int P_Sec(int numero);
extern int lee_objeto(FILE *);
extern void Deprime_Image(struct Make_Boton Bot_Imp);
extern void Imprime_Boton(int D_Bord, struct Make_Boton Bot_Imp);
extern char True_Push, // Parametros para el TRUE_PUSH
Push; // PRESION REAL !!!
extern void far *arrow; // YA !!!
extern int Secuencias, *n_Botones_Secuencia;
extern char memoria_asignada, vez;
extern struct Make_Boton far *Botones; // Puntero a estructura
void Anclar_Raton_PLC(void);
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//#define Comprueba_Secuencia_PLC(2) Comprueba_Secuencia(2)
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
extern int Muestra_Mensaje(int Mensaje, char *file) ;
extern Puertas DebugCode ;
extern void UpRow(void) ;
extern void DownRow(void) ;
extern void PrintCurrLine ( char Oculta_Mark, char Ultima ) ;
extern void PrintVisorLCD ( char Ultima ) ;
extern void MuestraLCD( char *texto1, char *texto2) ;
extern void redefine_cursor_raton(int r_e) ;
int Comprueba_Secuencia_PLC(char Sec_num ) ;
extern int CurrRow ,
CurrTopLine ;
extern char CurrCol ;
extern MemoriaRam *Ram;
extern FirmWare far *Programa;
extern char CurrCh_In ,
CurrCh_Out ;
extern Configuracion CFG;
char Running = 0;
void Run(void);
void Instala_Int8(void);
void DesInstala_Int8(void);
void Ejecuta_Programa(void);
void Ejecuta_Programa_BETA(void);
void remapea_relojes(void);
void Ejecuta_Programa(void)
{
}
void Instala_Int8(void){
}
void DesInstala_Int8(void){
}
void Run(void)
{
char ok = 0, Boton_Pulsado/*, Tipo_Run = 0*/;
Running = 1;
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
CFG.Int8.Bit = 0;
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
Imprime_Estaticos( 3, "PLC.dat");
// Fichero_bot(3);
redefine_cursor_raton(1); // Modo RUN
remapea_relojes();
if ( CFG.Int8.Bit ) Instala_Int8();
/*
else
Tipo_Run = 1;
*/
activa_raton();
do{
if ( CFG.Int8.Bit == 0 ) Ejecuta_Programa_BETA();
Boton_Pulsado = ( CFG.Int8.Bit ? Comprueba_Secuencia( 2 ) : Comprueba_Secuencia_PLC( 2 ) );
switch( Boton_Pulsado ) { // Iniciamos comprobacion
case 0: // No se pulso ningun BOTON
while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER
break;
case -1: // Hay una tecla especial en BUFFER
getch(); // La eliminamos
break;
case -2: // Hay una tecla especial en BUFFER
getch(); // La eliminamos
break;
case R_In0 :
case R_In1 :
case R_In2 :
case R_In3 :
case R_In4 :
case R_In5 :
case R_In6 :
case R_In7 :
case R_In8 :
case R_In9 :
case R_In10 :
case R_In11 :
case R_In12 :
case R_In13 :
case R_In14 :
case R_In15 :
if ( CurrCh_In != (5) ) {
if ( Ram -> In[Boton_Pulsado - R_In0][CurrCh_In].Bit == 1 ) {
// Ram -> CoIn[Boton_Pulsado - R_In0 ][CurrCh_In].Bit = Ram -> In[Boton_Pulsado - R_In0 ][CurrCh_In].Bit;
Ram -> In[Boton_Pulsado - R_In0 ][CurrCh_In].Bit = 0;
desactiva_raton();
Imprime_Bordes(2, Boton_Pulsado, -1);
activa_raton();
} else {
// Ram -> CoIn[Boton_Pulsado - R_In0 ][CurrCh_In].Bit = Ram -> In[Boton_Pulsado - R_In0 ][CurrCh_In].Bit;
Ram -> In[Boton_Pulsado - R_In0 ][CurrCh_In].Bit = 1;
desactiva_raton();
Imprime_Bordes(2, Boton_Pulsado, 2);
activa_raton();
}
}
break;
case R_Ch00_In :
case R_Ch01_In :
case R_Ch02_In :
case R_Ch03_In :
case R_Ch04_In :
case R_Ch19_In :
desactiva_raton();
Imprime_Bordes(2, (CurrCh_In + R_Ch00_In ), -1);
CurrCh_In = ( Boton_Pulsado - R_Ch00_In );
Imprime_Bordes(2, Boton_Pulsado, 4);
ReImprimeCanal_In(CurrCh_In);
activa_raton();
break;
case R_Ch00_Out :
case R_Ch01_Out :
case R_Ch02_Out :
case R_Ch03_Out :
case R_Ch04_Out :
case R_Ch19_Out :
desactiva_raton();
Imprime_Bordes(2, (CurrCh_Out + R_Ch00_Out ), -1);
CurrCh_Out = ( Boton_Pulsado - R_Ch00_Out );
Imprime_Bordes(2, Boton_Pulsado, 4);
ReImprimeCanal_Out(CurrCh_Out);
activa_raton();
break;
case R_Stop :
desactiva_raton();
Running = 0;
ok = 1;
break;
case R_Up :
desactiva_raton();
PrintCurrLine ( 0, 0 ); // Ocultamos linea anterior
UpRow();
Programa[10000] = Programa[CurrRow + CurrTopLine ];
PrintCurrLine( 1, 1 );
PrintVisorLCD ( 1 );
activa_raton();
break;
case R_Down :
desactiva_raton();
PrintCurrLine ( 0, 0 ); // Ocultamos linea anterior
DownRow();
Programa[10000] = Programa[ CurrRow + CurrTopLine ];
PrintCurrLine( 1, 1 );
PrintVisorLCD ( 1 );
activa_raton();
break;
default:
break;
}
if ( !Running ) ok = 1;
}while(!ok);
if ( CFG.Int8.Bit ) DesInstala_Int8();
Imprime_Estaticos( 4, "PLC.dat");
// Fichero_bot(4);
redefine_cursor_raton(2); // Modo Edit
}
void Ejecuta_Programa_BETA(void){
int pq_LD=0; // ¨ por cual LD va ?
// Hemos considerado cada LD un bloque de
// resultados l¢gicos entre las operaciones
// a realizar...
int i = 0; // Variable que ha de avanzar en el contador.
int Cpar;
Puertas ch;
for( i ; (Programa[i].Comando != End && i != 9999); i++ )
{
// Primero comprobamos el comando y ejecutamos el subcomando asociado.
switch( Programa[i].Comando)
{
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case 0 :
/*READ NOP ­­­­ Tambien es una funci¢n !!!! */
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Ld :
if( i > 0 && Programa[i-1].Comando == _Out ) pq_LD = 0;
pq_LD++;
switch ( Cpar = Programa[i].Parametros ) {
case 0 : // Sin Parametros
case P_Not :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out )
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato / 100)
{
// Canales de Entrada...
case 0: case 1: case 2: case 3: case 4:
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == 0 ) ?
Ram ->In [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
:
!Ram ->In [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
);
break;
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == 0 ) ?
Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit
:
!Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit
);
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: case 19:
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == 0 ) ?
Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [ (Programa[i].Dato / 100 ) - 10 ].Bit
:
!Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [ (Programa[i].Dato / 100 ) - 10 ].Bit
);
break;
}
break;
case P_Tr :
case P_Not_Tr :
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Tmp )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Tr ) ?
Ram ->Tr[ Programa[i].Dato ].Bit
:
!Ram ->Tr[ Programa[i].Dato ].Bit
);
break;
case P_Hr :
case P_Not_Hr :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out && ( Programa[i].Dato / 100) <= 9 )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Hr ) ?
Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
:
!Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
);
break;
case P_Cnt :
case P_Not_Cnt :
if ( ( Programa[i].Dato ) < Numero_Tim )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Cnt ) ?
Ram ->_Tim [Programa[i].Dato].Bit
:
!Ram ->_Tim [Programa[i].Dato].Bit
);
break;
case P_Tim :
case P_Not_Tim :
if ( ( Programa[i].Dato ) < Numero_Tim )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Tim ) ?
Ram ->_Tim [Programa[i].Dato].Bit
:
!Ram ->_Tim [Programa[i].Dato].Bit
);
break;
}
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Or :
switch ( Cpar = Programa[i].Parametros ) {
case 0 :
case P_Not :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out )
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato / 100)
{
// Canales de Entrada...
case 0: case 1: case 2: case 3: case 4:
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == 0 ) ?
Ram ->In [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
:
!Ram ->In [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
)
||
Ram ->_Ld[pq_LD].Bit;
break;
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == 0 ) ?
Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit
:
!Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit
)
||
Ram ->_Ld[pq_LD].Bit;
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: case 19:
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == 0 ) ?
Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [ (Programa[i].Dato / 100 ) - 10 ].Bit
:
!Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [ (Programa[i].Dato / 100 ) - 10 ].Bit
)
||
Ram ->_Ld[pq_LD].Bit;
break;
}
break;
case P_Ld :
Ram ->_Ld[1].Bit = ( Ram ->_Ld[1].Bit || Ram ->_Ld[2].Bit );
for(Cpar=2; Cpar<=pq_LD; Cpar++)
Ram ->_Ld[Cpar].Bit = Ram ->_Ld[ Cpar + 1 ].Bit;
pq_LD--;
break;
case P_Tr :
case P_Not_Tr :
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Tmp )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Tr ) ?
Ram ->Tr[ Programa[i].Dato ].Bit
:
!Ram ->Tr[ Programa[i].Dato ].Bit
)
||
Ram ->_Ld[pq_LD].Bit;
break;
case P_Hr :
case P_Not_Hr :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out && ( Programa[i].Dato / 100) <= 9 )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Hr ) ?
Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
:
!Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
)
||
Ram ->_Ld[pq_LD].Bit;
break;
case P_Cnt :
case P_Not_Cnt :
if ( ( Programa[i].Dato ) < Numero_Tim )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Cnt ) ?
Ram ->_Tim [Programa[i].Dato].Bit
:
!Ram ->_Tim [Programa[i].Dato].Bit
)
||
Ram ->_Ld[pq_LD].Bit;
break;
case P_Tim :
case P_Not_Tim :
if ( ( Programa[i].Dato ) < Numero_Tim )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Tim ) ?
Ram ->_Tim [Programa[i].Dato].Bit
:
!Ram ->_Tim [Programa[i].Dato].Bit
)
||
Ram ->_Ld[pq_LD].Bit;
break;
}
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case And :
switch ( Cpar = Programa[i].Parametros ) {
case 0 :
case P_Not :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out )
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato / 100)
{
// Canales de Entrada...
case 0: case 1: case 2: case 3: case 4:
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == 0 ) ?
Ram ->In [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
:
!Ram ->In [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
)
&&
Ram ->_Ld[pq_LD].Bit;
break;
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == 0 ) ?
Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit
:
!Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit
)
&&
Ram ->_Ld[pq_LD].Bit;
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: case 19:
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == 0 ) ?
Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [ (Programa[i].Dato / 100 ) - 10 ].Bit
:
!Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [ (Programa[i].Dato / 100 ) - 10 ].Bit
)
&&
Ram ->_Ld[pq_LD].Bit;
break;
}
break;
case P_Ld :
Ram ->_Ld[1].Bit = ( Ram ->_Ld[1].Bit && Ram ->_Ld[2].Bit );
for(Cpar=2; Cpar<=pq_LD; Cpar++)
Ram ->_Ld[Cpar].Bit = Ram ->_Ld[ Cpar + 1 ].Bit;
pq_LD--;
break;
case P_Tr :
case P_Not_Tr :
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Tmp )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Tr ) ?
Ram ->Tr[ Programa[i].Dato ].Bit
:
!Ram ->Tr[ Programa[i].Dato ].Bit
)
&&
Ram ->_Ld[pq_LD].Bit;
break;
case P_Hr :
case P_Not_Hr :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out && ( Programa[i].Dato / 100) <= 9 )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Hr ) ?
Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
:
!Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit
)
&&
Ram ->_Ld[pq_LD].Bit;
break;
case P_Cnt :
case P_Not_Cnt :
if ( ( Programa[i].Dato ) < Numero_Tim )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Cnt ) ?
Ram ->_Tim [Programa[i].Dato].Bit
:
!Ram ->_Tim [Programa[i].Dato].Bit
)
&&
Ram ->_Ld[pq_LD].Bit;
break;
case P_Tim :
case P_Not_Tim :
if ( ( Programa[i].Dato ) < Numero_Tim )
Ram ->_Ld[pq_LD].Bit = ( ( Cpar == P_Tim ) ?
Ram ->_Tim [Programa[i].Dato].Bit
:
!Ram ->_Tim [Programa[i].Dato].Bit
)
&&
Ram ->_Ld[pq_LD].Bit;
break;
}
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case _Out :
switch ( Cpar = Programa[i].Parametros ) {
case 0 :
case P_Not :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out )
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato / 100)
{
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
if ( Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit != ( ( Cpar == 0 ) ?
Ram ->_Ld[1].Bit
:
!Ram ->_Ld[1].Bit
) )
{
Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit = ( ( Cpar == 0 ) ?
Ram ->_Ld[1].Bit
:
!Ram ->_Ld[1].Bit
);
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )-5) )
{
desactiva_raton();
if ( ( ( Cpar == 0 ) ? Ram ->_Ld[1].Bit : !Ram ->_Ld[1].Bit ) )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), -1);
activa_raton();
}
}
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: // case 19:
if ( Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit != ( ( Cpar == 0 ) ?
Ram ->_Ld[1].Bit
:
!Ram ->_Ld[1].Bit
) )
{
// Ram ->CoRi[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit;
Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = ( ( Cpar == 0 ) ?
Ram ->_Ld[1].Bit
:
!Ram ->_Ld[1].Bit
);
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )-5) )
{
desactiva_raton();
if ( ( ( Cpar == 0 ) ? Ram ->_Ld[1].Bit : !Ram ->_Ld[1].Bit ) && ( Programa[i].Dato / 100) == 10 )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), -1);
activa_raton();
}
}
break;
}
break;
case P_Tr :
case P_Not_Tr :
if ( Programa[i].Dato < Numero_Tmp )
{
if ( Ram ->Tr [Programa[i].Dato].Bit != ( ( Cpar == P_Tr ) ?
Ram ->_Ld[1].Bit
:
!Ram ->_Ld[1].Bit
) )
Ram ->Tr [Programa[i].Dato].Bit = ( ( Cpar == P_Tr ) ?
Ram ->_Ld[1].Bit
:
!Ram ->_Ld[1].Bit
);
}
break;
case P_Hr :
case P_Not_Hr :
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out && ( Programa[i].Dato / 100) < 9 )
if ( Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit != ( ( Cpar == P_Hr ) ?
Ram ->_Ld[1].Bit
:
!Ram ->_Ld[1].Bit
) )
{
// Ram ->CoHr[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit;
Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = ( ( Cpar == P_Hr ) ?
Ram ->_Ld[1].Bit
:
!Ram ->_Ld[1].Bit
);
}
break;
}
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Tim :
if ( Programa[i].Dato < Numero_Tim )
if ( Ram -> _Ld[1].Bit == 0 )
{
Ram -> _Tim[ Programa[i].Dato ].Bit = 0;
Ram -> Tim_Cnt[ Programa[i].Dato ] = -1;
} else {
if ( Ram -> Tim_Cnt[ Programa[i].Dato ] < 0 )
Ram -> Tim_Cnt[ Programa[i].Dato ] = clock();
if ( ( ( ( clock() - Ram -> Tim_Cnt[ Programa[i].Dato ] ) / CLK_TCK ) * 10 ) >= Programa[i].SubDato )
Ram -> _Tim[ Programa[i].Dato ].Bit = 1;
}
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Cnt :
if ( pq_LD >= 2 && Programa[i].Dato < Numero_Tim )
{
if ( Ram -> _Ld[1].Bit && !Ram -> _Ld[2].Bit )
{
if ( Ram -> _Cnt[ Programa[i].Dato ].Bit != Ram -> _Ld[1].Bit )
if ( Ram -> Tim_Cnt[ Programa[i].Dato ] >= (Programa[i].SubDato - 1) )
Ram -> _Tim[ Programa[i].Dato ].Bit = 1;
else {
Ram -> Tim_Cnt[ Programa[i].Dato ]++;
Ram -> _Tim[ Programa[i].Dato ].Bit = 0;
}
}
if ( Ram -> _Ld[2].Bit )
{
Ram -> Tim_Cnt[ Programa[i].Dato ] = 0;
Ram -> _Tim[ Programa[i].Dato ].Bit = 0;
}
Ram -> _Cnt[ Programa[i].Dato ].Bit = Ram -> _Ld[1].Bit;
}
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Sft :
// Registro de desplazamiento vú2.0
if ( pq_LD >= 3 )
{
// Entrada de Reposici¢n
if ( Ram -> _Ld[3].Bit )
{
switch ( Programa[i].Parametros )
{
case 0 :
if ( (Programa[i].Dato - 5) <= 4 && (Programa[i].SubDato - 5) <= 4 )
for ( Cpar = (Programa[i].Dato - 5); Cpar <= (Programa[i].SubDato - 5); Cpar ++ )
for ( auto char Prop = 0; Prop < 16; Prop ++ )
if( Ram ->Out[ Prop ] [ Cpar ].Bit )
{
desactiva_raton();
Ram ->Out[ Prop ] [ Cpar ].Bit = 0;
if ( CurrCh_Out == Cpar )
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ( Prop + B_Out0), -1);
activa_raton();
}
else
if ( (Programa[i].Dato - 10) <= 8 && (Programa[i].SubDato - 10) <= 8 )
for ( Cpar = (Programa[i].Dato - 10); Cpar <= (Programa[i].SubDato - 10); Cpar ++ )
for ( auto char Prop = 0; Prop < 16; Prop ++ )
if ( Ram ->Ri [ Prop ] [ Cpar ].Bit )
{
Ram ->Ri [ Prop ] [ Cpar ].Bit = 0;
if ( CurrCh_Out == Cpar )
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ( Prop + B_Out0), -1);
}
break;
case P_Hr:
if ( Programa[i].Dato <= 9 )
for ( Cpar = (Programa[i].Dato - 5); Cpar <= (Programa[i].SubDato - 5); Cpar ++ )
for ( auto char Prop = 0; Prop < 16; Prop ++ )
{
Ram ->Hr [ Prop ] [ Cpar ].Bit = 0;
if ( CurrCh_Out == Cpar )
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ( Prop + B_Out0), -1);
}
break;
}
} else {
if ( !Ram -> Pre_Ld[i].Bit && Ram -> _Ld[2].Bit )
{
auto char Prop;
switch ( Programa[i].Parametros )
{
case 0 :
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato)
{
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( (Programa[i].SubDato-5) < (Numero_Out - 1) )
{
for ( Cpar = (Programa[i].SubDato - 5); Cpar >=(signed int)(Programa[i].Dato - 5); Cpar -- )
for ( Prop = 15; Prop >= 0; Prop-- )
{
if ( Prop != 0 )
{
if(Ram ->Out[ Prop ] [ Cpar ].Bit != Ram -> Out[Prop - 1][Cpar].Bit)
{
Ram ->Out[ Prop ] [ Cpar ].Bit = Ram -> Out[Prop - 1][Cpar].Bit;
if ( CurrCh_Out == Cpar )
{
desactiva_raton();
if ( Ram ->Out[ Prop ] [ Cpar ].Bit )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ( Prop + B_Out0), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ( Prop + B_Out0), -1);
activa_raton();
}
}
}
else if( Cpar != 0 )
if(Ram ->Out[ Prop ] [ Cpar ].Bit != Ram -> Out[15][Cpar-1].Bit)
{
Ram ->Out[ Prop ] [ Cpar ].Bit = Ram -> Out[15][Cpar-1].Bit;
if ( CurrCh_Out == Cpar )
{
desactiva_raton();
if ( Ram ->Out[ Prop ] [ Cpar ].Bit )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ( Prop + B_Out0), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ( Prop + B_Out0), -1);
activa_raton();
}
}
}
if (Ram ->Out[ 0 ] [ (signed int)(Programa[i].Dato - 5) ].Bit != Ram -> _Ld[1].Bit )
{
Ram ->Out[ 0 ] [ (signed int)(Programa[i].Dato - 5) ].Bit = Ram -> _Ld[1].Bit;
if ( CurrCh_Out == (signed int)(Programa[i].Dato - 5) )
{
desactiva_raton();
if ( Ram ->Out[ 0 ] [ (signed int)(Programa[i].Dato - 5) ].Bit )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ( B_Out0 ), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ( B_Out0 ), -1);
activa_raton();
}
}
}
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: // case 19:
if ( (Programa[i].SubDato-10) <= 8 )
{
for ( Cpar = (Programa[i].SubDato - 10); Cpar >= (signed int)(Programa[i].Dato - 10); Cpar -- )
for ( Prop = 8; Prop >= 0; Prop-- )
{
if ( Prop != 0 )
if ( Ram ->Ri [ Prop ] [ Cpar ].Bit != Ram -> Ri [Prop - 1][Cpar].Bit )
{
Ram ->Ri [ Prop ] [ Cpar ].Bit = Ram -> Ri [Prop - 1][Cpar].Bit;
if ( CurrCh_Out == 5 )
{
desactiva_raton();
if ( Ram ->Out[ Prop ] [ Cpar ].Bit )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ( Prop + B_Out0), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ( Prop + B_Out0), -1);
activa_raton();
}
}
else if( Cpar != 0 )
if ( Ram ->Ri [ Prop ] [ Cpar ].Bit != Ram -> Ri [16][Cpar-1].Bit )
{
Ram ->Ri [ Prop ] [ Cpar ].Bit = Ram -> Ri [16][Cpar-1].Bit;
if ( CurrCh_Out == 5 )
{
desactiva_raton();
if ( Ram ->Out[ Prop ] [ Cpar ].Bit )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ( Prop + B_Out0), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ( Prop + B_Out0), -1);
activa_raton();
}
}
}
if(Ram ->Ri [ 0 ] [ (signed int)(Programa[i].Dato-10) ].Bit != Ram -> _Ld[1].Bit)
{
desactiva_raton();
Ram ->Ri [ 0 ] [ (signed int)(Programa[i].Dato-10) ].Bit = Ram -> _Ld[1].Bit;
if ( CurrCh_Out == 5 )
if ( Ram ->Out[ 0 ] [ (signed int)(Programa[i].Dato-10) ].Bit )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ( Prop + B_Out0), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ( Prop + B_Out0), -1);
activa_raton();
}
}
break;
}
break;
case P_Hr :
// Canales de Internos no volatiles. ( HR ).
if ( (Programa[i].SubDato) <= 9 && (Programa[i].SubDato-9) <= 9 )
{
for ( Cpar = (Programa[i].SubDato - 9); Cpar >= (signed int)(Programa[i].Dato - 9); Cpar -- )
for ( Prop = 8; Prop >= 0; Prop-- )
{
if ( Prop != 0 )
Ram ->Hr [ Prop ] [ Cpar ].Bit = Ram -> Hr [Prop - 1][Cpar].Bit;
else if( Cpar != 0 )
Ram ->Hr [ Prop ] [ Cpar ].Bit = Ram -> Hr [16][Cpar-1].Bit;
}
Ram ->Hr [ 0 ] [ (signed int)(Programa[i].Dato-9) ].Bit = Ram -> _Ld[1].Bit;
}
break;
}
}
}
pq_LD = 0;
}
{
Ram -> Pre_Ld[i].Bit = Ram -> _Ld[2].Bit;
ch.Bit = 0;
}
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Keep :
if ( pq_LD >= 2 )
{
char ok;
switch ( Programa[i].Parametros ) {
case 0 :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out )
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato / 100)
{
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
ok = Ram -> Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit;
if( Ram -> _Ld[ 1 ].Bit && !Ram -> _Ld[ 2 ].Bit ) Ram -> Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit = 1;
if( Ram -> _Ld[ 2 ].Bit ) Ram -> Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit = 0;
if( ok != Ram -> Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit )
{
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )-5) )
{
desactiva_raton();
if ( Ram -> Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), -1);
activa_raton();
}
}
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: // case 19:
ok = Ram -> Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )].Bit;
if( Ram -> _Ld[ 1 ].Bit && !Ram -> _Ld[ 2 ].Bit ) Ram -> Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-10].Bit = 1;
if( Ram -> _Ld[ 2 ].Bit ) Ram -> Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-10].Bit = 0;
if( ok != Ram -> Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-10].Bit )
{
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )) )
{
desactiva_raton();
if ( ( Ram ->_Ld[ 1 ].Bit ) && ( Programa[i].Dato / 100) == 10 )
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), 2);
else
// Ponemos el borde correspondiente a OFF
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), -1);
activa_raton();
}
}
break;
}
break;
case P_Hr :
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out && ( Programa[i].Dato / 100) < 9 )
{
if( Ram -> _Ld[1].Bit && !Ram -> _Ld[2].Bit ) Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = 1;
if( Ram -> _Ld[2].Bit ) Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = 1;
}
break;
}
}
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case DifU :
// printf("%d %d\n",Ram -> Pre_Ld[i].Bit, Ram -> _Ld[1].Bit);
if ( !Ram -> Pre_Ld[i].Bit && Ram -> _Ld[1].Bit )
{
switch ( Programa[i].Parametros ) {
case 0 :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out )
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato / 100)
{
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit = 1;
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )-5) )
{
desactiva_raton();
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), 2);
activa_raton();
}
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: // case 19:
Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100) - 10].Bit = 1;
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )-5) )
{
desactiva_raton();
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), 2);
activa_raton();
}
break;
}
case P_Hr :
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out && ( Programa[i].Dato / 100) < 9 )
Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = 1;
break;
}
}
else
// Si el Dato esta activo se desactiva...
switch ( Programa[i].Parametros ) {
case 0 :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out )
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato / 100)
{
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
if ( Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit )
{
Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit = 0;
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )-5) )
{
desactiva_raton();
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), -1);
activa_raton();
}
}
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: // case 19:
if ( Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100) - 10].Bit )
{
Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100) - 10].Bit = 0;
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )-5) )
{
desactiva_raton();
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), -1);
activa_raton();
}
}
break;
}
case P_Hr :
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out && ( Programa[i].Dato / 100) < 9 )
Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = 0;
break;
}
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case DifD :
if ( Ram -> Pre_Ld[i].Bit && !Ram -> _Ld[1].Bit )
{
switch ( Programa[i].Parametros ) {
case 0 :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out )
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato / 100)
{
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit = 1;
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )-5) )
{
desactiva_raton();
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), 2);
activa_raton();
}
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: // case 19:
Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100)-10 ].Bit = 1;
if ( CurrCh_Out == 5 )
{
desactiva_raton();
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), 2);
activa_raton();
}
break;
}
case P_Hr :
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out && ( Programa[i].Dato / 100) < 9 )
Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = 1;
break;
}
}
else
// Si el Dato esta activo se desactiva...
switch ( Programa[i].Parametros ) {
case 0 :
// Miro si esta en el rango de Ch(xx00-15) [N§ IO's]
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out )
// Miro que canal esta usando para canalizarlo correctamente
switch ( Programa[i].Dato / 100)
{
// Canales de Salida...
case 5: case 6: case 7: case 8: case 9:
if ( Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit )
{
Ram ->Out[( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100 )-5].Bit = 0;
if ( CurrCh_Out == ( (Programa[i].Dato / 100 )-5) )
{
desactiva_raton();
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), -1);
activa_raton();
}
}
break;
// Canales de Internos ( Reles Internos ).
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: // case 19:
if ( Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100)-10 ].Bit )
{
Ram ->Ri [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [(Programa[i].Dato / 100)-10 ].Bit = 0;
if ( CurrCh_Out == 5 )
{
desactiva_raton();
// Ponemos el borde correspondiente a ON
Imprime_Bordes(1, ((( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )) + B_Out0), -1);
activa_raton();
}
}
break;
}
case P_Hr :
if ( ( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 ) < Numero_Out && ( Programa[i].Dato / 100) < 9 )
Ram ->Hr [( Programa[i].Dato - ( Programa[i].Dato / 100 ) * 100 )] [Programa[i].Dato / 100 ].Bit = 0;
break;
}
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case TimH :
if ( Programa[i].Dato < Numero_Tim )
if ( Ram -> _Ld[1].Bit == 0 )
{
Ram -> _Tim[ Programa[i].Dato ].Bit = 0;
Ram -> Tim_Cnt[ Programa[i].Dato ] = -1;
} else {
if ( Ram -> Tim_Cnt[ Programa[i].Dato ] < 0 )
Ram -> Tim_Cnt[ Programa[i].Dato ] = clock();
if ( ( ( ( clock() - Ram -> Tim_Cnt[ Programa[i].Dato ] ) / CLK_TCK ) * 100 ) >= Programa[i].SubDato )
Ram -> _Tim[ Programa[i].Dato ].Bit = 1;
}
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Cmp :
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Mov :
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Mvn :
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Add :
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Sub :
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Stc :
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Clc :
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case End :
pq_LD = 0;
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Il :
break;
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
case Ilc :
break;
default:
Muestra_Mensaje(501, "PLC.DAT");
Running = 0;
break;
}
////// Mantiene los relojes de TIEMPO
/////////////////////////////////////////////////////////////////////
/////////////////// Contadores internos 1900 a 1902 /////////////////
/////////////////////////////////////////////////////////////////////
/* 1900 0'1s 0'05s */
/* 1901 0'2s 0'1 s */
/* 1902 1 s 0'5 */
//////////////////////////////////////
// 1900
if ( ( ( (clock() - Ram ->Contador_de_Tiempo[0] ) / CLK_TCK) ) >= 0.05 )
if ( Ram ->Ri [ 0 ] [ 9 ].Bit == 0 )
{
Ram ->Ri [ 0 ] [ 9 ].Bit = 1;
Ram ->Contador_de_Tiempo[0] = clock();
if ( CurrCh_In == 5 )
{
desactiva_raton();
Imprime_Bordes(2, (R_In0 + 0), -1);
activa_raton();
}
} else {
Ram ->Ri [ 0 ] [ 9 ].Bit = 0;
Ram ->Contador_de_Tiempo[0] = clock();
if ( CurrCh_In == 5 )
{
desactiva_raton();
Imprime_Bordes(2, (R_In0 + 0), 2);
activa_raton();
}
}
// 1901
if ( ( ( (clock() - Ram ->Contador_de_Tiempo[1] ) / CLK_TCK) ) >= 0.1 )
if ( Ram ->Ri [ 1 ] [ 9 ].Bit == 0 )
{
Ram ->Ri [ 1 ] [ 9 ].Bit = 1;
Ram ->Contador_de_Tiempo[1] = clock();
if ( CurrCh_In == 5 )
{
desactiva_raton();
Imprime_Bordes(2, (R_In0 + 1), -1);
activa_raton();
}
} else {
Ram ->Ri [ 1 ] [ 9 ].Bit = 0;
Ram ->Contador_de_Tiempo[1] = clock();
if ( CurrCh_In == 5 )
{
desactiva_raton();
Imprime_Bordes(2, (R_In0 + 1), 2);
activa_raton();
}
}
// 1902
if ( ( ( (clock() - Ram ->Contador_de_Tiempo[2] ) / CLK_TCK) ) >= 0.5 )
if ( Ram ->Ri [ 2 ] [ 9 ].Bit == 0 )
{
Ram ->Ri [ 2 ] [ 9 ].Bit = 1;
Ram ->Contador_de_Tiempo[2] = clock();
if ( CurrCh_In == 5 )
{
desactiva_raton();
Imprime_Bordes(2, (R_In0 + 2), -1);
activa_raton();
}
} else {
Ram ->Ri [ 2 ] [ 9 ].Bit = 0;
Ram ->Contador_de_Tiempo[2] = clock();
if ( CurrCh_In == 5 )
{
desactiva_raton();
Imprime_Bordes(2, (R_In0 + 2), 2);
activa_raton();
}
}
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
if ( ch.Bit )
Ram -> Pre_Ld[i].Bit = Ram -> _Ld[1].Bit;
else
ch.Bit = 1;
}
if ( i == 9999 )
{
Muestra_Mensaje(500, "PLC.DAT");
Running = 0;
return;
}
}
// Esta funci¢n se diferencia de la original, en no ser fija: es decir que
// tras cada llamada vuelve, se pulse o no un boton, para poder continuar
// utilizando MB y otras cosas a la vez....
int Comprueba_Secuencia_PLC(char Sec_num )
{
// char boton_izq=0, boton_der=0;
char key, key2=0;
char i, Pulso = 0;
int psec = P_Sec(Sec_num-1);
union REGS io;
io.x.ax = 3;
if ( kbhit() ) {
if ( (key = getch())==0) key2 = getch();
for(i=0; i<n_Botones_Secuencia[Sec_num-1]; i++)
if( toupper( key ) == Botones[psec+i].Isc && key2 == Botones[psec+i].Sc) {
Push = ON;
desactiva_raton();
Imprime_Boton_i(Botones[psec+i]);
delay(50);
if( Push == ON && True_Push == ON ) Deprime_Image(Botones[psec+i]);
Push = OFF;
Imprime_Boton(0, Botones[psec+i]);
activa_raton();
return i+1;
}
if(key==0) { ungetch(key2); return (-1);
} else { ungetch(key); return (-2); }
}
int86(0x33, &io, &io); // lee posici¢n y estados del bot¢n
if ( io.x.bx & 1 )
{
// boton_der = (io.x.bx >> 1) & 1;
x_raton = io.x.cx;
y_raton = io.x.dx;
for(i = 0; i < n_Botones_Secuencia[Sec_num-1]; i++)
if( (x_raton >= Botones[psec+i].Left) && (x_raton <= Botones[psec+i].Right) &&
(y_raton >= Botones[psec+i].Up) && (y_raton <= Botones[psec+i].Down) ) {
Pulso = i + 1;
Push = ON;
desactiva_raton();
Imprime_Boton_i(Botones[psec+Pulso-1]);
Anclar_Raton_PLC();
// delay(10);
if( Push == ON && True_Push == ON ) Deprime_Image(Botones[psec+Pulso-1]);
Push = OFF;
Imprime_Boton(0, Botones[psec+Pulso-1]);
activa_raton();
return Pulso;
}
}
return (0);
}
void Anclar_Raton_PLC(void){
union REGS io;
io.x.ax = 3;
do {
int86(0x33, &io, &io);
Ejecuta_Programa_BETA();
} while( (io.x.bx & 1)==1 || ((io.x.bx >> 1) & 1)==1);
}
void remapea_relojes(void)
{
int i, ch;
for( i=0; i<200; i++ )
Ram -> _Ld[i].Bit = 0;
for( i=0; i<9999; i++ )
Ram -> Pre_Ld[i].Bit = 0;
for(ch=0;ch<10;ch++ )
for( i=0; i<Numero_Out; i++ )
Ram ->Hr[i][ch].Bit;
for(ch=0;ch<10;ch++ )
for( i=0; i<Numero_Out; i++ )
Ram ->Ri[i][ch].Bit;
for(ch=0;ch<Numero_Tmp;ch++ )
Ram ->Tr[ch].Bit;
for(ch=0;ch<Numero_Tim;ch++ )
Ram ->_Cnt[ch].Bit;
for(ch=0;ch<Numero_Tim;ch++ )
Ram ->_Tim[ch].Bit;
/*
for(ch=0;ch<3;ch++ )
Ram ->Bt[i].Bit = 1;
*/
for(ch=0;ch<Numero_Tim;ch++ )
Ram ->Tim_Cnt[ch] = 0;
for(ch=0;ch<3;ch++ )
Ram ->Contador_de_Tiempo[ch] = clock();
}