def btnFile_clicked(self):
     filePathDir = QFileDialog.getOpenFileName(
         self, "Open Fas Data", QCoreApplication.applicationDirPath(),
         "FAS Data Block Binary Files (*.bin)")
     if filePathDir == "":
         return
     fasDataBlockFile = FasDataBlockFile()
     fasDataBlockFile.method_1(filePathDir)
     self.txtDataBlock.Value = fasDataBlockFile.HexString
 def smethod_0(parent):
     fasDataBlockFile = None
     dlgFasDataBlockImport = DlgFasDataBlockImport()
     dlgFasDataBlockImport.txtDataBlock.set_Value("")
     dlgFasDataBlockImport.pnlCalculatedCRC.set_Value("")
     dlgResult = dlgFasDataBlockImport.exec_()
     if dlgResult != 1:
         fasDataBlockFile = None
     else:
         fasDataBlockFile = FasDataBlockFile()
         fasDataBlockFile.set_HexString(
             dlgFasDataBlockImport.txtDataBlock.get_Value())
     return fasDataBlockFile
    def smethod_0(parent, inputFilePath, crcCalcMethodStr=None):
        flag = False
        dlgCrcCheck = DlgCrcCheck(parent)
        dlgCrcCheck.crcCalcMethodStr = crcCalcMethodStr

        contents = None
        try:
            with open(inputFilePath, 'rb', 0) as tempFile:
                contents = tempFile.read()
                tempFile.close()
        except:
            return False
        bytes = FasDataBlockFile.CRC_Calculation(contents)

        string_0 = QString(inputFilePath)

        crcFileDir = string_0.left(string_0.length() - 3) + "crc"
        fileInfo = QFileInfo(crcFileDir)
        if not fileInfo.exists():
            if QMessageBox.warning(
                    dlgCrcCheck, "Warning",
                    "CRC file is not existing.\nDo you want to create the CRC file for this file?",
                    QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
                return False
            contents = None
            # with open(inputFilePath, 'rb', 0) as tempFile:
            #     contents = tempFile.read()
            #     tempFile.flush()
            #     tempFile.close()
            # bytes = FasDataBlockFile.CRC_Calculation(contents)
            # string_0 = QString(inputFilePath)
            # path = string_0.left(string_0.length() - 3) + "crc"
            fileStream = open(crcFileDir, 'wb')
            fileStream.write(bytes)
            fileStream.close()

        crcFileContents = None
        with open(crcFileDir, 'rb', 0) as tempFileCrc:
            crcFileContents = tempFileCrc.read()
            tempFileCrc.close()
        if bytes != crcFileContents:
            dlgCrcCheck.pnlCalculatedCrcValue.textBox.setStyleSheet(
                "color: rgb(255, 0, 0);")
        else:
            dlgCrcCheck.pnlCalculatedCrcValue.textBox.setStyleSheet(
                "color: rgb(0, 0, 0);")
        dlgCrcCheck.pnlSuppliedCrcValue.Value = crcFileContents
        dlgCrcCheck.pnlCalculatedCrcValue.Value = bytes

        resultDlg = dlgCrcCheck.exec_()
        if (resultDlg == 0):
            flag = False
        else:
            flag = True
        return flag
示例#4
0
    def method_30(self):
        filePath = define.appPath + "/Resource/settingData/phxtemplates.xml"
        fileInfo = QFileInfo(filePath)
        if fileInfo.exists():
            QFile.remove(filePath)

        doc = QDomDocument()
        rootElem = doc.createElement("Templates")
        xmlDeclaration = doc.createProcessingInstruction(
            "xml", "version=\"1.0\" encoding=\"utf-8\"")
        doc.appendChild(xmlDeclaration)

        for i in range(self.parametersPanel.gridModel.rowCount()):
            elem = doc.createElement(
                "Templates" + self.parametersPanel.gridModel.item(i, 0).text())
            valueElem = doc.createElement("title")
            valueElem.appendChild(
                doc.createTextNode(
                    self.parametersPanel.gridModel.item(i, 0).text()))
            elem.appendChild(valueElem)

            valueElem = doc.createElement("space")
            valueElem.appendChild(
                doc.createTextNode(
                    self.parametersPanel.gridModel.item(i, 1).text()))
            elem.appendChild(valueElem)

            valueElem = doc.createElement("value")
            valueElem.appendChild(
                doc.createTextNode(
                    self.parametersPanel.gridModel.item(i, 2).text()))
            elem.appendChild(valueElem)

            rootElem.appendChild(elem)

        doc.appendChild(rootElem)
        qFile = QFile(filePath)
        if qFile.open(QFile.WriteOnly):
            textStream = QTextStream(qFile)
            doc.save(textStream, 4)
            qFile.close()

            # ###CRC file is created.
            contents = None
            with open(filePath, 'rb', 0) as tempFile:
                contents = tempFile.read()
                tempFile.flush()
                tempFile.close()
            bytes = FasDataBlockFile.CRC_Calculation(contents)
            string_0 = QString(filePath)
            path = string_0.left(string_0.length() - 3) + "crc"
            fileStream = open(path, 'wb')
            fileStream.write(bytes)
            fileStream.close()
 def method_5(self):
     flag = False
     # self.errorProvider.method_1();
     fasDataBlockFile = FasDataBlockFile()
     fasDataBlockFile.set_HexString(self.txtDataBlock.Value)
     if self.txtDataBlock.Value == "":
         self.pnlCalculatedCRC.set_Value("")
     else:
         self.pnlCalculatedCRC.set_Value(fasDataBlockFile.CRC)
     if self.txtDataBlock.Value == "":
         self.pnlSuppliedCRC.set_Value("")
     else:
         value = fasDataBlockFile.HexString.split(' ')
         str0 = ""
         for i in range(36, 40):
             str0 += value[i]
         self.pnlSuppliedCRC.set_Value(str0)
     flag = True
     # except:
     #     # self.errorProvider.method_0(self.txtDataBlock, exception.Message);
     #     self.pnlCalculatedCRC.Value = "";
     #     self.pnlSuppliedCRC.Value = "";
     #     return False;
     return flag
示例#6
0
    def pnlFileEvent_1(self):

        inputFilePath = QFileDialog.getOpenFileName(
            self, "Open Xml File", QCoreApplication.applicationDirPath(),
            "Xml Files (*.xml)")
        if inputFilePath == "":
            return
        fileInfo = QFileInfo(inputFilePath)
        self.pnlFile.Value = fileInfo.fileName()
        contents = None
        with open(inputFilePath, 'rb', 0) as tempFile:
            contents = tempFile.read()
            tempFile.close()
        bytes = FasDataBlockFile.CRC_Calculation(contents)

        string_0 = QString(inputFilePath)

        crcFileDir = string_0.left(string_0.length() - 3) + "crc"
        fileInfo = QFileInfo(crcFileDir)
        if self.rwFlag == "r":
            if not fileInfo.exists():
                QMessageBox.warning(self, "Warning",
                                    "CRC file is not existing.")
                return
            crcFileContents = None
            with open(crcFileDir, 'rb', 0) as tempFileCrc:
                crcFileContents = tempFileCrc.read()
                tempFileCrc.close()
            if bytes != crcFileContents:
                self.pnlCalculatedCrcValue.textBox.setStyleSheet(
                    "color: rgb(255, 0, 0);")
            else:
                self.pnlCalculatedCrcValue.textBox.setStyleSheet(
                    "color: rgb(0, 0, 0);")
            self.pnlSuppliedCrcValue.Value = crcFileContents
            self.pnlCalculatedCrcValue.Value = bytes
        else:
            fileStream = open(crcFileDir, 'wb')
            fileStream.write(bytes)
            fileStream.close()
            self.pnlCalculatedCrcValue.Value = bytes
    def WriteProjectInfoXml(self):
        doc = QDomDocument()
        rootElem = doc.createElement("ProjectListClass")
        xmlDeclaration = doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\"")
        doc.appendChild(xmlDeclaration)

        elem = doc.createElement("ProjectCount")
        elem.appendChild(doc.createTextNode(str(len(self.ProjectsList))))
        rootElem.appendChild(elem)

        for i in range(len(self.ProjectsList)):
            elem = doc.createElement("ProjectInfo")
            objNameElem = doc.createElement("Name")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].Name))
            elem.appendChild(objNameElem)

            objNameElem = doc.createElement("Path")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].Path))
            elem.appendChild(objNameElem)

            objNameElem = doc.createElement("Created")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].Created))
            elem.appendChild(objNameElem)

            objNameElem = doc.createElement("ProcedureName")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].ProcedureName))
            elem.appendChild(objNameElem)

            objNameElem = doc.createElement("ProjName")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].ProjName))
            elem.appendChild(objNameElem)

            objNameElem = doc.createElement("Pt")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].Pt))
            elem.appendChild(objNameElem)

            objNameElem = doc.createElement("SubProjName")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].SubProjName))
            elem.appendChild(objNameElem)

            objNameElem = doc.createElement("UserName")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].UserName))
            elem.appendChild(objNameElem)

            objNameElem = doc.createElement("WorkspaceName")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].WorkspaceName))
            elem.appendChild(objNameElem)

            objNameElem = doc.createElement("FullName")
            objNameElem.appendChild(doc.createTextNode(self.ProjectsList[i].FullName))
            elem.appendChild(objNameElem)

            rootElem.appendChild(elem)
        doc.appendChild(rootElem)
        qFile = QFile(self.m_strProjectInfoFullName)
        if qFile.open(QFile.WriteOnly):
            textStream = QTextStream(qFile)
            doc.save(textStream, 4)
            qFile.close()

            # ###CRC file is created.

            with open(self.m_strProjectInfoFullName, 'rb', 0) as tempFile:
                contents = tempFile.read()
                tempFile.flush()
                tempFile.close()
            bytes = FasDataBlockFile.CRC_Calculation(contents)
            string_0 = QString(self.m_strProjectInfoFullName)
            path = string_0.left(string_0.length() - 3) + "crc"
            fileStream = open(path, 'wb')
            fileStream.write(bytes)
            fileStream.close()

        else:
            raise UserWarning, "can not open file:" + self.m_strProjectInfoFullName
