kernelv_ch_set_variable_value()

Prototype

[ret, data, variable]

set_variable_value(vnck: ct.CDLL,
chan_index: int,
variable_name: str,
variable: KERNELV_VARIABLE);

Description

Writes variables defined for a CNC kernel.

Writing a variable is only possible if it is writeable by the NC program. External variables can always be written irrespective of the access type configured.

Currently, the following variable types can be written.

Type

Example

External variables

V.E.VAR_1

Global variables

V.G.WZ_AKT.R

Axis-specific variables

V.A.WCS.X

Program global, self-defined variables

V.P.VAR_1

Cross-program, self-defined variables

V.S.VAR_1

Program non-global, self-defined variables

V.L.VAR_1

Currently, it is not possible to read Type V.G.WZ[]. variables.

The variable to be written is identified on the basis of its name and the channel index.

The complete name (including the V.E. prefix and the array index in the case of array variables) must be specified as the name.

Example: "V.E.VAR_FLOAT_ARRAY[3]"

The variable value to be written must be transferred in the structure KERNELV_VARIABLE * var.

An error code is returned if an error occurred while writing the variables.

Parameter

Name

Type

Meaning

vnck

ctypes.CDLL

Instance of the loaded KernelV DLL.

chan_index

int (unsigned)

Channel index

variable_name

str

Name of the variable to be written.

variable

KERNELV_VARIABLE

Structure of the variable.

Return values

Name

Type

Meaning

ret

KERNELV_RETURN

Return value of the native integrated C function.

data

Any

Returns the value of the variable in the corresponding data format.

variable

KERNELV_VARIABLE

Returns variable.

KERNELV_RETURN

Symbol

Value

Meaning

RET_FINISHED

0

The function was executed without error.

ERR_INVALID_CHAN

-1

The transferred channel index is higher than the number of configured channels -1.

ERR_CNC_NOT_INIT

-3

The simulation CNC kernel was not yet initialised.

ERR_CNC_RET_MEMORY

-4

The return value(s) does/do not fit into the memory provided.

ERR_INTERNAL_ERROR

-11

An internal error has occurred in the DLL.

ERR_UNKNOWN_VARIABLE

-12

The variable name is not known in the CNC kernel.

ERR_VARIABLE_SYNTAX

-13

The variable name is syntactically incorrect, e.g. no closing bracket in the case of an array variable.

ERR_DATA_TYPE_MISMATCH

-14

On write access to a variable, the transferred data type does not match the data type used internally in the CNC.

ERR_VAR_NAME_LENGTH

-18

The variable name passed on to the function exceeds the maximum permissible length (KERNELV_VAR_NAME_LENGTH).

ERR_ARRAY_NOT_SUPPORTED

-21

With many CNC real-time variants, an array can be read or written ‘en block’ by omitting the array index at access. The kernelv DLL does not currently support this access type.

ERR_VAR_NOT_WRITEABLE

-22

An attempt was made to write a non-writeable variant. For write access to variables, the same access rules apply as within an NC program. The only exception here are V.E. variables. They can always be written irrespective of the access rights configured.