예제 #1
0
    def value(self, epoch=None):
        '''
        Overriden.

        Raises: TypeNotFoundExImpl
        '''
        #if provided nothing just use the superclass directly
        if epoch == None:
            return_value = acstimeSWIG.EpochHelper.value(self)
            return acstime.Epoch(return_value.value)
        #epoch is SWIG generated
        elif isinstance(epoch, acstimeSWIG.Epoch):
            acstimeSWIG.EpochHelper.value(self, epoch)
        #epoch is CORBA generated
        elif isinstance(epoch, acstime.Epoch):
            #convert it into the SWIG generated class
            value = epoch.value
            epoch = acstimeSWIG.Epoch()
            epoch.value = value
            acstimeSWIG.EpochHelper.value(self, epoch)
        #let them also use simple types...
        elif isinstance(epoch, long):
            value = epoch
            epoch = acstimeSWIG.Epoch()
            epoch.value = value
            acstimeSWIG.EpochHelper.value(self, epoch)
        else:
            raise TypeNotFoundExImpl()
예제 #2
0
    def epoch2py(self, epoch):
        '''
        Convert an ACS Epoch to a Python Epoch.

        Parameters: epoch is the number of 100 nanoseconds that have passed since
        October 15, 1582.

        Return: epoch converted a Python Epoch (i.e., seconds that have passed
        since January 1, 1970.)

        Raises: Nothing
        '''
        #let them specify a regular long instead of the nasty acstime.Epoch
        #struct
        if isinstance(epoch, long):
            epoch = acstime.Epoch(epoch)

        acs_time = epoch.value - acstime.ACE_BEGIN  #100ns units
        sec = acs_time / 10000000L
        return sec
예제 #3
0
# 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
id2 = timer.schedule(simpleClient.activateOffShoot(myHandler2),
                     acstime.Epoch(start),
                     acstime.Duration(long(0)))

# Give it ten seconds to run
sleep(10)

timer.cancel(long(id1))

# Give it ten more seconds to run
sleep(10)
예제 #4
0
 def testEpoch2PyPyEpoch(self):
     '''TimeUtil.epoch2py handles Python epoch correctly'''
     rtn = self.th.epoch2py(acstime.Epoch(acstime.ACE_BEGIN))
     self.assertEqual(0L, rtn)
예제 #5
0
 def testEpoch2PyEpoch(self):
     '''TimeUtil.epoch2py handles ACS epoch correctly'''
     rtn = self.th.epoch2py(acstime.Epoch(0))
     self.assertEqual(True, isinstance(rtn, long))
     self.assertEqual(-acstime.ACE_BEGIN / 10000000L, rtn)
예제 #6
0
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307  USA
#
# @(#) $Id: acspyTestTimehelper.py,v 1.1.1.1 2012/03/07 17:40:45 acaproni Exp $
###############################################################################
'''
Tests the Python Time System.
'''
###############################################################################
import acstime
from Acspy.Common import TimeHelper

print "getTimeStamp is:", TimeHelper.getTimeStamp()

obj = TimeHelper.TimeUtil()

print "January 1, 1970 is:", obj.py2epoch(0).value, " in ACS time"

print "January 1, 1970 is:", obj.epoch2py(acstime.Epoch(
    obj.py2epoch(0).value)), " in Python time"

print "October 15, 1582 is:", obj.py2epoch(obj.epoch2py(
    acstime.Epoch(0))).value, " in ACS time"

print "October 15, 1582 is:", obj.epoch2py(acstime.Epoch(0)), " in Python time"

print "1000 seconds is:", obj.py2duration(1000).value, " in ACS time"

print "1000 seconds is:", obj.duration2py(
    acstime.Duration(obj.py2duration(1000).value)), " in Python time"