#!/usr/bin/python
# Filename: main.mi2app
# demo-MM-online

import os
import sys
import shutil
import traceback

import mi2app_utils
from mobile_insight.monitor import OnlineMonitor, OfflineReplayer

from mobile_insight.analyzer import LteNasAnalyzer, LteRrcAnalyzer, UmtsNasAnalyzer, WcdmaRrcAnalyzer
# from mobile_insight.analyzer import WcdmaRrcAnalyzer, LteNasAnalyzer

# from lte_nas_analyzer import LteNasAnalyzer
# from lte_rrc_analyzer import LteRrcAnalyzer
# from umts_nas_analyzer import UmtsNasAnalyzer
# from wcdma_rrc_analyzer import WcdmaRrcAnalyzer

try:
    mi_directory = "/sdcard/mobileinsight"

    src = OfflineReplayer()

    # Combined log
    src.set_input_path(os.path.join(mi_directory, "demo/misc/cm_logs/"))
    lte_nas_analyzer = LteNasAnalyzer()
    lte_nas_analyzer.set_source(src)

    umts_nas_analyzer = UmtsNasAnalyzer()
    umts_nas_analyzer.set_source(src)

    # lte_rrc_analyzer = LteRrcAnalyzer()
    # lte_rrc_analyzer.set_source(src)

    # wcdma_rrc_analyzer = WcdmaRrcAnalyzer()
    # wcdma_rrc_analyzer.set_source(src)

    src.run()

except:
    # src.log_error(traceback.format_exc())
    print traceback.format_exc()

    # finally:
    # mi2app_utils.detach_thread()
    pass