Skip to content

Commit bc09d0d

Browse files
committed
halui -add gui ok/canel pins
1 parent 19a4d92 commit bc09d0d

2 files changed

Lines changed: 56 additions & 2 deletions

File tree

lib/python/bridgeui/bridge.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ def cycleStart(self):
156156
def cyclePause(self):
157157
self.writeMsg('request_cycle_pause', True)
158158

159+
def ok(self):
160+
self.writeMsg('request_ok', True)
161+
162+
def cancel(self):
163+
self.writeMsg('request_cancel', True)
164+
159165
def getMdiName(self, num):
160166
if num >len(self.INFO.MDI_COMMAND_DICT)-1:
161167
return 'None'

src/emc/usr_intf/halui.cc

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,12 @@ static int axis_mask = 0;
204204
\
205205
FIELD(hal_bit_t,home_all) /* pin for homing all joints in sequence */ \
206206
FIELD(hal_bit_t,abort) /* pin for aborting */ \
207+
\
207208
ARRAY(hal_bit_t,mdi_commands,MDI_MAX) \
208209
ARRAY(hal_bit_t,gui_mdi_commands,MDI_MAX) \
210+
\
211+
FIELD(hal_bit_t,gui_ok) /* pin for acknowledging dialog ok */ \
212+
FIELD(hal_bit_t,gui_cancel) /* pin for acknowledging dialog cancel */ \
209213
\
210214
FIELD(hal_float_t,units_per_mm) \
211215

@@ -587,6 +591,34 @@ static void py_call_cyclePause() {
587591
return ;
588592
}
589593

594+
static void py_call_ok() {
595+
596+
// check socket messages for gui ok message
597+
pFuncWrite = PyObject_GetAttrString(pInstance, "ok");
598+
if (pFuncRead && PyCallable_Check(pFuncWrite)) {
599+
pValue = PyObject_CallNoArgs(pFuncWrite);
600+
if (pValue == NULL){
601+
fprintf(stderr, "Halui Bridge: ok function failed: returned NULL\n");
602+
}
603+
Py_DECREF(pValue);
604+
}
605+
Py_DECREF(pFuncWrite);
606+
return ;
607+
}
608+
static void py_call_cancel() {
609+
610+
// check socket messages for gui cancel message
611+
pFuncWrite = PyObject_GetAttrString(pInstance, "cancel");
612+
if (pFuncRead && PyCallable_Check(pFuncWrite)) {
613+
pValue = PyObject_CallNoArgs(pFuncWrite);
614+
if (pValue == NULL){
615+
fprintf(stderr, "Halui Bridge: cancel function failed: returned NULL\n");
616+
}
617+
Py_DECREF(pValue);
618+
}
619+
Py_DECREF(pFuncWrite);
620+
return ;
621+
}
590622
static int py_call_get_mdi_count() {
591623
int value = 0;
592624
// check socket messages for jogspeed
@@ -1042,10 +1074,16 @@ int halui_hal_init(void)
10421074

10431075
for (int n=0; n<num_gui_mdi_commands; n++) {
10441076
printf("MDI name returned: %s %i\n", py_call_get_mdi_name(n),n);
1045-
retval = hal_pin_bit_newf(HAL_IN, &(halui_data->gui_mdi_commands[n]), comp_id, "halui.mdi-command-%s", py_call_get_mdi_name(n));
1077+
retval = hal_pin_bit_newf(HAL_IN, &(halui_data->gui_mdi_commands[n]), comp_id, "halui.gui.mdi-command-%s", py_call_get_mdi_name(n));
10461078
if (retval < 0) return retval;
10471079
}
10481080

1081+
retval = halui_export_pin_IN_bit(&(halui_data->gui_ok), "halui.gui.ok");
1082+
if (retval < 0) return retval;
1083+
1084+
retval = halui_export_pin_IN_bit(&(halui_data->gui_cancel), "halui.gui.cancel");
1085+
if (retval < 0) return retval;
1086+
10491087
hal_ready(comp_id);
10501088
return 0;
10511089
}
@@ -2473,10 +2511,20 @@ static void check_hal_changes()
24732511
// request GUI ti run MDI commands
24742512
for(int n = 0; n < num_gui_mdi_commands; n++) {
24752513
if (check_bit_changed(new_halui_data.gui_mdi_commands[n], old_halui_data.gui_mdi_commands[n]) != 0){
2476-
printf("GUI MDI command called index: %i\n", n);
2514+
fprintf(stderr,"GUI MDI command called index: %i\n", n);
24772515
py_call_request_MDI(n);
24782516
}
24792517
}
2518+
2519+
if (check_bit_changed(new_halui_data.gui_ok, old_halui_data.gui_ok) != 0) {
2520+
fprintf(stderr,"GUI OK command called\n");
2521+
py_call_ok();
2522+
}
2523+
2524+
if (check_bit_changed(new_halui_data.gui_cancel, old_halui_data.gui_cancel) != 0) {
2525+
fprintf(stderr,"GUI CANCEL command called\n");
2526+
py_call_cancel();
2527+
}
24802528
}
24812529

24822530
// this function looks at the received NML status message

0 commit comments

Comments
 (0)