diff --git a/SenzorDataCollectorApp.xcodeproj/project.pbxproj b/SenzorDataCollectorApp.xcodeproj/project.pbxproj index 3d9f51424dd233e5fd786382e4198618ba7d3eb8..19fcfcb70a12606a1692ce498726659eaa82ab2e 100644 --- a/SenzorDataCollectorApp.xcodeproj/project.pbxproj +++ b/SenzorDataCollectorApp.xcodeproj/project.pbxproj @@ -489,6 +489,7 @@ INFOPLIST_KEY_NSFileProviderPresenceUsageDescription = "The app needs it to save files"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "The needs ot use senzor data"; + INFOPLIST_KEY_NSMotionUsageDescription = "THe app need is"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; @@ -526,6 +527,7 @@ INFOPLIST_KEY_NSFileProviderPresenceUsageDescription = "The app needs it to save files"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "The needs ot use senzor data"; + INFOPLIST_KEY_NSMotionUsageDescription = "THe app need is"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; diff --git a/SenzorDataCollectorApp/Info.plist b/SenzorDataCollectorApp/Info.plist index fd4062296392fa9425f636ee3ba6990298b6344d..dd703eebf4c484566e67def28ed2ff8195b44644 100644 --- a/SenzorDataCollectorApp/Info.plist +++ b/SenzorDataCollectorApp/Info.plist @@ -2,6 +2,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>NSMotionUsageDescription</key> + <string>App mesasures sensors</string> <key>BGTaskSchedulerPermittedIdentifiers</key> <array> <string>hu.itk.ppke.backgroundTask</string> diff --git a/SenzorDataCollectorApp/Sensors.swift b/SenzorDataCollectorApp/Sensors.swift index 03eafa3c7af8e05a041600367f9763d49de60951..5cf4ec758f3e94c29d074859dcdb729315522d1f 100644 --- a/SenzorDataCollectorApp/Sensors.swift +++ b/SenzorDataCollectorApp/Sensors.swift @@ -74,20 +74,15 @@ class SensorCollector: ObservableObject { gyroStartRecording(motionManager: motionManager) magStartRecording(motionManager: motionManager) altStartRecording(altimeter: altimeter) - } func stopAllRecording(motionManager: CMMotionManager, altimeter: CMAltimeter){ - print("Sensors stopped all recording") motionManager.stopAccelerometerUpdates() motionManager.stopGyroUpdates() motionManager.stopMagnetometerUpdates() altimeter.stopRelativeAltitudeUpdates() - - - //many missing :/ - + print("Sensors stopped all recording") for index in 0..<activeSensorsList.count { activeSensorsList[index].isSensorActive = false } @@ -130,9 +125,6 @@ class SensorCollector: ObservableObject { func accStartRecording(motionManager: CMMotionManager){ //if there is an acc.meter available: if(motionManager.isAccelerometerAvailable){ - - //changing the status of the sensor active in the list of sensors - //set accelerometer update frequency - to the maximum that the device is capable motionManager.accelerometerUpdateInterval = motionManager.deviceMotionUpdateInterval //start accelerometer update: diff --git a/SenzorDataCollectorApp/StartingView.swift b/SenzorDataCollectorApp/StartingView.swift index f8783c85d6567812ec87c0bfcd8187e443bea4f6..6b0ab955ccd874c1560269e16ae19c1e1c731c27 100644 --- a/SenzorDataCollectorApp/StartingView.swift +++ b/SenzorDataCollectorApp/StartingView.swift @@ -72,8 +72,9 @@ struct StartingView: View { }.padding().disabled(manager.state != "Ready").opacity(debug ? 0 : 1) Button("STOP Iterations") { - sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) customTimer.stopTimer() + sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) + }.padding().opacity(debug ? 0 : 1) Text("\(manager.numberOfMeasurements - manager.timerIntervalValues.count >= 0 ? "\(manager.numberOfMeasurements - manager.timerIntervalValues.count)/\(manager.numberOfMeasurements)" : "Not initialised")") @@ -230,11 +231,11 @@ struct StartingView: View { // } // } //----------------------------- NOTIFICAION HANDELING --------------------------------- - .alert("\(manager.numberOfMeasurements - manager.timerIntervalValues.count >= 0 ? "\(manager.numberOfMeasurements - manager.timerIntervalValues.count)/\(manager.numberOfMeasurements)" : "Not initialised") Measurement", isPresented: $customTimer.isFinished) { + .alert("\(manager.numberOfMeasurements - manager.timerIntervalValues.count >= -1 ? "\(manager.numberOfMeasurements - manager.timerIntervalValues.count)/\(manager.numberOfMeasurements)" : "Not initialised") Measurement", isPresented: $customTimer.isFinished) { Button(manager.timerIntervalValues.count == 0 ? "End" : "Next" ,role: .cancel){ - - sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) customTimer.stopTimer() + + sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) saveAllToJson() setNextMeasurement() @@ -244,16 +245,16 @@ struct StartingView: View { } } Button("Stop", role: .destructive){ - sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) customTimer.stopTimer() + sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) saveAllToJson() } } //------------------ DEMO NOTIFICATION - MEASUREMENT STARTING ---------------------- .alert("Demo Alert - press start if you are ready to start!", isPresented: $demostart){ Button("Start",role: .cancel){ - sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) customTimer.stopTimer() + sensor.stopAllRecording(motionManager: motionManager, altimeter: altimeter) setNextMeasurement() if customTimer.totalSeconds != 0 { sensor.startAllRecording(motionManager: motionManager, altimeter: altimeter)