示例#8
0
    def method_32(self, bool_0):
        # degree = Degrees();
        # degree1 = Degrees();
        # degree2 = Degrees();
        # degree3 = Degrees();
        # if (not self.method_29(bool_0))
        # {
        #     return null;
        # }
        fasDataBlockFile = FasDataBlockFile()
        fasDataBlockFile.set_OperationType(
            self.parametersPanel.pnlOperationType.Value)
        fasDataBlockFile.set_SbasProviderId(
            self.parametersPanel.pnlSbasProvider.Value)
        fasDataBlockFile.set_AirportId(
            self.parametersPanel.pnlAirportId.Value.toUpper())
        fasDataBlockFile.set_RunwayNumber(
            Type.ByteFunc.d2b(self.parametersPanel.txtRunwayDesignator.Value))
        fasDataBlockFile.set_RunwayLetter(
            self.parametersPanel.cmbRunwayLetter.Value)
        fasDataBlockFile.set_ApproachPerformanceDesignator(
            self.parametersPanel.pnlApproachPerformanceDesignator.Value)
        fasDataBlockFile.set_RouteIndicator(
            self.parametersPanel.pnlRouteIndicator.SelectedItem)
        fasDataBlockFile.set_ReferencePathDataSelector(
            Type.ByteFunc.d2b(
                self.parametersPanel.pnlReferencePathDataSelector.Value))
        fasDataBlockFile.set_ReferencePathIdentifier(
            self.parametersPanel.pnlReferencePathId.Value)
        result, degree, degree1 = self.parametersPanel.pnlLtpFtp.method_3()
        if (not result):
            return None
            # throw new Exception(Geo.LastError);
        fasDataBlockFile.set_LtpFtpLatitude(degree)
        fasDataBlockFile.set_LtpFtpLongitude(degree1)
        fasDataBlockFile.set_LtpFtpHeight(
            self.parametersPanel.pnlLtpFtpEllipsoidalHeight.Value)
        result1, degree2, degree3 = self.parametersPanel.pnlFpap.method_3()
        if (not result1):
            return None
            # throw new Exception(Geo.LastError);

        fasDataBlockFile.set_DeltaFpapLatitude(degree2 - degree)
        fasDataBlockFile.set_DeltaFpapLongitude(degree3 - degree1)
        fasDataBlockFile.method_0(
            self.parametersPanel.txtApproachTCH.Value,
            self.parametersPanel.cmbApproachTCHunits.Value)
        fasDataBlockFile.set_GPA(self.parametersPanel.pnlGPA.Value)
        fasDataBlockFile.set_CourseWidth(
            self.parametersPanel.pnlCourseWidth.Value)
        fasDataBlockFile.set_DeltaLengthOffset(
            self.parametersPanel.pnlLengthOffset.Value)
        fasDataBlockFile.set_HAL(self.parametersPanel.pnlHAL.Value)
        fasDataBlockFile.set_VAL(self.parametersPanel.pnlVAL.Value)
        return fasDataBlockFile