|
12 | 12 | from gcode.threading import generate_threading_gcode_core |
13 | 13 | from gcode.turning import generate_turning_gcode_core |
14 | 14 |
|
15 | | -halc = hal.component("lathe") |
16 | | -haluic = hal.component("halui") |
| 15 | +# Side-effect import: creating HAL pins has to happen before the Flask app |
| 16 | +# serves its first request. Re-exported below so existing route handlers can |
| 17 | +# read/write pins without a name change. |
| 18 | +from hal_pins import ( |
| 19 | + halc, |
| 20 | + haluic, |
| 21 | + hal_pin_machine_is_on, |
| 22 | + hal_pin_control_source, |
| 23 | + hal_pin_position_z, |
| 24 | + hal_pin_position_x, |
| 25 | + hal_pin_position_a, |
| 26 | + hal_pin_speed_rps, |
| 27 | + hal_pin_forward_z, |
| 28 | + hal_pin_forward_x, |
| 29 | + hal_pin_enable_z, |
| 30 | + hal_pin_enable_x, |
| 31 | + hal_pin_enable_stepper_z, |
| 32 | + hal_pin_enable_stepper_x, |
| 33 | + hal_pin_position_z_encoder, |
| 34 | + hal_pin_position_x_encoder, |
| 35 | + hal_pin_offset_z_encoder, |
| 36 | + hal_pin_offset_z_stepper, |
| 37 | + hal_pin_offset_x_encoder, |
| 38 | + hal_pin_offset_x_stepper, |
| 39 | + hal_pin_control_z_type, |
| 40 | + hal_pin_control_x_type, |
| 41 | + hal_pin_velocity_z_cmd, |
| 42 | + hal_pin_velocity_x_cmd, |
| 43 | + hal_pin_reset_z, |
| 44 | + hal_pin_reset_x, |
| 45 | + hal_pin_scale_encoder_z, |
| 46 | + hal_pin_scale_encoder_x, |
| 47 | +) |
| 48 | + |
17 | 49 | c = linuxcnc.command() |
18 | 50 | reset_z = 0 |
19 | 51 | reset_x = 0 |
20 | 52 |
|
21 | | -hal_pin_machine_is_on = haluic.newpin("machine.is-on", hal.HAL_BIT, hal.HAL_OUT) |
22 | | - |
23 | | -hal_pin_control_source = halc.newpin("control_source", hal.HAL_BIT, hal.HAL_OUT) |
24 | | - |
25 | | -hal_pin_position_z = halc.newpin("position_z", hal.HAL_FLOAT, hal.HAL_IN) |
26 | | -hal_pin_position_x = halc.newpin("position_x", hal.HAL_FLOAT, hal.HAL_IN) |
27 | | -hal_pin_position_a = halc.newpin("position_a", hal.HAL_FLOAT, hal.HAL_IN) |
28 | | -hal_pin_speed_rps = halc.newpin("speed_rps", hal.HAL_FLOAT, hal.HAL_IN) |
29 | | - |
30 | | -hal_pin_forward_z = halc.newpin("forward_z", hal.HAL_FLOAT, hal.HAL_OUT) |
31 | | -hal_pin_forward_x = halc.newpin("forward_x", hal.HAL_FLOAT, hal.HAL_OUT) |
32 | | -hal_pin_enable_z = halc.newpin("enable_z", hal.HAL_BIT, hal.HAL_OUT) |
33 | | -hal_pin_enable_x = halc.newpin("enable_x", hal.HAL_BIT, hal.HAL_OUT) |
34 | | -hal_pin_enable_stepper_z = halc.newpin("enable_stepper_z", hal.HAL_BIT, hal.HAL_OUT) |
35 | | -hal_pin_enable_stepper_x = halc.newpin("enable_stepper_x", hal.HAL_BIT, hal.HAL_OUT) |
36 | | - |
37 | | -hal_pin_position_z_encoder = halc.newpin("position_z_encoder", hal.HAL_FLOAT, hal.HAL_IN) |
38 | | -hal_pin_position_x_encoder = halc.newpin("position_x_encoder", hal.HAL_FLOAT, hal.HAL_IN) |
39 | | -hal_pin_offset_z_encoder = halc.newpin("offset_z_encoder", hal.HAL_FLOAT, hal.HAL_OUT) |
40 | | -hal_pin_offset_z_stepper = halc.newpin("offset_z_stepper", hal.HAL_FLOAT, hal.HAL_OUT) |
41 | | -hal_pin_offset_x_encoder = halc.newpin("offset_x_encoder", hal.HAL_FLOAT, hal.HAL_OUT) |
42 | | -hal_pin_offset_x_stepper = halc.newpin("offset_x_stepper", hal.HAL_FLOAT, hal.HAL_OUT) |
43 | | - |
44 | | -hal_pin_control_z_type = halc.newpin("control_z_type", hal.HAL_BIT, hal.HAL_OUT) |
45 | | -hal_pin_control_x_type = halc.newpin("control_x_type", hal.HAL_BIT, hal.HAL_OUT) |
46 | | -hal_pin_velocity_z_cmd = halc.newpin("velocity_z_cmd", hal.HAL_FLOAT, hal.HAL_OUT) |
47 | | -hal_pin_velocity_x_cmd = halc.newpin("velocity_x_cmd", hal.HAL_FLOAT, hal.HAL_OUT) |
48 | | - |
49 | | -hal_pin_reset_z = halc.newpin("reset_z", hal.HAL_U32, hal.HAL_OUT) |
50 | | -hal_pin_reset_x = halc.newpin("reset_x", hal.HAL_U32, hal.HAL_OUT) |
51 | | - |
52 | | -hal_pin_scale_encoder_z = halc.newpin("scale_encoder_z", hal.HAL_FLOAT, hal.HAL_OUT) |
53 | | -hal_pin_scale_encoder_x = halc.newpin("scale_encoder_x", hal.HAL_FLOAT, hal.HAL_OUT) |
54 | | - |
55 | 53 | app = Flask(__name__) |
56 | 54 | CORS(app, resources={r"/*": {"origins": "*"}}) |
57 | 55 |
|
|
0 commit comments