def push_structured_event(self, event):
        try:
            print "push_structured_event called!"
            self.numReceived = self.numReceived + 1

            receptionTime = getTimeStamp().value

            # output the reception time (only done for the first and last messages)
            if (self.numReceived == 1 or self.numReceived >= self.numToExpect):
                print >> self.outputfile, "reception time: " + str(
                    receptionTime)

            #calculate the time difference in seconds
            sentTime = event.remainder_of_body.value().timestamp
            timeDiff = duration2py(long(receptionTime - sentTime))

            # special check for negative values - still not clear why we get the occasional value below zero, for
            # remote consumers - hypothesis is something to do w/ precision of clock synchronization. See wiki page
            # for more detailed explanation of this hypothesis. For now, make the negative values equal to zero.
            if timeDiff < 0.0:
                timeDiff = 0.0

            print >> self.outputfile, str(timeDiff)
            # flush is needed because monitoring applications are watching output for sign of completion
            # and will not know when things are finished if they're buffered
            if (self.numReceived >= self.numToExpect):
                self.outputfile.flush()

            sleep(self.waitBetweenEvents)

        except Exception, e:
            self.logger.logCritical('Unable to use handler function...' +
                                    str(e))
            print_exc()
Пример #2
0
    def set_sync(self, newVal):
        '''
        Implementation of the IDL method.

        ACSErr::Completion set_sync (in double value);
        '''
        try:
            #first just try to get the value from the DevIO...
            compl = self.value.write(newVal)

            #developer didn't want to create a completion.
            if compl == None:
                #succeeded! now just create a "no-error" completion
                compl = Completion(
                    long(getTimeStamp().value),  #unsigned long long timeStamp;
                    0L,  #ACSErr::CompletionType type;
                    0L,  #ACSErr::CompletionCode code;
                    ())  #ErrorLinkedList  previousError;
        except Exception, e:
            self.getLogger().logAlert(
                "Some problem occurred when using the DevIO's write method")
            print_exc()
            #let's see if it raised an ACS Error
            #System exception first...
            try:
                compl = CouldntAccessPropertyCompletionImpl(exception=e)
            except:
                #a native Python exception was raised...not much we can do
                #here
                compl = CouldntAccessPropertyCompletionImpl()
Пример #3
0
    def set_sync(self, newVal):
        '''
        Implementation of the IDL method.

        ACSErr::Completion set_sync (in double value);
        '''
        try:
            #first just try to get the value from the DevIO...
            compl = self.value.write(newVal)

            #developer didn't want to create a completion.
            if compl == None:
                #succeeded! now just create a "no-error" completion
                compl = Completion(long(getTimeStamp().value),  #unsigned long long timeStamp;
                                   0L,  #ACSErr::CompletionType type;
                                   0L,  #ACSErr::CompletionCode code;
                                   ())  #ErrorLinkedList  previousError;
        except Exception, e:
            self.getLogger().logAlert("Some problem occurred when using the DevIO's write method")
            print_exc()
            #let's see if it raised an ACS Error
            #System exception first...
            try:
                compl = CouldntAccessPropertyCompletionImpl(exception=e)
            except:
                #a native Python exception was raised...not much we can do
                #here
                compl = CouldntAccessPropertyCompletionImpl()
Пример #4
0
    def stop(self):
        '''
        Stops a timing operation. Can only be called after a start invocation.
        
        Params: None
        
        Returns: the duration of time that has passed since start was
        called in ms units
        '''
        if self.last_start_time == 0:
            print "Looks like Profiler::stop was called twice in a row without invoking Profiler::start"
            return 0

        #get the time difference in millisecond units
        timeDiff = (getTimeStamp().value - self.last_start_time) / 10000.0

        #check to see if we have new records for the min or max
        #durations
        if timeDiff > self.max:
            self.max = timeDiff

        if timeDiff < self.min:
            self.min = timeDiff

        self.last_start_time = 0
        self.total_time = self.total_time + timeDiff

        return timeDiff
