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

1804 lines
45 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <dir.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"
extern void Acerca_de( void );
extern MemoriaRam *Ram;
extern FirmWare far *Programa;
extern void Run(void);
extern char Optar( char *texto1, char *texto2, char *texto3 );
char file_browser( char *comodin_name, char *texto1, char Cargar_Salvar );
int Muestra_Mensaje(int Mensaje, char *file);
void BEEP(void) ;
void UpRow(void) ;
void DownRow(void) ;
void Configurar(void) ;
void BuscarItem(void) ;
void GetProgram(void) ;
void SendProgram(void) ;
void LoadProgram(void) ;
void WriteProgram(void) ;
void PrintWholeScreen (void) ;
int Select_Columna_Up(void) ;
int Select_Columna_Down(void) ;
void Numero_Pulsado(char numero) ;
void DelRow( void ) ;
void AddRow( char Arriba_Abajo ) ;
void PrintCurrLine ( char Oculta_Mark, char Ultima ) ;
void PrintVisorLCD ( char Ultima ) ;
void MuestraLCD( char *texto1, char *texto2) ;
Configuracion CFG;
void CFG_File( char Cargar_Salvar );
#define Salvar 1
#define Cargar 2
char Buffer_Teclado[16], BT = 0;
Puertas DebugCode;
int CurrRow = 0,
CurrTopLine = 0;
char CurrCol = 0;
char CurrCh_In = 0,
CurrCh_Out = 0;
int Menu_Edicion(void){
int Boton_Pulsado, ok = 0;
PrintWholeScreen ();
CurrRow = 0; CurrTopLine = 0;
PrintCurrLine(1, 0);
PrintVisorLCD ( 0 );
do{
Boton_Pulsado = Comprueba_Secuencia( 1 );
switch( Boton_Pulsado ) { // Iniciamos comprobacion
case 0: // No se pulso ningun BOTON
while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER
Anclar_Raton();
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 B_In0 :
case B_In1 :
case B_In2 :
case B_In3 :
case B_In4 :
case B_In5 :
case B_In6 :
case B_In7 :
case B_In8 :
case B_In9 :
case B_In10 :
case B_In11 :
case B_In12 :
case B_In13 :
case B_In14 :
case B_In15 :
if ( CurrCh_In != (5) ) {
if ( Ram -> In[Boton_Pulsado - B_In0][CurrCh_In].Bit == 1 ) {
// Ram -> CoIn[Boton_Pulsado - B_In0 ][CurrCh_In].Bit = Ram -> In[Boton_Pulsado - B_In0 ][CurrCh_In].Bit;
Ram -> In[Boton_Pulsado - B_In0 ][CurrCh_In].Bit = 0;
Imprime_Bordes(1, Boton_Pulsado, -1);
} else {
// Ram -> CoIn[Boton_Pulsado - B_In0 ][CurrCh_In].Bit = Ram -> In[Boton_Pulsado - B_In0 ][CurrCh_In].Bit;
Ram -> In[Boton_Pulsado - B_In0 ][CurrCh_In].Bit = 1;
Imprime_Bordes(1, Boton_Pulsado, 2);
}
}
break;
case B_Ch00_In :
case B_Ch01_In :
case B_Ch02_In :
case B_Ch03_In :
case B_Ch04_In :
case B_Ch19_In :
Imprime_Bordes(1, (CurrCh_In + B_Ch00_In ), -1);
CurrCh_In = ( Boton_Pulsado - B_Ch00_In );
Imprime_Bordes(1, Boton_Pulsado, 4);
ReImprimeCanal_In(CurrCh_In);
break;
case B_Ch00_Out :
case B_Ch01_Out :
case B_Ch02_Out :
case B_Ch03_Out :
case B_Ch04_Out :
case B_Ch19_Out :
Imprime_Bordes(1, (CurrCh_Out + B_Ch00_Out ), -1);
CurrCh_Out = ( Boton_Pulsado - B_Ch00_Out );
Imprime_Bordes(1, Boton_Pulsado, 4);
ReImprimeCanal_Out(CurrCh_Out);
break;
case B_AcercaDe :
Acerca_de();
break;
case B_Fun :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
Programa[10000].Comando = Fun;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
}
break;
case B_Sft :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
Programa[10000].Comando = Sft;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
CurrCol = 1;
}
break;
case B_Not :
// gotoxy(1,1); printf("Not %3d", Boton_Pulsado);
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
// Funciones que admiten un NOT
switch( Programa[10000].Comando ) {
case Ld :
case And :
case Or :
case _Out :
Programa[10000].Parametros = P_Not;
break;
default:
break;
}
}
break;
case B_Run :
BT = 0;
Run();
// gotoxy(1,1); printf("Run %3d", Boton_Pulsado);
break;
case B_And :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
Programa[10000].Comando = And;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
}
break;
case B_Or :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
Programa[10000].Comando = Or;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
}
break;
case B_Cnt :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
// Funciones que admiten un Cnt
switch( Programa[10000].Comando ) {
case Ld :
case And :
case Or :
if ( Programa[10000].Parametros == P_Not )
Programa[10000].Parametros = P_Not_Cnt;
else if ( Programa[10000].Parametros == 0 )
Programa[10000].Parametros = P_Cnt;
else {
Programa[10000].Comando = Cnt;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
CurrCol = 1;
}
break;
default:
Programa[10000].Comando = Cnt;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
CurrCol = 1;
break;
}
}
break;
case B_Tr :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
// Funciones que admiten un Tr
switch( Programa[10000].Comando ) {
case Ld :
case And :
case Or :
case _Out :
if ( Programa[10000].Parametros == P_Not )
Programa[10000].Parametros = P_Not_Tr;
else if ( Programa[10000].Parametros == 0 )
Programa[10000].Parametros = P_Tr;
/*
else {
Programa[10000].Comando = _Tr;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
}
*/
break;
default:
break;
}
}
break;
case B_Lr :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
break;
case B_Hr :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
// gotoxy(1,1); printf("Hr %3d", Boton_Pulsado);
// Funciones que admiten un Hr
switch( Programa[10000].Comando ) {
case Ld :
case And :
case Or :
case _Out :
case Keep :
case DifU :
case DifD :
case Sft :
case Cmp :
case Mov :
case Mvn :
case Add :
case Sub :
if ( Programa[10000].Parametros == P_Not )
Programa[10000].Parametros = P_Not_Hr;
else
Programa[10000].Parametros = P_Hr;
break;
default:
break;
}
}
break;
case B_Ld :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
// Funciones que admiten un Ld
switch( Programa[10000].Comando ) {
case And :
case Or :
if( Programa[10000].Parametros == 0 )
Programa[10000].Parametros = P_Ld;
else {
Programa[10000].Comando = Ld;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
}
break;
default:
Programa[10000].Comando = Ld;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
break;
}
}
break;
case B_Out :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
Programa[10000].Comando =_Out;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
}
break;
case B_Tim :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
// Funciones que admiten un Tim
switch( Programa[10000].Comando ) {
case Ld :
case And :
case Or :
if ( Programa[10000].Parametros == P_Not )
Programa[10000].Parametros = P_Not_Tim;
else if ( Programa[10000].Parametros == 0 )
Programa[10000].Parametros = P_Tim;
else {
Programa[10000].Comando = Tim;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
CurrCol = 1;
}
break;
default:
Programa[10000].Comando = Tim;
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
CurrCol = 1;
break;
}
}
break;
case B_Dm :
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
break;
case B_Ch :
/*
if ( CurrCol == 0 || CurrCol == 1 ) {
BT = 0;
// Funciones que admiten un Tim
switch( Programa[10000].Comando ) {
case Ld :
case And :
case Or :
if ( Programa[10000].Parametros == P_Not )
Programa[10000].Parametros = P_Not_Tim;
else
Programa[10000].Parametros = P_Tim;
break;
default:
break;
}
}
*/
break;
case B_Cont :
BT = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
break;
case B_Ext :
BT = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
break;
case B_Chg :
BT = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
break;
case B_Scrh :
BT = 0;
BuscarItem();
break;
case B_Play :
BT = 0;
GetProgram();
break;
case B_Del :
Buffer_Teclado[BT] = B_Del;
BT++;
break;
case B_Mont :
BT = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
break;
case B_Rec :
BT = 0;
SendProgram();
break;
case B_Ins :
Buffer_Teclado[BT] = B_Ins;
BT++;
break;
case B_Up :
if ( Buffer_Teclado[0] == B_Ins ) {
BT = 0;
MuestraLCD( "", " Insert Line ?");
if ( Comprueba_Secuencia( 1 ) == B_Up )
AddRow( 0 );
}
else
if ( Buffer_Teclado[0] == B_Del ) {
BT = 0;
MuestraLCD( "", " Delete Line ?");
if ( Comprueba_Secuencia( 1 ) == B_Up )
DelRow( );
} else {
BT = 0;
PrintCurrLine ( 0, 0 ); // Ocultamos linea anterior
UpRow();
Programa[10000] = Programa[CurrRow + CurrTopLine ];
}
break;
case B_Clr :
BT = 0;
Programa[10000] = Programa[CurrRow + CurrTopLine ];
break;
case B_Ver :
BT = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F> <20>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱<EFBFBD>۱ <20>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
break;
case B_Write :
BT = 0;
if ( Programa[ 10000 ].Comando == Fun ) {
switch ( Programa[ 10000 ].Dato + 100) {
case Sft : // Registro de desplazamiento
case Add : // Add (Suma en BCD)
case Sub : // Subtract ( Resta en BCD )
case TimH : // Temporizador de alta velocidad
case Cmp : // Comparador
case Mov : // Move
case Mvn : // Move Not
Programa[ 10000 ].Comando = 100 + Programa[ 10000 ].Dato;
Programa[ 10000 ].Dato = 0;
CurrCol = 1;
break;
case End : // Final de programa
case Il : // Instrucci<63>n de condici<63>n
case Ilc : // Instrucci<63>n fin de condici<63>n
case Keep : // Switch biestable ( Rel<65> Latch )
case DifU : // Activador en el flanco de subida
case DifD : // Activador en el flanco de bajada
case Stc : // Introduce un 1 en el flag de acarreo
case Clc : // Borra el flag de acarreo
Programa[ 10000 ].Comando = 100 + Programa[ 10000 ].Dato;
Programa[ 10000 ].Dato = 0;
break;
default:
break;
}
Programa[10000].Parametros = 0;
Programa[10000].Dato = 0;
Programa[10000].SubDato = 0;
// // Confirma linea editada y la copia en la DIRECCION REAL
// Programa[ CurrRow + CurrTopLine ] = Programa[ 10000 ];
} else {
// Confirma linea editada y la copia en la DIRECCION REAL
Programa[ CurrRow + CurrTopLine ] = Programa[ 10000 ];
PrintCurrLine ( 0, 1 ); // Ocultamos linea anterior
DownRow();
Programa[10000] = Programa[ CurrRow + CurrTopLine ];
}
break;
case B_Down :
if ( Buffer_Teclado[0] == B_Ins ) {
BT = 0;
MuestraLCD( "", " Insert Line ?");
if ( Comprueba_Secuencia( 1 ) == B_Down )
AddRow( 1 );
}
else
if ( Buffer_Teclado[0] == B_Del ) {
BT = 0;
MuestraLCD( "", " Delete Line ?");
if ( Comprueba_Secuencia( 1 ) == B_Down )
DelRow( );
} else {
PrintCurrLine ( 0, 0 ); // Ocultamos linea anterior
DownRow();
Programa[10000] = Programa[ CurrRow + CurrTopLine ];
}
break;
case B_DebugCode :
DebugCode.Bit = ( DebugCode.Bit ? 0 : 1 ) ;
break;
case B_ResetValores :
Resetea_Memoria();
ReImprimeCanal_In (CurrCh_In );
ReImprimeCanal_Out(CurrCh_Out);
break;
case B_Configurar :
Configurar();
break;
case B_Reset :
if ( Optar( "Confirme borrado", "total de DATOS","" ) == 1 ) {
Resetea_Memoria();
ReImprimeCanal_In (CurrCh_In );
ReImprimeCanal_Out(CurrCh_Out);
Reset_Programa();
CurrRow = 0; CurrTopLine = 0;
PrintWholeScreen();
PrintCurrLine( 1, 0 );
}
break;
case B_Salvar :
WriteProgram();
break;
case B_Cargar :
LoadProgram();
break;
case B_Salir :
ok = 1;
break;
case B_0 :
BT = 0;
Numero_Pulsado( 0 );
break;
case B_1 :
BT = 0;
Numero_Pulsado( 1 );
break;
case B_2 :
BT = 0;
Numero_Pulsado( 2 );
break;
case B_3 :
BT = 0;
Numero_Pulsado( 3 );
break;
case B_4 :
BT = 0;
Numero_Pulsado( 4 );
break;
case B_5 :
BT = 0;
Numero_Pulsado( 5 );
break;
case B_6 :
BT = 0;
Numero_Pulsado( 6 );
break;
case B_7 :
BT = 0;
Numero_Pulsado( 7 );
break;
case B_8 :
BT = 0;
Numero_Pulsado( 8 );
break;
case B_9 :
BT = 0;
Numero_Pulsado( 9 );
break;
default:
break;
}
PrintCurrLine( 1, 1 );
PrintVisorLCD ( 1 );
if ( BT == 0 ) {
for ( BT = 0; BT < 16; BT ++ )
Buffer_Teclado[BT] = 0;
BT = 0;
}
}while(!ok);
return ok;
}
void Resetea_Memoria(void){
int i, ch;
// Resetea Salidas
for( ch = 0;ch < 6 ;ch++ )
for( i = 0; i < Numero_Out ; i++ )
Ram -> Out [i][ch].Bit = 0;
// Resetea Entradas
for( ch = 0;ch < 6 ;ch++ )
for( i = 0; i < Numero_Out ; i++ )
Ram -> In [i][ch].Bit = 0;
/*
// Resetea Salidas Internas
for( ch = 0;ch < 9 ;ch++ )
for( i = 0; i < Numero_Out ; i++ )
Ram -> Out2 [i][ch].Bit = 0;
*/
// Resetea Salidas no volatiles
for( ch = 0;ch < 9 ;ch++ )
for( i = 0; i < Numero_Out ; i++ )
Ram -> Hr [i][ch].Bit = 0;
for( i = 0; i < Numero_Tmp ; i++ )
Ram -> Tr [i] .Bit = 0;
for( i = 0; i < Numero_Tim ; i++ )
Ram -> Tim_Cnt [i] = 0;
}
void Reset_Programa(void){
int i=0;
for ( i; i<10001; i++ )
{
Programa[i].Comando = 0;
Programa[i].Parametros = 0;
Programa[i].Dato = 0;
Programa[i].SubDato = 0;
}
}
void Abandona_Programa(char *texto, long valor){
// Comprobar donde estamos. ( Texto / Gr<47>fico )
closegraph();
cprintf("\n%s <%ld>", texto, valor );
exit(valor);
}
void ReImprimeCanal_In(int Canal){
int i;
for ( i = 0; i < Numero_In; i++ )
if ( Ram -> In[i][Canal].Bit == 1 ) {
Imprime_Bordes(1, (i+B_In0), 2);
} else {
Imprime_Bordes(1, (i+B_In0), -1);
}
}
void ReImprimeCanal_Out(int Canal){
int i;
for ( i = 0; i < Numero_Out; i++ )
if ( Ram -> Out[i][Canal].Bit == 1 ) {
Imprime_Bordes(1, (i+B_Out0), 2);
} else {
Imprime_Bordes(1, (i+B_Out0), -1);
}
}
void PrintWholeScreen (void)
{
int OldCurrRow = CurrRow ;
char Contador;
PrintCurrLine ( 0, 0 );
for ( Contador = 0; Contador < 10; Contador++ )
DownRow();
CurrRow = OldCurrRow;
}
void PrintCurrLine ( char Oculta_Mark, char Ultima )
{
char Buffer[80] ;
int Buff_int ;
settextstyle( SMALL_FONT, HORIZ_DIR, 5 );
// Solo 11 Lineas de 5 puntos
if ( Oculta_Mark == 0 ) {
setfillstyle( SOLID_FILL, 0 );
bar( 7, (176 + ( ( CurrRow ) * 15 ) ), 84, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
bar( 102, (176 + ( ( CurrRow ) * 15 ) ), 225, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
bar( 242, (176 + ( ( CurrRow ) * 15 ) ), 419, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
setcolor(CFG.Colores.Texto );
Buff_int = (CurrRow + CurrTopLine);
}else{
setfillstyle( SOLID_FILL, 0 );
bar( 242, (176 + ( ( CurrRow ) * 15 ) ), 419, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
setfillstyle( SOLID_FILL, CFG.Colores.F_Texto );
bar( 7, (176 + ( ( CurrRow ) * 15 ) ), 84, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
bar( 102, (176 + ( ( CurrRow ) * 15 ) ), 225, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
switch( CurrCol ) {
case 1: // Primera Zona
bar( 242, (176 + ( ( CurrRow ) * 15 ) ), 301, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
break;
case 2: // Segunda Zona
bar( 301, (176 + ( ( CurrRow ) * 15 ) ), 360, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
break;
case 3: // Tercera Zona
bar( 360, (176 + ( ( CurrRow ) * 15 ) ), 419, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
break;
default:
bar( 242, (176 + ( ( CurrRow ) * 15 ) ), 419, ( (176 + 15) + ( ( CurrRow ) * 15 ) ) );
break;
}
setcolor(0);
Buff_int = (CurrRow + CurrTopLine);
}
if ( Ultima == 1 )
Buff_int = 10000;
sprintf( Buffer, " %04d", ( CurrRow + CurrTopLine ) );
outtextxy( 10, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
switch ( Programa[Buff_int].Comando ) {
case ReadNop :
sprintf( Buffer, "ReadNop" );
break;
case Fun :
sprintf( Buffer, "FUN " );
break;
case Ld :
sprintf( Buffer, "Ld " );
break;
case Or :
sprintf( Buffer, "Or " );
break;
case And :
sprintf( Buffer, "And " );
break;
case _Out :
sprintf( Buffer, "Out " );
break;
case Tim :
sprintf( Buffer, "Tim " );
break;
case Cnt :
sprintf( Buffer, "Cnt " );
break;
/*
case _Tr :
sprintf( Buffer, "Tr " );
break;
*/
case End :
sprintf( Buffer, "End (01)" );
break;
case Il :
sprintf( Buffer, "Il (02)" );
break;
case Ilc :
sprintf( Buffer, "Ilc (03)" );
break;
case Sft :
sprintf( Buffer, "Sft (10)" );
break;
case Keep :
sprintf( Buffer, "Keep (11)" );
break;
case DifU :
sprintf( Buffer, "DifU (13)" );
break;
case DifD :
sprintf( Buffer, "DifD (14)" );
break;
case TimH :
sprintf( Buffer, "TimH (15)" );
break;
case Cmp :
sprintf( Buffer, "Cmp (15)" );
break;
case Mov :
sprintf( Buffer, "Mov (21)" );
break;
case Mvn :
sprintf( Buffer, "Mvn (22)" );
break;
case Add :
sprintf( Buffer, "Add (30)" );
break;
case Sub :
sprintf( Buffer, "Sub (31)" );
break;
case Stc :
sprintf( Buffer, "Stc (40)" );
break;
case Clc :
sprintf( Buffer, "Clc (41)" );
break;
default :
sprintf( Buffer, "Error " );
break;
}
if ( Programa[Buff_int].Comando != Add && Programa[Buff_int].Comando != Sub )
switch ( Programa[Buff_int].Parametros ) {
case 0 :
break;
case P_Ld :
strcat( Buffer, "Ld " );
break;
case P_Tr :
strcat( Buffer, "Tr " );
break;
case P_Hr :
strcat( Buffer, "Hr " );
break;
case P_Cnt :
strcat( Buffer, "Cnt " );
break;
case P_Tim :
strcat( Buffer, "Tim " );
break;
case P_Keep :
strcat( Buffer, "Keep " );
break;
case P_Not :
strcat( Buffer, "Not " );
break;
case P_Not_Tr :
strcat( Buffer, "Not Tr" );
break;
case P_Not_Hr :
strcat( Buffer, "Not Hr" );
break;
case P_Not_Cnt :
strcat( Buffer, "Not Cnt" );
break;
case P_Not_Tim :
strcat( Buffer, "Not Tim" );
break;
case P_Keep_Hr :
strcat( Buffer, "Keep Hr" );
break;
case P_Tim_Data :
strcat( Buffer, "Tim Data" );
break;
case P_Out :
strcat( Buffer, "Out " );
break;
default :
strcat( Buffer, "Error " );
break;
}
outtextxy( 105, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
switch( Programa[Buff_int].Comando ) {
case ReadNop :
case End :
case Il :
case Ilc :
break;
case Tim :
case TimH:
case Cnt :
case Cmp :
case Sft :
case Mov :
case Mvn :
switch( CurrCol ) {
case 1:
sprintf( Buffer, " %02d", Programa[Buff_int].Dato );
outtextxy( /*334*/242, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
setcolor(CFG.Colores.Texto );
// sprintf( Buffer, "# % 4d", Programa[Buff_int].SubDato );
// outtextxy( /*334*/360, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
sprintf( Buffer, " #% 5d", Programa[Buff_int].SubDato );
outtextxy( /*334*/331, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
break;
case 3:
// sprintf( Buffer, "# % 4d", Programa[Buff_int].SubDato );
sprintf( Buffer, " #% 5d", Programa[Buff_int].SubDato );
outtextxy( /*334*/331, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
// outtextxy( /*334*/360, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
setcolor(CFG.Colores.Texto );
sprintf( Buffer, " %02d", Programa[Buff_int].Dato );
outtextxy( /*334*/242, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
break;
default:
break;
}
break;
case Add :
case Sub :
switch( CurrCol ) {
case 1:
sprintf( Buffer, "# %04d", Programa[Buff_int].Dato );
outtextxy( /*334*/242, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
setcolor(CFG.Colores.Texto );
sprintf( Buffer, "# %04d", Programa[Buff_int].SubDato );
outtextxy( /*334*/301, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
sprintf( Buffer, "Ch %02d", Programa[Buff_int].Parametros );
outtextxy( /*334*/360, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
break;
case 2:
sprintf( Buffer, "# %04d", Programa[Buff_int].SubDato );
outtextxy( /*334*/301, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
setcolor(CFG.Colores.Texto );
sprintf( Buffer, "# %04d", Programa[Buff_int].Dato );
outtextxy( /*334*/242, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
sprintf( Buffer, "Ch %02d", Programa[Buff_int].Parametros );
outtextxy( /*334*/360, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
break;
case 3:
sprintf( Buffer, "Ch %02d", Programa[Buff_int].Parametros );
outtextxy( /*334*/360, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
setcolor(CFG.Colores.Texto );
sprintf( Buffer, "# %04d", Programa[Buff_int].Dato );
outtextxy( /*334*/242, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
sprintf( Buffer, "# %04d", Programa[Buff_int].SubDato );
outtextxy( /*334*/301, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
break;
default:
break;
}
break;
default:
sprintf( Buffer, " %04d", Programa[Buff_int].Dato );
outtextxy( /*334*/331, (176 + ( ( CurrRow ) * 15 ) ), Buffer );
break;
}
}
void PrintVisorLCD ( char Ultima )
{
char Buffer[80] ;
int Buff_int ;
settextstyle( SMALL_FONT, HORIZ_DIR, 5 );
// Solo 11 Lineas de 5 puntos
setfillstyle( SOLID_FILL, 0 );
bar( 242, 101, 419, 129 );
setcolor(CFG.Colores.VisorLCD );
if ( Ultima == 1 )
Buff_int = 10000;
else
Buff_int = (CurrRow + CurrTopLine);
// Direcci<63>n
sprintf( Buffer, "%04d", ( CurrRow + CurrTopLine ) );
outtextxy( 243, 100, Buffer );
switch ( Programa[Buff_int].Comando ) {
case ReadNop :
outtextxy( 243, 100, " Read" );
sprintf( Buffer, " Nop (00)" );
break;
case Fun :
sprintf( Buffer, " FUN" );
break;
case Ld :
sprintf( Buffer, " Ld " );
break;
case Or :
sprintf( Buffer, " Or " );
break;
case And :
sprintf( Buffer, " And " );
break;
case _Out :
sprintf( Buffer, " Out " );
break;
case Tim :
if ( CurrCol == 1 )
sprintf( Buffer, " Tim " );
else
sprintf( Buffer, " Tim Data" );
break;
case Cnt :
if ( CurrCol == 1 )
sprintf( Buffer, " Cnt " );
else
sprintf( Buffer, " Cnt Data" );
break;
/*
case _Tr :
sprintf( Buffer, " Tr " );
break;
*/
case End :
sprintf( Buffer, " End (01)" );
break;
case Il :
sprintf( Buffer, " Il (02)" );
break;
case Ilc :
sprintf( Buffer, " Ilc (03)" );
break;
case Sft :
if ( CurrCol == 1 )
sprintf( Buffer, " Sft (10)" );
else
sprintf( Buffer, " Sft ]Ch" );
break;
case Keep :
sprintf( Buffer, " Keep (11)" );
break;
case DifU :
sprintf( Buffer, " DifU (13)" );
break;
case DifD :
sprintf( Buffer, " DifD (14)" );
break;
case TimH :
if ( CurrCol == 1 )
sprintf( Buffer, " TimH (15)" );
else
sprintf( Buffer, " TimH Data" );
break;
case Cmp :
if ( CurrCol == 1 )
sprintf( Buffer, " Cmp (15)" );
else
sprintf( Buffer, " Cmp Data" );
break;
case Mov :
if ( CurrCol == 1 )
sprintf( Buffer, " Mov (21)" );
else
sprintf( Buffer, " Mov Data" );
break;
case Mvn :
if ( CurrCol == 1 )
sprintf( Buffer, " Mvn (22)" );
else
sprintf( Buffer, " Mvn Data" );
break;
case Add :
if ( CurrCol == 1 )
sprintf( Buffer, " Add (30)" );
else
if ( CurrCol == 2 )
sprintf( Buffer, " Add Data" );
else
sprintf( Buffer, " Add to Channel" );
break;
case Sub :
if ( CurrCol == 1 )
sprintf( Buffer, " Sub (31)" );
else
if ( CurrCol == 2 )
sprintf( Buffer, " Sub Data" );
else
sprintf( Buffer, " Sub to Channel" );
break;
case Stc :
sprintf( Buffer, " Stc (40)" );
break;
case Clc :
sprintf( Buffer, " Clc (41)" );
break;
default :
sprintf( Buffer, " Error " );
break;
}
if ( Programa[Buff_int].Comando != Add && Programa[Buff_int].Comando != Sub ) {
switch ( Programa[Buff_int].Parametros ) {
case 0 :
break;
case P_Ld :
strcat( Buffer, "Ld" );
break;
case P_Tr :
strcat( Buffer, "Tr" );
break;
case P_Hr :
strcat( Buffer, "Hr" );
break;
case P_Cnt :
strcat( Buffer, "Cnt" );
break;
case P_Tim :
strcat( Buffer, "Tim" );
break;
case P_Keep :
strcat( Buffer, "Keep" );
break;
case P_Not :
strcat( Buffer, "Not" );
break;
case P_Not_Tr :
strcat( Buffer, "Not Tr" );
break;
case P_Not_Hr :
strcat( Buffer, "Not Hr" );
break;
case P_Not_Cnt :
strcat( Buffer, "Not Cnt" );
break;
case P_Not_Tim :
strcat( Buffer, "Not Tim" );
break;
case P_Keep_Hr :
strcat( Buffer, "Keep Hr" );
break;
case P_Tim_Data :
strcat( Buffer, "Tim Data" );
break;
case P_Out :
strcat( Buffer, "Out" );
break;
default :
strcat( Buffer, "Error" );
break;
}
}
outtextxy( 243, 115, Buffer );
switch( Programa[Buff_int].Comando ) {
case ReadNop :
case End :
case Il :
case Ilc :
sprintf( Buffer, " ");
break;
case Tim :
case TimH :
case Cnt :
case Cmp :
case Sft :
case Mov :
case Mvn :
switch( CurrCol ) {
case 1:
sprintf( Buffer, " %02d", Programa[Buff_int].Dato );
break;
case 3:
sprintf( Buffer, "#% 5d", Programa[Buff_int].SubDato );
break;
default:
break;
}
break;
case Add :
case Sub :
switch( CurrCol ) {
case 1:
sprintf( Buffer, "# %04d", Programa[Buff_int].Dato );
break;
case 2:
sprintf( Buffer, "# %04d", Programa[Buff_int].SubDato );
break;
case 3:
sprintf( Buffer, " Ch %02d", Programa[Buff_int].Parametros );
break;
default:
break;
}
break;
default :
sprintf( Buffer, " %04d", Programa[Buff_int].Dato );
break;
}
outtextxy( 373, 115, Buffer );
}
void BuscarItem(void)
{
}
void GetProgram(void)
{
}
void SendProgram(void)
{
}
void AddRow( char Arriba_Abajo )
{
int avance, Stop;
if ( Arriba_Abajo == 0 && (CurrRow+CurrTopLine) == 0 ) return;
if ( Arriba_Abajo == 1 && (CurrRow+CurrTopLine) == 9999 ) return;
if ( Arriba_Abajo == 0 )
Stop = CurrRow + CurrTopLine - 1;
else
Stop = CurrRow + CurrTopLine + 1;
// Comienza proceso de eliminaci<63>n
avance = 9999;
do{
Programa[avance + 1] = Programa[avance];
avance--;
}while(avance >= Stop );
if ( Arriba_Abajo == 0 )
Stop++;
Programa[Stop].Comando = 0;
Programa[Stop].Parametros = 0;
Programa[Stop].Dato = 0;
Programa[Stop].SubDato = 0;
avance = CurrRow; CurrRow = 0;
PrintWholeScreen();
if ( (CurrRow = avance + ( (Arriba_Abajo==0) ? (0) : (1) )) <0 )
{
CurrRow = 0;
UpRow();
}
if ( CurrRow > 10 )
{
CurrRow = 10;
DownRow();
}
Programa[10000] = Programa[CurrRow + CurrTopLine ];
}
void DelRow(void)
{
int avance;
// Comienza proceso de eliminaci<63>n
avance = CurrRow + CurrTopLine;
do{
Programa[avance] = Programa[avance+1];
avance++;
}while(avance < 10000 );
Programa[9999].Comando = 0;
Programa[9999].Parametros = 0;
Programa[9999].Dato = 0;
Programa[9999].SubDato = 0;
avance = CurrRow; CurrRow = 0;
PrintWholeScreen();
CurrRow = avance;
Programa[10000] = Programa[CurrRow + CurrTopLine ];
}
void UpRow(void)
{
if( CurrCol > 1 ) Select_Columna_Up();
else
if ( ( CurrRow + CurrTopLine ) <= 0 ) BEEP(); // Rebasado n<> de lineas
else {
if ( Select_Columna_Up() == 1 ) {
if ( ( CurrRow ) <= 0 )
{
CurrTopLine -= 11;
if ( CurrTopLine < 0 ) CurrTopLine = 0;
CurrRow = 0;
PrintWholeScreen();
CurrRow = 10;
Select_Columna_Up();
PrintCurrLine ( 1, 0 );
}else{
CurrRow--;
Select_Columna_Up();
PrintCurrLine ( 0, 0 );
}
} else
PrintCurrLine ( 0, 0 );
}
}
void DownRow(void)
{
if ( ( CurrRow + CurrTopLine ) >= 9999 ) BEEP(); // Rebasado n<> de lineas
else {
if ( Select_Columna_Down() == 1 ) {
if ( ( CurrRow ) >= 10 )
{
CurrRow = 0;
CurrTopLine += 11;
if ( CurrTopLine + CurrRow > 9999 ) CurrTopLine = ( 9999 - 10 );
PrintWholeScreen();
Select_Columna_Down();
PrintCurrLine ( 1, 0 );
}else{
CurrRow++;
Select_Columna_Down();
PrintCurrLine ( 0, 0 );
}
} else {
PrintCurrLine ( 0, 0 );
}
}
}
void LoadProgram(void)
{
char Buffer[500] = "*.PLC";
struct Cabecera {
char Nombre_del_Programa[70];
char Comentario_Inicial[70];
char VerHi, VerLow;
char Register;
long Records;
};
Cabecera C_PLC;
if ( file_browser( Buffer, "Cargar Programa PLC", 0 ) ) {
FILE *handle_Load;
if ( (handle_Load = fopen( Buffer, "rb") ) == NULL ) Muestra_Mensaje(200, "PLC.DAT");
fread ( &C_PLC, sizeof( struct Cabecera ), 1, handle_Load );
if ( C_PLC.VerHi == 2 && C_PLC.VerLow == 0 ) {
fread ( Programa, sizeof(FirmWare), 10000, handle_Load );
fread ( Ram, sizeof(MemoriaRam), 1, handle_Load );
}
fclose(handle_Load);
CurrRow = 0; CurrTopLine = 0;
PrintWholeScreen();
PrintCurrLine( 1, 0 );
Programa[10000] = Programa[CurrRow + CurrTopLine ];
ReImprimeCanal_Out(CurrCh_Out);
ReImprimeCanal_In(CurrCh_In);
}
/*
char drive[MAXDRIVE];
char dir[MAXDIR];
char file[MAXFILE];
char ext[MAXEXT];
int flags;
flags=fnsplit(Buffer,drive,dir,file,ext);
if( !strcmpi( file, "SFT" ) || !strcmpi( file, "CNT" )
||!strcmpi( file, "KEEP(11)") || !strcmpi( file, "DIFD(14)" )
||!strcmpi( file, "DIFU(13)") )
Run();
*/
}
void WriteProgram(void)
{
char Buffer[500] = "*.PLC";
char Buffer2[13];
struct Cabecera {
char Nombre_del_Programa[70];
char Comentario_Inicial[70];
char VerHi, VerLow;
char Register;
long Records;
};
Cabecera C_PLC;
sprintf( C_PLC.Nombre_del_Programa, "P.L.C\nJ<EFBFBD>se David Guill<6C>n\n%c", 26 );
C_PLC.VerHi = 2; C_PLC.VerLow = 0;
C_PLC.Register = 1; C_PLC.Records = 1;
if ( file_browser( Buffer, "Salvar Programa PLC", 1 ) ) {
char drive[MAXDRIVE];
char dir[MAXDIR];
char file[MAXFILE];
char ext[MAXEXT];
int flags;
flags=fnsplit(Buffer,drive,dir,file,ext);
if( !(flags & EXTENSION) )
strcpy( ext, ".PLC" );
fnmerge(Buffer ,drive,dir,file,ext);
FILE *handle_Save;
if ( (handle_Save = fopen( Buffer, "wb") ) == NULL ) Muestra_Mensaje(200, "PLC.DAT");
fwrite( &C_PLC, sizeof( struct Cabecera ), 1, handle_Save );
fwrite( Programa, sizeof(FirmWare), 10000, handle_Save );
fwrite( Ram, sizeof(MemoriaRam), 1, handle_Save );
fclose(handle_Save);
CurrRow = 0; CurrTopLine = 0;
PrintWholeScreen();
PrintCurrLine( 1, 0 );
Programa[10000] = Programa[CurrRow + CurrTopLine ];
}
}
void Configurar(void)
{
/*
struct Colores {
char Texto;
char F_Texto;
char VisorLCD;
};
typedef struct {
struct Colores Colores;
char PcOut.Bit;
char TimeFlow.Bit;
char Int8.Bit;
} Configuracion;
Configuracion CFG;
*/
char Boton_Pulsado, ok = 0, C_Texto = 5;
setfillstyle(SOLID_FILL, 0);
bar( 9, 372, 542, 471);
Imprime_Secuencia(5);
// Fichero_bot(20);
Imprime_Estaticos(20, "PLC.dat");
Imprime_Bordes(5, 5, CFG.Colores.Texto);
if ( CFG.Int8.Bit ) Imprime_Bordes(5, 2, 4);
if ( CFG.PcOut.Bit ) Imprime_Bordes(5, 3, 4);
if ( CFG.TimeFlow.Bit ) Imprime_Bordes(5, 4, 4);
do{
Boton_Pulsado = Comprueba_Secuencia( 5 );
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;
// Retroceder
case 1 :
ok = 1;
break;
// Usar Int8.Bit
case 2 :
if ( CFG.Int8.Bit ) {
CFG.Int8.Bit = 0;
Imprime_Bordes(5, 2, -1);
} else {
CFG.Int8.Bit = 1;
Imprime_Bordes(5, 2, 4);
}
break;
// Usar Pc_Out
case 3 :
if ( CFG.PcOut.Bit ) {
CFG.PcOut.Bit = 0;
Imprime_Bordes(5, 3, -1);
} else {
CFG.PcOut.Bit = 1;
Imprime_Bordes(5, 3, 4);
}
break;
// Usar TimeFlow.Bit
case 4 :
if ( CFG.TimeFlow.Bit ) {
CFG.TimeFlow.Bit = 0;
Imprime_Bordes(5, 4, -1);
} else {
CFG.TimeFlow.Bit = 1;
Imprime_Bordes(5, 4, 4);
}
break;
// Texto
case 5 :
C_Texto = 5;
Imprime_Bordes(5, 5, CFG.Colores.Texto);
Imprime_Bordes(5, 6, -1);
Imprime_Bordes(5, 7, -1);
break;
// Texto Se<53>alado
case 6 :
C_Texto = 6;
Imprime_Bordes(5, 5, -1);
Imprime_Bordes(5, 6, CFG.Colores.F_Texto);
Imprime_Bordes(5, 7, -1);
break;
// Visor LCD
case 7 :
C_Texto = 7;
Imprime_Bordes(5, 5, -1);
Imprime_Bordes(5, 6, -1);
Imprime_Bordes(5, 7, CFG.Colores.VisorLCD);
break;
case 8 :
case 9 :
case 10 :
case 11 :
case 12 :
case 13 :
case 14 :
case 15 :
case 16 :
case 17 :
case 18 :
case 19 :
case 20 :
case 21 :
case 22 :
switch ( C_Texto ) {
case 5:
CFG.Colores.Texto = ( Boton_Pulsado - 7);
Imprime_Bordes(5, 5, CFG.Colores.Texto);
break;
case 6:
CFG.Colores.F_Texto = ( Boton_Pulsado - 7 );
Imprime_Bordes(5, 6, CFG.Colores.F_Texto);
break;
case 7:
CFG.Colores.VisorLCD = ( Boton_Pulsado - 7 );
Imprime_Bordes(5, 7, CFG.Colores.VisorLCD);
break;
}
break;
default:
break;
}
}while(!ok);
if ( Optar( "Cambios en la configuraci<63>n.", "<EFBFBD> SALVAR ?", "") == 1 )
CFG_File( Salvar );
else
CFG_File( Cargar );
setfillstyle(SOLID_FILL, 0);
bar( 9, 372, 542, 471);
}
void BEEP(void)
{
}
int Select_Columna_Up(void){
int back = 0;
// Antes de Bajar una linea, mira si se ha de bajar una linea REAL
// o una linea VIRTUAL
switch( Programa[CurrRow + CurrTopLine].Comando ){
case Tim:
case Cnt:
case Sft:
case Cmp:
case Mov:
case Mvn:
case TimH:
if ( CurrCol == 3 ) { CurrCol = 1; }
else
if ( CurrCol == 1 ) { CurrCol = 0; back = 1; }
else
if ( CurrCol == 0 ) { CurrCol = 3; }
break;
case Add:
case Sub:
if ( CurrCol == 3 ) { CurrCol = 2; }
else
if ( CurrCol == 2 ) { CurrCol = 1; }
else
if ( CurrCol == 1 ) { CurrCol = 0; back = 1; }
else
if ( CurrCol == 0 ) { CurrCol = 3; }
break;
default:
CurrCol = 0;
back = 1;
break;
}
return back;
}
int Select_Columna_Down(void){
int back = 0;
// Antes de Bajar una linea, mira si se ha de bajar una linea REAL
// o una linea VIRTUAL
switch( Programa[CurrRow + CurrTopLine].Comando ){
case Tim:
case Cnt:
case Sft:
case Cmp:
case Mov:
case Mvn:
case TimH:
if ( CurrCol == 0 ) { CurrCol = 1; }
else
if ( CurrCol == 1 ) { CurrCol = 3; }
else
if ( CurrCol == 3 ) { CurrCol = 0; back = 1; }
break;
case Add:
case Sub:
if ( CurrCol == 0 ) { CurrCol = 1; }
else
if ( CurrCol == 1 ) { CurrCol = 2; }
else
if ( CurrCol == 2 ) { CurrCol = 3; }
else
if ( CurrCol == 3 ) { CurrCol = 0; back = 1; }
break;
default:
CurrCol = 0;
back = 1;
break;
}
return back;
}
void Numero_Pulsado(char numero) {
// Vemos si posee dato secundario...
// y lo canalizamos a su posici<63>n correcta
switch( Programa[10000].Comando ) {
case Tim :
case TimH:
case Cnt :
case Cmp :
case Sft :
case Mov :
case Mvn :
if ( CurrCol == 1 )
Programa[10000].Dato = ( ( ( Programa[10000].Dato - ( ( Programa[10000].Dato / 10 ) * 10 ) ) * 10 ) + numero );
else
if ( CurrCol == 3 )
Programa[10000].SubDato = ( ( ( Programa[10000].SubDato - ( ( Programa[10000].SubDato / 1000 ) * 1000 ) ) * 10 ) + numero );
break;
case Add :
case Sub :
if ( CurrCol == 1 )
Programa[10000].Dato = ( ( ( Programa[10000].Dato - ( ( Programa[10000].Dato / 1000 ) * 1000 ) ) * 10 ) + numero );
else
if ( CurrCol == 2 )
Programa[10000].SubDato = ( ( ( Programa[10000].SubDato - ( ( Programa[10000].SubDato / 1000 ) * 1000 ) ) * 10 ) + numero );
else
if ( CurrCol == 3 )
Programa[10000].Parametros = ( ( ( Programa[10000].Parametros - ( ( Programa[10000].Parametros / 10 ) * 10 ) ) * 10 ) + numero );
break;
default:
CurrCol = 0;
Programa[10000].Dato = ( ( ( Programa[10000].Dato - ( ( Programa[10000].Dato / 1000 ) * 1000 ) ) * 10 ) + numero );
break;
}
}
void MuestraLCD( char *texto1, char *texto2)
{
char Buffer[20];
setfillstyle( SOLID_FILL, 0 );
bar( 242, 101, 419, 129 );
setcolor(CFG.Colores.VisorLCD );
sprintf( Buffer, "%04d", ( CurrRow + CurrTopLine ) );
outtextxy( 243, 100, Buffer );
outtextxy( 243, 100, texto1 );
outtextxy( 243, 115, texto2 );
}
void CFG_File( char Cargar_Salvar ) {
FILE *handle_CFG;
if ( Cargar_Salvar == Cargar ) {
if ( ( handle_CFG = fopen( "PLC.CFG", "rb") ) == NULL ) {
( handle_CFG = fopen( "PLC.CFG", "wb") );
CFG.Colores.Texto = 2;
CFG.Colores.F_Texto =14;
CFG.Colores.VisorLCD= 6;
CFG.PcOut.Bit = 0;
CFG.TimeFlow.Bit = 0;
CFG.Int8.Bit = 0;
fwrite( &CFG, sizeof(Configuracion), 1, handle_CFG );
fclose( handle_CFG );
} else {
fread( &CFG, sizeof(Configuracion), 1, handle_CFG );
fclose( handle_CFG );
}
} else {
if ( ( handle_CFG = fopen( "PLC.CFG", "wb") ) == NULL ) {
CFG.Colores.Texto = 2;
CFG.Colores.F_Texto =14;
CFG.Colores.VisorLCD= 6;
CFG.PcOut.Bit = 0;
CFG.TimeFlow.Bit = 0;
CFG.Int8.Bit = 0;
} else {
fwrite( &CFG, sizeof(Configuracion), 1, handle_CFG );
fclose( handle_CFG );
}
}
}