예제 #1
0
    def PerformLoadFileTask(self, Params):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Marvin Type="OscarTask">
        #    <Version>1.0</Version>
        #     <OscarID>DemoOscar</OscarID>
        #     <Task>LoadFile</Task>
        #     <Param>filename</Param>
        #</Marvin>
        if len(Params) != 1:
            Log.getLogger().error(
                "Oscar Task to load file failed - no file specified.")

        filename = Alias.Alias(Params[0])
        Log.getLogger().info("Performing Oscar task: Load File -->" +
                             str(filename))
        GuiMgr.OnStopPlayback()
        GuiMgr.OnStopRecording(True)  #drop all recorded packets
        GuiMgr.OnStopLiveData()
        if GuiMgr.ReadFromFile(filename):
            GuiMgr.OnEnablePlayback()
            GuiMgr.SetPlaybackFilename(filename)
        else:
            Log.getLogger().warning("Oscar Task to load file [" + filename +
                                    "] failed")
            return False

        return True
예제 #2
0
    def PerformStopRecordingTask(self, Params):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Marvin Type="OscarTask">
        #    <Version>1.0</Version>
        #     <OscarID>DemoOscar</OscarID>
        #     <Task>StopRecording</Task>
        #     <Param>File=SaveFile.glk</Param>
        #</Marvin>

        fileName = None
        param = ""
        if len(Params) > 0:
            param = Params[0]
            parts = param.split("=")
            if len(parts) == 2:
                if parts[0].lower() == 'file':
                    fileName = Alias.Alias(parts[1])

        if None == fileName:
            Log.getLogger().error(
                "Received invalid Stop Recording task.  No save file: " +
                str(param))
            return

        GuiMgr.OnStopRecording()
        GuiMgr.WriteToFile(fileName)
예제 #3
0
 def PerformGoLiveTask(self, Params):
     #<?xml version="1.0" encoding="utf-8"?>
     #<Marvin Type="OscarTask">
     #    <Version>1.0</Version>
     #     <OscarID>DemoOscar</OscarID>
     #     <Task>Go Live</Task>
     #</Marvin>
     Log.getLogger().info("Performing Oscar task: Start Live Data.")
     GuiMgr.OnStopPlayback()
     GuiMgr.OnStopRecording()
     GuiMgr.OnStartLiveData()
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()
 def onRecordStopBtn(self):
     GuiMgr.OnStopRecording()
예제 #6
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()