Esempio n. 1
0
 def ProbeMemory(self,force=False):
     """ """
     # report memory consumption
     if force or (self._ProbeMem > 0) and ((self._StepCount%self._ProbeMem) == 0):
         ret,vm,rss = simV2.VisItGetMemory()
         vmn = parallel.globalmin(vm)
         vmx = parallel.globalmax(vm)
         vme = parallel.globalave(vm)
         pStatus('MemUse=%g %g %g'%(vmn,vme,vmx))
     return
Esempio n. 2
0
 def ProbeMemory(self, force=False):
     """ """
     # report memory consumption
     if force or (self._ProbeMem > 0) and (
         (self._StepCount % self._ProbeMem) == 0):
         ret, vm, rss = simV2.VisItGetMemory()
         vmn = parallel.globalmin(vm)
         vmx = parallel.globalmax(vm)
         vme = parallel.globalave(vm)
         pStatus('MemUse=%g %g %g' % (vmn, vme, vmx))
     return
Esempio n. 3
0
    def Process(self, qcmd):
        """
        process monitor control commands.
        """
        if qcmd == 'pause':
            pStatus('WarpVisItEngine pause')
            self.__Engine._VisItBlockingComm = True
            self.__Engine._VisItControlStepping = True
            self.__Engine._UpdateVisItGUI = True
            self.Update()

        elif qcmd == 'step':
            pStatus('WarpVisItEngine step')
            self.__Engine._VisItBlockingComm = True
            self.__Engine._VisItControlStepping = True
            self.__Engine._UpdateVisItGUI = True
            self.__Engine.StepSimulation()
            self.Update()

        elif qcmd == 'run':
            pStatus('WarpVisItEngine run')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = True

        elif qcmd == 'continue':
            pStatus('WarpVisItEngine continue')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = False

        elif qcmd == 'end' or qcmd == 'disconnect':
            pStatus('WarpVisItEngine disconnect')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = False
            self.__Engine.Disconnect()

        else:
            pError('Unrecognized command %s' % (qcmd))
        return
Esempio n. 4
0
    def Process(self, qcmd):
        """
        process monitor control commands.
        """
        if qcmd == 'pause':
            pStatus('WarpVisItEngine pause')
            self.__Engine._VisItBlockingComm = True
            self.__Engine._VisItControlStepping = True
            self.__Engine._UpdateVisItGUI = True
            self.Update()

        elif qcmd == 'step':
            pStatus('WarpVisItEngine step')
            self.__Engine._VisItBlockingComm = True
            self.__Engine._VisItControlStepping = True
            self.__Engine._UpdateVisItGUI = True
            self.__Engine.StepSimulation()
            self.Update()

        elif qcmd == 'run':
            pStatus('WarpVisItEngine run')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = True

        elif qcmd == 'continue':
            pStatus('WarpVisItEngine continue')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = False

        elif qcmd == 'end' or qcmd == 'disconnect':
            pStatus('WarpVisItEngine disconnect')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = False
            self.__Engine.Disconnect()

        else:
            pError('Unrecognized command %s'%(qcmd))
        return
Esempio n. 5
0
    def Process(self, qcmd):
        """
        process interact control commands.
        """
        if (qcmd == 'end'):
            self.__Engine.RequestShutdown()

        elif qcmd == 'pause':
            pStatus('WarpVisItEngine pause')
            self.__Engine._VisItBlockingComm = True
            self.__Engine._VisItControlStepping = True
            self.__Engine._UpdateVisItGUI = True
            self.Update()

        elif qcmd == 'step':
            pStatus('WarpVisItEngine step')
            self.__Engine._VisItBlockingComm = True
            self.__Engine._VisItControlStepping = True
            self.__Engine._UpdateVisItGUI = True
            self.__Engine.StepSimulation()
            self.Update()

        elif qcmd == 'run':
            pStatus('WarpVisItEngine run')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = True

        elif qcmd == 'continue':
            pStatus('WarpVisItEngine continue')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = False

        else:
            pError('Unrecognized command %s' % (qcmd))

        return
