00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2004 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 00011 __facility__ = "Online" 00012 __abstract__ = "Register access class" 00013 __author__ = "Amedeo Perazzo <perazzo@slac.stanford.edu> SLAC - GLAST I&T/Online" 00014 __date__ = ("$Date: 2004/08/24 22:57:25 $").split(' ')[1] 00015 __version__ = "$Revision: 2.3 $" 00016 __release__ = "$Name: R04-12-00 $" 00017 __credits__ = "SLAC" 00018 00019 import LATTE.copyright_SLAC 00020 import struct 00021 00022 class Register: 00023 def __init__(self, timestamp, status, payloads, format): 00024 self.__timestamp = timestamp 00025 self.__status = status 00026 p = 0 00027 shift = 0 00028 value = 0 00029 for payload in payloads: 00030 f = format[p] 00031 value |= payload << shift 00032 p += 1 00033 shift += struct.calcsize(f) << 3 00034 self.__value = value 00035 00036 def timestamp(self): 00037 return self.__timestamp 00038 00039 def status(self): 00040 return self.__status 00041 00042 def value(self): 00043 return self.__value