Skip to content

Commit 8f7e98f

Browse files
committed
prototype
1 parent 761c31d commit 8f7e98f

File tree

22 files changed

+35300
-17
lines changed

22 files changed

+35300
-17
lines changed

CONTRIBUTING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Contribution Guidelines
2+
3+
## Development Setup
4+
5+
### Prerequisites
6+
- Xcode 15+ with command line tools
7+
- Homebrew (for dependency management)
8+
- Swift 5.9+
9+
10+
### Environment Configuration
11+
```bash
12+
# Install build dependencies
13+
brew install swiftlint sourcery
14+
15+
# Clone repository
16+
git clone https://github.com/yourusername/power-suite.git
17+
cd power-suite
18+
19+
# Install pre-commit hooks
20+
swiftlint install-hook
21+
```
22+
23+
## Workflow
24+
25+
1. Create feature branch from `main`
26+
```bash
27+
git checkout -b feat/new-power-metric
28+
```
29+
30+
2. Implement changes following Swift style guide
31+
```bash
32+
swiftlint autocorrect # Before committing
33+
```
34+
35+
3. Update documentation when adding new features
36+
37+
4. Create pull request with:
38+
- Description of changes
39+
- Screenshots for UI changes
40+
- Updated unit tests
41+
42+
## Code Standards
43+
44+
### Swift
45+
- Follow Apple's Swift API Design Guidelines
46+
- Use SwiftLint with included .swiftlint.yml
47+
- Document public APIs using DocC format
48+
49+
### C Code
50+
- Follow Linux kernel coding style for CLI tools
51+
- Include Doxygen comments for complex functions
52+
53+
## Testing Requirements
54+
- 80%+ test coverage for core modules
55+
- Performance tests for battery monitoring
56+
- UI tests for power flow visualization
57+
58+
## Review Process
59+
- All PRs require 2 maintainer approvals
60+
- CI must pass SwiftPM tests and lint checks
61+
- Security-sensitive code requires audit

LICENSE

