Пример #1
0
    def _Database_ReadFile(self):
        '''
        Read data from file
        :return:
        '''
        status = True
        msg =''
        data = []

        # Read all lines into the database
        with open(self._database_path, 'r') as f:
            line = f.readline()
            data.append(line)

            while line:
                line = f.readline()
                data.append(line)
                pass
            pass

        AIRAC_CYCLE = data[1][8:-1]
        Date = data[2][10:-1]
        logger.info(r'Navigation IDENT database version: {0}'.format(AIRAC_CYCLE))

        ret_data = {'AIRAC':AIRAC_CYCLE, 'Date': Date}

        return status, msg, ret_data
Пример #2
0
    def _Database_Path_Existing(self, createFile):
        '''
        检查数据库文件是否存在
        :return:
        '''

        # 检查数据库的路径是否存在
        if not os.path.exists(self._database_path):
            logger.info(r"{0} 不存在,开始创建".format(self._name))

            # Whether need to create file
            if not createFile:
                return False
            else:
                self._Database_CreateFile()
            pass
        else:
            pass
        return True
Пример #3
0
    def _Database_ReadFile(self):
        '''
        Read data from file
        :return:
        '''
        status = True
        msg = ''
        data = []

        # Read all lines into the database
        with open(self._database_path, 'r') as f:
            line = f.readline()
            data.append(line)

            while line:
                line = f.readline()
                data.append(line)
                pass
            pass

        AIRAC_CYCLE = data[14][1:-1]
        logger.info(
            r'Navigation AIRPORTS database version: {0}'.format(AIRAC_CYCLE))

        data = data[16:]

        mData = {}
        for i in range(len(data) - 1):
            mData[data[i][0:4]] = {
                "Longitude": float(data[i][14:]),
                "Latitude": float(data[i][4:14])
            }

        ret_data = {'AIRAC': AIRAC_CYCLE, 'AIRPORTS': mData}

        return status, msg, ret_data
Пример #4
0
    def __init__(self, *args, **kwargs):
        '''
        Initialize the database and read in configs
        :param args:
        :param kwargs:
        '''
        super().__init__()

        logger.info('开始加载配置文件')
        # Configuration Instance
        self.configuration = Configuration()
        # Config Data Structure
        self.config = self.configuration.Configuration_Interface_Get_Config()

        logger.info('开始加载数据库')
        # Datafile
        self.dataFile = DataFile()

        logger.info('启动FYCYC-CDU')

        self.title = ss.CDU_WINDOW_TITLE
        self.imagePath = ss.CDU_WINDOW_BACKGROUND
        self.window_width = int(self.config['App']['Window_Width'])
        self.window_height = int(self.config['App']['Window_Height'])
        self.window_x = int(self.config['App']['Position_X'])
        self.window_y = int(self.config['App']['Position_Y'])
        self.window_background_pxmap = QPixmap(self.imagePath)

        self.currentPage = variable.page_index.INDEX
        self.currentPageIndex = 1
        self.key = ""
        self.inputLine = ["", "", ""]
        self.msgFlag = False  # True代表消息被清除了,但是不是CLR方式清除的,还需要再CLR一下
        # 0-INPUT, 1-DELETE, 2-MSG
        self.inputDisplayMode = variable.input_line_display_mode.SELFINPUT
        self.lineDisplay = self.ResetLineDisplay()

        # 启动更新线程
        self.gridData = GridData()
        self.update_data_thread = UpdateData()
        self.update_data_thread.setCDU(self)
        self.update_data_thread.update_date.connect(
            self.gridData.update_item_data)
        self.update_data_thread.start()

        # 右键菜单
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.rightMenuShow)
        # Initialize the UI
        self.initUI()

        pass
Пример #5
0
# -*- coding: utf-8 -*-
# @File       : run.py
# @Author     : Yuchen Chai
# @Date       : 2019/12/26 18:20
# @Description: Start File

from PyQt5.QtWidgets import *
import sys
import settings as ss

if ss.APPLICATION_MODE == "DEVELOPMENT":
    from Version_1.logger import logger
    from Version_1.CDU import CDU
else:
    from logger import logger
    from CDU import CDU

logger.info('启动 FYCYC-737NG-CDU程序')

logger.info('检测用户注册状态')

if __name__ == '__main__':
    app = QApplication([])
    app.setApplicationName("FYCYC-CDU-737NG")

    cdu = CDU()
    cdu.show()
    sys.exit(app.exec_())
Пример #6
0
    def _Database_ReadFile(self):
        '''
        Read data from file
        :return:
        '''
        status = True
        msg = ''
        data = []

        # Read all lines into the database
        with open(self._database_path, 'r') as f:
            line = f.readline()
            data.append(line)

            while line:
                line = f.readline()
                data.append(line)
                pass
            pass

        AIRAC_CYCLE = data[14][1:-2]
        logger.info(
            r'Navigation RTE database version: {0}'.format(AIRAC_CYCLE))

        # Get data from the file
        data = data[16:]

        split_data = []
        route_data = {}
        fix_data = {}
        # Split route, fix
        for i in range(len(data) - 1):
            item = data[i]
            item = item.replace('\n', '').split(' ')
            split_data.append(item)

            # Organize the data according to route:
            if item[0] not in route_data:
                route_data[item[0]] = []
                route_data[item[0]].append(item[2])
                pass
            else:
                route_data[item[0]].append(item[2])
                pass

            # Organize the data according to Fixes:
            if item[2] not in fix_data:
                fix_data[item[2]] = []
                fix_data[item[2]].append(item[0])
                pass
            else:
                fix_data[item[2]].append(item[0])
                pass
            pass

        ret_data = {
            'AIRAC': AIRAC_CYCLE,
            'Raw': split_data,
            'Fix': fix_data,
            'Route': route_data
        }

        return status, msg, ret_data