Esempio n. 6
0
    def Process(self, qcmd):
        """
        process interact control commands.
        """
        if (qcmd == 'end'):
            self.__Engine.RequestShutdown()

        elif qcmd == 'pause':
            pStatus('WarpVisItEngine pause')
            self.__Engine._VisItBlockingComm = True
            self.__Engine._VisItControlStepping = True
            self.__Engine._UpdateVisItGUI = True
            self.Update()

        elif qcmd == 'step':
            pStatus('WarpVisItEngine step')
            self.__Engine._VisItBlockingComm = True
            self.__Engine._VisItControlStepping = True
            self.__Engine._UpdateVisItGUI = True
            self.__Engine.StepSimulation()
            self.Update()

        elif qcmd == 'run':
            pStatus('WarpVisItEngine run')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = True

        elif qcmd == 'continue':
            pStatus('WarpVisItEngine continue')
            self.__Engine._VisItBlockingComm = False
            self.__Engine._VisItControlStepping = False
            self.__Engine._UpdateVisItGUI = False

        else:
            pError('Unrecognized command %s'%(qcmd))

        return
Esempio n. 7
0
    def Process(self, qcmd):
        """
        process prompt control commands.
        """
        masterRank = lambda r: r == 0
        if self.__Engine._Connected:
            # hanlde commands from the GUI
            if qcmd == 'pause':
                pStatus('WarpVisItEngine pause')
                self.__Engine._VisItBlockingComm = True
                self.__Engine._VisItControlStepping = True
                self.__Engine._UpdateVisItGUI = True
                self.Update()

            elif qcmd == 'step':
                pStatus('WarpVisItEngine step')
                self.__Engine._VisItBlockingComm = True
                self.__Engine._VisItControlStepping = True
                self.__Engine._UpdateVisItGUI = True
                self.__Engine.StepSimulation()
                self.Update()

            elif qcmd == 'run':
                pStatus('WarpVisItEngine run')
                self.__Engine._VisItBlockingComm = False
                self.__Engine._VisItControlStepping = False
                self.__Engine._UpdateVisItGUI = True

            elif qcmd == 'continue':
                pStatus('WarpVisItEngine continue')
                self.__Engine._VisItBlockingComm = False
                self.__Engine._VisItControlStepping = False
                self.__Engine._UpdateVisItGUI = False

            elif qcmd == 'end':
                pStatus('WarpVisItEngine disconnect')
                self.__Engine._VisItBlockingComm = False
                self.__Engine._VisItControlStepping = False
                self.__Engine._UpdateVisItGUI = False
                self.__Engine.Disconnect()

        else:
            # handle user prompt
            if (qcmd == 'quit'):
                self.__Engine.RequestShutdown()

            elif qcmd == 'connect':
                pStatus('WarpVisItEngine connect')
                # put the engine in interact mode
                self.__Engine._UpdateVisItGUI = False
                self.__Engine._VisItControlStepping = True
                self.__Engine._VisItBlockingComm = True
                self.__Engine._Synchronous = 0
                self.__Engine._CommandQueue = []
            else:
                # exec command
                try:
                    exec qcmd in self.__Globals
                except:
                    if masterRank(self.__Engine._CommRank):
                        einf = sys.exc_info()
                        traceback.print_exception(einf[0], einf[1], None)
                    pass

        return
Esempio n. 8
0
    def EventLoop(self):
        """
        Run the VisIt controlled event loop. Return False on error
        """
        doError = lambda e: e < 0
        doUpdate = lambda e: e == 0
        doConnect = lambda e: e == 1
        doInternal = lambda e: e == 2
        masterRank = lambda r: r == 0
        onErrorContinue = lambda: self._Behavior == 'Monitor'

        if __debug__: pDebug('WarpVisItEngine::EventLoop')

        while 1:
            # test or wait for incomming communication.
            if masterRank(self._CommRank):
                event = simV2.VisItDetectInput(self._VisItBlockingComm, -1)
                parallel.broadcast(event)
            else:
                event = parallel.broadcast(0)

            # process incomming communication
            if __debug__: pDebug('event=%d' % (event))

            # internal comm error
            if doError(event):
                # the VisIt viewer disconnected.
                pError('An communication error was detected')
                self._Behavior.Initialize()
                if onErrorContinue():
                    continue
                else:
                    return False

            # simulate
            elif doUpdate(event):
                # this is where we can safely do things.
                # it occurs only when VisIt is not in the
                # middle of processing its own commands.
                if __debug__: pDebug('update')
                self._Behavior.Update()
                # TODO -- is it useful to force gc??
                #gc.collect()

            # internal connection
            elif doConnect(event):
                if simV2.VisItAttemptToCompleteConnection() == 1:
                    pStatus('WarpVisItEngine connected')
                    self.ConnectLibsim()
                    self._Behavior.Connect()
                    self._Behavior.Update()
                else:
                    pError('Connection failed')
                    self._Behavior.Initialize()
                    if onErrorContinue():
                        continue
                    else:
                        return False

            # internal comm
            elif doInternal(event):
                if __debug__: pDebug('internal')
                if not self.CommunicateLibsim():
                    pError('Error while processing internal commands')
                    self._Behavior.Initialize()
                    if onErrorContinue():
                        continue
                    else:
                        return False

            # bad value
            else:
                pError('unknown command %d' % (event))

            # check for asynchronous shutdown request
            if self._ShutdownRequested:
                pStatus('WarpVisItEngine exiting the event loop')
                simV2.VisItDisconnect()
                self._Connected = False
                return True

            continue

        return False
