if self.scriptState in [axscript.SCRIPTSTATE_UNINITIALIZED,axscript.SCRIPTSTATE_INITIALIZED]:
self.ChangeScriptState(axscript.SCRIPTSTATE_STARTED) # report transition through started
self.Run()
if self.scriptState == axscript.SCRIPTSTATE_STARTED:
self.Connect()
self.ChangeScriptState(state)
elif state==axscript.SCRIPTSTATE_DISCONNECTED:
if self.scriptState == axscript.SCRIPTSTATE_CONNECTED:
self.Disconnect()
elif state==axscript.SCRIPTSTATE_CLOSED:
self.Close()
elif state==axscript.SCRIPTSTATE_UNINITIALIZED:
if self.scriptState == axscript.SCRIPTSTATE_STARTED:
self.Stop()
if self.scriptState == axscript.SCRIPTSTATE_CONNECTED:
self.Disconnect()
if self.scriptState == axscript.SCRIPTSTATE_DISCONNECTED:
self.Reset()
self.ChangeScriptState(state)
else:
raise Exception(scode=winerror.E_INVALIDARG)
def GetScriptState(self):
return self.scriptState
def Close(self):
# trace("Close")
if self.scriptState in [axscript.SCRIPTSTATE_CONNECTED, axscript.SCRIPTSTATE_DISCONNECTED]:
self.Stop()
if self.scriptState in [axscript.SCRIPTSTATE_CONNECTED, axscript.SCRIPTSTATE_DISCONNECTED, axscript.SCRIPTSTATE_INITIALIZED, axscript.SCRIPTSTATE_STARTED]:
pass # engine.close??
if self.scriptState in [axscript.SCRIPTSTATE_UNINITIALIZED, axscript.SCRIPTSTATE_CONNECTED, axscript.SCRIPTSTATE_DISCONNECTED, axscript.SCRIPTSTATE_INITIALIZED, axscript.SCRIPTSTATE_STARTED]: