File

src/api/model/cncVariables.ts

Description

This class groups all the services related to CNC built-in variable system.

QUERCUS/8070 CNC has a built-in variable system to get data related to cnc operation, tables, parameters, etc.

Cnc variables are well documented in installation and variable manuals distrubuted FAGOR HQ.

Extends

EventEmitter

Index

Methods

Constructor

constructor(_hmiComm: CommHmiNodeServer, cncKernelType: enums.CncKernelType, route: string, cncNodeIndex: number)
Parameters :
Name Type Optional
_hmiComm CommHmiNodeServer No
cncKernelType enums.CncKernelType No
route string No
cncNodeIndex number No

Methods

Async read
read(varName: string | string[], cncNodeIndex: number)

Read cnc system variable and returns it.

Returns a ServiceResponse promise. This promise is fulfilled with returnCode = 0 if everything is ok and data = Variable object or an array of Variable objects, or returnCode = -1 when something goes wrong.

Variable may contain a raw value that cannot be converted, for example, the number of channels in the system or may have a positionment value convertible to mm or inches.


//Positionment variables are complex, and can be converted to human-readable formats using {@link Variable} class' methods.
cnc.variables.read('V.A.PPOS.X').then(response => {
if (response.returnCode === 0) {
console.log(`Internal value ${response.data.value} decimicra - External value ${response.data.external} mm`);
}
else {
console.error('error reading cnc variable', error);
}
});
//output --> Internal value 4440000 decimicra - External value 444 mm

cnc.variables.read(['V.A.PPOS.X', 'V.A.PPOS.Y']).then(response => {
if (response.returnCode === 0) {
response.data.forEach(variable => {
console.log(`Internal value ${variable.value} decimicra - External value ${variable.external} mm`);
})
}
else {
console.error('error reading cnc variable', error);
}
});

//output -> Internal value 461994 decimicra - External value 46.1994 mm
//output -> Internal value 0 decimicra - External value 0 mm


TODO: Document fsys internal return codes.

Parameters :
Name Type Optional Default value Description
varName string | string[] No

variable name to get value.

cncNodeIndex number No 0
Public Async readLegacyVariable
readLegacyVariable(varName: string | string[], cncNodeIndex: number)
Parameters :
Name Type Optional Default value
varName string | string[] No
cncNodeIndex number No 0
Async write
write(varName: string | string[], varValue: | (string | number)[], cncNodeIndex: number)

Writes variable value

Returns a promise. This promise is fulfilled with reply object ServiceResponse or is rejected with CncServiceOperationException when something goes wrong.

return object will contain the returnCode, if value is 0 everything went well, if not data will have the explanation of the error.

cnc.variables.write('V.PLC.R[1]', 15).then((response => {
if(response.returnCode < 0){
console.error('error in writing process', response.returnCode)
return;
}
console.log('V.PLC.R[1] register have been updated properly.');
}).catch(error => {
console.error('unexpected excpetion writing variable', error)}
);

//Output --> V.PLC.R1 register have been updated properly.

TODO: Document fsys internal return codes.

Parameters :
Name Type Optional Default value Description
varName string | string[] No

variable name to write value.

varValue | (string | number)[] No

variable value to write.

cncNodeIndex number No 0

results matching ""

    No results matching ""