Skip to content

Commit

Permalink
Implemented stressRmv serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Aug 8, 2024
1 parent dd440ef commit 12c6493
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
1 change: 0 additions & 1 deletion doc/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Following list of features and improvements ordered by priority is under develop
* Custom diver stress sac rate ratio
* Add to general settings
* Add to dive settings
* Apply to gas algorithm
* Visualize on consumption chart
* Add minimum gas reserve for first tank and for stage
* Add option to ignore some warnings (ICD, density)
Expand Down
17 changes: 17 additions & 0 deletions projects/planner/src/app/shared/PlanUrlSerialization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DepthsService } from './depths.service';
import { ReloadDispatcher } from './reloadDispatcher';
import { DiveSchedules } from './dive.schedules';
import { SettingsNormalizationService } from './settings-normalization.service';
import { Diver } from 'scuba-physics';

class TestSut {
constructor(
Expand Down Expand Up @@ -144,6 +145,22 @@ describe('Url Serialization', () => {
expect(result.length).toBeLessThan(2048);
});

describe('Diver options', () => {
it('Serialize both Rmv and stressRmv', () => {
expect(simpleViewUrl).toContain('di=20,30');
});

it('Deserialize both Rmv and stressRmv', () => {
const missingStressUrl = 't=1-18-0-200-0.209-0&' +
'de=0-30-102-1,30-30-618-1&' +
'di=24&' +
'o=0,9,6,3,3,18,2,0.85,0.4,3,1.6,30,1.4,10,1,1,0,2,1&' +
'ao=0,0';
complexSut.urlSerialization.fromUrl(missingStressUrl);
expect(complexSut.schedules.selected.optionsService.getDiver()).toEqual(new Diver(24, 36));
});
});

describe('Complex vs. Simple view', () => {
it('Load complex plan to simple view',() => {
const current = createSimpleSut();
Expand Down
7 changes: 5 additions & 2 deletions projects/planner/src/app/shared/PlanUrlSerialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,18 @@ export class PlanUrlSerialization {
const context = new ParseContext(parseParam, ',');
const result: DiverDto = {
rmv: context.parseNumber(0),
// TODO add test to verify default value is loaded if not present
stressRmv: context.parseNumber(1)
};

if(!result.stressRmv) {
result.stressRmv = new Diver(result.rmv).stressRmv;
}

return result;
}

private static toDiverParam(di: Diver): string {
const result = `${di.rmv}`;
const result = `${di.rmv},${di.stressRmv}`;
return result;
}

Expand Down
2 changes: 1 addition & 1 deletion projects/planner/src/app/shared/PlanValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class PlanValidation {
}

private diverValid(diver: DiverDto): boolean {
return this.isRmvValid(diver.rmv);
return this.isRmvValid(diver.rmv) && this.isRmvValid(diver.stressRmv);
}

private complexModeValid(app: AppPreferencesDto): boolean {
Expand Down

0 comments on commit 12c6493

Please sign in to comment.