|
- {"kind":"symbol","identifier":{"url":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/ScanView2\/handleScan(result:)","interfaceLanguage":"swift"},"variants":[{"traits":[{"interfaceLanguage":"swift"}],"paths":["\/documentation\/fueling\/scanview2\/handlescan(result:)"]}],"metadata":{"symbolKind":"method","title":"handleScan(result:)","externalID":"s:7Fueling9ScanView2V06handleB06resultys6ResultOy11CodeScanner0bF0VAH0B5ErrorOG_tF","roleHeading":"Instance Method","fragments":[{"text":"func","kind":"keyword"},{"text":" ","kind":"text"},{"kind":"identifier","text":"handleScan"},{"kind":"text","text":"("},{"text":"result","kind":"externalParam"},{"kind":"text","text":": "},{"text":"Result","kind":"typeIdentifier","preciseIdentifier":"s:s6ResultO"},{"text":"<","kind":"text"},{"kind":"typeIdentifier","preciseIdentifier":"s:11CodeScanner10ScanResultV","text":"ScanResult"},{"text":", ","kind":"text"},{"kind":"typeIdentifier","text":"ScanError","preciseIdentifier":"s:11CodeScanner9ScanErrorO"},{"kind":"text","text":">)"}],"role":"symbol","modules":[{"name":"Fueling"}]},"hierarchy":{"paths":[["doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling","doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/ScanView2"]]},"abstract":[{"type":"text","text":"Handles the scan result from the QR code scanner."}],"primaryContentSections":[{"declarations":[{"languages":["swift"],"platforms":["iOS"],"tokens":[{"text":"@","kind":"attribute"},{"text":"MainActor","kind":"attribute","preciseIdentifier":"s:ScM"},{"text":" ","kind":"text"},{"text":"func","kind":"keyword"},{"text":" ","kind":"text"},{"kind":"identifier","text":"handleScan"},{"text":"(","kind":"text"},{"text":"result","kind":"externalParam"},{"text":": ","kind":"text"},{"kind":"typeIdentifier","preciseIdentifier":"s:s6ResultO","text":"Result"},{"kind":"text","text":"<"},{"text":"ScanResult","kind":"typeIdentifier","preciseIdentifier":"s:11CodeScanner10ScanResultV"},{"text":", ","kind":"text"},{"kind":"typeIdentifier","preciseIdentifier":"s:11CodeScanner9ScanErrorO","text":"ScanError"},{"text":">)","kind":"text"}]}],"kind":"declarations"},{"parameters":[{"name":"result","content":[{"type":"paragraph","inlineContent":[{"type":"text","text":"The result of the scan, which can be a success or failure."}]}]}],"kind":"parameters"},{"content":[{"level":2,"text":"Overview","anchor":"Overview","type":"heading"},{"code":["func handleScan(result: Result<ScanResult, ScanError>) {"," isShowingScanner = false"," switch result {"," case .success(let result):"," webSocket.scan = result.string.components(separatedBy: \"|\")"," webSocket.assetType = webSocket.scan[3]"," webSocket.isScanPerformed = true"," print(\"Scan successful: \\(webSocket.scan)\")"," switch webSocket.assetType {"," case \"Saddle tank\":"," networkMonitor.joinWiFi(result: result.string)"," dispenseTankType = webSocket.scan[3]"," dispenseTankID = webSocket.scan[5]"," dispenseTankFuelType = webSocket.scan[7]"," ssid = networkMonitor.getCurrentSSID() ?? \"\""," partNumber = ssid"," "," print(\"Trying to connect to web socket\")"," "," case \"NOTAG\":"," webSocket.isShowingNoTag = true"," case \"RERENT\":"," webSocket.isShowingRental = true"," default:"," isSaddleOrSwitchTankClick = false"," setupTankValuesWithPayLoad(payload: webSocket.scan, webSocket: webSocket)"," webSocket.scannedTank = webSocket.tankNumber"," print(\"Scanned tank: \\(webSocket.scannedTank)\")"," if webSocket.fuelType == dispenseTankFuelType {"," print(\"Running Pump\")"," print(\"Fuel pump status: \\(webSocket.refillStatusMessage.dyedFuelPump)\")"," if webSocket.informationMessage.informationMessageVersion != \"2\" {"," print(\"Sending >MODE;4; and >RUN;0; commands\")"," webSocket.socket.write(string: \">MODE;4;\")"," webSocket.socket.write(string: \">RUN;0;\\(webSocket.tankCapacity);\")"," } else {"," if webSocket.refillStatusMessage.dyedFuelPump == \"0\" {"," print(\"Sending >RUN;\\(webSocket.tankCapacity); command\")"," usleep(10000)"," webSocket.socket.write(string: \">RUN;\\(webSocket.tankCapacity);\")"," }"," }"," } else if webSocket.fuelType == \"OFF\" {"," print(\"Running Pump - Override\")"," DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {"," webSocket.alertTitle = \"Fuel Type Mismatch\""," webSocket.alertMessage = \"You are trying to pump OTR fuel into an OFF ROAD tank. This will be marked as an override exception for tax purposes.\""," webSocket.isShowingAlert = true"," }"," webSocket.isOverride = true"," if webSocket.informationMessage.informationMessageVersion != \"2\" {"," print(\"Sending >MODE;4; and >RUN;0; commands\")"," webSocket.socket.write(string: \">MODE;4;\")"," webSocket.socket.write(string: \">RUN;0;\\(webSocket.tankCapacity);\")"," } else {"," if webSocket.refillStatusMessage.dyedFuelPump == \"0\" {"," print(\"Sending >RUN;\\(webSocket.tankCapacity); command\")"," usleep(10000)"," webSocket.socket.write(string: \">RUN;\\(webSocket.tankCapacity);\")"," }"," }"," } else {"," print(\"Fuel type mismatch: \\(webSocket.fuelType) != \\(dispenseTankFuelType)\")"," DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {"," webSocket.alertTitle = \"Fuel Type Mismatch\""," webSocket.alertMessage = \"You can't put dyed fuel in this tank.\""," webSocket.isShowingAlert = true"," }"," }"," }"," case .failure(let error):"," print(\"Scanning failed: \\(error.localizedDescription)\")"," }","}"],"syntax":"swift","type":"codeListing"}],"kind":"content"}],"sections":[],"schemaVersion":{"major":0,"patch":0,"minor":3},"references":{"doc://rpm.com.production.Scanner/documentation/Fueling/ScanView2/handleScan(result:)":{"identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/ScanView2\/handleScan(result:)","kind":"symbol","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"text":"handleScan","kind":"identifier"},{"kind":"text","text":"("},{"kind":"externalParam","text":"result"},{"kind":"text","text":": "},{"preciseIdentifier":"s:s6ResultO","kind":"typeIdentifier","text":"Result"},{"text":"<","kind":"text"},{"text":"ScanResult","preciseIdentifier":"s:11CodeScanner10ScanResultV","kind":"typeIdentifier"},{"kind":"text","text":", "},{"text":"ScanError","kind":"typeIdentifier","preciseIdentifier":"s:11CodeScanner9ScanErrorO"},{"text":">)","kind":"text"}],"url":"\/documentation\/fueling\/scanview2\/handlescan(result:)","type":"topic","title":"handleScan(result:)","abstract":[{"text":"Handles the scan result from the QR code scanner.","type":"text"}],"role":"symbol"},"doc://rpm.com.production.Scanner/documentation/Fueling":{"kind":"symbol","url":"\/documentation\/fueling","title":"Fueling","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling","abstract":[{"type":"text","text":"The Scanner app is designed to facilitate secure and efficient fuel management operations, primarily focusing on user authentication, fuel data collection, and network communication. The app includes several key features to ensure seamless and reliable interactions between users and the backend systems, leveraging technologies like WebSockets, Core Data, and biometric authentication."}],"type":"topic","role":"collection"},"doc://rpm.com.production.Scanner/documentation/Fueling/ScanView2":{"kind":"symbol","abstract":[{"type":"codeVoice","code":"ScanView2"},{"text":" is a SwiftUI view that manages the UI for scanning and displaying tank information.","type":"text"}],"navigatorTitle":[{"kind":"identifier","text":"ScanView2"}],"fragments":[{"text":"struct","kind":"keyword"},{"kind":"text","text":" "},{"kind":"identifier","text":"ScanView2"}],"identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/ScanView2","role":"symbol","type":"topic","title":"ScanView2","url":"\/documentation\/fueling\/scanview2"}}}
|