घड़ी#
परिचय#
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)
पैरामीटर |
विवरण |
|---|---|
|
टाइमर इवेंट होने पर निष्पादित होने वाला एक फ़ंक्शन। |
|
फंक्शन को कॉल किए जाने से पहले का विलंब, मिलीसेकंड में। |
|
वैकल्पिक। कॉलबैक फ़ंक्शन को पास करने के लिए तर्क युक्त एक टपल। अधिक जानकारी के लिए पैरामीटर वाले फ़ंक्शन देखें। |
# 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 एक नया टाइमर बनाता है। Timer ऑब्जेक्ट बनते ही तुरंत गिनती शुरू कर देगा और timer के सभी तरीकों के साथ काम करेगा।
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)