Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle triple condition in dialog field #150

Merged
merged 1 commit into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Handle tripple condition in dialog field
  • Loading branch information
karniv00l committed Dec 11, 2022
commit 32e947ef89a06f202599b9541c67c47c7e349bde
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"devDependencies": {
"@types/js-yaml": "^4.0.5",
"@types/node": "^18.11.12",
"@types/node": "^18.11.13",
"@types/parsimmon": "^1.10.6",
"rome": "^11.0.0",
"typescript": "^4.9.4"
Expand Down
14 changes: 13 additions & 1 deletion src/ini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,19 @@ export class INI implements ParserInterface {
['condition', this.expression],
];

const fieldResult = P.seqObj<any>(...fieldWithDoubleCondition, P.all)
// field = "!Warning: The board you have selected may not have enough channels for sequential fuel!", {}, {}, { injLayout == 3 && !sequentialFuelAvailable }
const fieldWithTripleCondition = [
...fieldBase,
...this.delimiter,
P.regexp(/{.*?}/),
...this.delimiter,
P.regexp(/{.*?}/),
...this.delimiter,
['condition', this.expression],
];

const fieldResult = P.seqObj<any>(...fieldWithTripleCondition, P.all)
.or(P.seqObj<any>(...fieldWithDoubleCondition, P.all))
.or(P.seqObj<any>(...fieldWithCondition, P.all))
.or(P.seqObj<any>(...fieldWithName, P.all))
.or(P.seqObj<any>(...fieldBase, P.all))
Expand Down
2 changes: 1 addition & 1 deletion test/data/speeduino/json/202012.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/data/speeduino/json/202103.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/data/speeduino/json/202108.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/data/speeduino/json/202201.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/data/speeduino/json/202202.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/data/speeduino/json/202207.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/data/speeduino/tmp/202012.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/data/speeduino/tmp/202012.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58746,6 +58746,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -59728,6 +59729,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -59854,6 +59856,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
2 changes: 1 addition & 1 deletion test/data/speeduino/tmp/202103.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/data/speeduino/tmp/202103.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58920,6 +58920,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -59907,6 +59908,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -60039,6 +60041,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
2 changes: 1 addition & 1 deletion test/data/speeduino/tmp/202108.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/data/speeduino/tmp/202108.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61906,6 +61906,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -62893,6 +62894,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -63052,6 +63054,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
2 changes: 1 addition & 1 deletion test/data/speeduino/tmp/202201.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/data/speeduino/tmp/202201.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62754,6 +62754,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -63761,6 +63762,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -63920,6 +63922,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
2 changes: 1 addition & 1 deletion test/data/speeduino/tmp/202202.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/data/speeduino/tmp/202202.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62754,6 +62754,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -63761,6 +63762,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -63920,6 +63922,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
2 changes: 1 addition & 1 deletion test/data/speeduino/tmp/202207.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test/data/speeduino/tmp/202207.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65109,6 +65109,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -66120,6 +66121,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -66278,8 +66280,10 @@ dialogs:
fields:
- name: _fieldText_
title: In open loop mode, the values in this table are duty cycle %
condition: '{ boostType == 0 }'
- name: _fieldText_
title: In closed loop mode, the values in this table are boost targets in kPa
condition: '{ boostType == 1 }'
boostLoad:
title: ''
panels:
Expand Down Expand Up @@ -66313,6 +66317,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
3 changes: 3 additions & 0 deletions test/data/speeduino/yaml/202012.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58746,6 +58746,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -59728,6 +59729,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -59854,6 +59856,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
3 changes: 3 additions & 0 deletions test/data/speeduino/yaml/202103.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58920,6 +58920,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -59907,6 +59908,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -60039,6 +60041,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
3 changes: 3 additions & 0 deletions test/data/speeduino/yaml/202108.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61906,6 +61906,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -62893,6 +62894,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -63052,6 +63054,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
3 changes: 3 additions & 0 deletions test/data/speeduino/yaml/202201.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62754,6 +62754,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -63761,6 +63762,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -63920,6 +63922,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
3 changes: 3 additions & 0 deletions test/data/speeduino/yaml/202202.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62754,6 +62754,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -63761,6 +63762,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -63920,6 +63922,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down
5 changes: 5 additions & 0 deletions test/data/speeduino/yaml/202207.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65109,6 +65109,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential fuel!
condition: '{ injLayout == 3 && !sequentialFuelAvailable }'
engine_constants:
title: ''
layout: border
Expand Down Expand Up @@ -66120,6 +66121,7 @@ dialogs:
title: >-
!Warning: The board you have selected may not have enough channels for
sequential ignition!
condition: '{ sparkMode == 3 && !sequentialIgnitionAvailable }'
- name: ignAlgorithm
title: Ignition load source
- name: sparkMode
Expand Down Expand Up @@ -66278,8 +66280,10 @@ dialogs:
fields:
- name: _fieldText_
title: In open loop mode, the values in this table are duty cycle %
condition: '{ boostType == 0 }'
- name: _fieldText_
title: In closed loop mode, the values in this table are boost targets in kPa
condition: '{ boostType == 1 }'
boostLoad:
title: ''
panels:
Expand Down Expand Up @@ -66313,6 +66317,7 @@ dialogs:
title: Rev Limiter
- name: _fieldText_
title: '!Soft limiter only available with ignition cut'
condition: '{ engineProtectType == 2 }'
- name: SoftRevLim
title: Soft rev limit
condition: '{ engineProtectType == 1 || engineProtectType == 3 }'
Expand Down