def __get_indices(self, data: xlrd.sheet, kwargs: dict) -> dict: indices = [] for x in [*kwargs.values()]: try: indices.append(data.row_values(0).index(x)) except ValueError: continue return dict(zip(indices, [*kwargs.keys()]))
def doBase(sheet: xlrd.sheet, configName: str, configHead: str, configTail: str, configKeyCount: int): outputTypeList = sheet.row_values(5, 1, sheet.ncols) markList = sheet.row_values(6, 1, sheet.ncols) clientConfig = {} serverConfig = [] print("key数量:", configKeyCount) for i in range(configKeyCount): for j in range(7, sheet.nrows): cellValue = sheet.cell(j, i + 1).value tempdict = {} if ((cellValue in clientConfig) == True): for k in range(1, sheet.ncols): tempdict[markList[k - 1]] = sheet.cell(j, k).value clientConfig[cellValue].append(tempdict) else: for n in range(1, sheet.ncols): tempdict[markList[n - 1]] = sheet.cell(j, n).value clientConfig[cellValue] = [tempdict] print("数据:", clientConfig)
def __init__(self, env: simpy.Environment, sheet: xlrd.sheet, machine: Machine, conditions: RoadConditionsState, user_memory: UserMemory, persona: str, max_mental: int, max_perc: int): self.visual = simpy.PreemptiveResource(env, capacity=1) self.visual_peripheral = simpy.PreemptiveResource(env, capacity=1) self.sound_vocal = simpy.PreemptiveResource(env, capacity=1) self.sound_non_vocal = simpy.PreemptiveResource(env, capacity=1) self.haptic_hands = simpy.PreemptiveResource(env, capacity=1) self.haptic_seat = simpy.PreemptiveResource(env, capacity=1) self.psychomotor = simpy.PreemptiveResource(env, capacity=1) self.cognitive_workload = simpy.Container(env, capacity=max_mental) self.perceptional_workload = simpy.Container(env, capacity=max_perc) self.machine = machine self.road_conditions = conditions self.user_memory = user_memory # cognitive resources of human self.tasks = [ Task(env=env, row=sheet.row_values(i), resources=[ self.visual, self.visual_peripheral, self.sound_vocal, self.sound_non_vocal, self.haptic_hands, self.haptic_seat, self.psychomotor, self.cognitive_workload, self.perceptional_workload ], machine=machine, user_memory=user_memory, road_conditions=conditions) for i in np.arange(1, sheet.nrows) ] self.tasks = [ task for task in self.tasks if task.persona == persona or task.persona == '' ] self.control_tasks = [ task for task in self.tasks if 'user_switch_regime' in task.trigger ] self.env = env self.tasks_to_execute: List[Task] = [] self.interrupted_tasks = [] self.finished_tasks = [] self.env.process(self.interrupted_tasks_monitor())