2020-01-04 Fred Gleason <fredg@paravelsystems.com>

* Added 'Repetitions=' and 'RepetitionDelay=' directive to the
	configuration of the 'pypad_xds.py' PyPAD script.
This commit is contained in:
Fred Gleason 2020-01-04 14:51:48 -05:00
parent 0e8234afc6
commit 63949df482
3 changed files with 39 additions and 15 deletions

View File

@ -19395,3 +19395,6 @@
2020-01-04 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in the 'pypad_xds.py' PyPAD script that could cause it
to emit duplicate CIC updates.
2020-01-04 Fred Gleason <fredg@paravelsystems.com>
* Added 'Repetitions=' and 'RepetitionDelay=' directive to the
configuration of the 'pypad_xds.py' PyPAD script.

View File

@ -30,6 +30,16 @@ UdpPort=1234
;
IsciPrefix=TEST_
; Repetitions
;
; Send each CIC update packet this many times.
Repetitions=1
; Repetition Delay
;
; Delay this many milliseconds between each repetition.
RepetitionDelay=100
; Log Selection
;
; Set the status for each log to 'Yes', 'No' or 'Onair' to indicate whether
@ -67,6 +77,8 @@ VLog120=No
;UdpPort=6789
;TtyDevice=/dev/ttyS1
;TtySpeed=19200
;Repetitions=1
;RepetitionDelay=100
;MasterLog=Yes
;Aux1Log=No
;Aux2Log=Onair

View File

@ -24,6 +24,7 @@ import sys
import socket
import configparser
import serial
import time
import pypad
#
@ -76,23 +77,31 @@ def ProcessPad(update):
if update.shouldBeProcessed(section) and update.hasPadType(pypad.TYPE_NOW) and update.hasService() and (last_updates[update.machine()] != update.startDateTimeString(pypad.TYPE_NOW)):
last_updates[update.machine()]=update.startDateTimeString(pypad.TYPE_NOW)
packet='0:'+update.serviceProgramCode()+':'+update.config().get(section,'IsciPrefix')+FilterField(update.padField(pypad.TYPE_NOW,pypad.FIELD_EXTERNAL_EVENT_ID))+':*'
try:
#
# Use serial output
#
tty_dev=update.config().get(section,'TtyDevice')
speed=int(update.config().get(section,'TtySpeed'))
parity=serial.PARITY_NONE
dev=serial.Serial(tty_dev,speed,parity=parity,bytesize=8)
dev.write(packet.encode('utf-8'))
dev.close()
reps=range(1)
if(update.config().has_option(section,'Repetitions')):
reps=range(update.config().getint(section,'Repetitions'))
delay=0.1
if(update.config().has_option(section,'RepetitionDelay')):
delay=update.config().getfloat(section,'RepetitionDelay')/1000.0
for r in reps:
try:
#
# Use serial output
#
tty_dev=update.config().get(section,'TtyDevice')
speed=int(update.config().get(section,'TtySpeed'))
parity=serial.PARITY_NONE
dev=serial.Serial(tty_dev,speed,parity=parity,bytesize=8)
dev.write(packet.encode('utf-8'))
dev.close()
except configparser.NoOptionError:
#
# Use UDP output
#
send_sock.sendto(packet.encode('utf-8'),
except configparser.NoOptionError:
#
# Use UDP output
#
send_sock.sendto(packet.encode('utf-8'),
(update.config().get(section,'IpAddress'),int(update.config().get(section,'UdpPort'))))
time.sleep(delay)
n=n+1
section='Udp'+str(n)