@@ -253,6 +253,7 @@ static double lastjogspeed = 0;
253253static double internaljogspeed = 0 ;
254254static double lastangularjogspeed = 0 ;
255255static double internalangularjogspeed = 0 ;
256+ static double tempjogspeed = 0 ;
256257static int lastaxis = -1 ;
257258
258259static char *mdi_commands[MDI_MAX];
@@ -652,7 +653,7 @@ static int py_call_get_mdi_count() {
652653 return value;
653654}
654655
655- // turns a undex number into a macro name
656+ // turns a index number into a macro name
656657static char * py_call_get_mdi_name ( int num) {
657658 pFuncWrite = PyObject_GetAttrString (pInstance, " getMdiName" );
658659
@@ -1733,7 +1734,6 @@ static int iniLoad(const char *filename)
17331734 gui_mdi_commands[num_gui_mdi_commands++] = py_call_get_mdi_name (n);
17341735 }
17351736
1736-
17371737 // close it
17381738 inifile.Close ();
17391739
@@ -2009,6 +2009,35 @@ static void py_call_request_MDI( int index)
20092009 Py_DECREF (pFuncWrite);
20102010}
20112011
2012+ static int py_call_get_axis_type ( int index) {
2013+ int value = 0 ;
2014+ // check socket messages for selected axis
2015+ pFuncRead = PyObject_GetAttrString (pInstance, " getAxisIndexType" );
2016+ if (pFuncRead && PyCallable_Check (pFuncRead)) {
2017+ pValue = PyObject_CallFunction (pFuncRead, " i" , index);
2018+ if (pValue == NULL ){
2019+ if (PyErr_Occurred ()) PyErr_Print ();
2020+ fprintf (stderr, " Halui Bridge: getSelectAxis function failed: returned NULL\n " );
2021+ value = -1 ;
2022+ }else {
2023+ if (PyLong_Check (pValue)) {
2024+ value = (int ) PyLong_AsLong (pValue);
2025+ // fprintf(stderr, "axis value %d\n",value);
2026+ if (PyErr_Occurred ()) {
2027+ value = -1 ;
2028+ // Handle conversion error
2029+ PyErr_Print ();
2030+ // Clear the error state if needed
2031+ PyErr_Clear ();
2032+ }
2033+ }
2034+ }
2035+ Py_DECREF (pValue);
2036+ }
2037+ Py_DECREF (pFuncRead);
2038+ return value;
2039+ }
2040+
20122041// this function looks if any of the hal pins has changed
20132042// and sends appropriate messages if so
20142043static void check_hal_changes ()
@@ -2023,7 +2052,6 @@ static void check_hal_changes()
20232052 double angularjogspeed;
20242053 int jjog_speed_changed;
20252054 int ajog_speed_changed;
2026- int ajog_speed_angular_changed;
20272055 int is_any_axis_selected, deselected;
20282056
20292057 // get python to process socket messages
@@ -2319,16 +2347,16 @@ static void check_hal_changes()
23192347 if (fabs (old_halui_data.ajog_speed_angular - new_halui_data.ajog_speed_angular ) > 0.00001 ) {
23202348 old_halui_data.ajog_speed_angular = new_halui_data.ajog_speed_angular ;
23212349 internalangularjogspeed = new_halui_data.ajog_speed_angular ;
2322- ajog_speed_angular_changed = 1 ;
2350+ ajog_speed_changed = 1 ;
23232351 py_call_axis_angular_jogspeed (internalangularjogspeed);
23242352 } else {
2325- ajog_speed_angular_changed = 0 ;
2353+ ajog_speed_changed = 0 ;
23262354 }
23272355
23282356 // check socket messages for ANGULAR jogspeed
23292357 angularjogspeed = py_call_axis_get_angular_jogspeed ();
23302358 if (fabs (angularjogspeed - lastangularjogspeed) > 0.00001 ) {
2331- ajog_speed_angular_changed = 1 ;
2359+ ajog_speed_changed = 1 ;
23322360 lastangularjogspeed = angularjogspeed;
23332361 internalangularjogspeed = angularjogspeed;
23342362 fprintf (stderr, " angular JogRate value = %f\n " , angularjogspeed );
@@ -2422,11 +2450,18 @@ static void check_hal_changes()
24222450
24232451 if ( !(axis_mask & (1 << axis_num)) ) { continue ; }
24242452
2453+ // check for axis type: linear/rotary
2454+ if (py_call_get_axis_type (axis_num) == 1 ){
2455+ tempjogspeed = internaljogspeed;
2456+ }else {
2457+ tempjogspeed = internalangularjogspeed;
2458+ }
2459+
24252460 // axis jog -
24262461 bit = new_halui_data.ajog_minus [axis_num];
24272462 if ((bit != old_halui_data.ajog_minus [axis_num]) || (bit && ajog_speed_changed)) {
24282463 if (bit != 0 )
2429- sendJogCont (axis_num,-internaljogspeed ,JOGTELEOP);
2464+ sendJogCont (axis_num,-tempjogspeed ,JOGTELEOP);
24302465 else
24312466 sendJogStop (axis_num,JOGTELEOP);
24322467 old_halui_data.ajog_minus [axis_num] = bit;
@@ -2436,7 +2471,7 @@ static void check_hal_changes()
24362471 bit = new_halui_data.ajog_plus [axis_num];
24372472 if ((bit != old_halui_data.ajog_plus [axis_num]) || (bit && ajog_speed_changed)) {
24382473 if (bit != 0 )
2439- sendJogCont (axis_num,internaljogspeed ,JOGTELEOP);
2474+ sendJogCont (axis_num,tempjogspeed ,JOGTELEOP);
24402475 else
24412476 sendJogStop (axis_num,JOGTELEOP);
24422477 old_halui_data.ajog_plus [axis_num] = bit;
@@ -2447,7 +2482,7 @@ static void check_hal_changes()
24472482 bit = (fabs (floatt) > new_halui_data.ajog_deadband );
24482483 if ((floatt != old_halui_data.ajog_analog [axis_num]) || (bit && ajog_speed_changed)) {
24492484 if (bit)
2450- sendJogCont (axis_num,(internaljogspeed ) * (new_halui_data.ajog_analog [axis_num]),JOGTELEOP);
2485+ sendJogCont (axis_num,(tempjogspeed ) * (new_halui_data.ajog_analog [axis_num]),JOGTELEOP);
24512486 else
24522487 sendJogStop (axis_num,JOGTELEOP);
24532488 old_halui_data.ajog_analog [axis_num] = floatt;
@@ -2457,15 +2492,15 @@ static void check_hal_changes()
24572492 bit = new_halui_data.ajog_increment_plus [axis_num];
24582493 if (bit != old_halui_data.ajog_increment_plus [axis_num]) {
24592494 if (bit)
2460- sendJogIncr (axis_num, internaljogspeed , new_halui_data.ajog_increment [axis_num],JOGTELEOP);
2495+ sendJogIncr (axis_num, tempjogspeed , new_halui_data.ajog_increment [axis_num],JOGTELEOP);
24612496 old_halui_data.ajog_increment_plus [axis_num] = bit;
24622497 }
24632498
24642499 // jog a- increment
24652500 bit = new_halui_data.ajog_increment_minus [axis_num];
24662501 if (bit != old_halui_data.ajog_increment_minus [axis_num]) {
24672502 if (bit)
2468- sendJogIncr (axis_num, internaljogspeed , -(new_halui_data.ajog_increment [axis_num]),JOGTELEOP);
2503+ sendJogIncr (axis_num, tempjogspeed , -(new_halui_data.ajog_increment [axis_num]),JOGTELEOP);
24692504 old_halui_data.ajog_increment_minus [axis_num] = bit;
24702505 }
24712506
@@ -2514,12 +2549,20 @@ static void check_hal_changes()
25142549 sendJogStop (axis_num,JOGTELEOP);
25152550 }
25162551 } else {
2552+
2553+ // check for axis type: linear/rotary
2554+ if (py_call_get_axis_type (axis_num) == 1 ){
2555+ tempjogspeed = internaljogspeed;
2556+ }else {
2557+ tempjogspeed = internalangularjogspeed;
2558+ }
2559+
25172560 *(halui_data->axis_is_selected [axis_num]) = 1 ;
25182561 if (*halui_data->ajog_plus [num_axes]) {
25192562 fprintf (stderr, " halui: jog plus: %d\n " ,num_axes);
2520- sendJogCont (axis_num, internaljogspeed ,JOGTELEOP);
2563+ sendJogCont (axis_num, tempjogspeed ,JOGTELEOP);
25212564 } else if (*halui_data->ajog_minus [num_axes]) {
2522- sendJogCont (axis_num, -internaljogspeed ,JOGTELEOP);
2565+ sendJogCont (axis_num, -tempjogspeed ,JOGTELEOP);
25232566 }
25242567 }
25252568 }
@@ -2570,8 +2613,17 @@ static void check_hal_changes()
25702613 bit = new_halui_data.ajog_minus [EMCMOT_MAX_AXIS];
25712614 js = new_halui_data.axis_selected ;
25722615 if ((bit != old_halui_data.ajog_minus [EMCMOT_MAX_AXIS]) || (bit && ajog_speed_changed)) {
2573- if (bit != 0 )
2574- sendJogCont (js, -internaljogspeed,JOGTELEOP);
2616+ if (bit != 0 ){
2617+
2618+ // check for axis type: linear/rotary
2619+ if (py_call_get_axis_type (js) == 1 ){
2620+ tempjogspeed = internaljogspeed;
2621+ }else {
2622+ tempjogspeed = internalangularjogspeed;
2623+ }
2624+
2625+ sendJogCont (js, -tempjogspeed,JOGTELEOP);
2626+ }
25752627 else
25762628 sendJogStop (js,JOGTELEOP);
25772629 old_halui_data.ajog_minus [EMCMOT_MAX_AXIS] = bit;
@@ -2580,8 +2632,17 @@ static void check_hal_changes()
25802632 bit = new_halui_data.ajog_plus [EMCMOT_MAX_AXIS];
25812633 js = new_halui_data.axis_selected ;
25822634 if ((bit != old_halui_data.ajog_plus [EMCMOT_MAX_AXIS]) || (bit && ajog_speed_changed)) {
2583- if (bit != 0 )
2584- sendJogCont (js,internaljogspeed,JOGTELEOP);
2635+ if (bit != 0 ){
2636+
2637+ // check for axis type: linear/rotary
2638+ if (py_call_get_axis_type (js) == 1 ){
2639+ tempjogspeed = internaljogspeed;
2640+ }else {
2641+ tempjogspeed = internalangularjogspeed;
2642+ }
2643+
2644+ sendJogCont (js,tempjogspeed,JOGTELEOP);
2645+ }
25852646 else
25862647 sendJogStop (js,JOGTELEOP);
25872648 old_halui_data.ajog_plus [EMCMOT_MAX_AXIS] = bit;
@@ -2591,15 +2652,15 @@ static void check_hal_changes()
25912652 js = new_halui_data.axis_selected ;
25922653 if (bit != old_halui_data.ajog_increment_plus [EMCMOT_MAX_AXIS]) {
25932654 if (bit)
2594- sendJogIncr (js, internaljogspeed , new_halui_data.ajog_increment [EMCMOT_MAX_AXIS],JOGTELEOP);
2655+ sendJogIncr (js, tempjogspeed , new_halui_data.ajog_increment [EMCMOT_MAX_AXIS],JOGTELEOP);
25952656 old_halui_data.ajog_increment_plus [EMCMOT_MAX_AXIS] = bit;
25962657 }
25972658
25982659 bit = new_halui_data.ajog_increment_minus [EMCMOT_MAX_AXIS];
25992660 js = new_halui_data.axis_selected ;
26002661 if (bit != old_halui_data.ajog_increment_minus [EMCMOT_MAX_AXIS]) {
26012662 if (bit)
2602- sendJogIncr (js, internaljogspeed , -(new_halui_data.ajog_increment [EMCMOT_MAX_AXIS]),JOGTELEOP);
2663+ sendJogIncr (js, tempjogspeed , -(new_halui_data.ajog_increment [EMCMOT_MAX_AXIS]),JOGTELEOP);
26032664 old_halui_data.ajog_increment_minus [EMCMOT_MAX_AXIS] = bit;
26042665 }
26052666
0 commit comments