class MacroPlayer: def __init__(self, gatewayIPAddress=None): if (gatewayIPAddress is None): self.player = Factory().GetIMacroPlayer("") else: self.player = Factory().GetIMacroPlayer(gatewayIPAddress) def LoadMacro(self, file): """Loads a workspace macro.""" _RaiseException_(self.player.LoadMacro(file)) def PlayState(self): """Acquires the current play state.""" data = self.player.PlayState() if (data == PlayStateEnum.NotPlaying): return PyMacroPlayerState.NotPlaying elif (data == PlayStateEnum.Playing): return PyMacroPlayerState.Playing elif (data == PlayStateEnum.Paused): return PyMacroPlayerState.Paused def PlayMacro(self, mode): """Replays the loaded macro.""" if (mode == 0): _RaiseException_(self.player.PlayMacro(PlayModeEnum.IgnoreTiming)) else: _RaiseException_(self.player.PlayMacro(PlayModeEnum.UseTiming)) def Wait(self): _RaiseException_(self.player.Wait()) def PausePlaying(self): _RaiseException_(self.player.PausePlaying()) def ResumePlaying(self): _RaiseException_(self.player.ResumePlaying()) def StopPlaying(self): _RaiseException_(self.player.StopPlaying()) def GetCommandLines(self): data = self.player.GetCommandLines() _RaiseException_(data[0]) commandLines = [] for i in data[1]: data = {'seconds': i.seconds, 'cmdLine': i.cmdLine} commandLines.append(data) return commandLines
class MacroRecorder: def __init__(self): self.record = Factory().GetIMacroRecorder() def StartRecording(self): _RaiseException_(self.record.StartRecording()) def StopRecording(self): _RaiseException_(self.record.StopRecording()) def ResumeRecording(self): _RaiseException_(self.record.ResumeRecording()) def SaveMacro(self, file): _RaiseException_(self.record.SaveMacro(file)) def GetCommandLines(self): data = self.record.GetCommandLines() _RaiseException_(data[0]) commandLines = [] for i in data[1]: data = {'seconds': i.seconds, 'cmdLine': i.cmdLine} commandLines.append(data) return commandLines