当前位置: 首页>>代码示例>>Python>>正文


Python Timer.reset方法代码示例

本文整理汇总了Python中Timer.Timer.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.reset方法的具体用法?Python Timer.reset怎么用?Python Timer.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timer.Timer的用法示例。


在下文中一共展示了Timer.reset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import reset [as 别名]
class Schedule:

	tdl = None
	taskList = []

	timer = None

	def __init__(self, fname):

		self.tdl = ToDoList(fname)
		self.taskList = self.tdl.getTaskList()

		random.shuffle(self.taskList)
		self.timer = Timer()
	
	def rereadTDL(self):

		currentTask = self.getCurrentTask()
		self.tdl.readTDL()
		self.taskList = self.tdl.getTaskList()
		random.shuffle(self.taskList)

		if currentTask in self.taskList:
			self.taskList.remove(currentTask)
			self.taskList.append(currentTask)
			self.taskList.reverse()
		else:
			self.timer.reset()
	
	def getCurrentTask(self):
		if len(self.taskList)==0:
			return None

		idx = (int(self.timer.getElapsed())/3600)%len(self.taskList)
		return self.taskList[idx]

	def getTimeRemaining(self):
		return int((3600-self.timer.getElapsed()%3600)/60)

	def markDone(self):
		if len(self.taskList)==0:
			return

		idx = int(self.timer.getElapsed()/3600)%len(self.taskList)
		self.taskList.pop(idx)
	
	def pauseTimer(self):
		self.timer.pause()
	
	def isPaused(self):
		return self.timer.paused

	def shuffle(self):
		random.shuffle(self.taskList)
开发者ID:tgvaughan,项目名称:taskmuxer,代码行数:56,代码来源:Schedule.py

示例2: updateK

# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import reset [as 别名]
    def updateK(self):
        [fro, to, pts] = eval(self.animationKEntry.get())

        self.K = np.linspace(fro, to, pts)
        t = np.linspace(0, float(self.timeEntry.get()), TIME_PTS)

        self.x_main = np.zeros((len(self.K), TIME_PTS, len(self.inpt.PlantFrame.getA())))
        self.u_main = np.zeros((len(self.K), TIME_PTS, self.inpt.PlantFrame.getB().shape[1]))

        for i in range(len(self.K)):
            Timer.reset(t)
            (x, u) = self.inpt.getX(t, self.Kset + [self.K[i]])

            self.u_main[i, :, :] = u
            self.x_main[i, :, :] = x
开发者ID:fgonz012,项目名称:Control-System-Application,代码行数:17,代码来源:PlotFrame.py

示例3: MainView

# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import reset [as 别名]
class MainView(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.label = QLabel("Alarm!", self)
        
        
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.label)
        
        self.timer = Timer()
        
        self.add_button_timer(10)
        
        self.add_button("&Quit", SLOT("quit()"))
        
        self.setLayout(self.layout)
        
    def add_button_timer(self, m):
        button = QPushButton("%dmin"%m, self)
        button.clicked.connect(lambda: self.timer.reset(m))
        self.layout.addWidget(button)
        
        
    def add_button(self, msg, slot):
        button = QPushButton(msg, self)
        self.connect(button, SIGNAL("clicked()"), QCoreApplication.instance(), slot)
        self.layout.addWidget(button)
开发者ID:shallwexuewei,项目名称:Alarm,代码行数:29,代码来源:MainView.py

示例4: run

# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import reset [as 别名]
    def run(self):

        """Get Timer"""
        try:
            t = np.linspace(0, float(self.timeEntry.get()), TIME_PTS)
            Timer.reset(t)
            self.feedbackFrame.clearMessages()

            (x, u) = self.inpt.getX(Timer.t)

        except Exception as e:
            print(e)
            self.feedbackFrame.clearMessages()
            self.feedbackFrame.addMsg("Invalid Input.")
        else:
            self.xlines = []
            self.ulines = []
            self.splines = []

            self.setNamesX(self.inpt.PlantFrame.getxnames())
            self.adjustX(self.inpt.PlantFrame.getxsize())

            self.setNamesU(self.inpt.PlantFrame.getunames())
            self.adjustU(self.inpt.PlantFrame.getusize())

            self.adjustSP()

            u_matrix = self.inpt.ControllerFrame.u_matrix

            self.analysis(x, u, self.names, self.unames, self.u, self.x)

            self.f.axes[0].cla()
            self.f.axes[0].grid()
            self.f.axes[0].set_xlabel("Time")

            color_index = 0

            for i in range(len(self.x)):
                self.xlines.append(
                    Line2D(
                        Timer.t,
                        x[:, i],
                        label=self.names[i],
                        linewidth=2,
                        c=self.colors[color_index % len(self.colors)],
                    )
                )
                color_index += 1
                if self.x[i].get():
                    self.f.axes[0].add_line(self.xlines[-1])

            for i in range(len(self.u)):
                self.ulines.append(
                    Line2D(
                        Timer.t,
                        u[:, i],
                        label=self.unames[i],
                        linewidth=2,
                        c=self.colors[color_index % len(self.colors)],
                    )
                )
                color_index += 1
                if self.u[i].get():
                    self.f.axes[0].add_line(self.ulines[-1])

            for i in range(len(self.sp)):
                if self.sp[i] != None:
                    self.splines.append(
                        Line2D(
                            Timer.t,
                            u_matrix[i].editWindow.get(),
                            label=self.sp[i].getName(),
                            linewidth=2,
                            c=self.colors[color_index % len(self.colors)],
                            ls="--",
                        )
                    )
                    color_index += 1
                    if self.sp[i].get():
                        self.f.axes[0].add_line(self.splines[-1])

            self.f.axes[0].margins(y=0.1)
            self.f.axes[0].set_xlim(0, Timer.t[-1])

            [ybot, ytop] = self.f.axes[0].get_ylim()

            self.f.axes[0].yaxis.set_major_locator(MaxNLocator(20))

            self.f.axes[0].legend(bbox_to_anchor=(1, 1), loc=2, borderaxespad=0.0)

            self.canvas.show()
