Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with $time

Status
Not open for further replies.

traderbob

IS-IT--Management
Apr 15, 2001
11
0
0
US
I work with a radio station and I'm researching and working with using a new device to pulse some relays.

The device we are looking at is a broadcast tools src-8 III serial remote control.

It’s a pretty cool device.

I’ve been writing a Procomm Aspect script to transmit pulses to the device which will cause the relays to pulse.

I’ve had a lot of success with the scripts and the testing.



Without boring you with what we are trying to do…

We have this long sequence of events which we are trying to program these pulses for…

I’ll be happy to post some of the stuff we've been testing – but the main problem I’ve been having is getting the aspect script to work with $Time.

For example, at 5:30 in the AM, the Board Operator in the Studio is supposed to punch this button which will send this closure to the serial port on a PC.

I can put aspect in a waiting state using :



waitfor "S0P,A,1,0,0,0,0,0,0,0"

waitfor "S0P,A,0,0,0,0,0,0,0,0"



It actually works quite well – waiting and “listening” on the COM port.



When it “hears” that response, it’s supposed to transmit the following:

transmit "*0OR1P^M"



This actually works quite well also.

Then, the Aspect script is supposed to wait for 40 seconds and transmit another pulse… wait till 5:35 and send another pulse… wait for 4 more minutes and send another pulse.

These are all working quite well.

The problem I’m having is that we don’t want to assume the board op is going to push the button when they are supposed to at 5:30 to start this whole thing. In addition, if he doesn't push the button when he is supposed to, and finally remebers to push it later, I don't want the script to start firing off transmits out of sequence.

So I’m trying to write into the script to listen for the two inputs ( waitfor "S0P,A,1,0,0,0,0,0,0,0" and waitfor "S0P,A,0,0,0,0,0,0,0,0" ) but if it doesn’t hear anything by 5:30:15, to go ahead and stop listening and transmit the pulse anyway. Or if it finally hears the pulse, to check the time, and if it is within a certain window to either wait to begin it's sequence or jump to the next module.

The problem is that everytime I try to write and compile an if statement to read the current machine time, and wait till 5:30:15, I get an error that says invalid variable operand and invalid number.

Some of the code I’m using looks like this:

;test if statement
if $Time <= "5:30:15" ;test current time and listen on COMM Port if time less than or equal to 5:30:15

waitfor "S0P,A,1,0,0,0,0,0,0,0"

waitfor "S0P,A,0,0,0,0,0,0,0,0"

transmit "*0OR1P^M"

else

waituntil 5:34:00

transmit "*0OR1P^M"

endif

Does any of this make any sense?
Can I not do what I’m trying to do with the $Time?
Thanks for any help you can provide.

 
From Aspects documention:

Code:
proc main
   string DateStr             ; String to contain date.
   string TimeStr             ; String to contain time.

   DateStr = "12/31/99"       ; Assign date to date string.
   TimeStr = "11:59:59"       ; Assign time to time string.
   waituntil TimeStr DateStr  ; Wait until turn of century.
endproc

I believe waituntil may be the answer you're looking for.
You can use 'when' to look for your other events (manually triggering or 'pushing the button.')

Code:
proc main
   when TARGET 0 "First?" call FirstName
   when TARGET 1 "Last?" call LastName
   while $CARRIER       ; Loop while connected.
      yield             ; Release ASPECT process time
   endwhile
endproc

proc FirstName
   transmit "John^M"    ; Transmit first name.
endproc

proc LastName
   transmit "Doe^M"     ; Transmit last name.
endproc
 
Thanks.
But I'm trying to get Aspect to discern the current time. I 've been successful in getting it to take action at a desired time - which I can assign it. But now I need for it to discern what the current time is right now. If it is before 5:30 just wait and listen to the COM port... which it will successfully do. But if the current time is 5:30:15 and it hasn't heard anyting yet on the COM port, it needs to start the process of doing all the transmit stuff.
I have been successful in getting Aspect to write the current time to a log file - but I can't seem to get the syntax right to analyze the current time in an if statement.
Any thoughts?
 
A quick test I did included AM/PM in $TIME ('5:30:15AM') so you need to take that into account in your if statements.

Make your if statement:

if $TIME <= "5:30:15AM"

or

if $TIME24 <= "05:30:15"



 
I'll give that a try. I wasn't thinking I'd need an AM or PM - I kinda figured it would be based on military time.
Thanks for the assistance...
I'll let you know if I'm successful.
 
I've tried the $time and $time24 and I'm still getting
Error C110 Line 59: Invalid operand
Error C150 Line 59: Invalid number
Here is the text of my if:

;test if statement

$Time
if $Time24 <= "11:48:00"
waitfor "S0P,A,1,0,0,0,0,0,0,0"
waitfor "S0P,A,0,0,0,0,0,0,0,0"
transmit "*0OR1P^M"
else
alarm 1
endif

I looked up the Error C110 and C150 and all it says is invalid operand and invalid number...
Is my syntax wrong?
 
Sorry, my mistake. Your compairing strings here, not numbers.

I got the same results testing your code.

I don't think <= works with strings. May have to use strcmp.
 
Here's some code that may or may not help.

Code:
string sDay, sHour, sMin, sSec, sMonth, sYear, sTemp
integer iDay, iYear, iHour, iMin, iSec

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
numtostr iHour sHour
numtostr iMin sMin
nomtostr iSec sSec

; To generate a string of the current time
strcat sTemp sHour
strcat sTemp ":"
strcat sTemp sMin
strcat sTemp ":"
strcat sTemp sSec

; To time comparison
if iHour <= 11
     if iMin <= 48
          if iSec <= 00
               ; your code here
          endif
     endif
endif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top