I Need Help With This Programa
edwgeo
Posts: 8
EXCUSEME I DON'T SPEAK ENGLISH.
I NEED TO REALIZE A PROGRAM THAT HE COMPARES THE DATE OF THE NETLINX WITH A NUMBER DEPOSITED BY THE SERIAL PORT WITH THE HYPERTERMINAL
THE NUMBER IS INPUT ONE BY ONE.
PROGRAM_NAME='accesos'
DEFINE_DEVICE
SWT = 5555:1:1 //serial port rs-232
dvRLY = 5555:4:0 //relay
DEFINE_CONSTANT
DEFINE_TYPE
DEFINE_VARIABLE
SWT_BUFFER[4]
FECHA, FECHA1
TEMP_CHAR
CLAVE
INTEGER nYear, nMonth, nDay
DEFINE_LATCHING
DEFINE_MUTUALLY_EXCLUSIVE
DEFINE_START
DEFINE_EVENT
DATA_EVENT[SWT]
{
ONLINE:
{ // Initialize serial port
SEND_COMMAND SWT,'SET BAUD 9600,N,8,1 485 DISABLE' // Set baud & port type
SEND_COMMAND SWT,'HSOFF' // set handshake off
SEND_COMMAND SWT,'XOFF' // set more info
}
}
DEFINE_PROGRAM //example
nYear = DATE_TO_YEAR (DATE) //08
nMonth = DATE_TO_MONTH (DATE) //01
nDay = DATE_TO_DAY (DATE) //04
FECHA = nYear + nMonth + nDay //I NEED CONCATENATE FOR THIS RESULT = 080104
//
IF (LENGTH_STRING(SWT_BUFFER)) //THERE IS AT LEAST ONE CHARACTER IN BUFFER
{
TEMP_CHAR = get_buffer_char(SWT_BUFFER) //REMOVE FIRST CHAR
CLAVE = CLAVE + TEMP_CHAR //I NEED THIS RESULT (CLAVE=080104) THE NUMBER 080104 IS DEPOSITED ONE BY ONE BY THE HYPERTERMINAL PROGRAM FOR THE SERAIL PORT THE NENLINX 2100
IF (CLAVE = FECHA)
{
ON [dvRLY,1]
WAIT 60
OFF [dvRLY,1]
}
IF (TEMP_CHAR='*')
{
CLEAR_BUFFER SWT_BUFFER
CLAVE=0
}
}
//WITH THIS PROGRAM THE RESULT CLAVE IS DIFERENT THE FECHA FOR EXAMPLE
//CLAVE=5 , FECHA =213
I NEED TO REALIZE A PROGRAM THAT HE COMPARES THE DATE OF THE NETLINX WITH A NUMBER DEPOSITED BY THE SERIAL PORT WITH THE HYPERTERMINAL
THE NUMBER IS INPUT ONE BY ONE.
PROGRAM_NAME='accesos'
DEFINE_DEVICE
SWT = 5555:1:1 //serial port rs-232
dvRLY = 5555:4:0 //relay
DEFINE_CONSTANT
DEFINE_TYPE
DEFINE_VARIABLE
SWT_BUFFER[4]
FECHA, FECHA1
TEMP_CHAR
CLAVE
INTEGER nYear, nMonth, nDay
DEFINE_LATCHING
DEFINE_MUTUALLY_EXCLUSIVE
DEFINE_START
DEFINE_EVENT
DATA_EVENT[SWT]
{
ONLINE:
{ // Initialize serial port
SEND_COMMAND SWT,'SET BAUD 9600,N,8,1 485 DISABLE' // Set baud & port type
SEND_COMMAND SWT,'HSOFF' // set handshake off
SEND_COMMAND SWT,'XOFF' // set more info
}
}
DEFINE_PROGRAM //example
nYear = DATE_TO_YEAR (DATE) //08
nMonth = DATE_TO_MONTH (DATE) //01
nDay = DATE_TO_DAY (DATE) //04
FECHA = nYear + nMonth + nDay //I NEED CONCATENATE FOR THIS RESULT = 080104
//
IF (LENGTH_STRING(SWT_BUFFER)) //THERE IS AT LEAST ONE CHARACTER IN BUFFER
{
TEMP_CHAR = get_buffer_char(SWT_BUFFER) //REMOVE FIRST CHAR
CLAVE = CLAVE + TEMP_CHAR //I NEED THIS RESULT (CLAVE=080104) THE NUMBER 080104 IS DEPOSITED ONE BY ONE BY THE HYPERTERMINAL PROGRAM FOR THE SERAIL PORT THE NENLINX 2100
IF (CLAVE = FECHA)
{
ON [dvRLY,1]
WAIT 60
OFF [dvRLY,1]
}
IF (TEMP_CHAR='*')
{
CLEAR_BUFFER SWT_BUFFER
CLAVE=0
}
}
//WITH THIS PROGRAM THE RESULT CLAVE IS DIFERENT THE FECHA FOR EXAMPLE
//CLAVE=5 , FECHA =213
0
Comments
There's obviously a whole lot of stuff you'd want to do about clearing the buffer, creating a time out, etc...
But, hopefully, this gives you the basic logic of it.