Пример #5
0
    def stop(self):
        '''
        Stops a timing operation. Can only be called after a start invocation.
        
        Params: None
        
        Returns: the duration of time that has passed since start was
        called in ms units
        '''
        if self.last_start_time == 0:
            print "Looks like Profiler::stop was called twice in a row without invoking Profiler::start"
            return 0
        
        #get the time difference in millisecond units
        timeDiff = (getTimeStamp().value - self.last_start_time)/10000.0
        
        #check to see if we have new records for the min or max
        #durations
        if timeDiff > self.max:
            self.max = timeDiff
	    
        if timeDiff < self.min:
            self.min=timeDiff
	    
        self.last_start_time=0
        self.total_time = self.total_time + timeDiff
        
        return timeDiff
Пример #6
0
    def authenticate(self, execution_id, question): # pragma: NO COVER 
        '''
        Implementation of IDL method.
        '''
#        return "CacsCORBA Client"
        return AuthenticationData("CacsCORBA Client", maci.CLIENT_TYPE,
                                  maci.PYTHON, False, getTimeStamp().value, execution_id)
    def push_structured_event (self, event):
        try:
            print "push_structured_event called!"
            self.numReceived = self.numReceived + 1

            receptionTime = getTimeStamp().value

            # output the reception time (only done for the first and last messages)
            if(self.numReceived == 1 or self.numReceived >= self.numToExpect):
                print >> self.outputfile, "reception time: " + str(receptionTime)
            
            #calculate the time difference in seconds
            sentTime = event.remainder_of_body.value().timestamp
            timeDiff = duration2py(long(receptionTime - sentTime))

            # special check for negative values - still not clear why we get the occasional value below zero, for
            # remote consumers - hypothesis is something to do w/ precision of clock synchronization. See wiki page
            # for more detailed explanation of this hypothesis. For now, make the negative values equal to zero.
            if timeDiff < 0.0:
               timeDiff = 0.0

            print >> self.outputfile, str(timeDiff)
            # flush is needed because monitoring applications are watching output for sign of completion
            # and will not know when things are finished if they're buffered
            if(self.numReceived >= self.numToExpect):
                self.outputfile.flush()

            sleep(self.waitBetweenEvents)

        except Exception, e:
            self.logger.logCritical('Unable to use handler function...' + str(e))
            print_exc()
