Cmd operator


The <Cmd> operator provides a flexible mechanism for working with the current CLData command. It returns a reference to the current command, on which you can request a code, name and parameters of this command. Format of access to specific command data following.

<Cmd.Code> - returns a unique numeric code of the CLData command. Each command is uniquely identified by this code. List of command codes listed in the appendicies.

<Cmd.Name> - returns the text name of the command or command parameter.

<Cmd.Data> - for individual CLData commands, which have a single string parameter (such as Comment, PartNo, etc.), returns string value. For the rest of the commands returns a string representation of the command, exactly what is displayed on the tab CLData of main window.

<Cmd.Data[Index]> - an alternative way to access an array of numeric parameters of command CLD. Returns the real value of the parameters array element with the index Index.

The following below are a few language structures allow access to the parameters of CLData command by parameter name. As the parameter name in them can be not only a string constant, as shown here, but the string variables and expressions. Each CLData command can be characterized by its own set of named parameters. The names of the parameters with description for each command are listed in the appendicies. The parameter names can be seen on CLData tab at the bottom of the main window.

<Cmd.Str["ParameterName"]> - returns the value of the command parameter with the name ParameterName as a text String.

<Cmd.Int["ParameterName"]> - returns the value of the command parameter with the name ParameterName as an Integer number.

<Cmd.Flt["ParameterName"]> - returns the value of the command parameter with the name ParameterName as a Real number (floating point number).

<Cmd.Ptr["ParameterName"]> - returns a reference to the command parameter with the ParameterName name. If a parameter with that name in this command does not exist, then the operator returns the value 0, otherwise the number is nonzero. From the obtained reference through the point may be accessed either to the value of this parameter or to one of the child parameters. To do this, after the point again need to specify one of the commands described here: Str, Int, Flt, Ptr, Item, ItemCount, Code, Name. If the following instructions do not specify the parameter name, it means that it refers to this parameter. For example, the instruction Cmd.Ptr ["Parameter1"].Int means take the value of the parameter with the name <Parameter1> as an integer number. A record Cmd.Ptr ["Parameter1"].Int["SubParameter1"] means to take an integer value of the child parameter <SubParameter1> inside parameter <Parameter1>.

<Cmd.Item[Index]> - returns a reference to the child parameter by index. Parameter's indexing starts with 1.

<Cmd.ItemCount> - returns the number of child parameters in list.

 

Parameters of CLData commands may represent not only the elements of a simple type (String, Integer, Real), but also more complex structures (complex parameters and arrays). Each parameter is characterized by its unique name and type. There are the following types of parameters.

  • String - the parameters of this type have a value in the form of a text string and can not have child parameters.
  • Integer - the parameters of this type have a value as an integer number and can not have child parameters.
  • Double - the parameters of this type have a value in the form of a fractional floating point number (Float) and can not have child parameters.
  • Complex parameters (ComplexType) - parameters of this type do not have their own value, but they can have child properties of any of the types described here. This type is necessary to combine multiple parameters in the group. Each of the child parameters has a unique name. To get access to the child parameters you must consistently through the point specify the names of the parameters from parent to most nested child.
    For example, the instruction
     
    Cmd.Flt["MCS.OriginPoint.X"]
     
    means to take from the <MCS> property of the current command child parameter named <OriginPoint>, where to find the child property named <X>; it is necessary to return the result as a fractional number.
  • Arrays (Array). Array parameter as complex does not have their own value and may have child properties. However, the child properties of arrays typically have a common type and, consequently, the same name. Therefore, access to child properties of arrays should be done not by name but by index. To access child properties of the array with the number 4 should write either
     
    Cmd.Ptr["ArrayName"].Item[4], or
    Cmd.Ptr["ArrayName(4)"].
     
    Here <ArrayName> - the name of the array parameter.
    In addition to index access, access to the child array parameters in some cases can be implemented by a key. If the array has a defined parameter Key, which specifies the name of the key field in the child parameters, to obtain access to a particular element of the array after the array name must specify the key value in parentheses. For example, the instruction
     
    Cmd.Ptr["ArrayName(KeyValue)"]
     
    means to take the parameter <ArrayName> from the current command, where to find the child property with a key field equal <KeyValue>.

 

Consider a few examples of CLData command parameters using.

 

Example 1. Inside the tool loading command handler LoadTl to NC-program output the string with address T, with number of the tool and with the name of the turret head in parentheses.

 

program LoadTl

  Output "T" + Cmd.Int["ToolID"] + "(" + Cmd.Str["RevolverID"] + ")"

end

A possible result of the output to the NC-code: T3 (TopTurret)

 

Example 2. Example of MultiGoto command processing using various methods to access elements of array parameter Axes.

 

program MultiGoto

  i: Integer

  AxisName: String

  

  for i = 1 to Cmd.Ptr["Axes"].ItemCount do begin

    AxisName = cmd.Ptr["Axes"].Item[i].Str["AxisID"]

    if AxisName="AxisXPos" then begin

      X = cmd.Ptr["Axes"].Item[i].Flt["Value"]

    end else

    if AxisName="AxisYPos" then begin

      Y = cmd.Ptr["Axes("+Str(i)+")"].Flt["Value"]

    end else

    if AxisName="AxisZPos" then begin

      Z = cmd.Flt["Axes("+Str(i)+").Value"]

    end else

    if cmd.Ptr["Axes(AxisCPos)"]<>0 then begin

      C = cmd.Flt["Axes(AxisCPos).Value"]

    end

  end

  OutBlock

end

 

Example 3. Example of coordinate system setup command processing Origin. It analyzes the <OriginType> property's value. If it is zero, output the standard workpiece coordinate system selection command G54-G59. Number of the coordinate system is taken from the parameter <CSNumber>. Otherwise the local coordinate system transfer command G92 X Y Z is formed. The values of the displacements along the axes of the coordinate system are taken in different ways from the corresponding child properties of the <MCS.OriginPoint> parameter.

 

program Origin

  if Cmd.Int["OriginType"]=0 then begin !G54-G59

    Output "G" + Cmd.Str["CSNumber"]

  end else begin                        !G92 X Y Z

    X = Cmd.Flt["MCS.OriginPoint.X"]

    Y = Cmd.Ptr["MCS.OriginPoint.Y"].Flt

    Z = Cmd.Ptr["MCS.OriginPoint"].Flt["Z"]

    Output "G92 X" + Str(X) + " Y" + Str(Y) + " Z" + Str(Z)

  end

end

 

 

 

Сопутствующие ссылки:

CLData functions and operators