开发者ID:fgonz012,项目名称:Control-System-Application,代码行数:93,代码来源:PlotFrame.py

示例5: validateTime

# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import reset [as 别名]
 def validateTime(self, event):
     try:
         t = np.linspace(0, float(self.timeEntry.get()), TIME_PTS)
         Timer.reset(t)
     except:
         self.feedbackFrame.addMsg("Invalid Time")
开发者ID:fgonz012,项目名称:Control-System-Application,代码行数:8,代码来源:PlotFrame.py

示例6: __init__

# 需要导入模块: from Timer import Timer [as 别名]
# 或者: from Timer.Timer import reset [as 别名]
    def __init__(self, parent, inpt, feedback, *args, **kwargs):
        LabelFrame.__init__(self, parent, *args, **kwargs)
        # self.test = scaleFrame(self)
        # self.test.pack()
        self.parent = parent

        self.inpt = inpt
        self.x = []
        self.u = []
        self.sp = []

        self.xlines = []
        self.ulines = []
        self.splines = []

        self.animation_lines = []

        self.names = []
        self.unames = []
        self.feedbackFrame = feedback

        self.colors = ["b", "g", "r", "brown", "purple", "orange"]
        self.f = Figure()
        self.f.add_subplot(111).grid()

        self.plottoolbarFrame = Frame(self)
        self.plottoolbarFrame.pack(side=LEFT, fill=BOTH, expand=True)

        self.canvas = FigureCanvasTkAgg(self.f, self.plottoolbarFrame)
        self.canvas.get_tk_widget().pack(fill=BOTH, expand=True)

        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.plottoolbarFrame)
        self.toolbar.update()
        self.canvas._tkcanvas.pack(fill=BOTH, expand=True)

        self.plotNotebook = ttk.Notebook(self)
        self.plotNotebook.pack(side=LEFT, fill=BOTH)

        self.plotOptionFrame = Frame(self.plotNotebook)
        self.plotOptionFrame.pack(fill=BOTH)

        self.plotsKFrame = Frame(self.plotNotebook)
        self.plotsKFrame.pack(fill=BOTH)

        self.animationFrame = LabelFrame(self.plotNotebook, text="test")
        self.animationFrame.pack(fill=BOTH, expand=True)

        self.plotNotebook.add(self.plotOptionFrame, text="Plot Options")
        self.plotNotebook.add(self.animationFrame, text="Animation")
        self.plotNotebook.add(self.plotsKFrame, text="K Plots")

        self.t = Frame(self.plotOptionFrame)
        self.t.pack(side=BOTTOM)
        # TIME STUFF
        self.timeLabel = Label(self.t, text="Time:")
        self.timeLabel.pack(side=LEFT)

        self.timeEntry = Entry(self.t, width=4)
        self.timeEntry.insert(0, "10")
        t = np.linspace(0, float(self.timeEntry.get()), TIME_PTS)
        Timer.reset(t)
        self.timeEntry.pack(side=LEFT)
        self.timeEntry.bind("<KeyRelease>", self.validateTime)

        self.RunPlotButton = Button(self.t, text="Run", command=self.run, width=10)
        self.RunPlotButton.pack(side=LEFT)
        # END

        self.xLabel = Label(self.plotOptionFrame, text="Outputs", width=10)
        self.xLabel.pack(side=TOP)

        self.xFrame = Frame(self.plotOptionFrame)
        self.xFrame.pack()

        self.uLabel = Label(self.plotOptionFrame, text="Inputs")
        self.uLabel.pack()

        self.uFrame = Frame(self.plotOptionFrame)
        self.uFrame.pack()

        self.spLabel = Label(self.plotOptionFrame, text="Set Points")
        self.spLabel.pack()

        self.spFrame = Frame(self.plotOptionFrame)
        self.spFrame.pack()

        self.RunAnim = Button(self.animationFrame, text="Run Animation", command=self.runAnimation)
        self.RunAnim.grid(row=7, column=5)

        self.animationKEntry = Entry(self.animationFrame)
        self.animationKEntry.grid(row=1, column=5)

        self.animationKLabel = Label(self.animationFrame, text="K:")
        self.animationKLabel.grid(row=1, column=4)

        self.animationKButton = Button(self.animationFrame, text="Choose K", command=self.chooseK)
        self.animationKButton.grid(row=1, column=6)

        self.animationCalcButton = Button(self.animationFrame, text="Update K", command=self.updateK)
        self.animationCalcButton.grid(row=7, column=6)
#.........这里部分代码省略.........
开发者ID:fgonz012,项目名称:Control-System-Application,代码行数:103,代码来源:PlotFrame.py


注:本文中的Timer.Timer.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。