Skip to content

Commit

Permalink
v7.7.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
flparrot committed Jun 12, 2023
1 parent 5a9c5b1 commit b418448
Show file tree
Hide file tree
Showing 153 changed files with 19,419 additions and 2,401 deletions.
Binary file added .DS_Store
Binary file not shown.
147 changes: 85 additions & 62 deletions OpenFlight/OpenFlight.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
3 changes: 2 additions & 1 deletion OpenFlight/OpenFlight/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Enable device battery monitoring.
UIDevice.current.isBatteryMonitoringEnabled = true
// ARCGIS KEY - Openflight
AGSArcGISRuntimeEnvironment.apiKey = "put-your-Arcgis-key-here"
AGSArcGISRuntimeEnvironment.apiKey =
"your-api-key"

// Enable gsdk system log
ULog.redirectToSystemLog(enabled: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public final class MyFlightsCoordinator: Coordinator {
let viewController = MyFlightsViewController.instantiate(coordinator: self,
defaultSelectedProject: defaultSelectedProject,
defaultSelectedFlight: defaultSelectedFlight,
defaultSelectedHeaderUuid: defaultSelectedHeaderUuid)
defaultSelectedHeaderUuid: defaultSelectedHeaderUuid,
projectManager: flightPlanServices.projectManager,
flightPlanManager: flightPlanServices.manager)

viewController.modalPresentationStyle = .fullScreen
navigationController = NavigationController(rootViewController: viewController)
navigationController?.isNavigationBarHidden = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,8 @@ private extension FrontRightButtonViewModel {
switch manualPilotingItf.smartTakeOffLandAction {
case .thrownTakeOff:
if Services.hub.drone.handLaunchService.canStart {
if Services.hub.drone.ophtalmoService.canStartHandCalibration {
ULog.i(.tag, "takeOffOrLandDrone execute ophtalmo start hand")
Services.hub.drone.ophtalmoService.startHandCalibration()
} else {
ULog.i(.tag, "takeOffOrLandDrone execute thrownTakeOff")
manualPilotingItf.thrownTakeOff()
}
ULog.i(.tag, "takeOffOrLandDrone execute thrownTakeOff")
manualPilotingItf.thrownTakeOff()
} else {
ULog.i(.tag, "takeOffOrLandDrone execute takeOff")
Services.hub.drone.handLaunchService.updateTakeOffButtonPressed(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import Combine
public protocol SettingsProvider {
/// Returns list of advanced settings types to show.
var advancedSettingsTypes: [SettingsType] { get }
/// Returns list of advanced controllers that will replace existing ones.
var advancedViewControllers: [(sectionToChange: SettingsType, controller: UIViewController)] { get }
}

/// AccountProvider protocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,18 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" translatesAutoresizingMaskIntoConstraints="NO" id="li2-Ue-yuo">
<rect key="frame" x="426" y="15" width="426" height="273"/>
<rect key="frame" x="426" y="5" width="426" height="293"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gyx-kv-01u" customClass="UpdatingSuccessHeader" customModule="OpenFlight" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="426" height="30"/>
<rect key="frame" x="0.0" y="0.0" width="426" height="50"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="3gW-am-IZ5"/>
</constraints>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="D39-ug-JmG" customClass="UpdatingTableView" customModule="OpenFlight" customModuleProvider="target">
<rect key="frame" x="0.0" y="60" width="426" height="57.333333333333343"/>
<rect key="frame" x="0.0" y="80" width="426" height="57.333333333333343"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iVJ-4X-jPQ">
<rect key="frame" x="0.0" y="147.33333333333334" width="426" height="40.666666666666657"/>
<rect key="frame" x="0.0" y="167.33333333333334" width="426" height="40.666666666666657"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="40.670000000000002" id="N4x-AZ-GLW"/>
</constraints>
Expand All @@ -85,7 +82,7 @@
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bxU-u7-XgK" customClass="UpdatingDoneFooter" customModule="OpenFlight" customModuleProvider="target">
<rect key="frame" x="0.0" y="218" width="426" height="55"/>
<rect key="frame" x="0.0" y="238" width="426" height="55"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="55" id="20M-D6-XEF"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import UIKit
import Combine
import GroundSdk

/// The interface for the battery updating process
class BatteryUpdatingViewController: UIViewController {
Expand All @@ -37,6 +38,7 @@ class BatteryUpdatingViewController: UIViewController {
private var cancellables = Set<AnyCancellable>()
private var viewModel: BatteryUpdatingViewModel!
private weak var coordinator: DroneFirmwaresCoordinator?
private var batteryInfoRef: Ref<BatteryInfo>?

@IBOutlet weak var cancelButton: InsetHitAreaButton!
@IBOutlet weak var titleLabel: UILabel!
Expand Down Expand Up @@ -130,8 +132,8 @@ class BatteryUpdatingViewController: UIViewController {
case .rebooting:
cancelButton.isHidden = true
progressView.setFakeProgress(duration: Constants.rebootDuration)
case .error:
displayErrorUI()
case .error(let errorType):
displayErrorUI(errorType)
case .success:
displaySuccessUI()
}
Expand All @@ -149,9 +151,14 @@ class BatteryUpdatingViewController: UIViewController {
}

/// Displays error UI.
func displayErrorUI() {
func displayErrorUI(_ errorType: BatteryUpdateErrorType) {
warningLabel.isHidden = true
reportView.setup(with: .error)
switch errorType {
case .defaultError:
reportView.setup(with: .error)
case .serialChange:
reportView.setup(with: .serialChange)
}
reportView.isHidden = false
continueView.setup(delegate: self, state: .error)
continueView.isHidden = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ struct BatteryUpdatingStep {
var label: String
}

enum BatteryUpdateErrorType {
case defaultError
case serialChange
}

enum ProgressStep {
case preparingUpdate(progress: Float)
case updating
case rebooting
case error
case error(_ error: BatteryUpdateErrorType)
case success
}

Expand Down Expand Up @@ -79,10 +84,16 @@ class BatteryUpdatingViewModel {
private var isRebooting = false
/// Becomes `true` when any error happens.
private var hasFailed = false
/// Becomes `true` if a different battery was plugged.
private var serialChanged = false
/// Subject for the updating process datasource.
private var elementsSubject = CurrentValueSubject<[BatteryUpdatingStep], Never>([])
/// Battery gauge updater service.
private var batteryGaugeUpdaterService: BatteryGaugeUpdaterService
/// Battery serial number.
private var batterySerial: String?
/// Battery configuration date.
private var batteryConfigurationDate: Date?
/// Current progress from 0 to 100, used to udpate the progress view.
@Published private(set) var currentProgress: Float = Constants.minProgress
/// progress step, used to update the progress view.
Expand Down Expand Up @@ -161,14 +172,40 @@ class BatteryUpdatingViewModel {
self.updateListForReboot()
} else {
// The connection was lost during preparation, possibly because the battery was removed. Stop the procedure immediately.
self.progressStep = .error
self.progressStep = .error(.defaultError)
}
} else {
let batteryInfo = drone?.getInstrument(Instruments.batteryInfo)
let configurationDate = batteryInfo?.batteryDescription?.configurationDate
ULog.i(.tag, "listenDroneConnection - on connection: "
+ "isRebooting: \(self.isRebooting)"
+ "previous date:\(String(describing: self.batteryConfigurationDate))"
+ "new date:\(String(describing: configurationDate))")
if self.batterySerial != nil
&& batteryInfo?.serial != nil
&& self.batterySerial != batteryInfo?.serial {
// The battery serial has changed: the battery has been replaced.
self.serialChanged = true
self.updateProgressForReboot()
self.updateListForReboot()
return
}
self.batterySerial = batteryInfo?.serial

if self.isRebooting {
// The drone is reconnected after rebooting.
// Check if configuration date has changed.
if self.batteryConfigurationDate != nil
&& configurationDate != nil
&& self.batteryConfigurationDate == configurationDate {
// Same date means no update.
self.progressStep = .error(.defaultError)
return
}
self.updateProgressForReboot()
self.updateListForReboot()
}
self.batteryConfigurationDate = configurationDate
}
}
.store(in: &cancellables)
Expand Down Expand Up @@ -197,6 +234,7 @@ class BatteryUpdatingViewModel {
updateElement.step = .waiting
rebootElement.step = .waiting
case .readyToUpdate:
prepareElement.step = .succeeded
if !isUpdating {
// Send the update commmand
batteryGaugeUpdaterService.update()
Expand Down Expand Up @@ -229,7 +267,7 @@ class BatteryUpdatingViewModel {
/// - unavailabilityReasons: the set of current unavailability reasons (e.g. USB unplugged)
func updateProgress(state: BatteryGaugeUpdaterState, currentProgress: UInt, unavailabilityReasons: Set<BatteryGaugeUpdaterUnavailabilityReasons>) {
guard unavailabilityReasons.isEmpty else {
self.progressStep = .error
self.progressStep = .error(.defaultError)
return
}
switch state {
Expand All @@ -240,7 +278,7 @@ class BatteryUpdatingViewModel {
case .readyToUpdate, .updating:
self.progressStep = .updating
case .error:
self.progressStep = .error
self.progressStep = .error(.defaultError)
}
}

Expand All @@ -250,8 +288,13 @@ class BatteryUpdatingViewModel {
var updateElement = elements[Elements.update.rawValue]
var rebootElement = elements[Elements.reboot.rawValue]
if isDroneConnected {
updateElement.step = .succeeded
rebootElement.step = .succeeded
if serialChanged {
updateElement.step = .failed("")
rebootElement.step = .succeeded
} else {
updateElement.step = .succeeded
rebootElement.step = .succeeded
}
} else {
updateElement.step = .succeeded
rebootElement.step = .loading
Expand All @@ -261,6 +304,10 @@ class BatteryUpdatingViewModel {

/// Updates the progress step during the reboot phase.
func updateProgressForReboot() {
if serialChanged {
self.progressStep = .error(.serialChange)
return
}
if isRebooting && isDroneConnected {
// reboot ended
self.progressStep = .success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private extension FirmwareUpdatingViewController {
self?.quitProcesses(closeFirmwareList: true)
}
})
let cancelAction = AlertAction(title: L10n.cancel, actionHandler: nil)
let cancelAction = AlertAction(title: L10n.firmwareMissionUpdateQuitInstallationCancelAction, actionHandler: nil)
let alert = AlertViewController.instantiate(
title: L10n.firmwareMissionUpdateQuitInstallationTitle,
message: L10n.firmwareMissionUpdateQuitInstallationDroneMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private extension FirmwareAndMissionsUpdateViewController {
self?.quitProcesses(closeFirmwareList: true)
}
})
let cancelAction = AlertAction(title: L10n.cancel, actionHandler: nil)
let cancelAction = AlertAction(title: L10n.firmwareMissionUpdateQuitInstallationCancelAction, actionHandler: nil)

let alert = AlertViewController.instantiate(
title: L10n.firmwareMissionUpdateQuitInstallationTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ final class UpdatingDoneFooter: UIView, NibOwnerLoadable {
switch state {
case .waiting:
continueButton.isHidden = true
case .error,
.success:
case .error, .serialChange, .success:
continueButton.isHidden = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Reusable
enum UpdatingState {
case success
case error
case serialChange
case waiting
}

Expand All @@ -42,7 +43,7 @@ private extension UpdatingState {
/// Title color.
var titleColor: UIColor {
switch self {
case .error, .success:
case .error, .success, .serialChange:
return ColorName.defaultTextColor.color
case .waiting:
return ColorName.clear.color
Expand All @@ -53,6 +54,8 @@ private extension UpdatingState {
switch self {
case .error:
return L10n.firmwareMissionUpdateProcessesFailed
case .serialChange:
return L10n.batteryUpdateSerialChanged
case .success:
return L10n.firmwareMissionUpdateProcessesSucceeded
case .waiting:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private extension AirSdkMissionsUpdatingViewController {
self?.quitProcesses(closeFirmwareList: true)
}
})
let cancelAction = AlertAction(title: L10n.cancel, actionHandler: nil)
let cancelAction = AlertAction(title: L10n.firmwareMissionUpdateQuitInstallationCancelAction, actionHandler: nil)

let alert = AlertViewController.instantiate(
title: L10n.firmwareMissionUpdateQuitInstallationTitle,
Expand Down
Loading

0 comments on commit b418448

Please sign in to comment.