Пример #7
0
    def _Database_ReadFile(self):
        '''
        Read data from file
        :return:
        '''
        status = True
        msg = ''
        data = []

        # Read all lines into the database
        with open(self._database_path, 'r') as f:
            line = f.readline()
            data.append(line)

            while line:
                line = f.readline()
                data.append(line)
                pass
            pass

        AIRAC_CYCLE = data[15][2:-1]
        logger.info(r'AIRPORTS {0} database version: {1}'.format(
            self._name, AIRAC_CYCLE))

        data = data[17:-1]

        state = 0
        index = -1

        FIXES = {}
        RNWS = {}
        SIDS = {}
        STARS = {}
        APPROACHES = {}
        GATES = {}

        LATLON = {"N": 1, "S": -1, "E": 1, "W": -1}

        SIDContent = []
        STARContent = []
        APPROACHESContent = []

        while index < len(data) - 1:
            index = index + 1
            content = data[index].replace("\n", "")

            # 状态机转换
            if content == "FIXES":
                state = 0
                continue
            elif content == "RNWS":
                state = 1
                continue
            elif content == "SIDS":
                state = 2
                continue
            elif content == "STARS":
                state = 3
                continue
            elif content == "APPROACHES":
                state = 4
                continue
            elif content == "GATES":
                state = 5
                continue
            elif content == "" or content == "ENDFIXES" or content == "ENDRNWS" or content == "ENDGATES":
                continue

            # FIXES
            if state == 0:
                content = content.split(" ")
                LAT = round(
                    LATLON[content[3]] *
                    (int(content[4]) + float(content[5]) / 60), 6)
                LON = round(
                    LATLON[content[6]] *
                    (int(content[7]) + float(content[8]) / 60), 6)
                FIXES[content[1]] = {"Latitude": LAT, "Longitude": LON}
                pass
            # RNWS
            elif state == 1:
                content = content.split(" ")
                RNWS[content[1]] = {"RUNWAY": content[1], "SIDS": []}
                pass
            # SIDS
            elif state == 2:
                if content[0] == "S" or content == "ENDSIDS":
                    # 暂存位置为空,则放进去
                    if len(SIDContent) == 0:
                        SIDContent.append(content)
                        pass
                    else:
                        # 处理,然后加进去
                        SIDName, mData = self._Database_ProcessSID(SIDContent)
                        SIDS[SIDName] = mData

                        # 清空暂存盘
                        SIDContent = []
                        SIDContent.append(content)
                        pass
                    pass
                else:
                    SIDContent.append(content)

                pass
            # STARS
            elif state == 3:
                if content[0] == "S" or content == "ENDSTARS":
                    # 暂存位置为空,则放进去
                    if len(STARContent) == 0:
                        STARContent.append(content)
                        pass
                    else:
                        # 处理,然后加进去
                        STARName, mStarData = self._Database_ProcessSTAR(
                            STARContent)
                        STARS[STARName] = mStarData

                        # 清空暂存盘
                        STARContent = []
                        STARContent.append(content)
                        pass
                    pass
                else:
                    STARContent.append(content)
                pass
            # APPROACHES
            elif state == 4:
                if content[0] == "A" or content == "ENDAPPROACHES":
                    # 暂存位置为空,则放进去
                    if len(APPROACHESContent) == 0:
                        APPROACHESContent.append(content)
                        pass
                    else:
                        # 处理,然后加进去
                        APPROACHESName, mAPPROACHESData = self._Database_ProcessAPPROACH(
                            APPROACHESContent)
                        APPROACHES[APPROACHESName] = mAPPROACHESData

                        # 清空暂存盘
                        APPROACHESContent = []
                        APPROACHESContent.append(content)
                        pass
                    pass
                else:
                    APPROACHESContent.append(content)
                pass
            # GATES
            elif state == 5:
                content = content.split(" ")
                Latitude = int(content[3]) + float(content[4]) / 60
                Longitude = int(content[6]) + float(content[7]) / 60

                if content[2] == "S":
                    Latitude = -Latitude
                    pass

                if content[5] == "W":
                    Longitude = -Longitude
                GATES[content[1]] = {
                    "Gate": content[1],
                    "Latitude": Latitude,
                    "Longitude": Longitude
                }
                pass
            pass

        # 扫描一遍SIDS,为RNWS产生内容
        for item in SIDS:
            item = SIDS[item]
            for i in range(len(item["Runways"])):
                RNWS[item["Runways"][i]]["SIDS"].append(item["SID"])
                pass
            pass

        ret_data = {
            "ICAO": self._name,
            'AIRAC': AIRAC_CYCLE,
            'FIXES': FIXES,
            'RNWS': RNWS,
            "SIDS": SIDS,
            "STARS": STARS,
            "APPROACHES": APPROACHES,
            "GATES": GATES
        }

        return status, msg, ret_data