Skip to content

Commit ca63b4d

Browse files
committed
.
1 parent 01ed1e0 commit ca63b4d

3 files changed

Lines changed: 42 additions & 6 deletions

File tree

elle-app/elle-frontend/src/App.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const {
5252
endPoll,
5353
stopJogNow,
5454
setAxisOffset,
55+
scheduleResetPosition,
5556
scheduleHALOut,
5657
setButtonTime,
5758
scheduleButtonUp,
@@ -816,6 +817,7 @@ watch([zpitch, xpitch], () => {
816817
})
817818
818819
watch(selectedMenu, () => {
820+
scheduleResetPosition()
819821
scheduleHALOut()
820822
})
821823
@@ -1209,6 +1211,7 @@ onUnmounted(() => {
12091211
</div>
12101212
<span class="ml-3 text-sm font-semibold">{{ statusDisplay.text }}</span>
12111213
</div>
1214+
12121215
<div class="menu-separator"></div>
12131216
<button
12141217
class="w-full p-link flex align-items-center justify-content-start p-2 pl-4 text-color hover:surface-200 border-noround"

elle-app/elle-frontend/src/composables/useHAL.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function useHAL() {
2828
const zstepperactive = ref(false)
2929

3030
let updateInterval: NodeJS.Timeout
31+
let halOutResetPositionScheduled: boolean = false
3132
let halOutScheduled: boolean = false
3233
let xaxisoffset: number = 0
3334
let zaxisoffset: number = 0
@@ -66,6 +67,15 @@ export function useHAL() {
6667
selectedFeedMode: any
6768
}) {
6869
updateInterval = setInterval(() => {
70+
if (halOutResetPositionScheduled) {
71+
halOutResetPositionScheduled = false
72+
xaxisoffset = -xpos.value
73+
zaxisoffset = -zpos.value
74+
const halOut = {
75+
reset_position: true
76+
}
77+
putHalOut(halOut)
78+
}
6979
try {
7080
getHalIn().then((halIn) => {
7181
if (xaxissetscheduled) {
@@ -181,6 +191,10 @@ export function useHAL() {
181191
else if (axis === 'a') {aaxisoffset = value}
182192
}
183193

194+
const scheduleResetPosition = () => {
195+
halOutResetPositionScheduled = true
196+
}
197+
184198
const scheduleHALOut = () => {
185199
halOutScheduled = true
186200
}
@@ -399,6 +413,7 @@ export function useHAL() {
399413
endPoll,
400414
stopJogNow,
401415
setAxisOffset,
416+
scheduleResetPosition,
402417
scheduleHALOut,
403418
setButtonTime,
404419
scheduleButtonUp,

elle-app/elle-hal/lathe_halcomp.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
halc = hal.component("lathe")
1313
haluic = hal.component("halui")
1414
c = linuxcnc.command()
15+
reset_z = 0
16+
reset_x = 0
1517

1618
hal_pin_machine_is_on = haluic.newpin("machine.is-on", hal.HAL_BIT, hal.HAL_OUT)
1719

@@ -41,8 +43,8 @@
4143
hal_pin_velocity_z_cmd = halc.newpin("velocity_z_cmd", hal.HAL_FLOAT, hal.HAL_OUT)
4244
hal_pin_velocity_x_cmd = halc.newpin("velocity_x_cmd", hal.HAL_FLOAT, hal.HAL_OUT)
4345

44-
hal_pin_reset_z = halc.newpin("reset_z", hal.HAL_BIT, hal.HAL_OUT)
45-
hal_pin_reset_x = halc.newpin("reset_x", hal.HAL_BIT, hal.HAL_OUT)
46+
hal_pin_reset_z = halc.newpin("reset_z", hal.HAL_U32, hal.HAL_OUT)
47+
hal_pin_reset_x = halc.newpin("reset_x", hal.HAL_U32, hal.HAL_OUT)
4648

4749
app = Flask(__name__)
4850
CORS(app, resources={r"/*": {"origins": "*"}})
@@ -498,6 +500,7 @@ def execute_threading():
498500
return {"status": "Error", "message": error_msg}, 500
499501

500502

503+
501504
@app.put("/hal/cleanup")
502505
def cleanup_canned_cycle_files():
503506
"""Clean up temporary canned cycle .ngc files"""
@@ -531,14 +534,23 @@ def cleanup_canned_cycle_files():
531534

532535
@app.put("/hal/hal_out")
533536
def write_hal_out():
537+
global reset_z, reset_x
534538
json = request.json
535539

536540
if "control_stop_now" in json:
537541
hal_pin_velocity_z_cmd.set(0)
538542
hal_pin_velocity_x_cmd.set(0)
539543
hal_pin_control_z_type.set(0)
540544
hal_pin_control_x_type.set(0)
541-
545+
546+
if "reset_position" in json:
547+
print(f"reset_position {reset_z} {reset_x}")
548+
reset_z = reset_z + 1
549+
hal_pin_reset_z.set(reset_z)
550+
reset_x = reset_x + 1
551+
hal_pin_reset_x.set(reset_x)
552+
c.reset_interpreter()
553+
542554
hal_pin_offset_z_encoder.set(-hal_pin_position_a.get())
543555
hal_pin_offset_z_stepper.set(+hal_pin_position_z_encoder.get())
544556
hal_pin_offset_x_encoder.set(-hal_pin_position_a.get())
@@ -573,12 +585,18 @@ def write_hal_out():
573585

574586
return {"status": "OK"}
575587

576-
577588
halc.ready()
578589
haluic.ready()
579590

580-
hal_pin_reset_z.set(1)
581-
hal_pin_reset_x.set(1)
591+
hal_pin_reset_z.set(reset_z)
592+
hal_pin_reset_x.set(reset_x)
593+
594+
time.sleep(0.500)
595+
596+
reset_z = reset_z + 1
597+
hal_pin_reset_z.set(reset_z)
598+
reset_x = reset_x + 1
599+
hal_pin_reset_x.set(reset_x)
582600

583601
print("{REST_API_READY}")
584602

0 commit comments

Comments
 (0)