Skip to content

Commit

Permalink
Improve curve parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
karniv00l committed Feb 20, 2024
1 parent 373a0ef commit 0296e88
Show file tree
Hide file tree
Showing 7 changed files with 1,743 additions and 1,579 deletions.
45 changes: 41 additions & 4 deletions lib/models/ini_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,43 @@ class GaugeConfig {
}
}

class TableBins {
TableBins({
required this.constant,
this.channel,
});

final String constant;
final String? channel;

Map<String, dynamic> toJson() {
return {
'constant': constant,
'channel': channel,
};
}
}

class CurveAxis {
CurveAxis({
required this.min,
required this.max,
this.numDivisions,
});

final String min;
final String max;
final int? numDivisions;

Map<String, dynamic> toJson() {
return {
'min': min,
'max': max,
'numDivisions': numDivisions,
};
}
}

class Curve {
Curve({
required this.name,
Expand All @@ -784,10 +821,10 @@ class Curve {
final String name;
final String label;
List<String> columnLabels = [];
List<String> xAxis = [];
List<String> yAxis = [];
List<String> xBins = [];
List<String> yBins = [];
CurveAxis xAxis = CurveAxis(min: '0', max: '0');
CurveAxis yAxis = CurveAxis(min: '0', max: '0');
TableBins xBins = TableBins(constant: '');
TableBins yBins = TableBins(constant: '');
String? topicHelp;
bool showTextValues = false;
String? lineLabel;
Expand Down
30 changes: 24 additions & 6 deletions lib/sections/curve_editor_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ class CurveEditorParser {

Future<void> _parseLine(String line) async {
if (line.startsWith(RegExp(r'^curve\s*='))) {
await _parseTable(line);
await _parseCurve(line);
} else {
await _parseAttributes(line);
}
}

Future<void> _parseTable(String line) async {
Future<void> _parseCurve(String line) async {
final result = (await _parser.parse(line, onlyMatches: true))
.map((e) => e.text.clearString())
.toList();
Expand All @@ -63,13 +63,31 @@ class CurveEditorParser {
case 'columnLabel':
_currentCurve!.columnLabels = result.sublist(1);
case 'xAxis':
_currentCurve!.xAxis = result.sublist(1);
final parts = result.sublist(1);
_currentCurve!.xAxis = CurveAxis(
min: parts[0],
max: parts[1],
numDivisions: parts.length > 2 ? int.parse(parts[2]) : null,
);
case 'yAxis':
_currentCurve!.yAxis = result.sublist(1);
final parts = result.sublist(1);
_currentCurve!.yAxis = CurveAxis(
min: parts[0],
max: parts[1],
numDivisions: parts.length > 2 ? int.parse(parts[2]) : null,
);
case 'xBins':
_currentCurve!.xBins = result.sublist(1);
final parts = result.sublist(1);
_currentCurve!.xBins = TableBins(
constant: parts[0],
channel: parts.length > 1 ? parts[1] : null,
);
case 'yBins':
_currentCurve!.yBins = result.sublist(1);
final parts = result.sublist(1);
_currentCurve!.yBins = TableBins(
constant: parts[0],
channel: parts.length > 1 ? parts[1] : null,
);
case 'topicHelp':
_currentCurve!.topicHelp = result[1];
case 'showTextValues':
Expand Down
4 changes: 0 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ dev_dependencies:
spec: ^0.2.2
very_good_analysis: ^5.0.0+1

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:
4 changes: 2 additions & 2 deletions scripts/coverage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import 'dart:io';

void main() {
const threshold = 100.0;
const threshold = 99.0;
final file = File('coverage/summary.txt');
final lines = file.readAsStringSync();
final match = RegExp(r'([\d.]+)%').firstMatch(lines);
Expand All @@ -14,7 +14,7 @@ void main() {

final percentage = double.parse(match.group(1)!);

if (percentage < 99.4) {
if (percentage < threshold) {
print('❌ Current coverage $percentage% is below threshold of $threshold%');
exit(1);
}
Expand Down
Loading

0 comments on commit 0296e88

Please sign in to comment.