def collect_values(message, user_id): user = db_operator.get_user(user_id) try: user['last_sending_date'] except KeyError: db_operator.set_user_last_date(user_id, str(datetime.today())) lens = db_operator.check_collect_progress(user_id) if lens[1] < lens[0] and db_operator.get_current_state( user_id) == constants.States.S_ENTER_DATA.value: if data_processing.msg_check(message, 'digit'): if db_operator.update_data_value(user_id, user['vars'][f'{lens[1] + 22}'], message): lens = db_operator.check_collect_progress(user_id) if lens[0] >= lens[1] + 1: text = f"Введите {user['vars'][f'{lens[1] + 22}']}" options = { 'later_hour': 'через час', 'later_day': 'завтра', } bot_actions.bot_send_keyboard(text, user_id, options) else: bot_actions.send_message( user_id, text="Нужно ввести цифры, попробуй ещё раз.") if lens[1] == lens[0]: send_data(user_id) db_operator.set_user_next_date(user_id) bot_actions.send_message( user_id, f'Ваши данные успешно отправлены на адрес {user["mail_to"]}.\n' f'Следующая дата отправки - ' f'{db_operator.get_user_data(user_id, "next_date").split(".")[0][:-3]}' ) db_operator.set_state(user_id, constants.States.S_USER_WAIT.value) time.sleep(1)
def main(): url = getenv("USACE_URL") prefix = getenv("LAKE_PREFIX") temperature_url = getenv("TEMPERATURE_URL") print("fetching {}".format(url)) dt = fetch_lake_data_table(url=url) lake_temp = None if temperature_url: lake_temp = fetch_lake_temp(temperature_url) send_data(dt, prefix, lake_temp=lake_temp)
def main(): total_time = 0 # 网络开始运行,到第一个节点死亡结束 t = 0 while True: # auv_position_coordinates[0], auv_position_coordinates[1], \ # auv_position_coordinates[ # 2] = auv_position.get_auv_position_at_time_t(t, phi, rho, omega, v_h, h) flag = True if t >= h / v_h: flag = not flag t = 0 judge_type.judge_node_type(nodes, node_type, phi, rho, omega, v_h, r, d, h, flag) for i in range(node_number): if random.uniform(0, 1) <= percentage_of_source_node_per_second: send_data.send_data( nodes, i, node_type, d, energy, energy_consumption_per_bit_send * data_packs_length, energy_consumption_per_bit_rece * data_packs_length, phi, rho, omega, v_h, h, flag, total_data_packs_number, total_energy_comsumption, 4) # 节点发送数据 # send_data.send_data(nodes, i, node_type, d, energy, # energy_consumption_per_bit_send * data_packs_length, # energy_consumption_per_bit_rece * data_packs_length, # phi, rho, omega, v_h, h, True, # total_data_packs_number) pass t += 1 total_time += 1 if is_end.is_network_end(energy): break print(total_time) print(total_data_packs_number) print(total_energy_comsumption)
import time from open_con import open_connect from send_data import send_data from close_con import close_connect from one_file import s open_connect('1to3') time.sleep(3) send_data('1to3', b'1010101010101010') # close_connect('1to3') # time.sleep(5)
def test(): send_data.send_data(nodes, 1, energy, energy_consumption_per_bit_send * data_packs_length, energy_consumption_per_bit_rece * data_packs_length, total_energy_comsumption, total_data_packs_number, 4)