forked from fritob/Camper-Monitor
CamperMonitor (Haupt-Repo) und VanAligneiOS (aus dem gemergten solar-integration-Branch) liefen unter zwei verschiedenen internen Namen, obwohl die App nach aussen längst einheitlich "VanControl Pro" heisst. Jetzt durchgängig VanControl: - Ordner: CamperMonitor/, CamperMonitorWatch/, CamperMonitorComplication/, VanAligneiOSWidget/ → VanControl/, VanControlWatch/, VanControlComplication/, VanControlWidget/ - Xcode-Projekt: CamperMonitor.xcodeproj → VanControl.xcodeproj, alle Targets/Schemes/Produktnamen entsprechend umbenannt - Bundle-Identifier auf Wunsch mitgeändert: de.s0.fototeddy.VanControl* (App noch nicht veröffentlicht); dabei auch die WKCompanionAppBundleIdentifier-Werte korrigiert, die noch das alte de.fritob-Präfix statt des tatsächlichen de.s0.fototeddy-Präfixes trugen - Swift-Dateien/Typen: CamperMonitorApp → VanControlApp, VanAligneiOSWidget* → VanControlWidget* - Config/*-Info.plist umbenannt, README.md/Tools/README.md/run-tests.sh auf die neuen Pfade angepasst Bewusst unverändert: firmware/vanalign und alle Bezüge auf "VanAlign" als Namen der Neigungsmesser-Hardware (eigenständiges Produkt, kein App-Name) sowie der komplette Android/-Ordner. Build (App, Watch, Debug) und Protokoll-Testlauf grün. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
85 lines
4.3 KiB
Swift
85 lines
4.3 KiB
Swift
import Foundation
|
||
|
||
/// Erfundene Werte für den Simulator, damit sich die Ansichten ohne iPhone und
|
||
/// ohne Fahrzeug prüfen lassen. Eingeschaltet über `CAMPER_DEMO=1`:
|
||
///
|
||
/// xcrun simctl launch --terminate-running-process booted \
|
||
/// de.fritob.VanControl.watchkitapp
|
||
/// # mit SIMCTL_CHILD_CAMPER_DEMO=1 davor
|
||
///
|
||
/// Im normalen Betrieb wird hiervon nichts ausgeführt.
|
||
enum WatchDemo {
|
||
|
||
private static let profile = Profile(name: "Kastenwagen", symbol: "box.truck",
|
||
trackWidth: 1.85, wheelbase: 3.50)
|
||
|
||
private static let victronSolarID = UUID(uuidString: "00000000-0000-0000-0000-000000000050")!
|
||
private static let batteryID = UUID(uuidString: "00000000-0000-0000-0000-0000000000A0")!
|
||
private static let fridgeID = UUID(uuidString: "00000000-0000-0000-0000-0000000000F0")!
|
||
private static let levelID = UUID(uuidString: "00000000-0000-0000-0000-0000000000E0")!
|
||
|
||
/// `seconds` läuft weiter, damit sich die Neigung bewegt – sonst zeigt der
|
||
/// Ausrichtungs-Assistent nie einen Trend.
|
||
static func payload(at seconds: Double) -> WatchPayload {
|
||
let now = Date()
|
||
let swing = sin(seconds / 8)
|
||
|
||
var level = LevelState()
|
||
level.pitch = 1.4 * swing + 0.3
|
||
level.roll = -0.9 * cos(seconds / 11)
|
||
level.pitchOffset = 0.4
|
||
level.rollOffset = -0.2
|
||
|
||
var victronSolar = DeviceSnapshot(deviceID: victronSolarID, timestamp: now, rssi: -58)
|
||
victronSolar.state = "Konstantspannung (Absorption)"
|
||
victronSolar.metrics = [
|
||
Metric("pv_power", "PV-Leistung", 284 + 40 * swing, unit: "W", precision: 0, primary: true),
|
||
Metric("battery_voltage", "Batteriespannung", 14.12, unit: "V", precision: 2),
|
||
Metric("battery_current", "Ladestrom", 18.6, unit: "A", precision: 1),
|
||
]
|
||
|
||
var battery = DeviceSnapshot(deviceID: batteryID, timestamp: now, rssi: -64)
|
||
battery.state = "Lädt"
|
||
battery.metrics = [
|
||
Metric("soc", "Ladezustand", 78.4, unit: "%", precision: 1, primary: true),
|
||
Metric("voltage", "Spannung", 13.66, unit: "V", precision: 2),
|
||
Metric("current", "Strom", 18.6, unit: "A", precision: 1),
|
||
Metric("capacity", "Restkapazität", 156.8, unit: "Ah", precision: 1),
|
||
]
|
||
|
||
var fridge = DeviceSnapshot(deviceID: fridgeID, timestamp: now, rssi: -66)
|
||
fridge.state = "Kompressor läuft"
|
||
fridge.metrics = [
|
||
Metric("temperature", "Innentemperatur", 6, unit: "°C", precision: 0, primary: true),
|
||
Metric("target", "Solltemperatur", 4, unit: "°C", precision: 0),
|
||
Metric("battery_voltage", "Bordspannung", 12.7, unit: "V", precision: 1),
|
||
]
|
||
|
||
return WatchPayload(
|
||
generatedAt: now,
|
||
profile: profile,
|
||
isRadioReady: true,
|
||
radioStatus: "Demo-Modus",
|
||
devices: [
|
||
WatchDevice(id: levelID, name: "Nivellierung", role: .leveling,
|
||
link: .live, snapshot: level.snapshot(deviceID: levelID, rssi: -70),
|
||
level: level, orientation: .identity, fridge: nil),
|
||
WatchDevice(id: batteryID, name: "Bulltron 200 Ah", role: .bms,
|
||
link: .live, snapshot: battery, level: nil,
|
||
orientation: nil, fridge: nil),
|
||
WatchDevice(id: victronSolarID, name: "Solar Dach", role: .victronSolarCharger,
|
||
link: .live, snapshot: victronSolar, level: nil,
|
||
orientation: nil, fridge: nil),
|
||
WatchDevice(id: fridgeID, name: "Kühlbox", role: .fridge,
|
||
link: .live, snapshot: fridge, level: nil, orientation: nil,
|
||
fridge: WatchFridge(isLive: true, updated: now,
|
||
isPoweredOn: true, isEco: true, isLocked: false,
|
||
isDualZone: false, unitSymbol: "°C",
|
||
leftTarget: 4, leftCurrent: 6,
|
||
rightTarget: nil, rightCurrent: nil,
|
||
minTarget: -20, maxTarget: 20,
|
||
batteryVolts: 12.7)),
|
||
])
|
||
}
|
||
}
|