Skip to content

Commit a167540

Browse files
committed
CanSee fixes, better graphic consistency, code cleanup
1 parent e402913 commit a167540

35 files changed

+1810
-1455
lines changed

CanZE/CanZE.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@
4141
629D902725C31187007EF21A /* ChargingGraphViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 629D902625C31187007EF21A /* ChargingGraphViewController.swift */; };
4242
62A01DE825CD92CA00D69A01 /* DrivingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A01DE725CD92CA00D69A01 /* DrivingViewController.swift */; };
4343
62A27E1725CEB390005F3DD5 /* ChargingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A27E1625CEB390005F3DD5 /* ChargingHistoryViewController.swift */; };
44+
62A2D4DB25DFF4A500998571 /* StringProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A2D4DA25DFF4A500998571 /* StringProtocol.swift */; };
4445
62B1DFB025A9A255006454EE /* _assets in Resources */ = {isa = PBXBuildFile; fileRef = 62B1DFAF25A9A255006454EE /* _assets */; };
4546
62B1DFC525A9BA3C006454EE /* BatteryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62B1DFC425A9BA3C006454EE /* BatteryViewController.swift */; };
4647
62B1FBEA25DA9B4D000BFBFB /* GradientViewRed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62B1FBE425DA9B4D000BFBFB /* GradientViewRed.swift */; };
4748
62B1FBEB25DA9B4D000BFBFB /* GradientViewGreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62B1FBE525DA9B4D000BFBFB /* GradientViewGreen.swift */; };
4849
62B1FC0225DAA772000BFBFB /* GradientViewDecelAimRight.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62B1FBD725DA9AF3000BFBFB /* GradientViewDecelAimRight.swift */; };
4950
62B1FC0525DAADDA000BFBFB /* LoggerEmulator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62B1FC0425DAADDA000BFBFB /* LoggerEmulator.swift */; };
5051
62B5A56225A8B10600C4F050 /* Localizable.plist in Resources */ = {isa = PBXBuildFile; fileRef = 62B5A56425A8B10600C4F050 /* Localizable.plist */; };
52+
62C5C3E525E10282008160CC /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62C5C3E425E10282008160CC /* Button.swift */; };
5153
62D0A0B825A84B5400FB2EB7 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 62D0A0BA25A84B5400FB2EB7 /* Localizable.strings */; };
5254
62D1FFAE25C40E17006EDDA5 /* AllDataViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D1FFAD25C40E17006EDDA5 /* AllDataViewController.swift */; };
5355
62D2649D25B5BE9200421F14 /* DisclaimerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D2649C25B5BE9200421F14 /* DisclaimerViewController.swift */; };
@@ -130,6 +132,7 @@
130132
629D902625C31187007EF21A /* ChargingGraphViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChargingGraphViewController.swift; sourceTree = "<group>"; };
131133
62A01DE725CD92CA00D69A01 /* DrivingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrivingViewController.swift; sourceTree = "<group>"; };
132134
62A27E1625CEB390005F3DD5 /* ChargingHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChargingHistoryViewController.swift; sourceTree = "<group>"; };
135+
62A2D4DA25DFF4A500998571 /* StringProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringProtocol.swift; sourceTree = "<group>"; };
133136
62B1DFAF25A9A255006454EE /* _assets */ = {isa = PBXFileReference; lastKnownFileType = folder; path = _assets; sourceTree = "<group>"; };
134137
62B1DFC425A9BA3C006454EE /* BatteryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatteryViewController.swift; sourceTree = "<group>"; };
135138
62B1FBD725DA9AF3000BFBFB /* GradientViewDecelAimRight.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GradientViewDecelAimRight.swift; sourceTree = "<group>"; };
@@ -144,6 +147,7 @@
144147
62B5A56725A8B10C00C4F050 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = de; path = de.lproj/Localizable.plist; sourceTree = "<group>"; };
145148
62B5A56825A8B10D00C4F050 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = ru; path = ru.lproj/Localizable.plist; sourceTree = "<group>"; };
146149
62B5A56925A8B10D00C4F050 /* uk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = uk; path = uk.lproj/Localizable.plist; sourceTree = "<group>"; };
150+
62C5C3E425E10282008160CC /* Button.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
147151
62D0A0B925A84B5400FB2EB7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
148152
62D0A0BF25A84B9900FB2EB7 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
149153
62D1FFAD25C40E17006EDDA5 /* AllDataViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllDataViewController.swift; sourceTree = "<group>"; };
@@ -343,10 +347,12 @@
343347
6255283E259CEA1300C2772E /* AppSettings.swift */,
344348
62D3F967259337B3002CB6C7 /* AnyDecodable.swift */,
345349
62DFAB37259231C600B00C5C /* ButtonWithImage.swift */,
350+
62C5C3E425E10282008160CC /* Button.swift */,
346351
62D3F94825932BF5002CB6C7 /* Globals.swift */,
347352
621AC0E325C7F673004A293C /* Logger.swift */,
348353
62B1FC0425DAADDA000BFBFB /* LoggerEmulator.swift */,
349354
62D3F96025932F4B002CB6C7 /* Sid.swift */,
355+
62A2D4DA25DFF4A500998571 /* StringProtocol.swift */,
350356
62DFAB312592300500B00C5C /* Utils.swift */,
351357
);
352358
path = _helpers;
@@ -551,13 +557,15 @@
551557
621AC0E925C811D2004A293C /* Data.swift in Sources */,
552558
62D3F95A25932DFA002CB6C7 /* Message.swift in Sources */,
553559
6232908E25DAD575006AC42C /* _Test_Wifi.swift in Sources */,
560+
62C5C3E525E10282008160CC /* Button.swift in Sources */,
554561
6279AB0A25BC3A36009DE847 /* UserDefaults.swift in Sources */,
555562
62EF1D0D25D2DA0600E59E77 /* LeakCurrentsViewController.swift in Sources */,
556563
62DB50C025DA7711002FE369 /* GradientViewDecelAim.swift in Sources */,
557564
62D3F94325927126002CB6C7 /* Ecus.swift in Sources */,
558565
629D902725C31187007EF21A /* ChargingGraphViewController.swift in Sources */,
559566
62D1FFAE25C40E17006EDDA5 /* AllDataViewController.swift in Sources */,
560567
62FAC76325D3CFF700BA3AFD /* SpeedControlViewController.swift in Sources */,
568+
62A2D4DB25DFF4A500998571 /* StringProtocol.swift in Sources */,
561569
6232908625DAD56A006AC42C /* _TestViewController.swift in Sources */,
562570
622B484D25CAA54B00F27323 /* TemperatureHeatmapViewController.swift in Sources */,
563571
622B484A25CAA53C00F27323 /* VoltageHeatmapViewController.swift in Sources */,
@@ -710,6 +718,10 @@
710718
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
711719
MTL_FAST_MATH = YES;
712720
ONLY_ACTIVE_ARCH = YES;
721+
"OTHER_LDFLAGS[sdk=iphonesimulator14.4]" = (
722+
"-Xlinker",
723+
"-interposable",
724+
);
713725
SDKROOT = iphoneos;
714726
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
715727
SWIFT_OPTIMIZATION_LEVEL = "-Onone";

