Home AMX User Forum NetLinx Studio

I Need Help With This Programa

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

Comments

  • ericmedleyericmedley Posts: 4,177
    Here's what I'd do (or something like it)
    dv_Serial_Port  =  5001:01:0 // serial port
    
    DEFINE_VARIABLE
    
    port_buffer[10] // data format  mm/dd/yyyy
    
    DEFINE_START
    
    CREATE_BUFFER dv_Serial_Port,port_buffer
    
    DEFINE_EVENT
    
    DATA_EVENT[dv_Serial_Port]
    {
    STRING:
      {
      IF(LENGTH_STRING(port_buffer)>9)
        {
        IF(port_buffer=DATE)
           {
           // DO SOMETHING
           }
        ELSE
           {
           SEND_STRING dv_Serial_Port, 'Your feeble attempt to get in has failed'
           port_buffer=''
           }
        }
      }
    }
    
    

    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.
Sign In or Register to comment.