Example #1
0
 def __init__(self,elementValue):
     if elementValue.getValue() is None:
         raise Exception("Cannot create a Fact from an empty ElementValue.")
     self.stationId      = int(elementValue.stationId)
     self.datetimeId     = int(elementValue.datetimeId)
     self.elementId      = int(elementValue.elementId)
     self.value          = Decimal(elementValue.getValue())
     self.flag           = int(elementValue.getFlags().intValue())
     self.decimalPlaces  = int(elementValue.getDecimalPlaces() or 0)
     self.publishedDecimalPlaces = int(elementValue.getPublishedDecimalPlaces() or 0)
     self._esgManager     = ElementSubhourlyGroupManager.getManager()
Example #2
0
def freshenGlobals():
    ''' Refreshes the lists of stations and elements. You shouldn't generally need to call 
        this directly; it's automagically called when needed. '''
    global globalloadtime
    global allstations
    global allelements

    if (time.time() - globalloadtime > 1800): # reload every 1/2 hour 
        #print "Refreshing global variables (allstations,allelements)."
        globalloadtime = time.time()                                                          
        allstations = stationDao.getStations() # only load the list of stations once 
        allelements = elementDao.getElements() # only load the list of elements once
        
        # Add the artificial subhourly elements to the allelements list
        esgManager = ElementSubhourlyGroupManager.getManager()
        for curid in esgManager.getAllIds():
            allelements.put(curid,esgManager.generateElement(curid))