Ejemplo n.º 1
0
	def set_scheduler(self):
		self.scheduler.add_job(self.hi, 'interval', seconds=0.5)
		if self.enable_ems:
			if self.db is None:
				self.db = db_session()
			self.scheduler.add_job(self.get_ems_data, 'interval', seconds=1)

		self.scheduler.start()
Ejemplo n.º 2
0
	def __init__(self, db_queue=None):
		threading.Thread.__init__(self)
		self.name = 'Database Service'
		self.q = db_queue
		self.db = db_session()

		print(self.name)

		test0 = self.db.query(BicDBData).filter(BicDBData.name == 'bic0').first()
		if test0 is None:
			self.db.add(BicDBData(name='bic0', datetime1=datetime.now()))
			self.db.commit()

		test1 = self.db.query(BatteryDBData).filter(BatteryDBData.name == 'battery0').first()
		if test1 is None:
			self.db.add(BatteryDBData(name='battery0', datetime1=datetime.now()))
			self.db.commit()

		test2 = self.db.query(PVDBData).filter(PVDBData.name == 'pv0').first()
		if test2 is None:
			self.db.add(PVDBData(name='pv0', datetime1=datetime.now()))
			self.db.commit()