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
def PerformStopPlaybackTask(self, Params): #<?xml version="1.0" encoding="utf-8"?> #<Marvin Type="OscarTask"> # <Version>1.0</Version> # <OscarID>DemoOscar</OscarID> # <Task>PausePlayback</Task> #</Marvin> Log.getLogger().info("Performing Oscar task: Stop Playback.") GuiMgr.OnStopPlayback()
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 onStopBtn(self): GuiMgr.OnStopPlayback()
def __workerProc(self, fnKillSignalled, userData): from Helpers import GuiMgr self.CurrentIndex = self.startIndex self.StartTime = None xmlList = [] while not fnKillSignalled( ): # run until signalled to end - call passed function to check for the signal if self.Paused or self.Stopped: Sleep.SleepMs(100) continue if None == self.StartTime: self.StartTime = int( self.PlaybackData[self.CurrentIndex].ArrivalTime ) - 10 # can't remember why I subract 10ms... objData = self.PlaybackData[self.CurrentIndex] sleepVal = (int(objData.ArrivalTime) - self.StartTime) / self.PlaybackSpeed Sleep.SleepMs(sleepVal) try: # when looping, this data will be here after the 1st loop xmlData = self.PlaybackData[self.CurrentIndex].xmlData node = self.PlaybackData[self.CurrentIndex].firstNode except: xmlData = objData.ToXML( ) # be more efficient if I create a list of already created xmldata self.PlaybackData[ self. CurrentIndex].xmlData = xmlData # LOVe how you can just add stuff to an object in Python! if Configuration.get().GetShunting(): try: dom = xml.dom.minidom.parseString(rawData) node = dom._get_firstChild() except Exception as ex: Log.getLogger().error( "Error Something bad in Trying to re-encode saved data" ) else: node = None self.PlaybackData[self.CurrentIndex].firstNode = node TargetManager.GetTargetManager().BroadcastDownstream( xmlData, False, node) GuiMgr.OnDataPacketSentDownstream(objData, "Playback") try: self.StartTime = int( self.PlaybackData[self.CurrentIndex].ArrivalTime) except Exception: self.StartTime = None # just in case get an out of bounds error self.CurrentIndex += 1 if None == self.endIndex: self.endIndex = len(self.PlaybackData) - 1 if self.CurrentIndex >= self.endIndex: preProcessingDone = True if self.LoopMode == RepeatMode.NONE: GuiMgr.OnStopPlayback() if Configuration.get().GetExitAfterAutoPlay(): Log.getLogger().info( "Playback finished, exiting application per arguments" ) GuiMgr.Quit() elif self.LoopMode == RepeatMode.REPEAT: self.CurrentIndex = 0 self.LoopCount += 1 elif self.LoopMode == RepeatMode.LOOP: self.CurrentIndex = self.startIndex self.LoopCount += 1 self.StartTime = None