CanZE/CanZE/AllDataViewController.swift

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AllDataViewController: CanZeViewController {
2929

3030
// Do any additional setup after loading the view.
3131

32-
title = NSLocalizedString("title_activity_alldata", comment: "")
32+
title = NSLocalizedString_("title_activity_alldata", comment: "")
3333
lblDebug.text = ""
3434
NotificationCenter.default.addObserver(self, selector: #selector(updateDebugLabel(notification:)), name: Notification.Name("updateDebugLabel"), object: nil)
3535

@@ -38,7 +38,7 @@ class AllDataViewController: CanZeViewController {
3838
tv.text = ""
3939
setupPicker()
4040

41-
btnDownload_.setTitle(NSLocalizedString("button_alldata", comment: "").uppercased(), for: .normal)
41+
btnDownload_.setTitle(NSLocalizedString_("button_alldata", comment: "").uppercased(), for: .normal)
4242

4343
arrayEcu = []
4444
for ecu in Ecus.getInstance.getAllEcus() {
@@ -49,6 +49,9 @@ class AllDataViewController: CanZeViewController {
4949
arrayEcu.append(ecu) // all reachable ECU's plus the Free Fields Computer. We skip the Virtual Fields Computer for now as it requires real fields and thus frames.
5050
}
5151
}
52+
arrayEcu.sort { (a: Ecu, b: Ecu) -> Bool in
53+
a.mnemonic < b.mnemonic
54+
}
5255

5356
btnSelect_.setTitle(arrayEcu.first?.mnemonic, for: .normal)
5457
}
@@ -63,6 +66,8 @@ class AllDataViewController: CanZeViewController {
6366
NotificationCenter.default.addObserver(self, selector: #selector(decoded(notification:)), name: Notification.Name("decoded"), object: nil)
6467
NotificationCenter.default.addObserver(self, selector: #selector(endQueue2), name: Notification.Name("endQueue2"), object: nil)
6568
NotificationCenter.default.addObserver(self, selector: #selector(autoInit2), name: Notification.Name("autoInit"), object: nil)
69+
70+
btnSelect()
6671
}
6772

6873
override func viewWillDisappear(_ animated: Bool) {
@@ -81,17 +86,17 @@ class AllDataViewController: CanZeViewController {
8186
}
8287

8388
@objc func updateDebugLabel(notification: Notification) {
84-
let dic = notification.object as? [String: String]
85-
DispatchQueue.main.async {
86-
self.lblDebug.text = dic?["debug"]
89+
let notificationObject = notification.object as? [String: String]
90+
DispatchQueue.main.async { [self] in
91+
lblDebug.text = notificationObject?["debug"]
8792
}
88-
debug((dic?["debug"])!)
93+
debug((notificationObject?["debug"])!)
8994
}
9095

9196
override func startQueue() {
9297
if !Globals.shared.deviceIsConnected || !Globals.shared.deviceIsInitialized {
93-
DispatchQueue.main.async {
94-
self.view.makeToast("_device not connected")
98+
DispatchQueue.main.async { [self] in
99+
view.makeToast("_device not connected")
95100
}
96101
return
97102
}
@@ -111,19 +116,19 @@ class AllDataViewController: CanZeViewController {
111116

112117
let field = Fields.getInstance.fieldsBySid[sid!]
113118

114-
DispatchQueue.main.async {
115-
if self.lastSid != sid {
119+
DispatchQueue.main.async { [self] in
120+
if lastSid != sid {
116121
if field!.isString() || field!.isHexString() {
117-
self.tv.text += "\(sid!),\(field!.name ?? ""),\(field?.strVal ?? "")\n"
118-
self.lastSid = sid!
122+
tv.text += "\(sid!),\(field!.name ?? ""),\(field?.strVal ?? "")\n"
123+
lastSid = sid!
119124
} else if Globals.shared.fieldResultsDouble[sid!] != nil {
120-
self.tv.text += "\(sid!),\(field!.name ?? ""),\(field!.getValue())\n"
121-
self.lastSid = sid!
125+
tv.text += "\(sid!),\(field!.name ?? ""),\(field!.getValue())\n"
126+
lastSid = sid!
122127
} else {
123-
self.tv.text += "\(sid!),\(field!.name ?? "")\n"
124-
self.lastSid = sid!
128+
tv.text += "\(sid!),\(field!.name ?? "")\n"
129+
lastSid = sid!
125130
}
126-
self.tv.scrollToBottom()
131+
tv.scrollToBottom()
127132
}
128133
}
129134
}
@@ -147,7 +152,7 @@ class AllDataViewController: CanZeViewController {
147152

148153
/*
149154
} catch {
150-
tv.text += NSLocalizedString("message_NoEcuDefinition", comment: "")
155+
tv.text += NSLocalizedString_("message_NoEcuDefinition", comment: "")
151156
tv.scrollToBottom()
152157
// Reload the default frame & timings
153158
Frames.getInstance().load()
@@ -172,11 +177,12 @@ class AllDataViewController: CanZeViewController {
172177
}
173178

174179
func setupPicker() {
175-
pickerView.center = view.center
176180
pickerView.alpha = 0.0
177181
picker.delegate = self
178-
btnPickerDone.backgroundColor = .lightGray
179-
btnPickerCancel.backgroundColor = .lightGray
182+
//btnPickerDone.backgroundColor = .lightGray
183+
//btnPickerCancel.backgroundColor = .lightGray
184+
btnPickerDone.setTitle(NSLocalizedString_("default_Ok", comment: "").uppercased(), for: .normal)
185+
btnPickerCancel.setTitle(NSLocalizedString_("default_Cancel", comment: "").lowercased(), for: .normal)
180186
}
181187

182188
func showPicker() {

CanZE/CanZE/AppDelegate.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1717

1818
FirebaseApp.configure()
1919

20+
#if DEBUG
21+
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load()
22+
// for tvOS:
23+
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/tvOSInjection.bundle")?.load()
24+
// Or for macOS:
25+
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/macOSInjection.bundle")?.load()
26+
#endif
27+
2028
return true
2129
}
2230
}

CanZE/CanZE/AuxBatteryViewController.swift

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,36 @@ class AuxBatteryViewController: CanZeViewController {
3737
var line1: LineChartDataSet!
3838
var line2: LineChartDataSet!
3939

40-
let aux_Status = Globals.localizableFromPlist?.value(forKey: "list_AuxStatus") as? [String]
41-
let vehicle_Status = Globals.localizableFromPlist?.value(forKey: Utils.isPh2() ? "list_VehicleStatePh2" : "list_VehicleState") as? [String]
40+
var aux_Status: [String] = []
41+
var vehicle_Status: [String] = []
4242

4343
override func viewDidLoad() {
4444
super.viewDidLoad()
4545

4646
// Do any additional setup after loading the view.
4747

48-
title = NSLocalizedString("title_activity_auxbatt", comment: "")
48+
title = NSLocalizedString_("title_activity_auxbatt", comment: "")
4949
lblDebug.text = ""
5050
NotificationCenter.default.addObserver(self, selector: #selector(updateDebugLabel(notification:)), name: Notification.Name("updateDebugLabel"), object: nil)
5151

5252
///
5353

54-
label_12V.text = NSLocalizedString("label_12V", comment: "")
54+
aux_Status = localizableFromPlist("list_AuxStatus")
55+
vehicle_Status = localizableFromPlist(Utils.isPh2() ? "list_VehicleStatePh2" : "list_VehicleState")
56+
57+
label_12V.text = NSLocalizedString_("label_12V", comment: "")
5558
text12V.text = "-"
56-
label_12A.text = NSLocalizedString("label_12A", comment: "")
59+
label_12A.text = NSLocalizedString_("label_12A", comment: "")
5760
text12A.text = "-"
58-
label_DcLoad.text = NSLocalizedString("label_DcLoad", comment: "")
61+
label_DcLoad.text = NSLocalizedString_("label_DcLoad", comment: "")
5962
textDcLoad.text = "-"
60-
label_vehiclestate.text = NSLocalizedString("label_vehiclestate", comment: "")
63+
label_vehiclestate.text = NSLocalizedString_("label_vehiclestate", comment: "")
6164
text_vehicle_state.text = "-"
62-
label_VoltageUnderLoad.text = NSLocalizedString("label_VoltageLoad", comment: "")
65+
label_VoltageUnderLoad.text = NSLocalizedString_("label_VoltageLoad", comment: "")
6366
textVoltageUnderLoad.text = "-"
64-
label_CurrentUnderLoad.text = NSLocalizedString("label_CurrentUnderLoad", comment: "")
67+
label_CurrentUnderLoad.text = NSLocalizedString_("label_CurrentUnderLoad", comment: "")
6568
textCurrentUnderLoad.text = "-"
66-
label_AuxStatus.text = NSLocalizedString("label_AuxStatus", comment: "")
69+
label_AuxStatus.text = NSLocalizedString_("label_AuxStatus", comment: "")
6770
textAuxStatus.text = "-"
6871

6972
lblGraphTitle.text = "_Voltage, Vehicle state"
@@ -100,17 +103,17 @@ class AuxBatteryViewController: CanZeViewController {
100103
}
101104

102105
@objc func updateDebugLabel(notification: Notification) {
103-
let dic = notification.object as? [String: String]
104-
DispatchQueue.main.async {
105-
self.lblDebug.text = dic?["debug"]
106+
let notificationObject = notification.object as? [String: String]
107+
DispatchQueue.main.async { [self] in
108+
lblDebug.text = notificationObject?["debug"]
106109
}
107-
debug((dic?["debug"])!)
110+
debug((notificationObject?["debug"])!)
108111
}
109112

110113
override func startQueue() {
111114
if !Globals.shared.deviceIsConnected || !Globals.shared.deviceIsInitialized {
112-
DispatchQueue.main.async {
113-
self.view.makeToast("_device not connected")
115+
DispatchQueue.main.async { [self] in
116+
view.makeToast("_device not connected")
114117
}
115118
return
116119
}
@@ -130,8 +133,8 @@ class AuxBatteryViewController: CanZeViewController {
130133
}
131134

132135
@objc func endQueue2() {
133-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
134-
self.startQueue()
136+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [self] in
137+
startQueue()
135138
}
136139
}
137140

@@ -141,33 +144,33 @@ class AuxBatteryViewController: CanZeViewController {
141144

142145
let val = Globals.shared.fieldResultsDouble[sid!]
143146
if val != nil && !val!.isNaN {
144-
DispatchQueue.main.async {
147+
DispatchQueue.main.async { [self] in
145148
switch sid {
146149
case Sid.Aux12V:
147-
self.text12V.text = String(format: "%.1f", val!)
148-
self.lblVoltage.text = String(format: "%.2f", val!)
149-
self.chartEntries1.append(ChartDataEntry(x: Date().timeIntervalSince1970, y: val!))
150-
self.updateChart()
150+
text12V.text = String(format: "%.1f", val!)
151+
lblVoltage.text = String(format: "%.2f", val!)
152+
chartEntries1.append(ChartDataEntry(x: Date().timeIntervalSince1970, y: val!))
153+
updateChart()
151154
case Sid.Aux12A:
152-
self.text12A.text = String(format: "%.1f", val!)
155+
text12A.text = String(format: "%.1f", val!)
153156
case Sid.DcLoad:
154-
self.textDcLoad.text = String(format: "%.1f", val!)
157+
textDcLoad.text = String(format: "%.1f", val!)
155158
case Sid.AuxStatus:
156159
let i = Int(val!)
157-
if i >= 0, i < self.aux_Status!.count {
158-
self.textAuxStatus.text = self.aux_Status![i]
160+
if i >= 0, i < aux_Status.count {
161+
textAuxStatus.text = aux_Status[i]
159162
}
160163
case Sid.VehicleState:
161164
let i = Int(val!)
162-
if i >= 0, i < self.vehicle_Status!.count {
163-
self.text_vehicle_state.text = self.vehicle_Status![i]
164-
self.chartEntries2.append(ChartDataEntry(x: Date().timeIntervalSince1970, y: Double(i)))
165-
self.updateChart()
165+
if i >= 0, i < vehicle_Status.count {
166+
text_vehicle_state.text = vehicle_Status[i]
167+
chartEntries2.append(ChartDataEntry(x: Date().timeIntervalSince1970, y: Double(i)))
168+
updateChart()
166169
}
167170
case Sid.VoltageUnderLoad:
168-
self.textVoltageUnderLoad.text = String(format: "%.1f", val!)
171+
textVoltageUnderLoad.text = String(format: "%.1f", val!)
169172
case Sid.CurrentUnderLoad:
170-
self.textCurrentUnderLoad.text = String(format: "%.1f", val!)
173+
textCurrentUnderLoad.text = String(format: "%.1f", val!)
171174
default:
172175
print("unknown sid \(sid!)")
173176
}

0 commit comments

Comments
 (0)