مؤقت#
مقدمة#
تتيح لك خاصية المؤقت في VEX GO تتبع الوقت المنقضي وتنفيذ الإجراءات بناءً على فترات زمنية محددة. ويمكن استخدامها لقياس المدة التي يستغرقها شيء ما أو إعادة ضبطها لعمليات توقيت جديدة.
فيما يلي قائمة بجميع الطرق:
الأساليب – التحكم في مؤقت الدماغ والتفاعل معه.
reset– يعيد ضبط المؤقت إلى الصفر.time– تُرجع مقدار الوقت الذي انقضى.event– يسجل دالة ليتم استدعاؤها بعد عدد محدد من المللي ثانية.
الدالة البانية – إنشاء مؤقتات إضافية.
Timer– إنشاء مؤقت إضافي.
إعادة ضبط#
إعادة الضبط reset تُعيد المؤقت إلى الصفر. يمكن استخدام هذا لتوقيت أجزاء إضافية من التعليمات البرمجية ضمن نفس المشروع.
Usage:
timer.reset()
حدود |
وصف |
|---|---|
لا تحتوي هذه الطريقة على أي معلمات. |
# Build Used: Super Code Base 2.0
def main():
# Reset the timer when the bumper is pressed
while True:
console.clear()
console.print(timer.time(SECONDS))
wait(50, MSEC)
if bumper.is_pressed():
timer.reset()
# Start threads — Do not delete
start_thread(main)
وقت#
يُعيد الأمر time الوقت المنقضي منذ آخر إعادة ضبط للمؤقت كعدد عشري. تتم إعادة ضبط المؤقت تلقائيًا عند بدء المشروع.
Usage:
timer.time(units)
حدود |
وصف |
|---|---|
|
الوحدة التي تمثل الوقت: |
# Build Used: Super Code Base 2.0
def main():
# Display the time until the bumper is pressed
while True:
console.clear()
console.print(timer.time(SECONDS))
wait(50, MSEC)
if bumper.is_pressed():
timer.reset()
# Start threads — Do not delete
start_thread(main)
حدث#
الحدث event فترة زمنية محددة.
Usage:
timer.event(callback, delay, arg)
حدود |
وصف |
|---|---|
|
دالة يتم تنفيذها عند حدوث حدث المؤقت. |
|
التأخير قبل استدعاء الدالة، بالمللي ثانية. |
|
Optional. A tuple containing arguments to pass to the callback function. See Functions with Parameters for more information. |
# Build Used: Super Code Base 2.0
def timer_event():
drivetrain.drive_for(FORWARD, 200, MM)
def main():
# Drive forward after a 5000 millisecond delay
timer.event(timer_event, 5000)
# Start threads — Do not delete
start_thread(main)
المُنشئون#
Timer#
Timer creates a new timer. A Timer object will immediately begin counting the moment it is created and will work with all timer methods.
Usage:
my_timer = Timer()
حدود |
وصف |
|---|---|
لا يحتوي هذا المُنشئ على أي معلمات. |
def main():
# Display the time of two timers
wait(2, SECONDS)
timer_1 = Timer()
while True:
console.clear()
console.print("Timer: ", timer.time(SECONDS))
console.new_line()
console.print("timer_1: ", timer_1.time(SECONDS))
wait(15, MSEC)
# Start threads — Do not delete
start_thread(main)