def __init__(self): self.seq = SeqInfo() self.detail = DetailInfo() self.course = CourseInfo() self.stu = StuInfo() self.sum = SumInfo() self.ini = IniInfo()
class TimeWindows(object): def __init__(self): self.ini = IniInfo() # 获取当前系统时间 def get_time(self): """ 获取系统当前的时间 :return: """ return time.strftime("%H:%M", time.localtime()) # 获取当前系统时间 def get_time2(self): """ 获取系统当前的时间 :return: """ return time.strftime("%Y-%m-%d %X", time.localtime()) # # 设置计时器 # def set_time_windows(self, timer, times_long, times_end_then): # timer = threading.Timer(times_long, times_end_then) # return timer # # # 开启计时器 # def start_time_windows(self, timer): # timer.start() # # # 关闭计时器 # def end_time_wimdows(self, timer): # timer.cancel() # # # 判断计时器是否存在 # def IsTimerIn(self, timer): # if timer != None: # return True # else: # return False # 判定当前节次 def get_now_section(self): course_schedule = self.ini.read_ini() # print course_schedule now_time = self.get_time() # print now_time classnumber = 0 for i in range(0, 5): if course_schedule[i][0] < now_time and now_time < course_schedule[ i][1]: classnumber = i + 1 break return 1 # classnumber # 为了测试先定程1吧
class demo(object): list = [] def __init__(self): self.tim = TimeWindows() self.ini = IniInfo() self.t = None def fff(self, B): self.t = threading.Timer(int(self.ini.get_window_long()), B) self.t.start() def clear_arry(self): self.__class__.List = [] print "计时结束"
def __init__(self): self.ini = IniInfo() self.tim = TimeWindows()
class CheckInArray(object): # 队列元素【考勤对象1(节次, tecid, courseid)】 List = [] def __init__(self): self.ini = IniInfo() self.tim = TimeWindows() # 判断教师课程是否在考勤队列中 def check_arry_tec(self, tec_id, cii_arry): for a_cii in cii_arry: if a_cii.tecid == tec_id: return True return False # 判断学生是否在考勤队列中 def check_arry_stu(self, stu_id, cii_arry): for a_cii in cii_arry: if a_cii.stuids == stu_id: return True return False # 判断教师+课头是否在考勤队列中 # 完成考勤对象队列的维护 # 判断该当前对象与队内对象是否为相同节次 def same_section(self, now_cii, cii_arry): for one_cii in cii_arry: if now_cii.section == one_cii.section: return True else: return False # 判断当前对象与队列中的对象,班级是否冲突 def same_classnames(self, now_cii, list_arry): all_checkin_classnames = [] for acii in list_arry: all_checkin_classnames += acii.classnames for aclassname in now_cii.classnames: if aclassname in all_checkin_classnames: return True return False # 删除队列内与当前考勤对象有学生冲突的考勤对象并判断队首是否被更新 def remove_arry_same_class(self, now_cii, cii_arry): confit_cii = [] flag = 1 for one_cii in cii_arry: if list(set(one_cii.classnames) & set(now_cii.classnames)) or (one_cii.tecis == now_cii.tecid): # 人员冲突 confit_cii.append(one_cii) # 记录队列内的冲突对象 if cii_arry.index(one_cii) == 0: flag = 0 # 队首冲突标志 else: pass # 删除冲突对象 for one_cii in confit_cii: cii_arry.remove(one_cii) print "考勤结束" return flag # 判断当前考勤对象与考勤队列中的对象,教师是否冲突 def same_tecid(self, now_cii, list_arry): for acii in list_arry: if now_cii.tecid == acii.tecid: return True return False # 更新考勤队列 def update_arry(self, now_cii, cii_arry): # 队列更新步骤 # 2.查看学生是否已经在考勤队列?+该教师是否已经在考勤你队列 if self.same_classnames(now_cii, cii_arry) or self.check_arry_tec( now_cii.tecid, cii_arry): # 3.本考勤对象的学生在考勤队列,查看本考勤对象的节次,与队列内学生冲突的考勤对象的节次是否一致? if self.same_section(now_cii, cii_arry): # 5.节次相同,不允许进入,结束。 return False else: # 4.节次不同,踢队内的考勤对象,本对象进入队尾。结束。 # 踢队内学生冲突的对象 new_hand_flog = self.remove_arry_same_class(now_cii, cii_arry) cii_arry.append(now_cii) # 该教师进入队列 # 若队首被更新 判定方法待定 if new_hand_flog == 0: # 队首被更新 self.tim.t.cancel() timedev = int( self.ini.get_window_long()) - (self.tim.get_time_sub( cii_arry[0].starttime, now_cii.starttime)) self.tim.start_check_time(timedev) else: pass return True else: # 3.本考勤对象的学生不在考勤队列,本考勤对象进队尾。结束。 # 如果此对象为第一个教师 if cii_arry: pass else: self.tim.start_check_time(int(self.ini.get_window_long())) cii_arry.append(now_cii) # 该教师进入队列 return True
def __init__(self): self.detail = DetailInfo() self.ini = IniInfo()
else: print "别闹!没有这个选项。" to_end = raw_input("是否退出学生菜单? Y:是 任意键:否 :") if to_end == "Y": print "退出学生菜单" break else: pass if __name__ == "__main__": # 模拟教师发起考勤 TECID = "2004001" COURSEID = "51610101" COURSEFILENAME = "../internal/courseProgress.csv" STUFILENAME = "../internal/studentInfo.csv" SEQFILENAME = "../outputdemo/seq.csv" DEFAULTPATH = "../outputdemo/" STUID = "201516920101" cii = CheckInInfo(TECID, COURSEID, COURSEFILENAME, STUFILENAME, SEQFILENAME) cii.seqid = "3" ini = IniInfo() # ini.List.append(cii) print cii.tecid, cii.courseid, cii.seqid, cii.classnames, cii.stuids s = StuForm("201516920101") s.stu_form()
def __init__(self): self.ini = IniInfo()
class CheckInArray(object): # 队列元素【考勤对象1(节次, tecid, courseid)】 List = [] def __init__(self): self.ini = IniInfo() self.tim = TimeWindows() self.t = None # 计时器 # 完成考勤对象队列的维护 # 更新队列 # 时间窗口开启即队列更新规则: # 1.判定节次 # 2.该节次内不存在时间窗口,更新队列,开启计时器。 # 3.该节次内存在时间窗口,class不冲突,进入队列。 # 4.该节次内存在时间窗口,class冲突,不能进入队列。 # 5.不同节次,更新队列,关闭现有计时器,开启新计时器。 # 清空队列 def clear_arry(self): self.__class__.List = [] print "计时结束" # 判断该当前对象与队首是否为相同节次 def same_section(self, now_cii, list_first): if now_cii.section == list_first.section: return True else: return False # 判断当前对象与队列中的对象,班级是否冲突 def same_classnames(self, now_cii, list_arry): all_checkin_classnames = [] for acii in list_arry: all_checkin_classnames += acii.classnames for aclassname in now_cii.classnames: if aclassname in all_checkin_classnames: return False return True # 判断当前考勤对象与考勤队列中的对象,教师是否冲突 def same_tecid(self, now_cii, list_arry): for acii in list_arry: if now_cii.tecid == acii.tecid: return False return True def update_arry(self, now_cii): # 空队列添加考勤对象 # 考勤对象now_cii now_section = self.tim.get_now_section() # 判断节次是否为0 if now_section: # 判断现有队列是否为空 if self.__class__.List: # 如果当前考勤对象与队首的节次相同,进入队列 if self.same_section(now_cii, self.__class__.List[0]): # 判断人员是否冲突 if self.same_classnames(now_cii, self.__class__.List) \ and self.same_tecid(now_cii, self.__class__.List): # 人员不冲突,进入队列 self.__class__.List.append(now_cii) return True else: return False else: # 节次变化,清空队列,进入队列,重启计时器 self.clear_arry() self.__class__.List.append(now_cii) self.t.cancel() self.t = threading.Timer(float(self.ini.get_window_long()), self.clear_arry()) self.t.start() return True else: self.__class__.List.append(now_cii) # ??为什么立即结束了??问题出在类方法self.clesr_arry“()”<--日天,不要“()” time_long = float(self.ini.get_window_long()) self.t = threading.Timer(time_long, self.clear_arry) self.t.start() return True else: # 非考勤时间 return False