def activate_pod(): verify_auth(request) pod = Pod() archive_pod() pod.radio_address2 = get_next_pod_address() pod.Save(POD_FILE + POD_FILE_SUFFIX) pdm = get_pdm() pdm.activate_pod() save_activated_pod_address(pod.radio_address) return pod
def pair_pod(): _verify_auth(request) pod = _get_pod() if pod.state_progress >= PodProgress.Running: pod = Pod() _archive_pod() _set_pod(pod) pdm = _get_pdm() req_address = _get_next_pod_address() utc_offset = int(request.args.get('utc')) pdm.pair_pod(req_address, utc_offset=utc_offset) _save_activated_pod_address(req_address)
def _get_pod(): global g_pod try: if g_pod is None: if os.path.exists(DATA_PATH + POD_FILE + POD_FILE_SUFFIX): g_pod = Pod.Load(DATA_PATH + POD_FILE + POD_FILE_SUFFIX, DATA_PATH + POD_FILE + POD_DB_SUFFIX) else: g_pod = Pod() g_pod.path = DATA_PATH + POD_FILE + POD_FILE_SUFFIX g_pod.path_db = DATA_PATH + POD_FILE + POD_DB_SUFFIX g_pod.Save() return g_pod except: logger.exception("Error while loading pod") return None
def new_pod(): verify_auth(request) pod = Pod() if request.args.get('id_lot') is not None: pod.id_lot = int(request.args.get('id_lot')) if request.args.get('id_t') is not None: pod.id_t = int(request.args.get('id_t')) if request.args.get('radio_address') is not None: pod.radio_address = int(request.args.get('radio_address')) pod.radio_address2 = int(request.args.get('radio_address')) archive_pod() pod.Save(POD_FILE + POD_FILE_SUFFIX) return pod
def new_pod(): _verify_auth(request) pod = Pod() if request.args.get('id_lot') is not None: pod.id_lot = int(request.args.get('id_lot')) if request.args.get('id_t') is not None: pod.id_t = int(request.args.get('id_t')) if request.args.get('radio_address') is not None: pod.radio_address = int(request.args.get('radio_address')) else: pod.radio_address = 0 if pod.radio_address == 0: pod.radio_address = _get_pdm_address(45000) _archive_pod() _set_pod(pod)
def get_pod(): path = "data/bbe.json" log_path = "data/bbe.log" pod = None try: pod = Pod.Load(path) except: pass if pod is None: pod = Pod() pod.path = path pod.log_file_path = log_path pod.id_lot = 44147 pod.id_t = 1100256 pod.radio_address = 0x1f0e89f0 pod.Save() return pod
def new_pod(): try: verify_auth(request) pod = Pod() if request.args.get('lot') is not None: pod.lot = int(request.args.get('lot')) if request.args.get('tid') is not None: pod.tid = int(request.args.get('tid')) if request.args.get('address') is not None: pod.address = int(request.args.get('address')) archive_pod() pod.Save(POD_FILE + POD_FILE_SUFFIX) return respond_ok({}) except RestApiException as rae: return respond_error(str(rae)) except Exception: logger.exception("Error while creating new pod") return respond_error("Other error. Please check log files.")
def archive_pod(): _verify_auth(request) pod = Pod() _archive_pod() _set_pod(pod)
if packet.type == RadioPacketType.ACK: return None else: return packet path = "data/bbe.json" log_path = "data/bbe.log" pod = None try: pod = Pod.Load(path) except: pass if pod is None: pod = Pod() pod.path = path pod.log_file_path = log_path pod.id_lot = 44147 pod.id_t = 1100256 pod.radio_address = 0x1f0e89f0 pod.Save() mock_radio = MockPacketRadio(send_callback=skip_ack, allow_connect=True, allow_listen=True) radio = PdmRadio(pod.radio_address, packet_radio=mock_radio, msg_sequence=pod.radio_message_sequence, pkt_sequence=pod.radio_packet_sequence)
def main(): pod = Pod(msgHandler, errHandler, 123456, 123456) pod.start() raw_input() pod.stop()