Lines changed: 671 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Power Management Suite
2+
3+
[![Swift](https://img.shields.io/badge/Swift-5.9-orange.svg)]()
4+
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
5+
6+
A comprehensive power monitoring solution for macOS featuring:
7+
8+
- 🖥 GUI application with real-time power flow visualization
9+
- 🔋 Detailed battery health analytics
10+
- ⚡️ CLI tools for low-level power monitoring
11+
- 📊 System load statistics collection
12+
13+
![](image/capture0.png)
14+
![](image/capture1.png)
15+
16+
## Architecture Overview
17+
18+
```mermaid
19+
graph TD
20+
A[Power Management Suite] --> B{GUI Application}
21+
A --> C{CLI Tools}
22+
23+
B --> D[PowerFlowView]
24+
B --> E[BatteryMonitor]
25+
B --> F[SystemStats]
26+
27+
C --> G[power_info]
28+
C --> H[batt]
29+
30+
D --> I[SwiftUI Views]
31+
E --> J[IOKit Integration]
32+
F --> K[System Load Metrics]
33+
G --> L[SMC Access]
34+
H --> M[Battery Diagnostics]
35+
```
36+
37+
## Features
38+
39+
### GUI Application
40+
- Real-time power flow visualization
41+
- Battery health monitoring (cycles, capacity, temperature)
42+
- Adapter power input tracking
43+
- System load/power consumption correlation
44+
45+
### CLI Tools
46+
- `power_info`: Low-level SMC access for power metrics
47+
- `batt`: Advanced battery diagnostics (from [charlie0129/batt](https://github.com/charlie0129/batt))
48+
49+
## Requirements
50+
51+
- macOS 13 Ventura or newer
52+
- Xcode 15+
53+
- Administrative privileges for SMC access
54+
55+
## Installation
56+
57+
```bash
58+
# Clone repository
59+
git clone https://github.com/yourusername/power-suite.git
60+
cd power-suite
61+
62+
# Build GUI application
63+
xcodebuild -workspace app.xcodeproj/project.xcworkspace -scheme app
64+
65+
# Build CLI tools
66+
cd systemLoad_Claude
67+
make
68+
```
69+
70+
## Usage
71+
72+
GUI Application:
73+
```bash
74+
open app/build/Release/app.app
75+
```
76+
77+
CLI Monitoring:
78+
```bash
79+
# System power stats
80+
./systemLoad_Claude/power_info -c
81+
82+
# Battery health check
83+
./utility/batt health
84+
```
85+
86+
## Contributing
87+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
88+
89+
## License
90+
GPLv3 (see [LICENSE](LICENSE))

app.xcodeproj/project.pbxproj

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
attributes = {
172172
BuildIndependentTargetsInParallel = 1;
173173
LastSwiftUpdateCheck = 1620;
174-
LastUpgradeCheck = 1620;
174+
LastUpgradeCheck = 1630;
175175
TargetAttributes = {
176176
9DB688032D8E7A53007083F0 = {
177177
CreatedOnToolsVersion = 16.2;
@@ -192,6 +192,7 @@
192192
knownRegions = (
193193
en,
194194
Base,
195+
"zh-Hans",
195196
);
196197
mainGroup = 9DB687FB2D8E7A53007083F0;
197198
minimizedProjectReferenceProxies = 1;
@@ -303,6 +304,7 @@
303304
CLANG_WARN_UNREACHABLE_CODE = YES;
304305
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
305306
COPY_PHASE_STRIP = NO;
307+
DEAD_CODE_STRIPPING = YES;
306308
DEBUG_INFORMATION_FORMAT = dwarf;
307309
ENABLE_STRICT_OBJC_MSGSEND = YES;
308310
ENABLE_TESTABILITY = YES;
@@ -366,6 +368,7 @@
366368
CLANG_WARN_UNREACHABLE_CODE = YES;
367369
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
368370
COPY_PHASE_STRIP = NO;
371+
DEAD_CODE_STRIPPING = YES;
369372
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
370373
ENABLE_NS_ASSERTIONS = NO;
371374
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -396,9 +399,11 @@
396399
CODE_SIGN_STYLE = Automatic;
397400
COMBINE_HIDPI_IMAGES = YES;
398401
CURRENT_PROJECT_VERSION = 1;
402+
DEAD_CODE_STRIPPING = YES;
399403
DEVELOPMENT_ASSET_PATHS = "\"app/Preview Content\"";
400404
ENABLE_PREVIEWS = YES;
401405
GENERATE_INFOPLIST_FILE = YES;
406+
INFOPLIST_KEY_LSUIElement = YES;
402407
INFOPLIST_KEY_NSHumanReadableCopyright = "";
403408
LD_RUNPATH_SEARCH_PATHS = (
404409
"$(inherited)",
@@ -421,9 +426,11 @@
421426
CODE_SIGN_STYLE = Automatic;
422427
COMBINE_HIDPI_IMAGES = YES;
423428
CURRENT_PROJECT_VERSION = 1;
429+
DEAD_CODE_STRIPPING = YES;
424430
DEVELOPMENT_ASSET_PATHS = "\"app/Preview Content\"";
425431
ENABLE_PREVIEWS = YES;
426432
GENERATE_INFOPLIST_FILE = YES;
433+
INFOPLIST_KEY_LSUIElement = YES;
427434
INFOPLIST_KEY_NSHumanReadableCopyright = "";
428435
LD_RUNPATH_SEARCH_PATHS = (
429436
"$(inherited)",
@@ -443,6 +450,7 @@
443450
BUNDLE_LOADER = "$(TEST_HOST)";
444451
CODE_SIGN_STYLE = Automatic;
445452
CURRENT_PROJECT_VERSION = 1;
453+
DEAD_CODE_STRIPPING = YES;
446454
GENERATE_INFOPLIST_FILE = YES;
447455
MACOSX_DEPLOYMENT_TARGET = 15.2;
448456
MARKETING_VERSION = 1.0;
@@ -460,6 +468,7 @@
460468
BUNDLE_LOADER = "$(TEST_HOST)";
461469
CODE_SIGN_STYLE = Automatic;
462470
CURRENT_PROJECT_VERSION = 1;
471+
DEAD_CODE_STRIPPING = YES;
463472
GENERATE_INFOPLIST_FILE = YES;
464473
MACOSX_DEPLOYMENT_TARGET = 15.2;
465474
MARKETING_VERSION = 1.0;
@@ -476,6 +485,7 @@
476485
buildSettings = {
477486
CODE_SIGN_STYLE = Automatic;
478487
CURRENT_PROJECT_VERSION = 1;
488+
DEAD_CODE_STRIPPING = YES;
479489
GENERATE_INFOPLIST_FILE = YES;
480490
MARKETING_VERSION = 1.0;
481491
PRODUCT_BUNDLE_IDENTIFIER = clzoc.appUITests;
@@ -491,6 +501,7 @@
491501
buildSettings = {
492502
CODE_SIGN_STYLE = Automatic;
493503
CURRENT_PROJECT_VERSION = 1;
504+
DEAD_CODE_STRIPPING = YES;
494505
GENERATE_INFOPLIST_FILE = YES;
495506
MARKETING_VERSION = 1.0;
496507
PRODUCT_BUNDLE_IDENTIFIER = clzoc.appUITests;
@@ -511,7 +522,7 @@
511522
9DB688282D8E7A54007083F0 /* Release */,
512523
);
513524
defaultConfigurationIsVisible = 0;
514-
defaultConfigurationName = Release;
525+
defaultConfigurationName = Debug;
515526
};
516527
9DB688292D8E7A54007083F0 /* Build configuration list for PBXNativeTarget "app" */ = {
517528
isa = XCConfigurationList;
@@ -520,7 +531,7 @@
520531
9DB6882B2D8E7A54007083F0 /* Release */,
521532
);
522533
defaultConfigurationIsVisible = 0;
523-
defaultConfigurationName = Release;
534+
defaultConfigurationName = Debug;
524535
};
525536
9DB6882C2D8E7A54007083F0 /* Build configuration list for PBXNativeTarget "appTests" */ = {
526537
isa = XCConfigurationList;
@@ -529,7 +540,7 @@
529540
9DB6882E2D8E7A54007083F0 /* Release */,
530541
);
531542
defaultConfigurationIsVisible = 0;
532-
defaultConfigurationName = Release;
543+
defaultConfigurationName = Debug;
533544
};
534545
9DB6882F2D8E7A54007083F0 /* Build configuration list for PBXNativeTarget "appUITests" */ = {
535546
isa = XCConfigurationList;
@@ -538,7 +549,7 @@
538549
9DB688312D8E7A54007083F0 /* Release */,
539550
);
540551
defaultConfigurationIsVisible = 0;
541-
defaultConfigurationName = Release;
552+
defaultConfigurationName = Debug;
542553
};
543554
/* End XCConfigurationList section */
544555
};

0 commit comments

Comments
 (0)