Example #1
0
    def parseAndAssignFieldValue(self, fieldLabel, fieldName, fieldValue,
                                 printJobModel, errorCollection, lineNumber):

        if ("" == fieldValue or "-" == fieldValue or fieldValue == None):
            # check if mandatory
            return
        matched = self.tempPattern.match(fieldValue)
        if (matched):
            bedTemp = float(matched.group(1))
            toolTemp = float(matched.group(2))

            tempModel = TemperatureModel()
            tempModel.sensorName = "bed"
            tempModel.sensorValue = bedTemp
            printJobModel.addTemperatureModel(tempModel)

            tempModel = TemperatureModel()
            tempModel.sensorName = "tool0"
            tempModel.sensorValue = toolTemp
            printJobModel.addTemperatureModel(tempModel)
            pass
        else:
            errorCollection.append(
                "[" + str(lineNumber) + "]" +
                " Wrong temperature format. Allowed: 'bed:60.0 tool0:200.0'")
        pass
    def _addTemperatureToPrintModel(self, printJobModel, bedTemp, toolTemp):
        tempModel = TemperatureModel()
        tempModel.sensorName = "bed"
        tempModel.sensorValue = bedTemp
        printJobModel.addTemperatureModel(tempModel)

        tempModel = TemperatureModel()
        tempModel.sensorName = "tool0"
        tempModel.sensorValue = toolTemp
        printJobModel.addTemperatureModel(tempModel)
    def _addTemperatureToPrintModel(self, printJobModel, bedTemp, toolId,
                                    toolTemp):
        tempModel = TemperatureModel()
        tempModel.sensorName = "bed"
        # tempModel.sensorValue = bedTemp if bedTemp != None else"-"
        tempModel.sensorValue = bedTemp if bedTemp != None else "-"
        printJobModel.addTemperatureModel(tempModel)

        tempModel = TemperatureModel()
        tempModel.sensorName = toolId  #"tool0"
        tempModel.sensorValue = toolTemp if toolTemp != None else "-"
        printJobModel.addTemperatureModel(tempModel)
    def _createPrintJobModel(self, payload):
        self._currentPrintJobModel = PrintJobModel()
        self._currentPrintJobModel.printStartDateTime = datetime.datetime.now()

        self._currentPrintJobModel.fileOrigin = payload["origin"]
        self._currentPrintJobModel.fileName = payload["name"]
        self._currentPrintJobModel.filePathName = payload["path"]

        # self._file_manager.path_on_disk()
        if "owner" in payload:
            self._currentPrintJobModel.userName = payload["owner"]
        else:
            self._currentPrintJobModel.userName = "******"
        self._currentPrintJobModel.fileSize = payload["size"]

        tempFound = False
        tempTool = 0
        tempBed = 0

        if self._preHeatPluginImplementation != None:
            path_on_disk = octoprint.server.fileManager.path_on_disk(
                self._currentPrintJobModel.fileOrigin,
                self._currentPrintJobModel.filePathName)

            preHeatTemperature = self._preHeatPluginImplementation.read_temperatures_from_file(
                path_on_disk)
            if preHeatTemperature != None:
                if "bed" in preHeatTemperature:
                    tempBed = preHeatTemperature["bed"]
                    tempFound = True
                if "tool0" in preHeatTemperature:
                    tempTool = preHeatTemperature["tool0"]
                    tempFound = True
            pass

        else:
            currentTemps = self._printer.get_current_temperatures()
            if (len(currentTemps) > 0):
                tempBed = currentTemps[0]["bed"]["target"]
                tempTool = currentTemps[0]["tool0"]["target"]
                tempFound = True

        if (tempFound == True):
            tempModel = TemperatureModel()
            tempModel.sensorName = "bed"
            tempModel.sensorValue = tempBed
            self._currentPrintJobModel.addTemperatureModel(tempModel)

            tempModel = TemperatureModel()
            tempModel.sensorName = "tool0"
            tempModel.sensorValue = tempTool
            self._currentPrintJobModel.addTemperatureModel(tempModel)