Пример #8
0
def tryCallbackParams(params, compRef):
    '''
    Takes in some parameters that were passed to a component method and checks
    to see if any of them are actually callbacks. If this is the case, the
    callbacks done method is invoked.
    '''
    from Acssim.Corba.Generator import getRandomValue
    
    compl = ACSErr.Completion(long(getTimeStamp().value),  #ULL
                              0L,  #ACSErr::CompletionType type;
                              0L,  #ACSErr::CompletionCode code;
                              ())
                              
    cbId = 0L    #default value
    for param in params:
        if isinstance(param, ACS.CBDescIn):
            cbId = param.id_tag
            break
        
    cbDescOut = ACS.CBDescOut(0L, cbId)

    for param in params:
        if isinstance(param, ACS._objref_CBvoid):
            param.done(compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBpattern):
            param.done(getRandomValue(ACS._tc_pattern, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBpattern):
            param.done(getRandomValue(ACS._tc_pattern, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBdouble):
            param.done(getRandomValue(CORBA._tc_double, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBstring):
            param.done(getRandomValue(CORBA._tc_string, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBstringSeq):
            param.done(getRandomValue(ACS._tc_stringSeq, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBlong):
            param.done(getRandomValue(CORBA._tc_long, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBdoubleSeq):
            param.done(getRandomValue(ACS._tc_doubleSeq, compRef),
                       compl,
                       cbDescOut)
        elif isinstance(param, ACS._objref_CBlongSeq):
            param.done(getRandomValue(ACS._tc_longSeq, compRef),
                       compl,
                       cbDescOut)
        else:
            pass
Пример #9
0
 def authenticate(self, execution_id, question):  # pragma: NO COVER
     '''
     Implementation of IDL method.
     '''
     #        return "CacsCORBA Client"
     return AuthenticationData("CacsCORBA Client", maci.CLIENT_TYPE,
                               maci.PYTHON, False,
                               getTimeStamp().value, execution_id)
Пример #10
0
 def actionImpl(self, cb, desc):
     '''
     '''
     print "Aysnc. action finished"
     compl = Completion(long(getTimeStamp().value),  #unsigned long long timeStamp;
                        0L,  #ACSErr::CompletionType type;
                        0L,  #ACSErr::CompletionCode code;
                        ())  #ErrorLinkedList  previousError;
     
     cb.done(compl, CBDescOut(0L, desc.id_tag))
     return
Пример #11
0
def getKnownBaciType(ifr_id):
    '''
    Returns an instance of an ACS BACI type.
    
    Params: ifr_id interface repository ID of the type
    
    Returns: an instance of the class defined by ifr_id
    
    Raises: an exception if this type has not been implemented
    by ACS.
    '''
    if ifr_id == "IDL:alma/ACSErr/Completion:1.0":
        return ACSErr.Completion(long(getTimeStamp().value),  #ULL;
                                 0L,  #ACSErr::CompletionType type;
                                 0L,  #ACSErr::CompletionCode code;
                                 ())
    else:
        raise "dummie exception"
Пример #12
0
    def start(self):
        '''
        Starts a timing operation.
        
        Params: None
        
        Returns: Nothing
        
        Raises: ???
        '''

        if self.last_start_time == 0:
            self.total_num_starts = self.total_num_starts + 1
        else:
            print "Looks like Profiler::start was called twice in a row without invoking Profiler::stop"

        self.last_start_time = getTimeStamp().value
        return
Пример #13
0
    def start(self):
        '''
        Starts a timing operation.
        
        Params: None
        
        Returns: Nothing
        
        Raises: ???
        '''
        
        if self.last_start_time==0:
            self.total_num_starts=self.total_num_starts+1
        else:
            print "Looks like Profiler::start was called twice in a row without invoking Profiler::stop"

        self.last_start_time=getTimeStamp().value
        return
Пример #14
0
    def get_sync(self):
        '''
        Implementation of the IDL method.

        stringSeq get_sync (out ACSErr::Completion c);
        '''
        try:
            #first just try to get the value from the DevIO...
            retVal = self.value.read()

            #in order to provide the same interface as the C++ DevIOs,
            #a Python DevIO is expected to pass back a list of value
            #and timestamp.  To preserve backward compatablity, if the
            #DevIO does not return a tuple, a timestamp will be generated
            #as before.
            if isinstance(retVal, tuple):
                ts = retVal[-1]
                retVal = retVal[0]
            else:
                ts = long(getTimeStamp().value)

            #succeeded! now just create a "no-error" completion
            compl = Completion(
                ts,  #unsigned long long timeStamp;
                0L,  #ACSErr::CompletionType type;
                0L,  #ACSErr::CompletionCode code;
                ())  #ErrorLinkedList  previousError;
        except Exception, e:
            self.getLogger().logAlert(
                "Some problem occurred when accessing the DevIO's read method")
            print_exc()
            #whoops...something failed. use the default value as a return
            #value instead. this is bad to do but get_sync does not throw
            #IDL exceptions!
            retVal = self._get_default_value()

            #let's see if it raised an ACS Error
            #System exception first...
            try:
                compl = CouldntAccessPropertyCompletionImpl(exception=e)
            except:
                #a native Python exception was raised...not much we can do
                #here
                compl = CouldntAccessPropertyCompletionImpl()
Пример #15
0
    def get_sync(self):
        '''
        Implementation of the IDL method.

        stringSeq get_sync (out ACSErr::Completion c);
        '''
        try:
            #first just try to get the value from the DevIO...
            retVal = self.value.read()

            #in order to provide the same interface as the C++ DevIOs,
            #a Python DevIO is expected to pass back a list of value
            #and timestamp.  To preserve backward compatablity, if the
            #DevIO does not return a tuple, a timestamp will be generated
            #as before.
            if isinstance(retVal,tuple):
                ts = retVal[-1]
                retVal = retVal[0]
            else:
                ts = long(getTimeStamp().value)

            #succeeded! now just create a "no-error" completion
            compl = Completion(ts,  #unsigned long long timeStamp;
                               0L,  #ACSErr::CompletionType type;
                               0L,  #ACSErr::CompletionCode code;
                               ())  #ErrorLinkedList  previousError;
        except Exception, e:
            self.getLogger().logAlert("Some problem occurred when accessing the DevIO's read method")
            print_exc()
            #whoops...something failed. use the default value as a return
            #value instead. this is bad to do but get_sync does not throw
            #IDL exceptions!
            retVal = self._get_default_value()

            #let's see if it raised an ACS Error
            #System exception first...
            try:
                compl = CouldntAccessPropertyCompletionImpl(exception=e)
            except:
                #a native Python exception was raised...not much we can do
                #here
                compl = CouldntAccessPropertyCompletionImpl()
Пример #16
0
    def authenticate(self, execution_id, question):
        '''
        Authentication method. Method authenticate is the challenge issued to
        the client after it tries to login. The login will be successful if the
        clients authenticate() produces the expected result. Only in this case
        will the Managers login method return a valid handle, which the client
        will later use as the id parameter with all calls to the Manager.

        Parameters: question this string does not currently matter

        Return Answer - first character of the answer identifies the type of
        the client, and can be one of:
        - C = a regular client (implements just the Client interface).
        - A = a container (implements the Container interface).
        - AR = a container with recovery capability (implements the Container interface).
        - S = Supervisor (implements the Administrator interface).

        Raises: Nothing
    
        string authenticate (in string question);
        '''
        #to make pychecker happy
        question = None

        try:
            self.client_type
        except:
            self.client_type = maci.CLIENT_TYPE

        try:
            self.canRecover
        except:
            self.canRecover = False

        return maci.AuthenticationData(self.getCode() + self.name,
                                       self.client_type, maci.PYTHON,
                                       self.canRecover,
                                       getTimeStamp().value, execution_id)
Пример #17
0
    def authenticate(self, execution_id, question):
        '''
        Authentication method. Method authenticate is the challenge issued to
        the client after it tries to login. The login will be successful if the
        clients authenticate() produces the expected result. Only in this case
        will the Managers login method return a valid handle, which the client
        will later use as the id parameter with all calls to the Manager.

        Parameters: question this string does not currently matter

        Return Answer - first character of the answer identifies the type of
        the client, and can be one of:
        - C = a regular client (implements just the Client interface).
        - A = a container (implements the Container interface).
        - AR = a container with recovery capability (implements the Container interface).
        - S = Supervisor (implements the Administrator interface).

        Raises: Nothing
    
        string authenticate (in string question);
        '''
        #to make pychecker happy
        question = None

        try:
            self.client_type
        except:
            self.client_type = maci.CLIENT_TYPE

        try:
            self.canRecover
        except:
            self.canRecover = False
        
        return maci.AuthenticationData(self.getCode() + self.name, self.client_type,
                                 maci.PYTHON, self.canRecover, getTimeStamp().value, execution_id)
Пример #18
0
        # create list of Property to pass in the event
        new_list = [CosNotification.Property(acscommon.DEFAULTDATANAME,
                                             corba_any)]

        #Create the event dscription
        #get the component/client's name
        if supplier_name==None:
            try:
                component_name = self.component._get_name()
            except Exception, e:
                component_name = "Unknown"
        else:
            component_name = supplier_name
                
        #get the time the event is being sent
        time_stamp = getTimeStamp()
        
        event_descrip = acsnc.EventDescription(component_name,
                                               long(time_stamp.value),
                                               long(self.count))
        event_descrip = CORBA.Any(CORBA.TypeCode(CORBA.id(event_descrip)),
                                  event_descrip)

        # create the structured event
        se = CosNotification.StructuredEvent(header,
                                             new_list,
                                             event_descrip)
        
        # publish the event
        try:
            self.sppc.push_structured_event(se)
Пример #19
0
from Acspy.Common.TimeHelper     import getTimeStamp
from Acspy.Common.EpochHelper    import EpochHelper
from Acspy.Common.DurationHelper import DurationHelper
#------------------------------------------------------------------------------
print "DWF...need a real test here!!!"

# format string using all possible
allOut = "%G %g %x\n%Y %y %m %h %j %d %e %w %a %H:%M:%S.%q %1q %2q %3q %4q %5q %6q"

e1 = EpochHelper()	
e2 = EpochHelper()
	
d1 = DurationHelper()
	
# create an Epoch structure
eout = getTimeStamp()
	
e1.value(eout)
	
pStr = e1.toString(acstime.TSArray,
                   "%x",
                   0L, 
                   0L)
	
#print "Current time is " , pStr 

# test Epoch range & toUTUdate(), toJulianYear()
eout.value = 0xFFFFFFFFFFFFFFFA
e1.value(eout)
	
pStr = e1.toString(acstime.TSArray,"", 0L, 0L)
Пример #20
0
    def __init__(self,
                 error_type,
                 error_code,
                 exception = None,
                 description = "None", 
                 nvSeq = None,
                 level = 3,
                 severity = None,
                 sourceobject = ""):
        '''
        Parameters:
        - error_type is the error type (a long)
        - error_code is the error code (a long)
        - exception is a previous exception from the ACS Error System, or a Python 
	native exception, in which case, an ErrorTrace will be constructed. The traceback
	should be ok in most cases, but if you find that it isn't, a possible workaround is
	converting the python exception to an ACS exception using pyExceptionToCORBA()
	before passing it to an ACSError constructor. Remember, that if you don't use 
	pyExceptionToCORBA(), if 
	you are dealing with a native exception, you must pass create=1 to the ACSError 
	constructor.
        - description is a stringified description of the errror
        - nvSeq is a name-value sequence describing the error condition. Each value
        should be of the type ACSErr.NameValue
        - level is an offset from stack()
        - severity is the severity of the error
        '''
        call_frame = stack()[level]
        
        if nvSeq == None:
            nvSeq = []
    
        #Get the file name
        filename = str(call_frame[1])
    
        #Get the line number
        line = str(call_frame[2])
    
        #Get the routine name
        routine = str(call_frame[3])
    
        #Get the hostname
        host = gethostname()
    
        #Get the process ID
        process = str(getpid())
        
        #Try to get the thread ID
        if currentThread() != None:
            thread = str(currentThread().getName())
        else:
            thread = "Unavailable"
            
        #Get the ACS time
        time = getTimeStamp().value
            
        # Client, components and containers have 
        frame = call_frame[0]
        if 'self' in frame.f_locals and 'name' in frame.f_locals['self'].__dict__:
            sourceObject = frame.f_locals['self'].name
        else:
            sourceObject = sourceobject
        
        #Set the severity
        if severity == None:
            severity = ACSErr.Error
            
	
	#let's get the traceback in case we are dealing
	#with a Python native exception
	from traceback import extract_tb,format_exc
	string_tb=format_exc()
	from sys import exc_info
	tuple_tb=extract_tb(exc_info()[2])
        try:
            #If the previous exception is an ACS Error System Exception
            if isinstance(exception.errorTrace, ACSErr.ErrorTrace):
                #We can use an error stack...
                errortrace = [ exception.errorTrace ]
        except Exception, e:
           if exception == None:
                errortrace = []
           else:	
		#In this case we are dealing with a native Python Exception
		#so we have to "transform" it to an ACS exception
		#(actually we are only interested in the ErrorTrace)
                from ACSErrTypePythonNativeImpl import PythonExImpl
		

                #next get the type of native_ex. this will be used as the short
                #description
                descript = exception.__doc__

                #create the new exception
                new_except = PythonExImpl()

                #redo the error trace so that the level is one lower
                new_et = ErrorTrace(new_except.getErrorType(),
                                    new_except.getErrorCode(),
                                    description = new_except.getDescription(),
                                    level = 2, sourceobject=sourceObject)

		#Now modify some fields
		new_et.file=tuple_tb[0][0]
		new_et.lineNum=tuple_tb[0][1]
		new_et.routine=tuple_tb[0][2]

                new_except.setErrorTrace(new_et)

                #time to add the real description
                new_except.addData("Real Description", descript)

    		#add the real traceback
    		new_except.addData("Traceback", string_tb)


                errortrace= [ new_except.errorTrace ]
Пример #21
0
    def __init__(self,
                 error_type,
                 error_code,
                 exception=None,
                 description="None",
                 nvSeq=None,
                 level=3,
                 severity=None,
                 sourceobject=""):
        '''
        Parameters:
        - error_type is the error type (a long)
        - error_code is the error code (a long)
        - exception is a previous exception from the ACS Error System, or a Python 
	native exception, in which case, an ErrorTrace will be constructed. The traceback
	should be ok in most cases, but if you find that it isn't, a possible workaround is
	converting the python exception to an ACS exception using pyExceptionToCORBA()
	before passing it to an ACSError constructor. Remember, that if you don't use 
	pyExceptionToCORBA(), if 
	you are dealing with a native exception, you must pass create=1 to the ACSError 
	constructor.
        - description is a stringified description of the errror
        - nvSeq is a name-value sequence describing the error condition. Each value
        should be of the type ACSErr.NameValue
        - level is an offset from stack()
        - severity is the severity of the error
        '''
        call_frame = stack()[level]

        if nvSeq == None:
            nvSeq = []

        #Get the file name
        filename = str(call_frame[1])

        #Get the line number
        line = str(call_frame[2])

        #Get the routine name
        routine = str(call_frame[3])

        #Get the hostname
        host = gethostname()

        #Get the process ID
        process = str(getpid())

        #Try to get the thread ID
        if currentThread() != None:
            thread = str(currentThread().getName())
        else:
            thread = "Unavailable"

        #Get the ACS time
        time = getTimeStamp().value

        # Client, components and containers have
        frame = call_frame[0]
        if 'self' in frame.f_locals and 'name' in frame.f_locals[
                'self'].__dict__:
            sourceObject = frame.f_locals['self'].name
        else:
            sourceObject = sourceobject

        #Set the severity
        if severity == None:
            severity = ACSErr.Error

#let's get the traceback in case we are dealing
#with a Python native exception
        from traceback import extract_tb, format_exc
        string_tb = format_exc()
        from sys import exc_info
        tuple_tb = extract_tb(exc_info()[2])
        try:
            #If the previous exception is an ACS Error System Exception
            if isinstance(exception.errorTrace, ACSErr.ErrorTrace):
                #We can use an error stack...
                errortrace = [exception.errorTrace]
        except Exception, e:
            if exception == None:
                errortrace = []
            else:
                #In this case we are dealing with a native Python Exception
                #so we have to "transform" it to an ACS exception
                #(actually we are only interested in the ErrorTrace)
                from ACSErrTypePythonNativeImpl import PythonExImpl

                #next get the type of native_ex. this will be used as the short
                #description
                descript = exception.__doc__

                #create the new exception
                new_except = PythonExImpl()

                #redo the error trace so that the level is one lower
                new_et = ErrorTrace(new_except.getErrorType(),
                                    new_except.getErrorCode(),
                                    description=new_except.getDescription(),
                                    level=2,
                                    sourceobject=sourceObject)

                #Now modify some fields
                new_et.file = tuple_tb[0][0]
                new_et.lineNum = tuple_tb[0][1]
                new_et.routine = tuple_tb[0][2]

                new_except.setErrorTrace(new_et)

                #time to add the real description
                new_except.addData("Real Description", descript)

                #add the real traceback
                new_except.addData("Traceback", string_tb)

                errortrace = [new_except.errorTrace]
Пример #22
0
        new_list = [
            CosNotification.Property(acscommon.DEFAULTDATANAME, corba_any)
        ]

        #Create the event dscription
        #get the component/client's name
        if supplier_name == None:
            try:
                component_name = self.component._get_name()
            except Exception, e:
                component_name = "Unknown"
        else:
            component_name = supplier_name

        #get the time the event is being sent
        time_stamp = getTimeStamp()

        event_descrip = acsnc.EventDescription(component_name,
                                               long(time_stamp.value),
                                               long(self.count))
        event_descrip = CORBA.Any(CORBA.TypeCode(CORBA.id(event_descrip)),
                                  event_descrip)

        # create the structured event
        se = CosNotification.StructuredEvent(header, new_list, event_descrip)

        # publish the event
        try:
            self.sppc.push_structured_event(se)
            if event_callback != None:
                event_calback.eventSent(simple_data)
Пример #23
0
    Implementation of the TimeoutHandler IDL interface
    '''
    def handleTimeout(self, e):
        '''
        This method is overriden to do something useful
        once a timeout occurs
        '''
        print "The current time is: ", e.value
#---------------------------------------------------

# Make an instance of the PySimpleClient
simpleClient = PySimpleClient()

# Get the current time from the standard CLOCK1 Clock device and add 3 seconds to it
# This is when the timeout will occur.
start = long(getTimeStamp().value) + long(30000000)

# Get the standard Timer component which will
# schedule the timeout
timer = simpleClient.getDefaultComponent("IDL:alma/acstime/Timer:1.0")

# Create timeout handler and schedule its timeout
myHandler = TimeoutHandlerImpl()
myHandler2 = TimeoutHandlerImpl()

# A Duration of 0 implies the timeout will only occur once
id1 = timer.schedule(simpleClient.activateOffShoot(myHandler),
                     acstime.Epoch(start),
                     acstime.Duration(long(20000000)))

# A Duration of 0 implies the timeout will only occur once