Python Forum
TDMA scheduling help please
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()
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020