예제 #1
0
파일: Feed.py 프로젝트: Shadow2718/PyKOB
    # Pause between articles (in seconds):
    artPause = args.artPause

    # Default group pause to article pause value if no group pause value is supplied
    grpPause = args.grpPause if args.grpPause > 0.0 else args.artPause

    # Number of days (from today) of articles to read before repeating:
    days = args.days

    # The wait time (in seconds) after someone else transmits before resuming feed:
    wait = args.wait

    playback_finished = threading.Event()
    playback_last_sender = None

    mySender = morse.Sender(wpm, cwpm, codeType=code_type)
    myInternet = internet.Internet(idText)
    audio_setting = strtobool(str(args.sound))
    myKOB = kob.KOB(port=args.serial_port,
                    interfaceType=args.interface_type,
                    audio=audio_setting)

    myInternet.connect(wire)

    # create thread to listen for activity on the wire
    tLastSender = time.time()  # time of last activity
    listenerThread = threading.Thread(target=checkForActivity)
    listenerThread.daemon = True
    listenerThread.start()

    # See if the URI is a PyKOB recorder file or a RSS file/feed
예제 #2
0
파일: Clock.py 프로젝트: Shadow2718/PyKOB
    if (args.Interval < 1) or (args.Interval > 1440):
        print("Time announcement interval must be betwen 1 and 1440.")
        sys.exit(1)
    annc_interval = args.Interval * 60  # announcement interval (sec)
    local_text = args.Text

    myRecorder = None
    if (args.Record):
        ts = recorder.get_timestamp()
        targetFileName = "Clock." + str(ts) + ".json"
        myRecorder = recorder.Recorder(targetFileName,
                                       None,
                                       station_id="Clock")

    myKOB = kob.KOB(port=port, audio=sound)
    mySender = morse.Sender(text_speed)

    # Announce the current time right now
    now = time.localtime()
    msg = announcement(now.tm_hour, now.tm_min)
    announce(msg, myKOB, mySender, myRecorder)

    # Loop, making announcements as configured (every hour, on the hour, during the daytime)
    while True:
        t = time.localtime()
        next_time = round_up(hms_to_seconds(t.tm_hour, t.tm_min, t.tm_sec),
                             annc_interval)  # next announcement (sec)
        if next_time < start_time:
            next_time = start_time
        now = hms_to_seconds(t.tm_hour, t.tm_min,
                             t.tm_sec)  # current time (sec)
예제 #3
0
                return  # Stop signalled - return from run method


"""
Test code
"""
if __name__ == "__main__":
    # Self-test
    from pykob import morse

    test_target_filename = "test." + str(get_timestamp()) + ".json"
    myRecorder = Recorder(test_target_filename,
                          test_target_filename,
                          station_id="Test Recorder",
                          wire=-1)
    mySender = morse.Sender(20)

    # 'HI' at 20 wpm as a test
    print("HI")
    codesequence = (-1000, +2, -1000, +60, -60, +60, -60, +60, -60, +60, -180,
                    +60, -60, +60, -1000, +1)
    myRecorder.record(codesequence, kob.CodeSource.local)
    # Append more text to the same file
    for c in "This is a test":
        codesequence = mySender.encode(c, True)
        myRecorder.record(codesequence, kob.CodeSource.local, c)
    print()
    # Play the file
    myKOB = kob.KOB(port=None, audio=True)
    myRecorder.playback(myKOB)
예제 #4
0
    for char in s:
        code = mySender.encode(char)
        myKOB.sounder(code)  # to pace the code sent to the wire
        myInternet.write(code)


try:
    if DEBUG:
        print(DEBUG)
        sendForecast(DEBUG)
        exit()

    myInternet = internet.Internet(IDTEXT)
    myInternet.connect(WIRE)
    myReader = morse.Reader(callback=readerCallback)
    mySender = morse.Sender(WPM)
    myKOB = kob.KOB(port=None, audio=False)
    myReader.setWPM(WPM)
    code = []
    bracket = False
    msg = ''
    while True:
        try:
            code += myInternet.read()
            if code[-1] == 1:
                log.log('Weather.py: {}'.format(code))
                myReader.decode(code)
                myReader.flush()
                code = []
                bracket = False
                msg = ''
예제 #5
0
'configure.sh' script or executing 'python3 Configure.py'.
"""

import sys
import time
import pykob
from pykob import config, newsreader, morse, kob

SOURCE = 'https://www.ansa.it/sito/ansait_rss.xml'  # news feed
PORT = config.serial_port  # serial port for KOB interface
WPM = config.words_per_min_speed  # code speed (words per minute)
SOUND = config.sound  # whether to enable computer sound for sounder
CWPM = 18  # minimum character speed
PAUSE = 5  # gap to leave between articles (seconds)

mySender = morse.Sender(WPM, CWPM, morse.INTERNATIONAL, morse.CHARSPACING)
myKOB = kob.KOB(PORT, SOUND)

try:
    while True:
        print('')
        articles = newsreader.getArticles(SOURCE)
        for (title, description, pubDate) in articles:
            text = title + ' = ' + description + ' ='
            for char in text:
                code = mySender.encode(char)
                myKOB.sounder(code)
                if code:
                    sys.stdout.write(char)
                else:
                    sys.stdout.write(' ')