From 63949df482c01a33d52868393bc63b4a166e4d33 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Sat, 4 Jan 2020 14:51:48 -0500 Subject: [PATCH] 2020-01-04 Fred Gleason * Added 'Repetitions=' and 'RepetitionDelay=' directive to the configuration of the 'pypad_xds.py' PyPAD script. --- ChangeLog | 3 +++ apis/pypad/scripts/pypad_xds.exemplar | 12 +++++++++ apis/pypad/scripts/pypad_xds.py | 39 ++++++++++++++++----------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 69961c09..d0d0a2c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19395,3 +19395,6 @@ 2020-01-04 Fred Gleason * Fixed a bug in the 'pypad_xds.py' PyPAD script that could cause it to emit duplicate CIC updates. +2020-01-04 Fred Gleason + * Added 'Repetitions=' and 'RepetitionDelay=' directive to the + configuration of the 'pypad_xds.py' PyPAD script. diff --git a/apis/pypad/scripts/pypad_xds.exemplar b/apis/pypad/scripts/pypad_xds.exemplar index f650541d..161658e2 100644 --- a/apis/pypad/scripts/pypad_xds.exemplar +++ b/apis/pypad/scripts/pypad_xds.exemplar @@ -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 diff --git a/apis/pypad/scripts/pypad_xds.py b/apis/pypad/scripts/pypad_xds.py index 3fb9c491..8e97fe45 100755 --- a/apis/pypad/scripts/pypad_xds.py +++ b/apis/pypad/scripts/pypad_xds.py @@ -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)