@linuxcnc-node/hal
Version:
Node.js bindings for LinuxCNC HAL library
104 lines (103 loc) • 4.5 kB
TypeScript
import type { HalType, RtapiMsgLevel, HalPinInfo, HalSignalInfo, HalParamInfo, HalValue } from "@linuxcnc-node/types";
/**
* Gets the current RTAPI message verbosity level used by HAL.
*
* @returns The current message level (e.g., `hal.MSG_INFO`).
* See {@link RtapiMsgLevel} for available levels.
*/
export declare const getMsgLevel: () => RtapiMsgLevel;
/**
* Sets the RTAPI message verbosity level.
*
* @param level - The new message level to set. See {@link RtapiMsgLevel} for available levels.
*/
export declare const setMsgLevel: (level: RtapiMsgLevel) => void;
/**
* Links a HAL pin to a HAL signal.
*
* @param pinName - The full name of the pin (e.g., "my-comp.out1").
* @param signalName - The name of the signal to connect to.
* @returns `true` on success, `false` on failure (error is thrown by native layer).
* @throws Error if pin or signal doesn't exist, or if connection fails.
*/
export declare const connect: (pinName: string, signalName: string) => boolean;
/**
* Unlinks a HAL pin from any signal it's currently connected to.
*
* @param pinName - The full name of the pin.
* @returns `true` on success, `false` on failure (error is thrown).
* @throws Error if pin doesn't exist or disconnect fails.
*/
export declare const disconnect: (pinName: string) => boolean;
/**
* Gets the current value of any HAL item (pin, parameter, or signal) identified by its full name.
*
* @param name - The full name of the pin, parameter, or signal.
* @returns The value of the item (number or boolean).
* @throws Error if the item is not found.
*/
export declare const getValue: (name: string) => HalValue;
/**
* Retrieves a list of all HAL pins currently in the system.
*
* @returns An array of `HalPinInfo` objects. See {@link HalPinInfo} for structure.
*/
export declare const getInfoPins: () => HalPinInfo[];
/**
* Retrieves a list of all HAL signals currently in the system.
*
* @returns An array of `HalSignalInfo` objects. See {@link HalSignalInfo} for structure.
*/
export declare const getInfoSignals: () => HalSignalInfo[];
/**
* Retrieves a list of all HAL parameters currently in the system.
*
* @returns An array of `HalParamInfo` objects. See {@link HalParamInfo} for structure.
*/
export declare const getInfoParams: () => HalParamInfo[];
/**
* Creates a new HAL signal.
*
* @param signalName - The desired name for the new signal.
* @param type - The data type for the new signal. See {@link HalType} for available types.
* @returns `true` on success, `false` on failure (error is thrown).
* @throws Error if signal name already exists or creation fails.
*/
export declare const newSignal: (signalName: string, type: HalType) => boolean;
/**
* Checks if the signal connected to an IN pin has at least one writer (another pin driving it).
*
* @param pinName - The full name of the IN pin.
* @returns `true` if the pin is connected to a signal and that signal has one or more writers,
* `false` otherwise.
* @throws Error if the pin does not exist.
*/
export declare const pinHasWriter: (pinName: string) => boolean;
/**
* Sets the value of a HAL pin or parameter identified by its full name.
*
* The `value` is converted from its JavaScript type to a string and then parsed by
* the C++ layer, similar to `halcmd setp`. This can set unconnected IN pins
* (modifying their internal `dummysig`) or RW parameters.
*
* @param name - The full name of the pin or parameter.
* @param value - The value to set (string, number, or boolean).
* @returns `true` on success, `false` on failure (error is thrown).
* @throws Error if item not found, if trying to set OUT pin or connected IN pin,
* or if value conversion fails.
*
* @remarks Cannot set OUT pins or connected IN pins with this function.
* Use direct signal manipulation or component proxy access for connected items.
*/
export declare const setPinParamValue: (name: string, value: string | HalValue) => boolean;
/**
* Sets the value of an unconnected HAL signal identified by its name.
*
* The `value` is converted and parsed similarly to `setPinParamValue`.
*
* @param name - The full name of the signal.
* @param value - The value to set (string, number, or boolean).
* @returns `true` on success, `false` on failure (error is thrown).
* @throws Error if signal not found, if signal has writers, or if value conversion fails.
*/
export declare const setSignalValue: (name: string, value: string | HalValue) => boolean;