Conversation
✅ Deploy Preview for pmksprod ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
… for input speed.
KohmeiK
left a comment
There was a problem hiding this comment.
Reviewing: https://deploy-preview-212--pmksprod.netlify.app
Great work on creating the new rotational unit, that all looks good! You're missing a couple parts to make this fully work though. If you look a the other input fields, when you type in just a number, the unit autofills. (So entering 20 would give 20 rpm). Also, typing in 20 rpm now makes the analysis label got to NaN.
A couple things to look at on how to fix this.
- Take a look at
parseLengthStringinnumber-unit-parser.service.tsto see how to handle text inputs to find the right units. You need something similar for the rotational units. - Take a look at
this.jointForm.controls['yPos'].valueChanges.subscribe(Edit panel line 216) for how to handle a input field, it should be very similar
Also the graph should update when you change the input speed right? Right now, even though it shows RPM I think it's still using some other unit in the simulator.
- Take a look at Line 163 in the setting panel for how to do this.
this.mechanismSrv.onMechUpdateState.next(2);
| this.settingsForm.patchValue( | ||
| { objectScale: this.currentObjectScaleSetting.toString() }, | ||
| { emitEvent: false } | ||
| { emitEvent: false }, |
There was a problem hiding this comment.
This looks like we are resetting the input speed when the object scale is changed? Do we want to reset the input speed back to 20?
There was a problem hiding this comment.
We do not need to reset the input speed back to 20. I can make sure that when we change the grid, the inputVal stays the same value as assigned.
@KohmeiK I have a question on this part. For this objectScale, shouldn't we get rid of this emitEvent? I imagine we want to update the graph, right?
There was a problem hiding this comment.
A bunch of these emitEvent: false is true so that we don't cause a circular loop and therefore a stack overflow. Updating the value will cause the onChange to emit, which will cause the value to change and the onChange to emit and so on.
| this.settingsForm.controls['speed'].valueChanges.subscribe((val) => { | ||
| if (this.settingsForm.controls['speed'].invalid) { | ||
| this.settingsForm.patchValue({ speed: this.currentSpeedSetting.toString() }); | ||
| this.settingsForm.patchValue({ speed: this.nup.formatValueAndUnit(Number(val), this.settingsService.rotationalUnit.getValue()), |
There was a problem hiding this comment.
This will set the unit to always we be the setting's rotational unit value, ignoring the user's unit input. So 20 rps will be 20 rpm. Take a look at edit pane line 218 for a better example of how to handle this:
const [success, value] = this.nup.parseLengthString(
val!,
this.settingsService.lengthUnit.getValue()
);
You can see that the function takes the big string (with the value and unit) and converts it into a value with the units we want.
There was a problem hiding this comment.
This is a good catch!
There was a problem hiding this comment.
I'm creating another function called parseAngVelRateString that does a functionality similar to parseLengthString.
| } | ||
|
|
||
| numRegex = '^-?[0-9]+(.[0-9]{0,10})?$'; | ||
| numRegex = '^-?[0-9]+(\\.[0-9]{0,10})?\\s*[a-zA-Z]*$'; |
There was a problem hiding this comment.
I don't think we should use the regex for the input field with a value and unit. Instead the current behavior for the other combo input fields (where it's not just a number) is to revert back to the original number. (Try this for the edit panel input fields)
| return value.toFixed(2) + ' N'; | ||
| case RotationUnit.RPM: | ||
| return value.toFixed(2) + ' rpm'; | ||
| case RotationUnit.RPS: |
There was a problem hiding this comment.
This should be radians / second right? Not revolutions per sec
|
The text box looks really good! One small issue I see is when you type a invalid value in, it results in the original number populated but the unit is gone. Also, any rounding is gone. Try '1dps' then 'random'. It first correctly shows 0.17 rpm but reverts to 1.6666 after |
|
I corrected the error regarding showcasing the unit if someone types something incorrectly. I am not 100% sure what you mean by 'reverts to 1.666 after'. From playing around with this, I think this acts how I would expect this to act. Also, I am not sure what the error is regarding rounding. From my observation, the rounding appears to happen properly. Do let me know if this fixes all the issues that you had found on your side. |
…types in a unit incorrectly
|
Looks great! I don't want to add more than the original spec but I noticed that the clockwise / counter clockwise doesn't switch the input speed |
|
Super close to being done! Can you make a couple minor changes?
|
This PR resolves multiple issues: