def __init__(self, context): self._logFileName = context["reserveStateLogCSVFilePath"] with open(context["reserveStateCSVFilePath"], 'r') as f: self._fileName = context["reserveStateCSVFilePath"] reader = csv.reader(f) # TODO: この書き方だとUnboundLocalErrorが起きてしまうし、カッコ悪いので修正したい for row in reader: last_row_list = row self._timestamp = utils.strToDatetime(last_row_list[0]) self._onoff = last_row_list[1] self._settime = int(last_row_list[2]) # 数値にする min
def __init__(self, context): # TODO: 現状、インスタンス毎に設定コンテキストを指定しているので、 # 管理用のプログラムを書き、参照するCSVファイルの指定を # さらに抽象的なレベルで行いたい self._logFileName = context["acStateLogCSVFilePath"] with open(context["acStateCSVFilePath"], 'r') as f: self._fileName = context["acStateCSVFilePath"] reader = csv.reader(f) for row in reader: last_row_list = row # row = next(reader) self._timestamp = utils.strToDatetime(last_row_list[0]) self._onoff = last_row_list[1] self._operating = last_row_list[2] self._temperature = int(last_row_list[3]) self._wind = last_row_list[4]
# startTimes = [ utils.strToDatetime(date_str).timestamp() for date_str in trip[:25000].starttime.values ] # utils.plotHistogram(startTimes,'Tempos de chegada') # tripDurations = [ float(milisec.replace('.','')) for milisec in trip[:25000].tripduration.values ] # get 25000 tripduration in milisec # utils.plotHistogram(tripDurations,'Tempo de viagens') # simulation env = simpy.Environment() e1 = Entidades.Estacao(env, 'CBD-06', simpy.Resource(env, capacity=5)) cont = 0 usuarios = list() for registry in trip[:7].values: cont += 1 nomeUsuario = 'Usuario' + str(cont) tempoChegada = utils.strToDatetime(registry[0]).timestamp() tempoViagem = utils.strSecToMilisec(registry[3]) print(nomeUsuario, tempoChegada, tempoViagem, sep=',') usuarios.append( Entidades.Usuario(env, nomeUsuario, tempoChegada, tempoViagem)) for usuario in usuarios: env.process(e1.emprestaBicicleta(usuario)) env.run() # station = pd.read_csv('data/station.csv', sep =',', names=stationFields) # read data stations # dictStations = { name:{'bikes':0, 'docks':count,'docksAvailable':count} for name,count in station.values }