Commit 9ca1af4f authored by Timo Tegtmeier's avatar Timo Tegtmeier

Initial commit of release 0611

parents
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
## Gcc Patch
/*.gcno
//
// AppDelegate.h
// TTRCom
//
// Created by Timo Tegtmeier on 27.03.08.
//
// TTRCom MacEdition - A Program To Use The Trabitronic On Macs
// Copyright (C) 2008 Timo Tegtmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#import <Cocoa/Cocoa.h>
#import "PowerOffTransformer.h"
#import "BoolToStringTransformer.h"
#import "PathExpander.h"
@interface AppDelegate : NSObject {
}
-(bool) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) app;
-(AppDelegate *) init;
@end
//
// AppDelegate.m
// TTRCom
//
// Created by Timo Tegtmeier on 27.03.08.
//
// TTRCom MacEdition - A Program To Use The Trabitronic On Macs
// Copyright (C) 2008 Timo Tegtmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#import "AppDelegate.h"
@implementation AppDelegate
-(bool) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) app {
return YES;
}
-(AppDelegate *) init {
self = [super init];
if(self) {
NSString *userDefaultsValuesPath;
NSDictionary *userDefaultsValuesDict;
// load the default values for the user defaults
userDefaultsValuesPath=[[NSBundle mainBundle] pathForResource:@"DefaultPrefs"
ofType:@"plist"];
userDefaultsValuesDict=[NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath];
// set them in the standard user defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];
//
// Value Transformer einrichten
PowerOffTransformer * powerOffTransformer = [[[PowerOffTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer:powerOffTransformer
forName:@"PowerOffDelayTransformer"];
BoolToStringTransformer * bool2string = [[[BoolToStringTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer:bool2string
forName:@"BoolToStringTransformer"];
PathExpander *pathEx = [[[PathExpander alloc] init] autorelease];
[NSValueTransformer setValueTransformer:pathEx
forName:@"PathExpander"];
}
return self;
}
@end
//
// BoolToStringTransformer.h
// TTRCom
//
// Created by Timo Tegtmeier on 27.03.08.
//
// TTRCom MacEdition - A Program To Use The Trabitronic On Macs
// Copyright (C) 2008 Timo Tegtmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#import <Cocoa/Cocoa.h>
@interface BoolToStringTransformer : NSValueTransformer {
}
+(Class) transformedValueClass;
+(bool) allowsReverseTransformation;
-(id) transformedValue: (id) value;
@end
//
// BoolToStringTransformer.m
// TTRCom
//
// Created by Timo Tegtmeier on 27.03.08.
//
// TTRCom MacEdition - A Program To Use The Trabitronic On Macs
// Copyright (C) 2008 Timo Tegtmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#import "BoolToStringTransformer.h"
@implementation BoolToStringTransformer
+(Class) transformedValueClass
{
return [NSString class];
}
+(bool) allowsReverseTransformation
{
return NO;
}
-(id) transformedValue: (id) value
{
if([value boolValue]) {
return NSLocalizedString (@"On", "String representation of boolean YES");
} else {
return NSLocalizedString (@"Off", "String representation of boolean NO");
}
}
@end
<?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>NSNavLastRootDirectory</key>
<string>~/Documents</string>
<key>NSToolbar Configuration ttrmacToolbar</key>
<dict>
<key>TB Display Mode</key>
<integer>1</integer>
<key>TB Icon Size Mode</key>
<integer>1</integer>
<key>TB Is Shown</key>
<integer>1</integer>
<key>TB Item Identifiers</key>
<array>
<string>OpenParameters</string>
<string>OpenErrors</string>
<string>NSToolbarSeparatorItem</string>
<string>OpenMaintenance</string>
<string>NSToolbarFlexibleSpaceItem</string>
<string>Record</string>
<string>NSToolbarSeparatorItem</string>
<string>Connect</string>
</array>
<key>TB Size Mode</key>
<integer>1</integer>
<key>TB Visibility Priority Values</key>
<dict/>
</dict>
<key>readErrorsOnConnect</key>
<true/>
<key>recordingPath</key>
<string>~/Documents/TTRCom Recoding.csv</string>
<key>recIgnAngle</key>
<true/>
<key>recOffset</key>
<false/>
<key>recPowerState</key>
<false/>
<key>recRevTime</key>
<false/>
<key>recRpm</key>
<true/>
<key>recStarter</key>
<false/>
<key>recThrottle</key>
<true/>
<key>resetECUOnConnect</key>
<true/>
<key>showErrorsOnConnect</key>
<true/>
<key>showMaintenanceOnConnect</key>
<true/>
<key>truncateOldRec</key>
<false/>
<key>updateInterval</key>
<string>100</string>
</dict>
</plist>
//
// ECUError.h
// TTRCom
//
// Created by Timo Tegtmeier on 13.03.08.
//
// TTRCom MacEdition - A Program To Use The Trabitronic On Macs
// Copyright (C) 2008 Timo Tegtmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#import <Cocoa/Cocoa.h>
@interface ECUError : NSError {
}
+(ECUError *) errorWithGenericError: (NSString *)op;
+(ECUError *) errorWithQueryError: (NSString *)op;
+(ECUError *) errorWithUnexpectedResults: (NSString *)op;
+(ECUError *) errorWithSerialOpenError: (NSString *)op;
+(ECUError *) errorWithUnsupportedECU: (NSString *)op;
@end
//
// ECUError.m
// TTRCom
//
// Created by Timo Tegtmeier on 13.03.08.
//
// TTRCom MacEdition - A Program To Use The Trabitronic On Macs
// Copyright (C) 2008 Timo Tegtmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#import "ECUError.h"
@implementation ECUError
+(ECUError *) errorWithDesc:(NSString *)desc code:(int)code
isFatal:(bool)fatal proc:(NSString *)op {
return [ECUError errorWithDomain: NSLocalizedString(@"Engine Control Unit",
@"Error domain of ECU") code: code userInfo:
[NSDictionary dictionaryWithObjectsAndKeys:
desc, @"desc",
[NSNumber numberWithBool: fatal], @"fatal",
op, @"procedure",
nil]];
}
+(ECUError *) errorWithGenericError: (NSString *) op {
return [ECUError
errorWithDesc: NSLocalizedString (@"Generic error", @"Description for a generic error")
code:0 isFatal:YES proc:op];
}
+(ECUError *) errorWithQueryError: (NSString *) op {
return [ECUError
errorWithDesc: NSLocalizedString (@"An ECU query failed",
@"Description for ecu query error")
code:1 isFatal:YES proc:op];
}
+(ECUError *) errorWithUnexpectedResults: (NSString *) op {
return [ECUError
errorWithDesc: NSLocalizedString (@"ECU answered with an invalid result",
@"Description for an invalid answer")
code:2 isFatal:YES proc:op];
}
+(ECUError *) errorWithSerialOpenError: (NSString *) op {
return [ECUError
errorWithDesc: NSLocalizedString (@"The serial port could not be opened",
@"Description for open serial error")
code:3 isFatal:YES proc:op];
}
+(ECUError *) errorWithUnsupportedECU: (NSString *) op {
return [ECUError
errorWithDesc: NSLocalizedString (@"The connected ECU is not supported",
@"Description for an unsupported ecu error")
code:3 isFatal:YES proc:op];
}
@end
//
// ECUErrorModel.h
// TTRCom
//
// Created by Timo Tegtmeier on 01.03.08.
//
// TTRCom MacEdition - A Program To Use The Trabitronic On Macs
// Copyright (C) 2008 Timo Tegtmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#import <Cocoa/Cocoa.h>
#define ERROR_IS_STEADY_COUNT 16
@interface ECUErrorModel : NSObject {
@protected
NSMutableArray *store;
NSArray *texts;
}
-(ECUErrorModel *) init;
-(void) clear;
-(void) insertError: (int) code errCount: (int) count;
-(id) tableView: (NSTableView *) view objectValueForTableColumn: (NSTableColumn *) col row: (int) idx;
-(int) numberOfRowsInTableView: (NSTableView *) aTableView;
-(void) completed;
@end
//
// ECUErrorModel.m
// TTRCom
//
// Created by Timo Tegtmeier on 01.03.08.
//
// TTRCom MacEdition - A Program To Use The Trabitronic On Macs
// Copyright (C) 2008 Timo Tegtmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#import "ECUErrorModel.h"
@implementation ECUErrorModel
-(ECUErrorModel *) init {
self = [super init];
if(self) {
store = [[[NSMutableArray alloc] init] retain];
texts = [[NSArray arrayWithObjects:
/* 00 */ NSLocalizedString(@"Crankshaft turning signal cyl 1 not plausible", nil),
/* 01 */ NSLocalizedString(@"Crankshaft turning signal cyl 2 not plausible", nil),
/* 02 */ NSLocalizedString(@"Throttle signal not plausible", nil),
/* 03 */ NSLocalizedString(@"Temperature sensor at cylinder head: short-cut to mass", nil),
/* 04 */ NSLocalizedString(@"Temperature sensor at cylinder head: no signal", nil),
/* 05 */ NSLocalizedString(@"unknown error (05)", nil),
/* 06 */ NSLocalizedString(@"unknown error (06)", nil),
/* 07 */ NSLocalizedString(@"unknown error (07)", nil),
/* 08 */ NSLocalizedString(@"unknown error (08)", nil),
/* 09 */ NSLocalizedString(@"unknown error (09)", nil),
/* 10 */ NSLocalizedString(@"unknown error (10)", nil),
/* 11 */ NSLocalizedString(@"unknown error (11)", nil),
/* 12 */ NSLocalizedString(@"unknown error (12)", nil),
/* 13 */ NSLocalizedString(@"unknown error (13)", nil),
/* 14 */ NSLocalizedString(@"unknown error (14)", nil),
/* 15 */ NSLocalizedString(@"RF problem with high voltage circuit", nil),
/* 16 */ NSLocalizedString(@"unknown error (16)", nil),
nil
] retain];
}
return self;
}
-(void) clear {
[store removeAllObjects];
}
-(void) insertError: (int)code errCount:(int)count {
NSDictionary *error;
id cnt;
if(count >= ERROR_IS_STEADY_COUNT) {
cnt = NSLocalizedString(@"Constantly", nil);
} else {
cnt = [NSNumber numberWithInt: count];
}
error = [NSDictionary dictionaryWithObjectsAndKeys:
cnt, @"errCount",
[texts objectAtIndex: code], @"errText",
nil];
[store addObject: error];
}
-(void) completed {
NSDictionary *error;
if([store count] == 0) {
error = [NSDictionary dictionaryWithObjectsAndKeys:
@"-", @"errCount",
NSLocalizedString (@"No errors detected!", @"error store is empty"), @"errText",
nil];
[store addObject: error];
}
}
-(id) tableView: (NSTableView *) view objectValueForTableColumn: (NSTableColumn *) col row: (int) idx {
NSDictionary *error;
NSParameterAssert(idx >= 0 && idx < [store count]);
error = [store objectAtIndex:idx];
return [error objectForKey:[col identifier]];
}
-(int) numberOfRowsInTableView: (NSTableView *) aTableView
{
return [store count];
}
@end
//
// EngineControlUnit.h
// TTRCom
//
// Created by Timo Tegtmeier on 27.02.08.
//
// TTRCom MacEdition - A Program To Use The Trabitronic On Macs
// Copyright (C) 2008 Timo Tegtmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
#import <Cocoa/Cocoa.h>
#import <assert.h>
#import "ECUErrorModel.h"
#import "ECUError.h"
#import "cmds.h"
@interface EngineControlUnit : NSObject {
//
// Infos zum Steuergerät, sowie interne Stati
NSString *_type;
NSString *_subtype;
NSString *_generation;
NSString *_version;
NSString *_serial;
int _intVer;
bool _connected;
//
// Variablen für den Statusmonitor
NSTimer *timer;
bool _monitorRunning;
double _monitorInterval;
//
// Vornehmbare Einstellungen am Motorsteuergerät
// Achtung! Teilweise existieren namentlich fast gleiche Variablen,
// allerdings mit dem Vorsatz cur für current! Nicht verwechseln!
int _customPowerOffDelay;
bool _useCustomPowerOffDelay;
bool _autoPowerOffEnabled;
double _ignOffset;
bool _useIgnOffset;
//
// Aufzeichnungsdaten
// Alle aufzuzeichnenden Daten werden in Form eines Selektorstrings
// im Array gespeichert und dann bei der Aufzeichnung der Reihe nach
// iteriert; die Daten werden via [self performSelector: ... ] abgerufen.
int _fdRecord;
bool _recording;
double _recordStartTime;
NSMutableArray *_arrayRecItems;
//
// Aktuelle Betriebsdaten,
// alle Daten, die aufgezeichnet werden können, müssen
// als String vorliegen!
int _rpm;
int _revTime;
bool _powerOffState;
double _curIgnOffset;
double _curIgnAngle;
double _curIgnAngleCyl2;
NSString *_throttleString;
NSString *_starterString;
NSString *_powerStateString;
NSMutableString *_rpmString;
NSMutableString *_revTimeString;
NSMutableString *_curIgnOffsetString;
NSMutableString *_curIgnAngleString;
NSMutableString *_curIgnAngleStringCyl2;
//
// Fähigkeiten der ECU
// Auch diese hier werden seit 0602 mittels Getter/Setter
// angesprochen und nicht mehr direkt. Dies spart Code im
// Controller und macht statt dessen den Einsatz von Cocoa Bindings
// in der UI möglich.
bool _canSetAutoPowerOff;
bool _canSetCustomPowerOffDelay;
bool _canSetOffset;
bool _canQueryErrors;
bool _canQuerySensor;
bool _canQueryIgnAngleCyl2;
bool _isRacing;
//
// Fehlerbehandlung
// Gefällt mir nicht. Muss ich noch einmal überdenken.
ECUError *_lastError;
bool _supressNextError;
bool _comError;
}
//
// Methoden zum Verbinden/Trennen der Verbindung
// Diese sind so gestaltet, dass nur eine Verbindung möglich ist.
//
-(ECUError *) connect: (NSString *) iface;
-(ECUError *) disconnect;
-(bool) thisIsAnECU:(NSString *)path;
-(int) rpm;
-(NSMutableString *) rpmString;
-(void) setRpm: (int) rpm;