add position to ReserveResultPojo

This commit is contained in:
2022-03-08 13:50:04 +01:00
parent ba5f1bf5a5
commit 8b84b6ad71
5 changed files with 36 additions and 11 deletions
+13 -8
View File
@@ -19,13 +19,15 @@ from pojo.serial_modem import SerialModem
from logs.AppLogging import init_logger
from utils.message_receiver import MessageReceiver
BAUDRATE = 115200
OTP_TIMEOUT = 90
is_finished = False
commandor = Commandor()
contacts = []
current_gsm_modem = None
card_pool = CardPool(CARD_POOL_PORT)
# used to save the current slot position
current_card_pool_slot = 1
current_sim_position = 1
def get_devices_ports() -> list:
@@ -60,10 +62,6 @@ def get_phone_number(ser):
send_command(cmd, ser)
def execut_USSD_cmd(cmd, ser):
send_command(cmd, ser)
def create_modem_for_port(port: str) -> Union[SerialModem, None]:
logger.info('Initializing modem... for ' + port)
# Uncomment the following line to see what the modem is doing:
@@ -145,7 +143,9 @@ def on_message_received(ch, method, properties, body):
logger.info(" [x] Received {} {}".format(body, datetime.datetime.now()))
# parse the received message
result = ReserveResultPojo.from_json(body)
print(result)
result.sim_position = current_sim_position
result.slot_position = current_card_pool_slot
logger.info(result)
firebase_store_manager.save(result)
oracle_log_sender.send_appoint_result(result)
# set the flag to True
@@ -162,12 +162,14 @@ def start_listen():
def read_all_the_phone_number():
params.oracle_log_sender.send_log(msg="SIM卡自检开始", subject=LOG_SUBJECT_EVENT, type=LOG_SUBJECT_EVENT)
slot_number = 1
global current_card_pool_slot
slot_sum = 30
# card_pool.switch_to_slot(29)
firebase_store_manager.clear_all_sim_info()
for i in range(slot_number, slot_sum + 1):
card_pool.reset()
print("will switch to " + str(i))
logger.info("will switch to " + str(i))
current_card_pool_slot = i
card_pool.switch_to_slot(i)
modem_pool = ModemPool(get_devices_ports())
modem_pool.reset_all_modems()
@@ -179,7 +181,7 @@ def start_book():
slot_sum = 30
for i in range(slot_number, slot_sum + 1):
card_pool.reset()
print("will switch to " + str(i))
logger.info("will switch to " + str(i))
card_pool.switch_to_slot(i)
modem_pool = ModemPool(get_devices_ports())
modem_pool.reset_all_modems()
@@ -189,7 +191,10 @@ def start_book():
excel_reader = ExcelHelper()
global contacts
contacts = excel_reader.read_contacts()
global current_sim_position
current_sim_position = 1
for modem in modem_list:
current_sim_position = current_sim_position + 1
try:
# get contact for current modem
modem.get_ccid()