halui.cc
来自「CNC 的开放码,EMC2 V2.2.8版」· CC 代码 · 共 1,793 行 · 第 1/5 页
CC
1,793 行
/********************************************************************* Description: halui.cc* HAL User-Interface component.* This file exports various UI related hal pins, and communicates * with EMC through NML messages** Derived from a work by Fred Proctor & Will Shackleford (emcsh.cc)* some of the functions (sendFooBar() are adapted from there)** Author: Alex Joni* License: GPL Version 2* System: Linux** Copyright (c) 2006 All rights reserved.*********************************************************************/#include <stdio.h>#include <string.h>#include <stdlib.h>#include <signal.h>#include <math.h>#include "hal.h" /* access to HAL functions/definitions */#include "rtapi.h" /* rtapi_print_msg */#include "rcs.hh"#include "posemath.h" // PM_POSE, TO_RAD#include "emc.hh" // EMC NML#include "emc_nml.hh"#include "emcglb.h" // EMC_NMLFILE, TRAJ_MAX_VELOCITY, etc.#include "emccfg.h" // DEFAULT_TRAJ_MAX_VELOCITY#include "inifile.hh" // INIFILE#include "emcmotcfg.h" // EMCMOT_MAX_JOINTS#include "rcs_print.hh"#include "nml_oi.hh"#include "timer.hh"/* Using halui: halui {-ini <ini file>} With -ini <inifile>, uses inifile instead of emc.ini. Once executed, it connects to NML buffers, exports various HAL pins and communicates changes to EMC. It also sets certain HAL pins based on status values. Naming: All pins will be named after the following scheme: halui.name.<number>.action name refers to the name of the component, currently one of: - machine - estop - mode - mist - flood - lube - jog - program - probe ... <number> if more than one component of the same type exists action usually on/off or is-on for the status (this uses the NIST way of control, each action is done by momentary pushbuttons, and thus more than one source of control is allowed: e.g. multiple UI's, GUI's ) Exported pins:DONE: - machine: halui.machine.on bit //pin for setting machine On halui.machine.off bit //pin for setting machine Off halui.machine.is-on bit //pin for machine is On/OffDONE: - estop: halui.estop.activate bit //pin for setting Estop (emc internal) On halui.estop.reset bit //pin for resetting Estop (emc internal) Off halui.estop.is-activated bit //pin for displaying Estop state (emc internal) On/Off DONE: - mode: halui.mode.manual bit //pin for requesting manual mode halui.mode.is_manual bit //pin for manual mode is on halui.mode.auto bit //pin for requesting auto mode halui.mode.is_auto bit //pin for auto mode is on halui.mode.mdi bit //pin for requesting mdi mode halui.mode.is_mdi bit //pin for mdi mode is on halui.mode.teleop bit //pin for requesting teleop mode halui.mode.is_teleop bit //pin for teleop mode is on halui.mode.joint bit //pin for requesting joint mode halui.mode.is_joint bit //pin for joint mode is onDONE: - mist, flood, lube: halui.mist.on bit //pin for starting mist halui.mist.off bit //pin for stoping mist halui.mist.is-on bit //pin for mist is on halui.flood.on bit //pin for starting flood halui.flood.off bit //pin for stoping flood halui.flood.is-on bit //pin for flood is on halui.lube.on bit //pin for starting lube halui.lube.off bit //pin for stoping lube halui.lube.is-on bit //pin for lube is onDONE: - spindle: halui.spindle.start bit halui.spindle.stop bit halui.spindle.forward bit halui.spindle.reverse bit halui.spindle.increase bit halui.spindle.decrease bit halui.spindle.brake-on bit //pin for activating spindle-brake halui.spindle.brake-off bit //pin for deactivating spindle/brake halui.spindle.brake-is-on bit //status pin that tells us if brake is onDONE: - joint: halui.joint.0.home bit // pin for homing the specific joint halui.joint.0.is-homed bit // status pin telling that the joint is homed .. halui.joint.7.home bit halui.joint.7.is-homed bit halui.joint.selected.home bit // pin for homing the selected joint halui.joint.selected.is-homed bit // status pin telling that the selected joint is homed halui.joint.x.on-soft-min-limit bit halui.joint.x.on-soft-max-limit bit halui.joint.x.on-hard-min-limit bit halui.joint.x.on-hard-max-limit bit (x = 0..7, selected) halui.joint.x.has-fault bit (x = 0..7, selected) halui.joint.select u8 // select joint (0..7) - internal halui halui.joint.selected u8 // selected joint (0..7) - internal halui halui.joint.x.select bit // pins for selecting a joint - internal halui halui.joint.x.is-selected bit // status pin - internal haluiWIP: halui.axis.0.pos-commanded float //cartesian position, commanded halui.axis.0.pos-feedback float //cartesian position, actual ..DONE - jogging: halui.jog.speed float //set jog speed halui.jog-deadband float //pin for setting the jog analog deadband (where not to move) halui.jog.0.minus bit halui.jog.0.plus bit halui.jog.0.analog float //pin for jogging the axis 0 .. halui.jog.7.minus bit halui.jog.7.plus bit halui.jog.7.analog float //pin for jogging the axis 7 halui.jog.selected.minus bit halui.jog.selected.plus bitDONE - tool: halui.tool.number u32 //current selected tool halui.tool.length-offset float //current applied tool-length-offsetDONE: - program: halui.program.is-idle bit halui.program.is-running bit halui.program.is-paused bit halui.program.run bit halui.program.pause bit halui.program.resume bit halui.program.step bit halui.program.stop bitDONE: - general: halui.abort bit // pin to send an abort message (clears out most errors, stops running programs, etc)DONE: - feed-override halui.feed-override.value float //current FO value halui.feed-override.scale float // pin for setting the scale on changing the FO halui.feed-override.counts s32 //counts from an encoder for example to change FO halui.feed-override.increase bit // pin for increasing the FO (+=scale) halui.feed-override.decrease bit // pin for decreasing the FO (-=scale)DONE: - spindle-override halui.spindle-override.value float //current FO value halui.spindle-override.scale float // pin for setting the scale on changing the SO halui.spindle-override.counts s43 //counts from an encoder for example to change SO halui.spindle-override.increase bit // pin for increasing the SO (+=scale) halui.spindle-override.decrease bit // pin for decreasing the SO (-=scale)*/#define MDI_MAX 10struct halui_str { hal_bit_t *machine_on; //pin for setting machine On hal_bit_t *machine_off; //pin for setting machine Off hal_bit_t *machine_is_on; //pin for machine is On/Off // (check iocontrol.cc for a proper description) hal_bit_t *estop_activate; //pin for activating EMC ESTOP hal_bit_t *estop_reset; //pin for resetting ESTOP hal_bit_t *estop_is_activated; //pin for status ESTOP is activated hal_bit_t *mode_manual; //pin for requesting manual mode hal_bit_t *mode_is_manual; //pin for manual mode is on hal_bit_t *mode_auto; //pin for requesting auto mode hal_bit_t *mode_is_auto; //pin for auto mode is on hal_bit_t *mode_mdi; //pin for requesting mdi mode hal_bit_t *mode_is_mdi; //pin for mdi mode is on hal_bit_t *mode_teleop; //pin for requesting teleop mode hal_bit_t *mode_is_teleop; //pin for teleop mode is on hal_bit_t *mode_joint; //pin for requesting joint mode hal_bit_t *mode_is_joint; //pin for joint mode is on hal_bit_t *mist_on; //pin for starting mist hal_bit_t *mist_off; //pin for stoping mist hal_bit_t *mist_is_on; //pin for mist is on hal_bit_t *flood_on; //pin for starting flood hal_bit_t *flood_off; //pin for stoping flood hal_bit_t *flood_is_on; //pin for flood is on hal_bit_t *lube_on; //pin for starting lube hal_bit_t *lube_off; //pin for stoping lube hal_bit_t *lube_is_on; //pin for lube is on hal_bit_t *program_is_idle; //pin for notifying user that program is idle hal_bit_t *program_is_running; //pin for notifying user that program is running hal_bit_t *program_is_paused; //pin for notifying user that program is paused hal_bit_t *program_run; //pin for running program hal_bit_t *program_pause; //pin for pausing program hal_bit_t *program_resume; //pin for resuming program hal_bit_t *program_step; //pin for running one line of the program hal_bit_t *program_stop; //pin for stopping the program hal_bit_t *program_os_on; //pin for setting optional stop on hal_bit_t *program_os_off; //pin for setting optional stop off hal_bit_t *program_os_is_on; //status pin that optional stop is on hal_bit_t *program_bd_on; //pin for setting block delete on hal_bit_t *program_bd_off; //pin for setting block delete off hal_bit_t *program_bd_is_on; //status pin that block delete is on hal_u32_t *tool_number; //pin for current selected tool hal_float_t *tool_length_offset; //current applied tool-length-offset hal_bit_t *spindle_start; //pin for starting the spindle hal_bit_t *spindle_stop; //pin for stoping the spindle hal_bit_t *spindle_is_on; //status pin for spindle is on hal_bit_t *spindle_forward; //pin for making the spindle go forward hal_bit_t *spindle_runs_forward; //status pin for spindle running forward hal_bit_t *spindle_reverse; //pin for making the spindle go reverse hal_bit_t *spindle_runs_backward; //status pin for spindle running backward hal_bit_t *spindle_increase; //pin for making the spindle go faster hal_bit_t *spindle_decrease; //pin for making the spindle go slower hal_bit_t *spindle_brake_on; //pin for activating spindle-brake hal_bit_t *spindle_brake_off; //pin for deactivating spindle/brake hal_bit_t *spindle_brake_is_on;//status pin that tells us if brake is on hal_bit_t *joint_home[EMCMOT_MAX_JOINTS+1]; //pin for homing one joint hal_bit_t *joint_is_homed[EMCMOT_MAX_JOINTS+1]; //status pin that the joint is homed hal_bit_t *joint_on_soft_min_limit[EMCMOT_MAX_JOINTS+1]; //status pin that the joint is on the software min limit hal_bit_t *joint_on_soft_max_limit[EMCMOT_MAX_JOINTS+1]; //status pin that the joint is on the software max limit hal_bit_t *joint_on_hard_min_limit[EMCMOT_MAX_JOINTS+1]; //status pin that the joint is on the hardware min limit hal_bit_t *joint_on_hard_max_limit[EMCMOT_MAX_JOINTS+1]; //status pin that the joint is on the hardware max limit hal_bit_t *joint_has_fault[EMCMOT_MAX_JOINTS+1]; //status pin that the joint has a fault hal_u32_t *joint_selected; // status pin for the joint selected hal_bit_t *joint_nr_select[EMCMOT_MAX_JOINTS]; // nr. of pins to select a joint hal_bit_t *joint_is_selected[EMCMOT_MAX_JOINTS]; // nr. of status pins for joint selected hal_float_t *axis_pos_commanded[EMCMOT_MAX_AXIS+1]; //status pin for commanded cartesian position hal_float_t *axis_pos_feedback[EMCMOT_MAX_AXIS+1]; //status pin for actual cartesian position hal_float_t *jog_speed; //pin for setting the jog speed (halui internal) hal_bit_t *jog_minus[EMCMOT_MAX_JOINTS+1]; //pin to jog in positive direction hal_bit_t *jog_plus[EMCMOT_MAX_JOINTS+1]; //pin to jog in negative direction hal_float_t *jog_analog[EMCMOT_MAX_JOINTS+1]; //pin for analog jogging (-1..0..1) hal_float_t *jog_deadband; //pin for setting the jog analog deadband (where not to move) hal_s32_t *fo_counts; //pin for the Feed Override counting hal_float_t *fo_scale; //scale for the Feed Override counting hal_float_t *fo_value; //current Feed Override value hal_bit_t *fo_increase; // pin for increasing the FO (+=scale) hal_bit_t *fo_decrease; // pin for decreasing the FO (-=scale) hal_s32_t *so_counts; //pin for the Spindle Speed Override counting hal_float_t *so_scale; //scale for the Spindle Speed Override counting hal_float_t *so_value; //current Spindle speed Override value hal_bit_t *so_increase; // pin for increasing the SO (+=scale) hal_bit_t *so_decrease; // pin for decreasing the SO (-=scale) hal_bit_t *abort; //pin for aborting hal_bit_t *mdi_commands[MDI_MAX];} * halui_data; struct local_halui_str { hal_bit_t machine_on; //pin for setting machine On hal_bit_t machine_off; //pin for setting machine Off hal_bit_t estop_activate; //pin for activating EMC ESTOP hal_bit_t estop_reset; //pin for resetting ESTOP hal_bit_t mode_manual; //pin for requesting manual mode hal_bit_t mode_auto; //pin for requesting auto mode hal_bit_t mode_mdi; //pin for requesting mdi mode hal_bit_t mode_teleop; //pin for requesting teleop mode hal_bit_t mode_joint; //pin for requesting joint mode hal_bit_t mist_on; //pin for starting mist hal_bit_t mist_off; //pin for stoping mist hal_bit_t flood_on; //pin for starting flood hal_bit_t flood_off; //pin for stoping flood hal_bit_t lube_on; //pin for starting lube hal_bit_t lube_off; //pin for stoping lube hal_bit_t program_run; //pin for running program hal_bit_t program_pause; //pin for pausing program hal_bit_t program_resume; //pin for resuming program hal_bit_t program_step; //pin for running one line of the program hal_bit_t program_stop; //pin for stopping the program hal_bit_t program_os_on; //pin for setting optional stop on hal_bit_t program_os_off; //pin for setting optional stop off hal_bit_t program_bd_on; //pin for setting block delete on hal_bit_t program_bd_off; //pin for setting block delete off hal_bit_t spindle_start; //pin for starting the spindle hal_bit_t spindle_stop; //pin for stoping the spindle hal_bit_t spindle_forward; //pin for making the spindle go forward hal_bit_t spindle_reverse; //pin for making the spindle go reverse hal_bit_t spindle_increase; //pin for making the spindle go faster hal_bit_t spindle_decrease; //pin for making the spindle go slower hal_bit_t spindle_brake_on; //pin for activating spindle-brake hal_bit_t spindle_brake_off; //pin for deactivating spindle/brake hal_bit_t joint_home[EMCMOT_MAX_JOINTS+1]; //pin for homing one joint hal_u32_t joint_selected; hal_bit_t joint_nr_select[EMCMOT_MAX_JOINTS]; hal_bit_t joint_is_selected[EMCMOT_MAX_JOINTS]; hal_bit_t jog_minus[EMCMOT_MAX_JOINTS+1]; //pin to jog in positive direction hal_bit_t jog_plus[EMCMOT_MAX_JOINTS+1]; //pin to jog in negative direction hal_float_t jog_analog[EMCMOT_MAX_JOINTS+1]; //pin for analog jogging (-1..0..1) hal_s32_t fo_counts; //pin for the Feed Override counting hal_float_t fo_scale; //scale for the Feed Override counting hal_bit_t fo_increase; // pin for increasing the FO (+=scale) hal_bit_t fo_decrease; // pin for decreasing the FO (-=scale) hal_s32_t so_counts; //pin for the Spindle Speed Override counting hal_float_t so_scale; //scale for the Spindle Speed Override counting hal_bit_t so_increase; // pin for increasing the SO (+=scale) hal_bit_t so_decrease; // pin for decreasing the SO (-=scale)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?