Ejemplo n.º 1
0
Archivo: gui.py Proyecto: spalk/dimeteo
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        # get data
        d = db.Gui_Data().get_temp_24h()

        t3 = Toplevel(self,  bg='gray')
        t3.overrideredirect(1)
        t3.geometry('%sx%s' % (X, Y)) # сделать определение разрешения экрана

        self.canvas = Canvas(t3, width = X, height= Y)

        curtime = datetime.datetime.now().strftime('%H:%M:%S')
        self.sensors = sensors.sensors()
        curtemp_out = 'Temp Out: %s' % round(self.sensors.read_temp_DS18B20(), 2)
        curtemp_in = 'Temp In: %s' % round(self.sensors.read_temp_BME280(), 2)

        self.temp = graf(self.canvas, (0,0), (1,1), border = 1, border_color = 'red')
        self.temp.add_graf((20,5,28,25), d, smooth = 1, border = 1, tag = 'graf_temp_out')
        self.temp.add_x_axe(4, dash_shift = -24, x_lables_shift=(0, -11), x_lable_color = 'dark slate gray', x_lable_angle = 90)
        self.temp.add_y_axe(300, dash_shift = -4, y_dash_color = 'SteelBlue2',  y_lables_shift=(-10, 0), y_labels_font=('tahoma', 8))
        self.temp.add_title(curtime, position = (50,10), font = ('tahoma', 9), color = 'green', tag = 'time')
        self.temp.add_title(curtemp_out, position = (265,10), font = ('tahoma', 9), color = 'red', tag = 'cur_temp_out')
        self.temp.add_title(curtemp_in, position = (150,10), font = ('tahoma', 9), color = 'purple', tag = 'cur_temp_in')
        self.canvas.pack()


        self.update_clock()
        self.update_graf()
        self.update_axes()
        self.update_cur_temp()
Ejemplo n.º 2
0
def process_logfile_data(filename, doc, logdb, voltsdb):
    data_output_dir = config.log_file_download_path

    out_file_path = (os.path.join(data_output_dir, filename))
    out_file = open(out_file_path, 'wb')
    out_file.write(logdb.get_attachment(doc, filename).read())
    out_file.close()

    devices = sensors()

    with open(out_file_path, "r") as input_file:
        in_csv = csv.DictReader(input_file, delimiter=',')

        for line in in_csv:
            print(line)
            try:
                dt = datetime.datetime.strptime(line['Date'], "%m/%d/%y %H:%M:%S")

                for k, v in devices.items():
                    if v['sensor'] in line:
                        volts_doc = Volts(sensor_sn=v['sensor-sn'], gps=v['gps'], location=v['location'],
                                          logger_sn=v['logger-sn'], date=dt, volts=line[v['sensor']])
                        print(volts_doc)
                        volts_doc.store(voltsdb)
            except Exception as e:
                print(e)

    return True
Ejemplo n.º 3
0
# This script simply starts the sensor-thread & gives out the sensor-data in a desired mode.

from debug_log import debug_print
lg = debug_print()
import sensors
import time

mod = int(raw_input("Modus? 0, 1 oder 2? "))

sens = sensors.sensors(mode=mod, start=False)

raw_input("Press enter to start")
sens.start()

time.sleep(1)

while True:
	out = str(sens.running) + ": " + str(sens.measurements[0][0]) + ", ("
	for entry in sens.measurements[1]:
		out = out + str(entry[0]) + ", "
	out = out + "), "  + str(sens.measurements[2][0])
	f=open("test.txt", "w")
	print out + "\n"
	f.write(out + "\n")
	f.close()
	time.sleep(.5)
Ejemplo n.º 4
0
 def read_sensors():
     data = sensors.sensors().read_all()
     dbase = db.db()
     dbase.insert_sensor_data(data)
     dbase.close_connection()
Ejemplo n.º 5
0
gps_waiting_time = 0.5 # time in seconds in while-loop for waiting for valid GPS
log_file_name='log/RC_log'+str(time.time())+'.txt'	# log-file-name for the GPS-data (not for debug-messages)
accuracy = 0.00003 		 # when is the target reached?? define target-radius here; in degree! (0.000015 ~ 1,7m)
current_distance = accuracy * 10 # dummy value for current distance in meter (only needed for script to start)

Extra_Wait = False 	# Extra_Wait variable to remember that it is needed to wait longer in special cases
GPS_waiting_time = 0.1	# extra GPS-waiting time: for better average in GPS-data


#----------------------------------------------------------------------------------------#

#initialization

# start sensors
sens = sensors.sensors(mode=2, start=True, sensors_min=sens_min) # mode 2 seems to be the best mode: scanning

# start GPS
lg.prt("[01] start GPS & initialize speed control", inst=__name__, lv=200)
gpsp=GPS.GpsPoller()

# open GPS-log-file
lg.prt("[02] open GPS-log-file: " + log_file_name, inst=__name__, lv=200)
log_file = GPS_log.gpslog(log_file_name)

# waiting for GPS to fix
lg.prt("[03] Waiting for valid GPS-information", inst=__name__, lv=200)
time.sleep(2)
lg.prt(gpsp.data, inst=__name__, lv=100)

while (math.isnan(gpsp.data[0])):