Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 TDMA scheduling help please
#1
Hello, I was trying to implement TDMA scheduling but i dont know how to make a job sleep for certain time until some other job gets executed. For example i want job 1 to execute for 3 sec then job 2 for 3 sec then job3 for 3 secs. But the problem is job gets executed every t seconds. i want the first job to initiate again when all the jobs are finished. so i could not do it, therefore i created global i so that it switches to next job. but can someone help me do it without global 'i'.

This is the code i wrote
import schedule
import time
from datetime import datetime
global i
i = 0
def job1(i):
    print("a_CH1.append(N_message[0].pop(", str(i), ")", str(datetime.now()))

def job2():
    #i = 0
    global i
    i = i+1
    job1(i)

def nothing():
    time.sleep(5)

#schedule.every(10).seconds.do(job1)
schedule.every(2).seconds.do(job2)
schedule.every(2).seconds.do(nothing)
#schedule.every(10).seconds.do(job1)

while 1:
    schedule.run_pending()
    #schedule.run_all()
    time.sleep(1)

schedule.clear()
Larz60+ wrote Apr-21-2020, 01:56 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)