Acssim.Recorder
index
/alma/ACS-2016.6/ACSSW/lib/python/site-packages/Acssim/Recorder.py

#*******************************************************************************
# ALMA - Atacama Large Millimiter Array
# (c) Associated Universities Inc., 2005 

# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#
# "@(#) $Id: Recorder.py,v 1.2 2010/10/01 17:20:48 javarias Exp $"
#
# who       when        what
# --------  ----------  ----------------------------------------------
# rhiriart  2006-12-06  created
#

 
Modules
       
inspect
os
pickle
time

 
Classes
       
Call
Player
Recorder

 
class Call
    Represents an operation call over a given component.
Used by the Player class.
 
  Methods defined here:
__init__(self, meth_name, args, t)
Constructor.
Parameters:
meth_name - Method name.
args - Tuple containing the operation arguments.
getArgs(self)
Gets the method's arguments.
getMethodName(self)
Gets the method's name.
getReturnValue(self)
Get the return value. Calling this method only makes sense after
calling invoke().
getTime(self)
invoke(self, component)
Invoke the call represented by an instance of this class over a
component. Of course, the component should support the operation.
Parameters:
component - Component reference.
setArgs(self, args)
Sets the arguments for this call. This is useful for cases where it is needed
to replace arguments in order for an invokation to work. For example, if
the arguments are CORBA references or callbacks, which only are valid during
the recording session.
Parameters:
args - Arguments tuple.

 
class Player
    Plays a record file generated with the IDL Simulator.
 
  Methods defined here:
__getitem__(self, i)
Overrided indexing operation.
__init__(self, file_name)
Constructor.
Parameters:
file_name - File generated by the IDL simulator when the ACSSIM_REC_DIR
            environment variable is set in the process running the simulated
            components.
            This file contains a description of the calls to a simulated component,
            along with its arguments.
__len__(self)
fixCORBAEnums(self, obj)
Utility function.
Fixes a problem with CORBA Enums. For some reason that I don't quite understand yet,
CORBA enumerations are not pickled/unpickled correctly. Using them as they are after
unpickling will throw a CORBA.BAD_PARAM exception. One way to fix this is simply to
recreate them, which is what this function does. It goes through each one of obj
members, find the CORBA enums and recreates them. It works recursively for each one of
obj members.
 
Parameters:
obj - An arbitrary CORBA object.
getComponentName(self)
getStartTime(self)
replaceCall(self, i, call)
Replaces a call object.
Parameters:
i - Call number
call - Call object
restoreXMLEntities(self, s)
Utilitiy function. Replaces XML entities for its respective characters.
 
&amp   -> &
&apos  -> '
&lt;   -> <
&gt;   -> >
&quot; -> "

 
class Recorder
    This class is used by the ACS IDL Simulator to record a simulation session
into a file. This file can be used afterwards by the Player class to run
again the session over the "real" component.
 
  Methods defined here:
__init__(self, comp_name)
Constructor. Checks if the environment variable ACSSIM_REC_DIR has
been set. This should be the directory where the Recorder will output
invokation information. If this env. variable is not set the Recorder
class does nothing.
 
Parameters:
comp_name - Component name.
begin(self)
Begin the recording session.
end(self)
End the recording session.
record(self, meth_name, args)
Record a method invokation.
 
Parameters:
method_name - Method name.
args - Argument list.
replaceXMLEntities(self, s)
Replaces special characters of its corresponding XML entities.
 
& -> &amp;
' -> &apos;
< -> &lt;
> -> &gt;
" -> &quot;