Skip to content

Commit

Permalink
Updates logic with descriptions and ph map.
Browse files Browse the repository at this point in the history
  • Loading branch information
terracoda committed Sep 17, 2024
1 parent 3734aef commit 3f8cf42
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
37 changes: 37 additions & 0 deletions js/description/ph-scale-basics-description-logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default () => {
* Enumeration Mappings (value => enumeration value)
*********************************************/

// Qualitative Volume Ranges
const totalVolumeToEnum = totalVolume => {
if ( totalVolume === 0 ) {
return 'empty';
Expand All @@ -43,6 +44,39 @@ export default () => {
return 'full';
}
};
// pH Qualitative Ranges
const phValueToEnum = phValue => {
if(phValue === null) {
return 'none';
}
else if ( phValue <= 1 ) {
return 'extremelyAcidic';
}
else if ( phValue <= 3 ) {
return 'highlyAcidic';
}
else if ( phValue <= 5 ) {
return 'moderatelyAcidic';
}
else if ( phValue < 7 ) {
return 'slightlyAcidic';
}
else if ( phValue === 7 ) {
return 'neutral';
}
else if ( phValue < 9 ) {
return 'slightlyBasic';
}
else if ( phValue < 11 ) {
return 'moderatelyBasic';
}
else if ( phValue < 13 ) {
return 'highlyBasic';
}
else {
return 'extremelyBasic';
}
};

const flowRateToEnum = flowRate => {
if ( flowRate === 0 ) {
Expand Down Expand Up @@ -109,6 +143,7 @@ export default () => {
solute.tandemName,
totalVolumeToEnum( solutionTotalVolume ),
solutionPHProperty.value,
phValueToEnum( solutionPHProperty.value ),
solutionTotalVolumeProperty.value //needs rounding
);
} );
Expand All @@ -134,6 +169,7 @@ export default () => {

// pH Meter Probe
const phMeterProbeNode = context.get( 'phScaleBasics.macroScreen.view.pHMeterNode.probeNode' );
context.nodeSet( phMeterProbeNode, 'helpText', strings.phMeterProbeHelpText() );
{
context.nodeSet( phMeterProbeNode, 'accessibleName', strings.phMeterProbeAccessibleName() );
}
Expand All @@ -147,6 +183,7 @@ export default () => {

// Solute ComboBox
const soluteComboBox = context.get( 'phScaleBasics.macroScreen.view.soluteComboBox' );
context.nodeSet( soluteComboBox, 'helpText', strings.soluteComboBoxHelpText() );
context.nodeSet( soluteComboBox, 'accessibleName', strings.soluteComboBoxAccessibleName() );
for ( const solute of solutes ) {
context.propertySet( soluteComboBox.a11yNamePropertyMap.get( solute ), strings.soluteName( solute.tandemName ) );
Expand Down
20 changes: 18 additions & 2 deletions js/description/ph-scale-basics-description-strings_en.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ export default () => {
partiallyFilled: 'partially filled',
full: 'full'
};

const phValueMap = {
none: 'probe is not in beaker',
extremelyAcidic: 'extremely acidic',
highlyAcidic: 'highly acidic',
moderatelyAcidic: 'moderately acidic',
slightlyAcidic: 'slightly acidic',
neutral: 'neutral',
slightlyBasic: 'slightly basic',
moderatelyBasic: 'moderately basic',
highlyBasic: 'highly basic',
extremelyBasic: 'extremely basic'
};

const flowRateMap = {
off: 'off',
Expand Down Expand Up @@ -58,10 +71,11 @@ export default () => {
solute,
totalVolumeEnum,
solutionPH,
solutionPHEnum,
totalVolume
) {
//Currently, {{spit}} solution has a pH of {{7.02}} and is {{almost neutral}}. Solution is {{clear}} with {{lots of}} added water. Beaker is {{close to full}} at {{1.00}} liters.
return `Currently, ${soluteMap[ solute ]} solution has a pH of ${solutionPH}. Beaker is ${totalVolumeMap[ totalVolumeEnum ]} at ${totalVolume} liters.`;
return `Currently, ${soluteMap[ solute ]} solution has a pH of ${solutionPH} and is ${phValueMap[ solutionPHEnum ]}. Beaker is ${totalVolumeMap[ totalVolumeEnum ]} at ${totalVolume} liters.`;
},

/*********************************************
Expand All @@ -75,6 +89,7 @@ export default () => {
return 'pH Meter and Read Out';
},
phMeterProbeAccessibleName() { return 'pH Probe'; },
phMeterProbeHelpText() { return 'Look for pH probe to play. Once grabbed, use keyboard shortcuts to move probe. Space to release.'; },
controlsHeading() {
return 'Beaker and pH Meter Controls';
},
Expand All @@ -84,6 +99,7 @@ export default () => {
soluteName( solute ) {
return soluteMap[ solute ];
},
soluteComboBoxHelpText() { return 'Choose an everyday liquid for the dropper.'; },
dropperAccessibleName() { return 'Dropper'; },
waterFaucetAccessibleName() { return 'Water Faucet'; },
waterFaucetHelpText() { return 'Add water to solution in beaker.'; },
Expand Down Expand Up @@ -131,4 +147,4 @@ export default () => {
return `Level stable, now at ${totalVolumeMap[ totalVolumeEnum ]}.`;
}
} );
};
};

0 comments on commit 3f8cf42

Please sign in to comment.