Results

Obtaining the Measurement Results

After the upload of your scanned frames is completed (that is, the `TireTreadScanView’s callback method onUploadCompleted was invoked), your measurement results may still take a few seconds to become available. To fetch the results, call the function getTreadDepthReportResult(measurementUuid):

// Run the fetchResults in a background thread
private func fetchTreadDepthResult() {
    do {
        try AnylineTireTreadSdk.companion.getTreadDepthReportResult(
            measurementUuid: self.uuid,
            onGetTreadDepthReportResultSucceeded: { [weak self] treadDepthResult in
                guard let self = self else { return }
                DispatchQueue.main.async {
                    self.loadingViewModelDelegate?.displayDepthResultView(uuid: self.uuid, treadDepthResult: treadDepthResult)
                }
            },
            onGetTreadDepthReportResultFailed: { [weak self] measurementError in
                print("Error code: " + (measurementError.errorCode ?? "not available"))
                print("Error message: " + measurementError.errorMessage)
                self?.loadingViewModelDelegate?.displayError()
            }, timeoutSeconds: 60
        )
    } catch {
        self.loadingViewModelDelegate?.displayError()
    }
}

Once the result is available, the onGetTreadDepthReportResultSucceeded callback will be called with the TreadDepthResult object containing it.

In case of any failure, the onGetTreadDepthReportResultFailed will be called containing the MeasurementError object, where you can find the error code and message.

A timeoutSeconds parameter is also received by the function, limitting for how long the result fetching can run before interrupted (in case of bad network connection, etc.).

TreadDepthResult

The TreadDepthResult represents the result of a tread depth measurement. It contains three properties:

  • global: An instance of TreadResultRegion representing the global result.

    • This value represents the global tread depth of the entire tire.

    • This value is calculated from all individual measurements.

  • regions: A list of TreadResultRegion instances representing the results for each of the identified tire regions.

    • This value represents the tread depth of the identified tire regions (for more details, check the PDF Report); It does not represent measurements of single grooves.

    • The regions are always provided considering the direction from Left to Right side of the scanned tire.

  • measurementInfo: An instance of MeasurementInfo providing additional information about the measurement.

  • TreadDepthResult can be easily converted to JSON format via the toJson() extension function.

    • This property holds the Measurement UUID, the measurement’s status (MeasurementStatus) and - if provided before the scan process - the additional context of your measurement.

    • The possible values for the Measurement Status are WaitingForImages, Processing, ResultReady, ResultAndReportReady,Completed, Aborted, Failed, and Unknown.

    • The results are only available when the measurement’s status is ResultReady, ResultAndReportReady, or Completed.

PDF Report

To retrieve the PDF report of a measurement, use the function getTreadDepthReportPdf(uuid) from the AnylineTireTreadSdk class. The PDF will be returned as a byte array. The return value can then be saved and displayed as best fitting your application’s workflow, e.g.:

// Request PDF
func requestPDF(context: UIViewController) async {
    do {
        anylineSDK.getTreadDepthReportPdf(measurementUuid: self.uuid) { pdfByteArray in
            print("PDF fetched from SDK.")

            // Convert ByteArray to Swift Data
            let data = pdfByteArray.toNSData()

            self.resultDetailsViewModelDelegate?.showPDF(pdfData: data)
        }
    } catch {
        resultDetailsViewModelDelegate?.showError(error: "error.description".localized())
    }
}

Remember to do/catch the getTreadDepthReportPdf() function, as the PDF report may not yet be available.

The report will only be available when measurement’s status is ResultAndReportReady, or Completed.

Analytics

The Anyline Tire Tread SDK provides not only the final measurement results, but also analytics results from your tire. Check the Analytics section for more information.

User Corrected Values and Comments

User Comments

To send a comment on a measurement, use the sendCommentFeedback function of the AnylineTireTreadSdk.

As usual with the TireTreadSDK, the UUID for the scan must be passed as a parameter. The comment is passed as a string:

func postFeedbackComment(uuid: String, comment: String) {
    DispatchQueue.global().async {
        AnylineTireTreadSdk.companion.sendCommentFeedback(
            resultUuidString: uuid,
            comment: comment,
            onSendCommentSucceed: { [weak self] response in
                response.body { resultDTO, error in
                    guard let self = self else { return }

                    if let error = error {
                        DispatchQueue.main.async {
                            self.feedbackViewModelDelegate?.showError(error: error.asAFError?.responseCode ?? 0)
                        }
                        return
                    }

                    // Handle success
                    DispatchQueue.main.async {
                        self.feedbackViewModelDelegate?.didSendData()
                    }
                }
            },
            onSendCommentFailed: { [weak self] response, exception in
                DispatchQueue.main.async {
                    self?.feedbackViewModelDelegate?.showError(error: 0)
                }
            }
        )
    }
}

User-Corrected Region Values

To send user-corrected region values, use the sendTreadDepthResultFeedback function from the AnylineTireTreadSdk. The result feedback should be provided as a list of TreadResultRegion, ordered from left to right.

You can only provide feedback for the regions returned by the SDK in the TreadDepthResult object.

The values of all regions need be added to the list before sending the feedback.

The TreadResultRegion objects can be initialized with millimeter or inch units:

func sendTreadDepthFeedback(resultUuid: String, treadResultRegions: [TreadResultRegion]) {
    DispatchQueue.global().async {
        AnylineTireTreadSdk.companion.sendTreadDepthResultFeedback(
            resultUuid: resultUuid,
            treadResultRegions: treadResultRegions,
            onSendTreadDepthResultSucceed: { [weak self] response in
                response.body { resultDTO, error in
                    guard let self = self else { return }

                    if let error = error {
                        DispatchQueue.main.async {
                            self.feedbackViewModelDelegate?.showError(error: error.asAFError?.responseCode ?? 0)
                        }
                        return
                    }
                }
            },
            onSendTreadDepthResultFailed: { [weak self] response, exception in
                DispatchQueue.main.async {
                    self?.feedbackViewModelDelegate?.showError(error: 0)
                }
            }
        )
    }
}