Skip to content

Commit 9f74164

Browse files
committed
halui -add cycle start cycle pause pins
calls these functions in a GUI
1 parent 4e9f6dd commit 9f74164

2 files changed

Lines changed: 53 additions & 40 deletions

File tree

lib/python/bridgeui/bridge.py

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -144,51 +144,18 @@ def writeMsg(self, msg, data):
144144
[bytes(topic.encode('utf-8')),
145145
bytes((message).encode('utf-8'))])
146146

147-
# callback from HAL input pins
148-
def pinChanged(self, pinObject, value):
149-
LOG.debug('Pin name:{} changed value to {}'.format(pinObject.text(), value))
150-
# Axis selection change request
151-
if 'select' in pinObject.text():
152-
if bool(value) == False:
153-
pass
154-
#print('Not true state')
155-
return
156-
for i in (self.INFO.AVAILABLE_AXES):
157-
if '-{}-'.format(i.lower()) in pinObject.text():
158-
self.writeMsg('set_selected_axis', i)
159-
break
160-
else:
161-
if 'None' in pinObject.text():
162-
self.writeMsg('set_selected_axis', '')
163-
164-
# cycle start
165-
elif self.cycle_start == pinObject:
166-
if value:
167-
self.writeMsg('request_cycle_start', value)
168-
169-
# cycle pause
170-
elif self.cycle_pause == pinObject:
171-
#if value:
172-
self.writeMsg('request_cycle_pause', value)
173-
174-
# linear jog rate
175-
elif self.jogRateIn == pinObject:
176-
self.writeMsg('set_jograte', value)
177-
178-
# angular jog rate
179-
elif self.jogRateAngularIn == pinObject:
180-
self.writeMsg('set_jograte_angular', value)
181-
182-
# catch all default
183-
else:
184-
self.writeMsg(pinObject.text(),value)
185-
186-
187147
def shutdown(self,signum=None,stack_frame=None):
188148
LOG.debug('shutdown')
189149
global app
190150
app.quit()
191151

152+
def cycleStart(self):
153+
# cycle start
154+
self.writeMsg('request_cycle_start', True)
155+
156+
def cyclePause(self):
157+
self.writeMsg('request_cycle_pause', True)
158+
192159
def getMdiName(self, num):
193160
if num >len(self.INFO.MDI_COMMAND_DICT)-1:
194161
return 'None'

src/emc/usr_intf/halui.cc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ static int axis_mask = 0;
8686
FIELD(hal_bit_t,program_is_running) /* pin for notifying user that program is running */ \
8787
FIELD(hal_bit_t,halui_mdi_is_running) /* pin for notifying user that halui MDI commands is running */ \
8888
FIELD(hal_bit_t,program_is_paused) /* pin for notifying user that program is paused */ \
89+
FIELD(hal_bit_t,cycle_start) /* pin for running program */ \
90+
FIELD(hal_bit_t,cycle_pause) /* pin for running program */ \
8991
FIELD(hal_bit_t,program_run) /* pin for running program */ \
9092
FIELD(hal_bit_t,program_pause) /* pin for pausing program */ \
9193
FIELD(hal_bit_t,program_resume) /* pin for resuming program */ \
@@ -555,6 +557,36 @@ int halui_export_pin_OUT_bit(hal_bit_t **pin, const char *name)
555557
return 0;
556558
}
557559

560+
static void py_call_cycleStart() {
561+
562+
// check socket messages for jogspeed
563+
pFuncWrite = PyObject_GetAttrString(pInstance, "cycleStart");
564+
if (pFuncRead && PyCallable_Check(pFuncWrite)) {
565+
pValue = PyObject_CallNoArgs(pFuncWrite);
566+
if (pValue == NULL){
567+
fprintf(stderr, "Halui Bridge: cycleStart function failed: returned NULL\n");
568+
}
569+
Py_DECREF(pValue);
570+
}
571+
Py_DECREF(pFuncWrite);
572+
return ;
573+
}
574+
575+
static void py_call_cyclePause() {
576+
577+
// check socket messages for jogspeed
578+
pFuncWrite = PyObject_GetAttrString(pInstance, "cyclePause");
579+
if (pFuncRead && PyCallable_Check(pFuncWrite)) {
580+
pValue = PyObject_CallNoArgs(pFuncWrite);
581+
if (pValue == NULL){
582+
fprintf(stderr, "Halui Bridge: cyclePause function failed: returned NULL\n");
583+
}
584+
Py_DECREF(pValue);
585+
}
586+
Py_DECREF(pFuncWrite);
587+
return ;
588+
}
589+
558590
static int py_call_get_mdi_count() {
559591
int value = 0;
560592
// check socket messages for jogspeed
@@ -846,6 +878,10 @@ int halui_hal_init(void)
846878
if (retval < 0) return retval;
847879
retval = halui_export_pin_IN_bit(&(halui_data->flood_off), "halui.flood.off");
848880
if (retval < 0) return retval;
881+
retval = halui_export_pin_IN_bit(&(halui_data->cycle_start), "halui.cycle.start");
882+
if (retval < 0) return retval;
883+
retval = halui_export_pin_IN_bit(&(halui_data->cycle_pause), "halui.cycle.pause");
884+
if (retval < 0) return retval;
849885
retval = halui_export_pin_IN_bit(&(halui_data->program_run), "halui.program.run");
850886
if (retval < 0) return retval;
851887
retval = halui_export_pin_IN_bit(&(halui_data->program_pause), "halui.program.pause");
@@ -1975,6 +2011,16 @@ static void check_hal_changes()
19752011
if (check_bit_changed(new_halui_data.flood_off, old_halui_data.flood_off) != 0)
19762012
sendFloodOff();
19772013

2014+
if (check_bit_changed(new_halui_data.cycle_start, old_halui_data.cycle_start) != 0){
2015+
fprintf(stderr, "cycle-start value = %i\n", new_halui_data.cycle_start );
2016+
py_call_cycleStart();
2017+
}
2018+
2019+
if (check_bit_changed(new_halui_data.cycle_pause, old_halui_data.cycle_pause) != 0){
2020+
fprintf(stderr, "cycle-pause value = %i\n", new_halui_data.cycle_pause );
2021+
py_call_cyclePause();
2022+
}
2023+
19782024
if (check_bit_changed(new_halui_data.program_run, old_halui_data.program_run) != 0)
19792025
sendProgramRun(0);
19802026

0 commit comments

Comments
 (0)