コード例 #1
0
    def parseAndAssignFieldValue(self, fieldLabel, fieldName, fieldValue,
                                 printJobModel, errorCollection, lineNumber):
        if ("" == fieldValue or "-" == fieldValue or fieldValue == None):
            # check if mandatory
            return

        filemanentModel = None
        allFilemanentModel = printJobModel.getFilamentModels()
        if (allFilemanentModel != None and len(allFilemanentModel) > 0):
            filemanentModel = allFilemanentModel[0]
        else:
            filemanentModel = FilamentModel()
            printJobModel.addFilamentModel(filemanentModel)

        if (COLUMN_SPOOL_VENDOR == fieldLabel):
            filemanentModel.profileVendor = fieldValue
            pass
        elif (COLUMN_SPOOL_NAME == fieldLabel):
            filemanentModel.spoolName = fieldValue
            pass
        elif (COLUMN_MATERIAL == fieldLabel):
            filemanentModel.material = fieldValue
            pass
        elif (COLUMN_DIAMETER == fieldLabel):
            filemanentModel.diameter = float(fieldValue)
            pass
        elif (COLUMN_DENSITY == fieldLabel):
            filemanentModel.density = float(fieldValue)
            pass
        elif (COLUMN_USED_LENGTH == fieldLabel):
            filemanentModel.usedLength = float(fieldValue)
            pass
        elif (COLUMN_CALCULATED_LENGTH == fieldLabel):
            filemanentModel.calculatedLength = float(fieldValue)
            pass
        elif (COLUMN_USED_WEIGHT == fieldLabel):
            filemanentModel.usedWeight = float(fieldValue)
            pass
        elif (COLUMN_USED_FILAMENT_COSTS == fieldLabel):
            costUnit = fieldValue[-1]
            if (costUnit.isdigit()):
                # no unit present
                filemanentModel.usedCost = float(fieldValue)
            else:
                # Split between cost and unit
                costValue = ""
                for i in range(len(fieldValue)):
                    c = fieldValue[i]
                    if (c.isdigit() or c == "."):
                        costValue += c
                    else:
                        costUnit = fieldValue[i:]
                        break
                filemanentModel.usedCost = float(costValue)
                filemanentModel.spoolCostUnit = costUnit

            pass
        pass
コード例 #2
0
    def _createAndAssignFilamentModel(self, printJob, payload):
        filemanentModel = FilamentModel()

        fileData = self._file_manager.get_metadata(payload["origin"],
                                                   payload["path"])

        filamentLength = None
        if "analysis" in fileData:
            if "filament" in fileData["analysis"]:
                if "tool0" in fileData["analysis"]["filament"]:
                    filamentLength = fileData["analysis"]["filament"]["tool0"][
                        'length']

        filemanentModel.calculatedLength = filamentLength

        if self._filamentManagerPluginImplementation != None:

            filemanentModel.usedLength = self._filamentManagerPluginImplementation.filamentOdometer.totalExtrusion[
                0]
            selectedSpool = self._filamentManagerPluginImplementation.filamentManager.get_all_selections(
                self._filamentManagerPluginImplementation.client_id)
            if selectedSpool != None and len(selectedSpool) > 0:
                spoolData = selectedSpool[0]["spool"]
                spoolName = spoolData["name"]
                spoolCost = spoolData["cost"]
                spoolCostUnit = self._filamentManagerPluginImplementation._settings.get(
                    ["currencySymbol"])
                spoolWeight = spoolData["weight"]

                profileData = selectedSpool[0]["spool"]["profile"]
                diameter = profileData["diameter"]
                material = profileData["material"]
                vendor = profileData["vendor"]
                density = profileData["density"]

                filemanentModel.spoolName = spoolName
                filemanentModel.spoolCost = spoolCost
                filemanentModel.spoolCostUnit = spoolCostUnit
                filemanentModel.spoolWeight = spoolWeight

                filemanentModel.profileVendor = vendor
                filemanentModel.diameter = diameter
                filemanentModel.density = density
                filemanentModel.material = material

                radius = diameter / 2
                volume = filemanentModel.usedLength * math.pi * radius * radius / 1000
                usedWeight = volume * density

                filemanentModel.usedWeight = usedWeight
                filemanentModel.usedCost = spoolCost / spoolWeight * usedWeight

        printJob.addFilamentModel(filemanentModel)
        pass
