Skip to content

Commit

Permalink
Improved the reset graph code to happen at the XRGDataSet level.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepj committed Feb 7, 2020
1 parent f3f41f5 commit b4aaa76
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 27 deletions.
6 changes: 3 additions & 3 deletions Data Miners/XRGCPUMiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
@property CGFloat currentLoadAverage;

@property NSInteger *fastValues;
@property NSMutableArray *userValues;
@property NSMutableArray *systemValues;
@property NSMutableArray *niceValues;
@property NSMutableArray<XRGDataSet *> *userValues;
@property NSMutableArray<XRGDataSet *> *systemValues;
@property NSMutableArray<XRGDataSet *> *niceValues;

- (void)graphUpdate:(NSTimer *)aTimer;
- (void)fastUpdate:(NSTimer *)aTimer;
Expand Down
16 changes: 11 additions & 5 deletions Data Miners/XRGCPUMiner.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,17 @@ - (CGFloat)getLoadAverage {
}

- (void)reset {
self.userValues = nil;
self.systemValues = nil;
self.niceValues = nil;

[self setDataSize:numSamples];
for (XRGDataSet *set in self.userValues) {
[set reset];
}

for (XRGDataSet *set in self.systemValues) {
[set reset];
}

for (XRGDataSet *set in self.niceValues) {
[set reset];
}
}

- (void)setCurrentUptime {
Expand Down
8 changes: 3 additions & 5 deletions Data Miners/XRGMemoryMiner.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ - (void)setDataSize:(int)newNumSamples {
}

- (void)reset {
values1 = nil;
values2 = nil;
values3 = nil;

[self setDataSize:numSamples];
[values1 reset];
[values2 reset];
[values3 reset];
}

- (void)getLatestMemoryInfo {
Expand Down
8 changes: 3 additions & 5 deletions Data Miners/XRGNetMiner.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,9 @@ - (CGFloat)currentRX {
}

- (void)reset {
_rxValues = nil;
_txValues = nil;
_totalValues = nil;

[self setDataSize:self.numSamples];
[self.rxValues reset];
[self.txValues reset];
[self.totalValues reset];
}

- (void)setCurrentBandwidth {
Expand Down
4 changes: 2 additions & 2 deletions Data Miners/XRGTemperatureMiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
@private

int numSamples; // for the XRGDataSets, number of samples to record.
NSMutableArray *locationKeysInOrder; // locations in certain order, returned by locationKeysInOrder, generated by regenerateLocationKeyOrder.
NSMutableArray<NSString *> *locationKeysInOrder; // locations in certain order, returned by locationKeysInOrder, generated by regenerateLocationKeyOrder.

NSMutableDictionary *sensorData;
NSMutableDictionary<NSString *,NSDictionary *> *sensorData;
SMCSensors *smcSensors;
}

Expand Down
7 changes: 3 additions & 4 deletions Data Miners/XRGTemperatureMiner.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ - (instancetype)init {
}

- (void)reset {
int width = numSamples;

[self setDataSize:0];
[self setDataSize:width];
for (NSDictionary *sensorValue in [sensorData allValues]) {
[sensorValue[GSDataSetKey] reset];
}
}

- (int)numberOfCPUs {
Expand Down
8 changes: 5 additions & 3 deletions Graph Views/XRGDiskView.m
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,11 @@ - (void)openDiskPreferences:(NSEvent *)theEvent {
}

- (void)clearData:(NSEvent *)theEvent {
int width = numSamples;
[self setWidth:1];
[self setWidth:width];
for (NSInteger i = 0; i < numSamples; i++) {
values[i] = 0;
readValues[i] = 0;
writeValues[i] = 0;
}
}

- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent {
Expand Down
1 change: 1 addition & 0 deletions Utility/XRGDataSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- (CGFloat) currentValue;
- (void) valuesInOrder:(CGFloat *)destinationArray;

- (void) reset;
- (void) resize:(size_t)newNumValues;
- (void) setNextValue:(CGFloat)nextVal;
- (void) setAllValues:(CGFloat)value;
Expand Down
6 changes: 6 additions & 0 deletions Utility/XRGDataSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ - (void) valuesInOrder:(CGFloat *)destinationArray {
}
}

- (void) reset {
for (NSInteger i = 0; i < self.numValues; i++) {
_values[i] = 0;
}
}

- (void) resize:(size_t)newNumValues {
if (newNumValues == 0) {
self.min = 0;
Expand Down

0 comments on commit b4aaa76

Please sign in to comment.