Axis TCL code - bugs?

More
14 Apr 2022 16:23 - 14 Apr 2022 16:56 #240244 by Nebur
Axis TCL code - bugs? was created by Nebur
Not sure if this is the right place to post this stuff.
Currently I'm doing some stuff that requires a certain understanding of the implementation of the speed sliders in AXIS.
There are two procs involved that I'm failing to make real sense of. Additionally they seem to either be buggy or the codes purpose is even more obscure than it seems.

It would be great if a dev could have a look at my annotations and check the respective comments on potential bugs.
Also I would appreciate if you could shed some light on what the purpose of the code is.
Thanks.

# purpose?
# gets two numeric strings, returns an index
# last return stmt out of bounds of s1
proc places {s1 s2} {
    # returns index of last int digit of s1
    #     when s1 > 1 (numeric gt op if s1 is numeric)
    #     and integer part of s1 and s2 differ
    if {$s1 > 1 && int($s1) != int($s2)} {
        return [expr {[string first . $s1]-1}]
    }
    set l1 [string length $s1]
    set l2 [string length $s2]

    # iterate s1 and s2 starting at pos 15, till end of shorter string
    # why start @15? -> val2vel formats with %32.5f so there's a bunch of leading spaces
    for {set i 15} {$i < $l1 && $i < $l2} {incr i} {
        set c1 [string index $s1 $i]
        set c2 [string index $s2 $i]

        # return current index
        # when
        #     s1 @ idx isn't a 0 or decimal sep
        #     s1 and s2 differ @ pos

        if {$c1 != "0" && $c1 != "." && $c1 != $c2} { return $i }
    }

    # just return the len of s1
    # all other return values are related to 0-based positions
    # is this intentional or -1 is missing?
    return [string length $s1]
}

# purpose?
# translates slider val to speed value
# but wiggles the slider val slightly left and right and
# decides what value to return based on 'places'
# bugged, last_... never set / prev_... set but not used
proc val2vel_show {val maxvel} {
    # translate slider value [.0, 1.] to speed value
    set this_vel [val2vel $val $maxvel]
        
    # prep some vars
    set next_places 0
    set last_places 0
    
    # get speed value and 'places(current vel, offseted vel)' when offsetting slider by 0.005
    #     to the left if possible -> next_...
    #     to the right if possible -> prev_...
    if {$val > .005} {
        set next_vel [val2vel [expr {$val - .005}] $maxvel]
        set next_places [places $this_vel $next_vel]
    }
    if {$val < .995} {
        # this should be last_... there is no prev_...
        set prev_vel [val2vel [expr {$val + .005}] $maxvel]
        set prev_places [places $this_vel $prev_vel]
    }

    # compare 'places' and return adjusted string
    # last_places still is 0
    if {$next_places > $last_places} {
        string trim [string range $this_vel 0 $next_places]
    } {
        string trim [string range $this_vel 0 $last_places]
    }
}
Last edit: 14 Apr 2022 16:56 by Nebur. Reason: added to comments

Please Log in or Create an account to join the conversation.

More
14 Apr 2022 23:09 #240272 by andypugh
Replied by andypugh on topic Axis TCL code - bugs?
I can't really read Tcl. But what wrong behaviour are you seeing?

Please Log in or Create an account to join the conversation.

More
15 Apr 2022 00:09 #240278 by Nebur
Replied by Nebur on topic Axis TCL code - bugs?
It's not that I'm observing wrong behavior. I'm reading the code figuring out how certain parts work and these two procs are really resisting and have some odd lines that might not be intended.


 

Please Log in or Create an account to join the conversation.

More
19 Apr 2022 23:27 #240704 by andypugh
Replied by andypugh on topic Axis TCL code - bugs?
I asked the author:

"The function's concerned with showing a value on one of the "per second" sliders in a way that doesn't show an excess of digits. The sliders operate sort of exponentially. What's desired is that if the slider actually MOVES by a position that the numeric value displayed changes too. The general idea is that it finds some "nearby" slider values and converts them to velocities; both numbers are formatted the same way (%32.5) and then the first non-common digit is found.

no idea if there are bugs or not, but there are always bugs so I'll guess 'yes'."
The following user(s) said Thank You: Nebur

Please Log in or Create an account to join the conversation.

More
20 Apr 2022 12:44 #240733 by Nebur
Replied by Nebur on topic Axis TCL code - bugs?
Thank you!
Knowing the intention helps a lot.
Did you pass the snippet with my comments along? I think the issues I found still apply (at least messed up variable names in val2vel_show).

In any case I will check again now knowing what the two functions are supposed to do and post a potential fix in the hope that it is considered.

Btw. what I'm working on is related to changing the jog speed externally via axisui.xxx pins and having the ui (slider/text box) reflect the change without influencing it.

Please Log in or Create an account to join the conversation.

More
21 Apr 2022 21:35 #240815 by andypugh
Replied by andypugh on topic Axis TCL code - bugs?

Did you pass the snippet with my comments along? 

I didn't, though I did provide a link to the forum post. 

Please Log in or Create an account to join the conversation.

More
21 Apr 2022 22:15 #240826 by Nebur
Replied by Nebur on topic Axis TCL code - bugs?
Andy, please advise - what's the proper way to address this stuff?

I doesn't seem to make much sense to post more details and eventual fixes here in the forum and you playing the messenger or me hoping the author joins the discussion.

Should I raise an issue on github? Will that get the attention from the person responsible?

Thanks

Please Log in or Create an account to join the conversation.

More
21 Apr 2022 22:50 #240834 by andypugh
Replied by andypugh on topic Axis TCL code - bugs?
You can try raising an issue, but as there is no apparent problem being caused, it might not get much attention.

If you are in a position to create a pull-request that fixes possible issues and/or adds a new feature (ie remote slider control) then that is more likely to get attention.

(But even then, patience is likley to be needed, I am months behind in looking at pull requests)

Please Log in or Create an account to join the conversation.

More
21 Apr 2022 23:27 #240837 by Nebur
Replied by Nebur on topic Axis TCL code - bugs?
The problems are partly cosmetic and partly not evident unless one pays close attention to how the sliders react and the associated numeric labels behave. Basically the functionality the author described is broken. But it has little impact on usability and as is more of an annoyance. I guess I wouldn't have noticed if I wasn't working on those additional axisui hal pins to control jog speed.

Currently I don't have a suitable dev setup. I have made the fixes in situ on a regular installation. So a patch file is the only thing I would have at hand.

Anyway... thank you - I will think about how to proceed based on your infos.

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum