def get_N_day(): today1 = datetime.date.today() today2 = datetime.date.today() oneday = datetime.timedelta(days=1) m1 = calendar.MONDAY m2 = calendar.SUNDAY while today1.weekday() != m1: today1 += oneday # today1 += oneday # while today1.weekday() != m1: # today1 += oneday while today2.weekday() != m2: today2 += oneday today2 += oneday while today2.weekday() != m2: today2 += oneday nextMonday = today1.strftime("%Y%m%d") nextSunday = today2.strftime("%Y%m%d") date_list = [ d.strftime("%Y-%m-%d") for d in pd.date_range(nextMonday, nextSunday, freq="D") ] list_date = [] for i in date_list: one = i.split("-") time = ["月", "日"] time.insert(0, one[1]) time.insert(2, one[2]) time1 = "".join(time) list_date.append(time1) return list_date
def get_wekday_list(num=1): today1 = datetime.date.today() today2 = datetime.date.today() oneday = datetime.timedelta(days=1) oneweek = datetime.timedelta(days=7) m1 = calendar.MONDAY m2 = calendar.SUNDAY for i in range(num): if today1.weekday() != m1: while today1.weekday() != m1: today1 += oneday else: today1 += oneweek if today2.weekday() != m2: today2 += oneweek while today2.weekday() != m2: today2 += oneday else: today2 += oneweek nextMonday = today1.strftime('%Y%m%d') nextSunday = today2.strftime('%Y%m%d') date_list = [d.strftime("%Y-%m-%d") for d in pd.date_range(nextMonday, nextSunday, freq="D")] date_list_changed = [] for i in date_list: one = i.split('-') time = ['月', '日'] time.insert(0, one[1]) time.insert(2, one[2]) time1 = ''.join(time) date_list_changed.append(time1) return date_list,date_list_changed
def convertToSec(pace): time = re.findall(r"[0-9]+", pace) if len(time) < 3: while len(time) < 3: time.insert(0, "00") time_in_sec = 3600 * int(time[0]) + 60 * int(time[1]) + int(time[2]) return time_in_sec
def time2str(t): time_division = [('s', 60), ('m', 60), ('h', 24)] time = [] for symbol, duration in time_division: v = t % duration if v > 0: time.insert(0, str(v) + symbol) t = t / duration return ' '.join(time)
def parse_timedelta(value): global etime_pattern time = etime_pattern.split(value) time = [int(x) for x in time] while len(time) != 4: time.insert(0, 0) return datetime.timedelta(days=time[0], hours=time[1], minutes=time[2], seconds=time[3])
def setWorkout(this, program=0, time=0, distance=0, split=0, pace=0, calpace=0, powerpace=0): command = ['CSAFE_RESET_CMD'] #Set Workout Goal if program != 0: this.__checkvalue(program, "Program", 0, 15) elif time != 0: if len(time) == 1: time.insert(0,0) #if only seconds in time then pad minutes if len(time) == 2: time.insert(0,0) #if no hours in time then pad hours this.__checkvalue(time[0], "Time Hours", 0, 9) this.__checkvalue(time[1], "Time Minutes", 0, 59) this.__checkvalue(time[2], "Time Seconds", 0, 59) if time[0] == 0 and time[1] == 0 and time[2] < 20: raise ValueError("Workout too short") #checks if workout is < 20 seconds command.extend(['CSAFE_SETTWORK_CMD', time[0], time[1], time[2]]) elif distance != 0: this.__checkvalue(distance, "Distance", 100, 50000) command.extend(['CSAFE_SETHORIZONTAL_CMD', distance, 36]) #36 = meters #Set Split if split != 0: if time != 0 and program == 0: split = int(split*100) timeraw = time[0]*3600+time[1]*60+time[2] #total workout time (1 sec) minsplit = int(timeraw/30*100+0.5) #split time that will occur 30 times (.01 sec) this.__checkvalue(split, "Split Time", max(2000, minsplit), timeraw*100) command.extend(['CSAFE_PM_SET_SPLITDURATION', 0, split]) elif distance != 0 and program == 0: minsplit = int(distance/30+0.5) #split distance that will occur 30 times (m) this.__checkvalue(split, "Split distance", max(100, minsplit) , distance) command.extend(['CSAFE_PM_SET_SPLITDURATION', 128, split]) else: raise ValueError("Cannot set split for current goal") #Set Pace if pace != 0: powerpace = int(round(2.8 / ((splitpace / 500.) ** 3))) elif calpace != 0: powerpace = int(round((calpace - 300.)/(4.0 * 0.8604))) if powerpace != 0: command.extend(['CSAFE_SETPOWER_CMD', powerpace, 88]) #88 = watts command.extend(['CSAFE_SETPROGRAM_CMD', program, 0, 'CSAFE_GOINUSE_CMD']) this.send(command)
def __init__(self, time, colortemp, brightness): # times need to be in ascending order assert min(time) >= 0 assert max(time) <= 24 assert all( (time[i-1] < time[i]) for i in range(1, len(time)) ) # add "virtual" first/last hour so that interpolation correctly wraps around midnight first_time, last_time = time[0], time[-1] first_ct, last_ct = colortemp[0], colortemp[-1] first_bt, last_bt = brightness[0], brightness[-1] if time[0] > 0: time.insert(0, last_time-24) colortemp.insert(0, last_ct) brightness.insert(0, last_bt) if time[-1] < 24: time.append(first_time+24) colortemp.append(first_ct) brightness.append(first_bt) self.time = time self.colortemp = colortemp self.brightness = brightness
def moreScreen(): global speed # Create window for more menu other = Toplevel() other.title("Pepp Other Screen") other.geometry('800x480') other.configure(bg=main_bg) other.overrideredirect(1) # Fonts for screen stopFont = font.Font(family='Helvetica', size=50, weight='bold') otherFont = font.Font(family='Helvetica', size=24, weight='normal') headingFont = font.Font(family='Helvetica', size=20, weight='normal') calibFont = font.Font(family='Helvetica', size=30, weight='normal') diagFont = font.Font(family='Helvetica', size=19, weight='normal') # Other screen buttons helpButton = Button(other, text="HELP", font=stopFont, bg="red2", fg="#FFFFFF", command=sos, height=1, width=8) helpButton.place(x=460, y=20) home = Button(other, text="HOME", font=otherFont, bg=button_color, fg=main_fg, command=other.destroy, height=2, width=10) home.place(x=575, y=380) #TEMPORARY QUIT quitButton = Button(other, text="QUIT", font=diagFont, bg=button_color, fg=main_fg, command=screen.destroy, height=2, width=4) quitButton.place(x=300, y=10) # Machine diagnostics diag = Text(other, font=headingFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=21) diag.insert(INSERT, "MACHINE DIAGNOSTICS") diag.place(x=460, y=125) # Read data from file with open('SmartPepp/diagnostics.txt', 'r') as reader: diags = reader.read().splitlines() hours = Text(other, font=diagFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=37) hours.insert( INSERT, "Total Machine Hours.........." + str(int(int(diags[1]) / 60))) hours.place(x=460, y=170) pepped = Text(other, font=diagFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=37) pepped.insert(INSERT, "Total Pizzas Pepped.........." + diags[2]) pepped.place(x=460, y=220) time = Text(other, font=diagFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=37) time.insert(INSERT, "Average Pizza Time..........." + diags[3]) time.place(x=460, y=270) health = Text(other, font=diagFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=37) health.insert(INSERT, "Machine Health..........." + diags[4]) health.place(x=460, y=320) # Calibration calib = Text(other, font=headingFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=27) calib.insert(INSERT, "PEPP WEIGHT CALIBRATION") calib.place(x=10, y=10) text14 = Text(other, font=calibFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=3) text14.insert(INSERT, "14\"") text14.place(x=10, y=80) text12 = Text(other, font=calibFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=3) text12.insert(INSERT, "12\"") text12.place(x=10, y=170) text10 = Text(other, font=calibFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=3) text10.insert(INSERT, "10\"") text10.place(x=10, y=260) text7 = Text(other, font=calibFont, bd=-2, bg=main_bg, fg=main_fg, height=1, width=3) text7.insert(INSERT, "7\"") text7.place(x=10, y=350) speed14Var = DoubleVar() speed14Var.set(calibration[14]) speed14 = Label(other, font=calibFont, textvariable=speed14Var, bg=button_color, fg=main_fg, bd=-2, height=1, width=7) speed14.place(x=160, y=82) speed12Var = DoubleVar() speed12Var.set(calibration[12]) speed12 = Label(other, font=calibFont, textvariable=speed12Var, bg=button_color, fg=main_fg, bd=-2, height=1, width=7) speed12.place(x=160, y=172) speed10Var = DoubleVar() speed10Var.set(calibration[10]) speed10 = Label(other, font=calibFont, textvariable=speed10Var, bg=button_color, fg=main_fg, bd=-2, height=1, width=7) speed10.place(x=160, y=262) speed7Var = DoubleVar() speed7Var.set(calibration[7]) speed7 = Label(other, font=calibFont, textvariable=speed7Var, bg=button_color, fg=main_fg, bd=-2, height=1, width=7) speed7.place(x=160, y=352) sub14 = Button(other, text="-", font=calibFont, bg=button_color, fg=main_fg, command=lambda: subtract(14, speed14Var), height=1, width=2) sub14.place(x=80, y=75) add14 = Button(other, text="+", font=calibFont, bg=button_color, fg=main_fg, command=lambda: add(14, speed14Var), height=1, width=2) add14.place(x=325, y=75) sub12 = Button(other, text="-", font=calibFont, bg=button_color, fg=main_fg, command=lambda: subtract(12, speed12Var), height=1, width=2) sub12.place(x=80, y=165) add12 = Button(other, text="+", font=calibFont, bg=button_color, fg=main_fg, command=lambda: add(12, speed12Var), height=1, width=2) add12.place(x=325, y=165) sub10 = Button(other, text="-", font=calibFont, bg=button_color, fg=main_fg, command=lambda: subtract(10, speed10Var), height=1, width=2) sub10.place(x=80, y=255) add10 = Button(other, text="+", font=calibFont, bg=button_color, fg=main_fg, command=lambda: add(10, speed10Var), height=1, width=2) add10.place(x=325, y=255) sub7 = Button(other, text="-", font=calibFont, bg=button_color, fg=main_fg, command=lambda: subtract(7, speed7Var), height=1, width=2) sub7.place(x=80, y=345) add7 = Button(other, text="+", font=calibFont, bg=button_color, fg=main_fg, command=lambda: add(7, speed7Var), height=1, width=2) add7.place(x=325, y=345)
def bar_base() -> Bar: path = "Video_Monitor/video_list.json" ztstatus = Readjson(path) now = datetime.datetime.now() zsf = now.minute % 10 time = [] if zsf > 0: dqzsj = now - datetime.timedelta(minutes=zsf) else: dqzsj = now for j in range(720): tssj1 = dqzsj - datetime.timedelta(minutes=1 * (j - 1)) tssj = tssj1.strftime('%Y-%m-%d %H:%M') time.insert(0, tssj) # app.logger.info(time) data = select(time[0]) # app.logger.info(data) name = ztstatus[1][0] newData = [] for value in range(len(data)): x = time.index(data[value].get('testtime')) y = name.index(data[value].get('ztname')) z = data[value].get('ztstatus') newData.append([x, y, z]) data = [[d[0], d[1], d[2] or "-"] for d in newData] c = ( HeatMap().add_xaxis(xaxis_data=time).add_yaxis( series_name="详情", yaxis_data=name, value=data, label_opts=opts.LabelOpts(is_show=True, color="#fff", position="bottom", horizontal_align="100%"), ).set_series_opts( label_opts=opts.LabelOpts(is_show=True), minortick_opts=opts.MinorTickOpts(is_show=True, split_number=8), minorsplitkine_opts=opts.MinorSplitLineOpts(is_show=True)). set_global_opts( # tooltip_opts=opts.TooltipOpts(formatter='{a},{@time}:\n,{@[0]}'), # axistick_opts=opts.AxisTickOpts(is_show=False), visualmap_opts=opts.VisualMapOpts(is_show=True, is_piecewise=True, pos_left='center', orient='horizontal', pieces=[{ "value": 200, "label": '正常', "color": 'green' }, { "value": 404, "label": '异常', "color": 'Orange' }, { "value": 408, "label": '超时', "color": 'grey' }]), legend_opts=opts.LegendOpts(is_show=False), xaxis_opts=opts.AxisOpts( type_="category", boundary_gap=True, axistick_opts=opts.AxisTickOpts(is_align_with_label=True), splitarea_opts=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), splitline_opts=opts.SplitLineOpts( is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)), minor_split_line_opts=opts.MinorSplitLineOpts(is_show=True), ), yaxis_opts=opts.AxisOpts( type_="category", boundary_gap=True, axistick_opts=opts.AxisTickOpts(is_align_with_label=True), splitarea_opts=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), splitline_opts=opts.SplitLineOpts( is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)), ), )) return c
def insert_data_into_database(tablename, data, t): CONNECTION.execute(t.insert(), data)
print(node) row, col = df_results.shape time = [] inputval = [] outputval = [] #print(df_results["input"][0][1], df_results["output"][0][1]) #print(df_results["input"][0]) for i in range(row): time.append(df_results["input"][i][0]) inputval.append(df_results["input"][i][1]) outputval.append(df_results["output"][i][1]) #inputval.insert(len(inputval), 0) #outputval.insert(len(outputval), 0) time.insert(len(time), time[len(time) - 1] + 60) tuple_in = list(zip(time, inputval)) tuple_out = list(zip(time, outputval)) tuples = list(zip(time, inputval, outputval)) #print(tuples) #Do warning, count of NANs df_input = pd.DataFrame(data=tuple_in, columns=['Timestamp', 'Input']) #df_input["Input"] = df_input["Input"].replace(np.nan,0) df_input["Timestamp"] = pd.to_datetime(df_input["Timestamp"], unit='s') df_input = df_input.set_index(["Timestamp"]) df_input = df_input.resample("5T").agg(['min', 'max', 'mean', 'std'], axis="columns").round(5) cols = df_input.columns df_input[cols] = df_input[cols] * (1.25e-10) df_input = df_input[:1] df_input = df_input.reset_index()
def configSingulersum(self, top): row = 0 column = 0 if top!=self and isinstance(top, Toplevel) is True: # coming from menu, settings placed in a Toplevel (new Window) top.title("configure Singulersum object") top.geometry( "{:d}x{:d}".format(800, int(800/4*2)) ) top.bind('<Escape>', lambda e: top.destroy()) else: # in settingsPanel, set title l=Label(top, text="settings panel") l.grid(row=row, column=column, sticky=W) row+=2 entries = [] label = Label(top, text="") label.grid(row=row, column=column, sticky=W) row+=1 label = Label(top, text="set time") label.grid(row=row, column=column, sticky=W) column+=1 time = Entry(top) time.insert(0, self.sg.time) entries.append( { "object":self.sg, "name":"time", "value":time, "type":"f" } ) time.grid(row=row, column=column, sticky=W) column=0 row+=1 label = Label(top, text="show coordinate system") label.grid(row=row, column=column, sticky=W) column+=1 coord = IntVar() coord.set(self.sg.showCoordinateSystem) coordck = Checkbutton(top, variable=coord) entries.append( { "object":self.sg, "name":"showCoordinateSystem", "value":coord, "type":"b" } ) coordck.grid(row=row, column=column, sticky=W) column=0 row+=1 label = Label(top, text="show bounding boxes") label.grid(row=row, column=column, sticky=W) column+=1 bbs = IntVar() bbs.set(self.sg.showBoundingBox) bbsck = Checkbutton(top, variable=bbs) entries.append( { "object":self.sg, "name":"showBoundingBox", "value":bbs, "type":"b" } ) bbsck.grid(row=row, column=column, sticky=W) column=0 row+=1 label = Label(top, text="show backside") label.grid(row=row, column=column, sticky=W) column+=1 bs = IntVar() bs.set(self.sg.showBackside) bsck = Checkbutton(top, variable=bs) entries.append( { "object":self.sg, "name":"showBackside", "value":bs, "type":"b" } ) bsck.grid(row=row, column=column, sticky=W) column=0 row+=1 column=0 row+=1 label = Label(top, text="polyOnlyGrid") label.grid(row=row, column=column, sticky=W) column+=1 po = IntVar() po.set(self.sg.polyOnlyGrid) pock = Checkbutton(top, variable=po) entries.append( { "object":self.sg, "name":"polyOnlyGrid", "value":po, "type":"b" } ) pock.grid(row=row, column=column, sticky=W) column=0 row+=1 button = Button(top, text="Apply", command=lambda: self.apply(top, entries, True)) button.grid(row=row, column=column, sticky=W) column+=1 button = Button(top, text="Cancel", command=lambda: self.apply(top, entries, False)) button.grid(row=row, column=column, sticky=W)
f = open("data_compteurgeneral_second_2015_09.csv", "r") headers = open("Headers_CompteurGeneral.txt", "w") for row in csv.reader(f): for i in range(0, len(row)): headers.write(row[i] + '\n') break headers.close() time = []; gen = []; use = []; pp1 = []; pp2 = []; pp3 = []; ip1 = []; ip2 = []; ip3 = []; mcb = [] total = [time, gen, use, pp1, pp2, pp3, ip1, ip2, ip3, mcb] for row in csv.reader(f): n = len(total[0]) time.insert(n,datetime.datetime.strptime(row[0], "%Y-%m-%d %H:%M:%S")) for i in range(1, len(total)): total[i].insert(n,row[i]); #print((time[0])) #print(len(time)) # In[211]: # PLOT ONE DAY time_plot=dts.date2num(time) plt.plot(time_plot[0:1440], gen[0:1440]) plt.title("Generation over time on "+(str)(time[0].date())) plt.show()
def setWorkout(this, program=0, time=0, distance=0, split=0, pace=0, calpace=0, powerpace=0): command = ['CSAFE_RESET_CMD'] #Set Workout Goal if program != 0: this.__checkvalue(program, "Program", 0, 15) elif time != 0: if len(time) == 1: time.insert(0, 0) #if only seconds in time then pad minutes if len(time) == 2: time.insert(0, 0) #if no hours in time then pad hours this.__checkvalue(time[0], "Time Hours", 0, 9) this.__checkvalue(time[1], "Time Minutes", 0, 59) this.__checkvalue(time[2], "Time Seconds", 0, 59) if time[0] == 0 and time[1] == 0 and time[2] < 20: raise ValueError( "Workout too short") #checks if workout is < 20 seconds command.extend(['CSAFE_SETTWORK_CMD', time[0], time[1], time[2]]) elif distance != 0: this.__checkvalue(distance, "Distance", 100, 50000) command.extend(['CSAFE_SETHORIZONTAL_CMD', distance, 36]) #36 = meters #Set Split if split != 0: if time != 0 and program == 0: split = int(split * 100) timeraw = time[0] * 3600 + time[1] * 60 + time[ 2] #total workout time (1 sec) minsplit = int( timeraw / 30 * 100 + 0.5) #split time that will occur 30 times (.01 sec) this.__checkvalue(split, "Split Time", max(2000, minsplit), timeraw * 100) command.extend(['CSAFE_PM_SET_SPLITDURATION', 0, split]) elif distance != 0 and program == 0: minsplit = int( distance / 30 + 0.5) #split distance that will occur 30 times (m) this.__checkvalue(split, "Split distance", max(100, minsplit), distance) command.extend(['CSAFE_PM_SET_SPLITDURATION', 128, split]) else: raise ValueError("Cannot set split for current goal") #Set Pace if pace != 0: powerpace = int(round(2.8 / ((splitpace / 500.)**3))) elif calpace != 0: powerpace = int(round((calpace - 300.) / (4.0 * 0.8604))) if powerpace != 0: command.extend(['CSAFE_SETPOWER_CMD', powerpace, 88]) #88 = watts command.extend( ['CSAFE_SETPROGRAM_CMD', program, 0, 'CSAFE_GOINUSE_CMD']) this.send(command)
# root.overrideredirect(1) # root.geometry("%dx%d+0+0" % (w, h)) app = Frame(root) app.grid() customFont = tkFont.Font(family="Cambria", size=30) helv36 = tkFont.Font(family="Helvetica",size=36,weight="bold" ) time = Text(root) time.configure(bg='#000000',state=NORMAL, highlightthickness = 0) time.tag_configure('big', justify = RIGHT, foreground='#ffffff', background="black", font=("Helvetica",36,"bold" )) time.insert(END, timeNow, 'big') time.place(x = 1030, y = 10, height=45, width=160) text = Text(root) #state normal = default makes text area editable diabale after setting contents text.configure(bg='#000000',state=NORMAL, highlightthickness = 0) text.tag_configure('big', foreground='#ffffff', background="black", font=("Helvetica",36,"bold" )) text.insert(END, dateNow, 'big') text.insert(END, WeatherNow, 'big') text.configure(state=DISABLED) # text.pack() text.place(x = 10, y = 10, height=200, width=900) stocks = Text(root) stocks.configure(bg='#000000',state=NORMAL, highlightthickness = 0) stocks.tag_configure('big', foreground='#ffffff', background="black", font=("Helvetica",36,"bold" ))