Esempio n. 9
0
#!python
import os
import sys
import argparse
import time
from WarpVisItUtil import pError, pDebug, pStatus, VisItEnv
env = VisItEnv()
from WarpVisItCLI import WarpVisItCLI

#-----------------------------------------------------------------------------
if __name__ == "__main__":

    # parse command line args
    ap = argparse.ArgumentParser(usage=argparse.SUPPRESS,
                                 prog='',
                                 add_help=False)
    ap.add_argument('--help', default=False, action='store_true')
    opts = vars(ap.parse_known_args(sys.argv)[0])
    if opts['help']:
        pStatus('WarpVisItCLIMain\nUsage:\n\n%s' %
                (WarpVisItCLI.GetCommandLineHelp()))
        sys.exit(0)

    # create and run CLI/viewer
    cli = WarpVisItCLI(sys.argv)
    cli.Initialize()
    status = cli.EventLoop()
    cli.Finalize()

    sys.exit(status)
Esempio n. 10
0
#!python
import os
import sys
import argparse
import time
from WarpVisItUtil import pError,pDebug,pStatus,VisItEnv
env = VisItEnv()
from WarpVisItCLI import WarpVisItCLI

#-----------------------------------------------------------------------------
if __name__ == "__main__":

    # parse command line args
    ap = argparse.ArgumentParser(usage=argparse.SUPPRESS,prog='',add_help=False)
    ap.add_argument('--help',default=False,action='store_true')
    opts = vars(ap.parse_known_args(sys.argv)[0])
    if opts['help']:
        pStatus('WarpVisItCLIMain\nUsage:\n\n%s'%(WarpVisItCLI.GetCommandLineHelp()))
        sys.exit(0)

    # create and run CLI/viewer
    cli = WarpVisItCLI(sys.argv)
    cli.Initialize()
    status = cli.EventLoop()
    cli.Finalize()

    sys.exit(status)
Esempio n. 11
0
warpoptions.ignoreUnknownArgs = True
warpoptions.quietImport = True
warpoptions.init_parser()

import argparse
import time
from WarpVisItUtil import VisItEnv
env = VisItEnv()
from WarpVisItUtil import pError, pDebug, pStatus
from WarpVisItEngine import WarpVisItEngine
from WarpVisItSimulation import WarpVisItSimulation
from WarpVisItSimulationFactory import WarpVisItSimulationFactory

#-----------------------------------------------------------------------------
if __name__ == "__main__":
    pStatus('WarpVisItEngineMain started')

    # parse command line args
    ap = argparse.ArgumentParser(usage=argparse.SUPPRESS,
                                 prog='',
                                 add_help=False)
    ap.add_argument('--help', default=False, action='store_true')
    opts = vars(ap.parse_known_args(sys.argv)[0])
    if opts['help']:
        pStatus(
            '\nWarpVisItEngineMain\nUsage:\n\nWarp\n%s\nWarpVisItEngine\n%s\nWarpVisItSimulation\n%s\nWarpVisItSimulationFactory\n%s'
            % (warpoptions.warpoptionsstr(),
               WarpVisItEngine.GetCommandLineHelp(),
               WarpVisItSimulation.GetCommandLineHelp(),
               WarpVisItSimulationFactory.GetCommandLineHelp()))
        sys.exit(0)