コード例 #3
0
    def parseAndAssignFieldValue(self, fieldLabel, fieldName, fieldValue,
                                 printJobModel, errorCollection, lineNumber):
        if ("" == fieldValue or "-" == fieldValue or fieldValue == None):
            # check if mandatory
            return

        # allFilemanentModel  = printJobModel.getFilamentModels()
        filamanentModel = printJobModel.getFilamentModelByToolId("total")

        if (filamanentModel == None):
            filamanentModel = FilamentModel()
            filamanentModel.toolId = "total"
            printJobModel.addFilamentModel(filamanentModel)

        if (COLUMN_SPOOL_VENDOR == fieldLabel):
            filamanentModel.vendor = fieldValue
            pass
        elif (COLUMN_SPOOL_NAME == fieldLabel):
            filamanentModel.spoolName = fieldValue
            pass
        elif (COLUMN_MATERIAL == fieldLabel):
            filamanentModel.material = fieldValue
            pass
        elif (COLUMN_DIAMETER == fieldLabel):
            filamanentModel.diameter = float(fieldValue)
            pass
        elif (COLUMN_DENSITY == fieldLabel):
            filamanentModel.density = float(fieldValue)
            pass
        elif (COLUMN_USED_LENGTH == fieldLabel):
            filamanentModel.usedLength = float(fieldValue)
            pass
        elif (COLUMN_CALCULATED_LENGTH == fieldLabel):
            filamanentModel.calculatedLength = float(fieldValue)
            pass
        elif (COLUMN_USED_WEIGHT == fieldLabel):
            filamanentModel.usedWeight = float(fieldValue)
            pass
        pass
コード例 #4
0
    def _createAndAssignFilamentModel(self, printJob, payload):
        filemanentModel = FilamentModel()
        filePath = payload["path"]
        fileData = self._file_manager.get_metadata(payload["origin"], filePath)

        toolId = self._settings.get(
            [SettingsKeys.SETTINGS_KEY_DEFAULT_TOOL_ID])  # "tool0"
        filamentLength = None
        if "analysis" in fileData:
            if "filament" in fileData["analysis"]:
                if toolId in fileData["analysis"]["filament"]:
                    filamentLength = fileData["analysis"]["filament"][toolId][
                        'length']
                else:
                    self._logger.error(
                        "MetaFile Filamentlength not found for toolId '" +
                        str(toolId) + "'")
            else:
                self._logger.error("MetaFile of '" + str(filePath) +
                                   "' doesnt include 'filament'")
        else:
            self._logger.error("MetaFile of '" + str(filePath) +
                               "' doesnt include 'analysis'")

        if (filamentLength == None):
            self._logger.error("Filamentlength not found for toolId '" +
                               str(toolId) + "'")
        filemanentModel.calculatedLength = filamentLength

        if self._filamentManagerPluginImplementation != None and self._filamentManagerPluginImplementationState == "enabled":

            filemanentModel.usedLength = self._filamentManagerPluginImplementation.filamentOdometer.totalExtrusion[
                0]
            selectedSpools = self._filamentManagerPluginImplementation.filamentManager.get_all_selections(
                self._filamentManagerPluginImplementation.client_id)
            if selectedSpools != None and len(selectedSpools) > 0:
                spoolData = None
                defaultToolNumber = toolId[-1]
                for currentSpoolData in selectedSpools:
                    toolNumber = str(currentSpoolData["tool"])
                    if (defaultToolNumber == toolNumber):
                        spoolData = currentSpoolData["spool"]
                        break

                if (spoolData == None):
                    self._logger.error(
                        "Filamentmanager Spooldata could not be found for toolId '"
                        + toolId + "'")
                else:
                    spoolName = spoolData["name"]
                    spoolCost = spoolData["cost"]
                    spoolCostUnit = self._filamentManagerPluginImplementation._settings.get(
                        ["currencySymbol"])
                    spoolWeight = spoolData["weight"]

                    profileData = spoolData["profile"]
                    diameter = profileData["diameter"]
                    material = profileData["material"]
                    vendor = profileData["vendor"]
                    density = profileData["density"]

                    filemanentModel.spoolName = spoolName
                    filemanentModel.spoolCost = spoolCost
                    filemanentModel.spoolCostUnit = spoolCostUnit
                    filemanentModel.spoolWeight = spoolWeight

                    filemanentModel.profileVendor = vendor
                    filemanentModel.diameter = diameter
                    filemanentModel.density = density
                    filemanentModel.material = material

                    radius = diameter / 2.0
                    volume = filemanentModel.usedLength * math.pi * radius * radius / 1000.0
                    usedWeight = volume * density

                    filemanentModel.usedWeight = usedWeight
                    filemanentModel.usedCost = spoolCost / spoolWeight * usedWeight
        else:
            self._logger.info(
                "Empty filamentModel, because Filamentmanager not installed!")

        printJob.addFilamentModel(filemanentModel)
        pass