Example #1
0
 def time(self, val):
     """Set system time"""
     d = datetime.datetime.fromtimestamp(float(val))
     timestr = d.strftime('%Y-%m-%d %H:%M:%S')
     self.output('Got Time. Setting to ' + timestr)
     if os.system('timedatectl set-time "' + timestr + '"') == 0:
         TimeUpdated.set()
     else:
         self.output('Time update failed')
Example #2
0
 def buildUp(self):
     self.output('Waiting for time to update...')
     # wait for time to come
     while not TimeUpdated.is_set() and not QuitinTime.is_set():
         TimeUpdated.wait(0.5)
     else:
         # if time never came and it's time to quit, skip tear down
         if QuitinTime.is_set():
             self.tearDown = lambda : None
             return
     self.output('Time updated... Starting')
     
     # setup sensors
     ADC.setup()
Example #3
0
 def get(self, typestr, val):
     """Tell storage to send back latest values"""
     if not TimeUpdated.is_set():
         self.send('notime', 0.0)
         return
     m = Message(to=['storage'],msg=['get', typestr])
     self.MessageBox.put(m)
Example #4
0
 def buildUp(self):
     self.output('Waiting for time to update...')
     # wait for time to come
     while not TimeUpdated.is_set() and not QuitinTime.is_set():
         TimeUpdated.wait(0.5)
     else:
         # if time never came and it's time to quit, skip tear down
         if QuitinTime.is_set():
             self.tearDown = lambda : None
             return
     self.output('Time updated... Starting')
     self.dbpath = '{0}/storage/{1}.db'.format(os.path.abspath(os.path.dirname(BeagleCommand.__file__)),datetime.now().strftime('%m.%d.%Y'))
     self.output('Using '+self.dbpath)
     self.conn = sqlite3.connect(self.dbpath)
     self.conn.execute('create table if not exists data (time real primary key, duration real, voltage real, used real, charged real);')
     self.cursor = self.conn.cursor()
     for row in self.cursor.execute('select time, duration, voltage, used, charged from data order by time;'):
         self.process(row)