Esempio n. 12
0
    def Process(self, qcmd):
        """
        process prompt control commands.
        """
        masterRank = lambda r: r==0
        if self.__Engine._Connected:
            # hanlde commands from the GUI
            if qcmd == 'pause':
                pStatus('WarpVisItEngine pause')
                self.__Engine._VisItBlockingComm = True
                self.__Engine._VisItControlStepping = True
                self.__Engine._UpdateVisItGUI = True
                self.Update()

            elif qcmd == 'step':
                pStatus('WarpVisItEngine step')
                self.__Engine._VisItBlockingComm = True
                self.__Engine._VisItControlStepping = True
                self.__Engine._UpdateVisItGUI = True
                self.__Engine.StepSimulation()
                self.Update()

            elif qcmd == 'run':
                pStatus('WarpVisItEngine run')
                self.__Engine._VisItBlockingComm = False
                self.__Engine._VisItControlStepping = False
                self.__Engine._UpdateVisItGUI = True

            elif qcmd == 'continue':
                pStatus('WarpVisItEngine continue')
                self.__Engine._VisItBlockingComm = False
                self.__Engine._VisItControlStepping = False
                self.__Engine._UpdateVisItGUI = False

            elif qcmd == 'end':
                pStatus('WarpVisItEngine disconnect')
                self.__Engine._VisItBlockingComm = False
                self.__Engine._VisItControlStepping = False
                self.__Engine._UpdateVisItGUI = False
                self.__Engine.Disconnect()

        else:
            # handle user prompt
            if (qcmd == 'quit'):
                self.__Engine.RequestShutdown()

            elif qcmd == 'connect':
                pStatus('WarpVisItEngine connect')
                # put the engine in interact mode
                self.__Engine._UpdateVisItGUI = False
                self.__Engine._VisItControlStepping = True
                self.__Engine._VisItBlockingComm = True
                self.__Engine._Synchronous = 0
                self.__Engine._CommandQueue = []
            else:
                # exec command
                try:
                    exec qcmd in self.__Globals
                except:
                    if masterRank(self.__Engine._CommRank):
                        einf = sys.exc_info()
                        traceback.print_exception(einf[0], einf[1], None)
                    pass

        return
Esempio n. 13
0
    def EventLoop(self):
        """
        Run the VisIt controlled event loop. Return False on error
        """
        doError = lambda e: e<0
        doUpdate = lambda e: e==0
        doConnect = lambda e: e==1
        doInternal = lambda e: e==2
        masterRank = lambda r: r==0
        onErrorContinue = lambda : self._Behavior=='Monitor'

        if __debug__: pDebug('WarpVisItEngine::EventLoop')

        while 1:
            # test or wait for incomming communication.
            if masterRank(self._CommRank):
                event = simV2.VisItDetectInput(self._VisItBlockingComm, -1)
                parallel.broadcast(event)
            else:
                event = parallel.broadcast(0)

            # process incomming communication
            if __debug__: pDebug('event=%d'%(event))

            # internal comm error
            if doError(event):
                # the VisIt viewer disconnected.
                pError('An communication error was detected')
                self._Behavior.Initialize()
                if onErrorContinue():
                    continue
                else:
                    return False

            # simulate
            elif doUpdate(event):
                # this is where we can safely do things.
                # it occurs only when VisIt is not in the
                # middle of processing its own commands.
                if __debug__: pDebug('update')
                self._Behavior.Update()
                # TODO -- is it useful to force gc??
                #gc.collect()

            # internal connection
            elif doConnect(event):
                if simV2.VisItAttemptToCompleteConnection() == 1:
                    pStatus('WarpVisItEngine connected')
                    self.ConnectLibsim()
                    self._Behavior.Connect()
                    self._Behavior.Update()
                else:
                    pError('Connection failed')
                    self._Behavior.Initialize()
                    if onErrorContinue():
                        continue
                    else:
                        return False

            # internal comm
            elif doInternal(event):
                if __debug__: pDebug('internal')
                if not self.CommunicateLibsim():
                    pError('Error while processing internal commands')
                    self._Behavior.Initialize()
                    if onErrorContinue():
                        continue
                    else:
                        return False

            # bad value
            else:
                pError('unknown command %d'%(event))

            # check for asynchronous shutdown request
            if self._ShutdownRequested:
                pStatus('WarpVisItEngine exiting the event loop')
                simV2.VisItDisconnect()
                self._Connected = False
                return True

            continue

        return False