Skip to content

Commit 8082d33

Browse files
committed
halui -inject socket axis selection
1 parent c0c1c27 commit 8082d33

1 file changed

Lines changed: 35 additions & 18 deletions

File tree

src/emc/usr_intf/halui.cc

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,9 @@ static void sendJogStop(int ja, int jjogmode)
12811281

12821282
static void sendJogCont(int ja, double speed, int jjogmode)
12831283
{
1284+
// no selected axis/joint
1285+
if (ja < 0) { return; }
1286+
12841287
EMC_JOG_CONT emc_jog_cont_msg;
12851288

12861289
if (emcStatus->task.state != EMC_TASK_STATE::ON) { return; }
@@ -1631,7 +1634,7 @@ static void hal_init_pins()
16311634
*(halui_data->ajog_speed) = 0;
16321635

16331636
*(halui_data->joint_selected) = 0; // select joint 0 by default
1634-
*(halui_data->axis_selected) = 0; // select axis 0 by default
1637+
*(halui_data->axis_selected) = -1; // select no axis by default
16351638

16361639
*(halui_data->fo_scale) = old_halui_data.fo_scale = 0.1; //sane default
16371640
*(halui_data->ro_scale) = old_halui_data.ro_scale = 0.1; //sane default
@@ -1796,11 +1799,7 @@ static void check_hal_changes()
17961799
int ajog_speed_changed;
17971800
int is_any_axis_selected, deselected;
17981801

1799-
local_halui_str new_halui_data_mutable;
1800-
copy_hal_data(*halui_data, new_halui_data_mutable);
1801-
const local_halui_str &new_halui_data = new_halui_data_mutable;
1802-
1803-
// read socket messages
1802+
// get python to process socket messages
18041803
pFuncRead = PyObject_GetAttrString(pInstance, "readMsg");
18051804
if (pFuncRead && PyCallable_Check(pFuncRead)) {
18061805
pValue = PyObject_CallFunction(pFuncRead, "O", pClass);
@@ -1816,6 +1815,29 @@ static void check_hal_changes()
18161815
exit(1);
18171816
}
18181817

1818+
// check socket messages for current axis selection
1819+
int value = write_msg_get_axis_selected();
1820+
1821+
local_halui_str new_halui_data_mutable;
1822+
1823+
if (value != lastaxis) {
1824+
// inject socket axis selection over hal data
1825+
for (axis_num = 0; axis_num < EMCMOT_MAX_AXIS; axis_num++) {
1826+
if ( !(axis_mask & (1 << axis_num)) ) { continue; }
1827+
1828+
if (axis_num == value) {
1829+
*(halui_data->axis_nr_select[axis_num]) = 1;
1830+
}else{
1831+
*(halui_data->axis_nr_select[axis_num]) = 0;
1832+
}
1833+
}
1834+
lastaxis = value;
1835+
}
1836+
1837+
copy_hal_data(*halui_data, new_halui_data_mutable);
1838+
const local_halui_str &new_halui_data = new_halui_data_mutable;
1839+
1840+
18191841
//check if machine_on pin has changed (the rest work exactly the same)
18201842
if (check_bit_changed(new_halui_data.machine_on, old_halui_data.machine_on) != 0)
18211843
sendMachineOn(); //send MachineOn NML command
@@ -2184,25 +2206,20 @@ static void check_hal_changes()
21842206
bit = new_halui_data.axis_nr_select[axis_num];
21852207
if (bit != old_halui_data.axis_nr_select[axis_num]) {
21862208
if (bit != 0) {
2187-
is_any_axis_selected = 1;
2188-
*halui_data->axis_selected = axis_num;
2189-
write_msg_axis_changed(axis_num);
2190-
aselect_changed = axis_num; // flag that we changed the selected axis
2209+
is_any_axis_selected = 1;
2210+
*halui_data->axis_selected = axis_num;
2211+
write_msg_axis_changed(axis_num);
2212+
aselect_changed = axis_num; // flag that we changed the selected axis
21912213
}else{
21922214
deselected = 1;
2193-
}
2194-
old_halui_data.axis_nr_select[axis_num] = bit;
21952215
}
2216+
old_halui_data.axis_nr_select[axis_num] = bit;
2217+
}
21962218
}
21972219
// last axis has been deselected - no axis is selected now
21982220
if (is_any_axis_selected == 0 and deselected == 1) {
21992221
write_msg_axis_changed(-1);
2200-
}
2201-
2202-
// check socket messages for axis selection change
2203-
int value = write_msg_get_axis_selected();
2204-
if (value != lastaxis){
2205-
aselect_changed = lastaxis = value;
2222+
*halui_data->axis_selected = -1;
22062223
}
22072224

22082225
if (aselect_changed >= 0) {

0 commit comments

Comments
 (0)