mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-11-29 16:50:13 +01:00
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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user