def onSetPlaybackRepeatMode(self, event):
        if "NONE" == self.lstBoxRepeatMode.get():
            GuiMgr.OnSetRepeatMode(Playback.RepeatMode.NONE)
        elif "REPEAT" == self.lstBoxRepeatMode.get():
            GuiMgr.OnSetRepeatMode(Playback.RepeatMode.REPEAT)
        else:
            GuiMgr.OnSetRepeatMode(Playback.RepeatMode.LOOP)

        self.updateLoopValue()
def StartupWorkerProc(fnKillSignalled, userData):
    downstreamServer = userData[0]
    upstreamServer = userData[1]

    Sleep.SleepMs(500)
    downstreamServer.Start()
    upstreamServer.DropPackets(True)
    upstreamServer.Start()

    Watchdog.ConnectionUpdateTimer()
    Watchdog.WatchdogTimer()

    conf = Configuration.get()
    if None != conf.GetAutorunFilename():
        GuiMgr.OnStopLiveData()
        #GuiMgr.OnStopPlayback()
        #GuiMgr.OnStopRecording(True) #drop all recorded packets
        GuiMgr.OnSetPlaybackSpeed(Configuration.get().GetPlaybackSpeed())
        ss = Configuration.get().GetAutorunLocations()

        #GuiMgr.OnEnablePlayback()
        GuiMgr.ReadFromFile(Configuration.get().GetAutorunFilename())
        GuiMgr.OnStopPlayback()
        Sleep.SleepMs(
            100)  # let gui worker threads catch up, so gui updates properly
        GuiMgr.OnStartPlayback()
        GuiMgr.OnSetRepeatMode(Configuration.get().GetAutoRunMode(), ss[0],
                               ss[1])

    else:
        upstreamServer.DropPackets(False)

    if None != conf.GetAutorunTime() and conf.GetAutorunTime(
    ) > 0:  # specified a --time, so let's hang out for that long
        endTime = Time.GetCurrMS() + conf.GetAutorunTime() * 60 * 1000
        Log.getLogger().info("Waiting for " + str(conf.GetAutorunTime()) +
                             " minutes before auto shutdown")
        if conf.GetRecordFilename():
            GuiMgr.OnStartRecording()

        while not fnKillSignalled() and endTime > Time.GetCurrMS():
            Sleep.SleepMs(250)

        Log.getLogger().info("Shutting down after time period")
        if conf.GetRecordFilename(
        ):  # was a recording session, so quit after that time
            GuiMgr.OnStopRecording()
            GuiMgr.WriteToFile(conf.GetRecordFilename())
            Log.getLogger().info("Saving Recorded data to file: " +
                                 conf.GetRecordFilename())

        GuiMgr.Quit()
Beispiel #3
0
    def PerformPlayFileTask(self, Params):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Marvin Type="OscarTask">
        #    <Version>1.0</Version>
        #     <OscarID>DemoOscar</OscarID>
        #     <Task>Playback</Task>
        #     <Param>speed=2</Param>
        #</Marvin>
        #<?xml version="1.0" encoding="utf-8"?>
        #<Marvin Type="OscarTask">
        #    <Version>1.0</Version>
        #     <OscarID>DemoOscar</OscarID>
        #     <Task>Playback</Task>
        #     <Param>speed=2</Param>
        #     <Param>repeat</Param>
        #</Marvin>
        #<?xml version="1.0" encoding="utf-8"?>
        #<Marvin Type="OscarTask">
        #    <Version>1.0</Version>
        #     <OscarID>DemoOscar</OscarID>
        #     <Task>Playback</Task>
        #     <Param>loop</Param>
        #     <Param>speed=2</Param>
        #     <Param>start=10</Param>
        #     <Param>end=2400</Param>
        #</Marvin>

        speed = 1
        start = 0
        end = Playback.get().GetDataCount()
        type = Playback.RepeatMode.NONE
        file = None

        for param in Params:
            tParam = Alias.Alias(param.lower())
            if tParam == "repeat":
                type = Playback.RepeatMode.REPEAT
            elif tParam == "loop":
                type = Playback.RepeatMode.LOOP
            else:
                parts = tParam.split("=")
                if len(parts) == 2:
                    if parts[0].lower() == 'start' and Utility.IsNumeric(
                            Alias.Alias(parts[1])):
                        start = int(parts[1])
                    elif parts[0].lower() == 'end' and Utility.IsNumeric(
                            Alias.Alias(parts[1])):
                        end = int(parts[1])
                    elif parts[0].lower() == 'speed' and Utility.IsNumeric(
                            Alias.Alias(parts[1])):
                        speed = int(parts[1])
                    elif parts[0].lower() == 'file':
                        file = parts[1]
                        if False == self.PerformLoadFileTask([file]):
                            return

                        end = Playback.get().GetDataCount()

                    else:
                        Log.getLogger().info(
                            "Received unknown Oscar Play parameter: " + param)
                        return
                else:
                    Log.getLogger().info(
                        "Received unknown Oscar Play parameter: " + param)
                    return

        if Playback.get().GetDataCount() == 0:
            Log.getLogger().info("Oscar Play received - but no file loaded.")
            return

        if start >= end:
            Log.getLogger().info("Oscar Play Loop  - but start > end.")
            return

        Log.getLogger().info("Performing Oscar task: Start Playback.")
        GuiMgr.OnStopRecording(True)  #drop all recorded packets
        GuiMgr.OnStopLiveData()

        GuiMgr.OnSetPlaybackSpeed(speed)
        GuiMgr.OnSetRepeatMode(type, start, end)
        GuiMgr.OnStartPlayback()