Gmoccapy Tool/Offset pages: Value verification and tool data checking - #4436
Gmoccapy Tool/Offset pages: Value verification and tool data checking#4436Sigma1912 wants to merge 3 commits into
Conversation
|
That was quick, thanks. I haven't dug deep into this but I wonder if we should fix it better in tooledit (or additionally). linuxcnc/lib/python/gladevcp/tooledit_widget.py Lines 513 to 523 in bae5676 This would also fix it in this case. But it might be bad if this function gets accidentally a float value which is cut then. |
b1369d0 to
bb1801a
Compare
|
I noticed that the pocket number column currently allows negative integer values, which I don't think is correct? |
I don't know. Maybe one want to disable a tool by setting pocket to -1? |
|
I use duplicate pocket numbers, stacked tools |
|
Just checked in Axis gui (if that is anything to go by):
And yes, there is definitely a use for duplicate pocket number. |
|
Okay, but duplicated tool numbers? You would never know which one will be used. |
Yes, those should indeed not be allowed. |
|
I used programs where the tool ID has to be unique, it is tricky to do it without getting in the way when the user is renumbering tools for whatever reason, some thought need be put into that. Although at the final state there should be no duplicates, when user is wanting to do a renumbering, not having any hard blocks (current behavior) allows to have a moment where there are two tools with the same number; the trick is finding a reasonable way to allow renumbering without getting in the way of the renumbering cleanup flow, some kind of message confirmation, same number already in the table, want to swap number? cancel? |
| except: | ||
| pass | ||
| # validate input for orientation: check if int and valid range | ||
| elif col == 15: |
There was a problem hiding this comment.
This did not get the same float-tolerant treatment: it still uses plain int(new_text). Direct cell entry of 3.0 is now accepted for tool/pocket but still silently rejected for orientation. Same int(float(...)) pattern, keeping the existing range check, would unify it.
There was a problem hiding this comment.
What are the lines you are referring to? I think the above lines not.
There was a problem hiding this comment.
GitHub displays it weird because is not in the diff
I could imagine to do the check on save. So it's easy to rename the IDs and have duplicate IDs in between. |
|
Generally I cannot really comment since I don't use the tool table much. Check on save seems the most straight forward to me but we would probably also have to check on load since a tool table can easily be edited outside the gui.
I thought this was only shared by gscreen. |
|
As a tester, I don't think silently truncating a decimal value is the right behavior here. If the Tool Number or Pocket Number field expects an integer and a user accidentally enters, for example, From a testing/UX perspective, silently modifying the user's input can hide an input error and potentially lead to a different tool or pocket being used than the operator intended. In my opinion, it would be safer and clearer to reject the value and tell the user that an integer is required. The user can then correct the input explicitly. |
733754b to
361bc09
Compare
|
I agree that silent changes to the values entered is not the right thing to do so I made some deeper changes.
Testers welcome. |
| return None | ||
| if self.use_localization: | ||
| try: | ||
| value = locale.atof( value ) |
There was a problem hiding this comment.
Just a small reminder regarding the use of locale.atof() — perhaps it simply got overlooked in the context of the other changes. 🙂
We have spent quite a bit of time dealing with atof() and decimal separator localization in LCNC, and we even have a recommendation about this in the documentation: https://linuxcnc.org/docs/devel/html/en/gui/gui-dev-reference.html#_localization_of_float_numbers_in_guis
atof() can of course work correctly in some situations, but in combination with locales I find it rather tricky and potentially a bit of a time bomb — especially because the problem may not show up under the usual EN locale.
If the intention here is to keep using locale.atof(), I would at least ask for it to be tested with the DE locale, where the decimal separator is a comma. That is where I would expect any potential problems to show up first.
Please don't take this as a blocker for the change, but rather as a reminder based on the experience we've already had with this in LCNC.
There was a problem hiding this comment.
That is current code that got moved around not something new. That is there for backwards compatibility aimed at Gscreen only not something that Gmoccapy uses.
There was a problem hiding this comment.
Yes, I understand that this is existing code being moved around and that it is only there for Gscreen backwards compatibility.
The reason I mentioned it is precisely because this is how we ended up with problems in the past. atof() had been working without any apparent issues for a long time, and then some surrounding code changed and suddenly the locale-related problems started showing up.
So my concern is not that atof() is being introduced here as something new, but rather that moving it around can potentially change the context in which it runs. That's why I would still consider a quick test with the DE locale worthwhile, just to make sure the existing behaviour remains safe after the change.
If that has already been covered by the existing Gscreen compatibility testing, then of course that's fine.
361bc09 to
4265bc8
Compare
4265bc8 to
a27dfc9
Compare
a27dfc9 to
4a9e629
Compare
4a9e629 to
4eac6cc
Compare
Both implemented. |
6de1203 to
6ee058f
Compare
6ee058f to
3399b5b
Compare
|
Sorry for jumping in late. I can not imagine a situation where the same tool or pocket numbers may be used in one tool table. The G-code does name the tool number, the "change code" looks in the tool table for that tool and gets that way the corresponding pocket number. The mechanical tool changer doesn't care about the tool number, as it just gets the tool out of the pocket and puts it in the spindle. If you use a sister tool (i.e. 2 drills 5 mm diameter) in one tool changer the tools should have different tool and pocket numbers. If drill 1 is worn out an dyou want to use drill 2, you will need to edit the tool table. Otherwise, how will you know witch tool will be used? So IMHO it should not be possible to have duplicate tool numbers and also not duplicate pocket numbers. Norbert |
|
I could image a use case for duplicate pocket numbers: If you want to use the same tool for two different g-code files where they have different tool numbers, you could just give them the same pocket number. |
|
Multiple profiling wheels stacked on top of each other, on the same cone, all tools live in the same pocket, multiple tools with different height and diameters for different profiles, this is exactly how I use my edge profiling machines, when I call the tool change for a tool in the same pocket, the tool change routing is skipped, different tool same pocket is easy to use as conditional for skipping tool change, also simple to understand and manage, really don't see why it should be denied as a workflow, if you think is dangerous on some machines, might be worth an optional warning, I don't mind if you default it to warn about duplicate pockets, but removing the functionality altogether I don't think is wise. |
| self.model[path][col] = int(value) | ||
| except: | ||
| pass | ||
| msg = (_(f"\nMust be a positive whole number")) |
There was a problem hiding this comment.
| msg = (_(f"\nMust be a positive whole number")) | |
| msg = (_(f"\nMust be a positive integer")) |
There was a problem hiding this comment.
Sure, note though that 'integer' is a term out of computer science, not every machine operator might be as familiar with it as we are.
There was a problem hiding this comment.
As far as I know is Integer just the english word for "Ganzzahl". I think only german speaking people can imagine what you mean with "whole number" ;-)
There was a problem hiding this comment.
There was a problem hiding this comment.
The average machinist will understand "positive whole number" much faster and more naturally than "positive integer."
"Integer" is an academic term, I'm with Sigma on this one ;-)
Thanks.
|
Could you elaborate on the reasoning behind this?
Possibly, but why? The point is that the recipient widget verifies and displays the message as to why the entry was rejected. |
First it messes up the order. Ok no big thing.
Because the Gmoccapy dialogs are touch optimized. And contribute to a consistent UI. For the exit of the tool table there is also the Gmoccapy dialog used. |
Clicking on the header 'Tool#' will sort the table.
But in that case '61' would also not help, you would have to change the tool number either way.
The problem is that there might already be a tool '0' in the table. Also tool number '0' has different usage depending on random/non-random tool changers. |
Ok, I'll have a look. |
8ffb330 to
1e404c6
Compare
d0b25b6 to
ef085c4
Compare
Lines containing whitespace only are skipped rather than creating a new line with all '0' A message is shown on startup if - duplicate tool numbers have been found in the tool table - orientation is not in range 0...9 - a line is malformed, these are saved to a separate file so they are not silently deleted on save
- value validation is done by the widgets the values are entered for - if the calculator is set to 'integer_only' it will reject any value or expression containing '.' or ',' - value editing is handled in the widget regardless whether directly with the keyboard or the calculator - On save the table is checked for duplicate tool numbers
The tool number for a new tool is preset to one above the highest nummber found in the table instead of '0'
ef085c4 to
2223d77
Compare
|
Fixed the bug where an entry with a zero decimal (eg '16.0') in the calculator did not trigger an error. Modified as requested:
|
Discussion has shown that silent manipulation to make the user entered data fit the data type required by the cell is not wanted and that a rejected value should trigger a message to the user.
Value entries by the user to the offset or tool tables are currently 'verified' and manipulated in several places:
This PR moves value verification to the end recipient (ie the tooledit - and offsetpage widgets). The value is verified in the same place regardless whether the user uses the keyboard directly, the buttons in the calculator widget or the keyboard in the calculator widget. The cell and it's data range is known and a clear user message can be generated.
Fixes #4435
Also in this commit:
The second commit:
The third commit:
A message is shown on startup if the tool file contains
Example:
