How a parameter window builds its input rows

Contents · 中文版

The previous chapter explained how a page displays parameters. This chapter takes the next step: when an operator enters a number, how does the software identify the parameter it belongs to, and how does the macro program use it afterwards?

We will read the design of the existing Inner Hole Detection Settings window. It already contains names, values, descriptions, units, and a choice field. This chapter adds no buttons, parameters, or probing functions, and does not require a probing operation.

1. Start with the existing window

Figure 1: the standard Inner Hole Detection Settings window with its eleven visible parameter rows and instructions

Click the screenshot to view the original image.

Figure 1. The original env/macroParam.ui displaying the inner-hole probing parameters. The port is 0, meaning unassigned. The other values illustrate the existing design; they are not recommended machine setup values. The bottom buttons read OK and Cancel.

Look at four things first:

Where is the entry? The standard function library already defines InnerHole / Probe as #911.itemdesc[50], calling customprobe/centerprobing.nc. On a customer panel where this function has been assigned to a button, that button opens the function. In the setting-env checked for this chapter, function 50 is not assigned to any of the 36 positions in the right-hand panel. It would therefore be incorrect to describe it as a fixed button on every installation, or to treat Auto / Measure as the same entry. The next chapter will explain how existing functions are assigned to panel positions.

Study the files and screenshots to understand the parameter window. Before using the probing function, configure its function key and the required machine parameters.

2. Find the four relevant files

All paths below are relative to the software runtime directory.

File What to examine in this example
env/center/center-install A reference left by an earlier component deployment: how the title, item count, names, types, initial values, and units were originally assigned
env/customprobe/centerprobing.nc Which parameter group is selected, which values are prepared, and how the values are used after the window
env/macroParam.ui How one shared window creates a heading, table, and instructions from the selected parameters
env/i18n/translatPack-0 and translatPack-1 Chinese and English names, descriptions, choices, and unit text

center-install is a script left by an earlier component deployment. It was called during that deployment and is not called again afterwards. Application startup, opening this window, and running probing do not use it to redefine these parameters. We retain it in this lesson because it clearly records how the macro variables were originally defined.

Normal operation uses the parameter definitions and values already saved in the system configuration. The software loads those parameters, the language pack supplies the corresponding text, centerprobing.nc prepares values for this use before opening the window, and macroParam.ui reads them to build the window. Keep the two roles clear: the historical deployment script explains how the parameters were originally defined; the current configuration and scripts that actually run determine what is used now.

Editing only the center-install file on disk therefore does not change the current window or take effect automatically at the next startup. This lesson uses it as a definition reference, not as a current execution step or a place to apply live changes.

env/interfaceconf/macrodialog.ui is a different window for developers to edit parameter definitions. The macroParam.ui discussed here lets a function's user enter values for parameters that have already been defined. The similar filenames serve different purposes.

3. Select the parameter group before opening the window

The beginning of centerprobing.nc, through the window request, is reproduced below. This is the complete opening section. Probing moves follow it in the original file, so the whole NC file must not be run as an ordinary interface exercise.

#2500=2050

^2500.item[0]=#902.item[42]
^2500.item[1]=#902.itemmax[42]

MarcoDialog "/env/macroParam.ui"

Read the four statements in order:

  1. #2500=2050 selects parameter 2050 for this window.
  2. ^2500.item[0]=#902.item[42] copies the configured 3D probe signal port into input item 0.
  3. ^2500.item[1]=#902.itemmax[42] copies its active state into item 1. The standard configuration uses .itemmax[42] to store that state; the field name does not make it a maximum port number in this usage.
  4. MarcoDialog requests the existing shared parameter window. The command is spelled exactly MarcoDialog.

This example uses item 42 of #902. Do not substitute the separate general probing signal configuration. The two probing signals reference explains the distinction and the related protection logic; here we continue with the window.

The distinction between #2500 and ^2500 is:

Expression What it accesses when #2500=2050
#2500 The number 2050
^2500.title The title of parameter 2050, equivalent to #2050.title
^2500.item[6] Item 6 of parameter 2050, equivalent to #2050.item[6]

The UI therefore does not need 2050 written into every control. The opening program puts the desired parameter number in #2500; the window uses ^2500 to find it. Another function can select its own parameter group and reuse the same UI file.

#2500 is shared, rather than a separate variable for each open window. If another script changes it while this window still uses it, the read/write target can change. Finish the current editing operation before selecting another group and building its window.

4. Read one complete input definition

During the earlier deployment, center-install used #2050.itemnum=12 to define twelve items numbered 0–11. Those twelve items are also present in the current configuration. We use the original file below to explain the complete definition for Fine Detection Count. The historical deployment script uses Chinese text; the English language pack supplies the English labels shown in the pictures.

#2050.itemtitle[6]="精探次数"
#2050.itemdesc[6]=""
#2050.item[6]=3
#2050.itemunit[6]=""
#2050.itemtype[6]=3
Field What the line tells the software
itemtitle[6] The item name; the English pack displays Fine Detection Count
itemdesc[6] No separate description is provided
item[6] The initial value is 3; submitted input is written back here
itemunit[6] Leave the unit column empty
itemtype[6] Type number 3: this table creates an integer input field

Now examine an input with a decimal value and a unit, displayed as X+ Distance:

#2050.itemtitle[7]="X正向预置距离"
#2050.itemdesc[7]="X正向探测开始前,正向移动此距离后再开始探测"
#2050.item[7]=3
#2050.itemunit[7]="mm"
#2050.itemtype[7]=2

Its value also starts at 3, but type 2 displays it as a real number: 3.000 in Figure 1. The description says to move forward by this distance before X-axis probing. The unit is shown in a separate column; the value field contains a number. The original definition uses mm; the current English pack changes the unit text to unit, as shown in the picture.

These assignments explain how the parameters were originally created. The current values in the picture come from the configuration loaded for this check. If a customer has since changed and saved parameters, their current configuration is authoritative; the initial values in the historical script are not a substitute for it.

The choice displayed as Probe State is defined as follows:

#2050.itemtitle[1]="探针有效状态"
#2050.itemdesc[1]="常开型探针选择接通 常闭型探针选择断开"
#2050.item[1]=0
#2050.itemunit[1]="接通<<断开"
#2050.itemtype[1]=4

Type 4 creates a drop-down list. Here itemunit contains choice text, separated by <<. The first choice is value 0, the second value 1. With the English pack, they read Connected and Disconnected. The program stores the numeric index, not the displayed word.

Probe State selects which signal level counts as active. Seeing Connected in this field does not mean that the probe is currently triggered. It is also unrelated to the controller connection state discussed in the previous chapter.

The three types used in this example are:

itemtype Control created by this window Example
2 Numeric input allowing decimals X/Y distances and Detection Retract Distance
3 Integer numeric input Port, speeds, and Fine Detection Count
4 Drop-down choice Probe State and the hidden Detection Type item

These are the rules used by this window. Types also affect conversion and display; do not change an existing type just to change its appearance.

5. How the UI turns the definitions into rows

Open env/macroParam.ui in Qt Designer, find tableWidget, and inspect accessibleDescription. It holds the table's configuration. Its complete contents are:

{
-标题:(#9500_itemtitle0),0
-标题:(#9500_itemtitle1),300,6
-标题:(#9500_itemtitle7),200,6
-标题:(#9500_itemtitle3)
-标题:(#9500_itemtitle8),120
-属性:-D
}

{
-过滤器:^2500.itemversion%%==0
-rows:^2500.itemnum
-serial:0
-列:-T(%%)
-列:-T(^2500.itemtitle%0)
-列:-T(^2500.item%0) -D
-列:
     -T(^2500.itemdesc%0)
-列:
     -T(^2500.itemunit%0)
     -参数("")
     -条件,1(^2500_itemtype%0==4)
     -条件,0(^2500_itemtype%0!=4)
}

The Chinese words in this block are the original UI configuration keywords. Keep them as written; changing the interface language does not require translating this code.

Read it in two parts. The first defines the five column headings and column settings. Heading text comes from #9500. We retain these settings in this lesson; there is no need to memorize all the column layout options first.

The second part goes through the selected parameter's items and creates a row for each item that passes the condition. The five columns are:

Column What it reads Example for item 7
Parameter number %% 7
Parameter name ^2500.itemtitle%0 X+ Distance
value ^2500.item%0 3.000, editable
description ^2500.itemdesc%0 The explanation of this distance
unit ^2500.itemunit%0, with an additional type condition unit

Here %% is the original item number being processed. %0 means offset 0 from the item associated with this row. This table uses the default interval of 1, so the row for item 7 reads the name, value, description, and unit of item 7. These are table UI expressions. Ordinary scripts still use expressions such as .item[7].

The value column does not separately say “draw an input for the count” and “draw a choice for the state.” The software reads the parameter's itemtype and selects the control. Defining the parameter type is therefore part of designing the input interface.

The last three lines in the unit column handle an exception: show an empty string for type 4, and show the unit for other types. The choice list has already used the text, so the unit column does not repeat the entire Connected << Disconnected string. -D keeps the related display updated; it does not disable editing.

The heading and instructions are separate labels with these settings:

-T(^2500_title) -D
-T(^2500_description) -D

The first belongs to label_2 and reads #2050.title; the second belongs to label and reads #2050.description. Selecting another parameter group can therefore change the heading, instructions, and input rows while using the same window.

6. Why twelve items produce eleven visible rows

Item 2 has this original definition:

#2050.itemtitle[2]="探测类型"
#2050.itemdesc[2]=""
#2050.item[2]=0
#2050.itemunit[2]="内轮廓<<外轮廓"
#2050.itemtype[2]=4
#2050.itemversion[2]=1

Its English name is Detection Type, with Inner and Outer choices. The table condition is ^2500.itemversion%%==0. Item 2 has a flag of 1, so it does not get a visible row. Item 3 remains item 3.

Use this complete mapping to compare the code with Figure 1:

Original item English name Display
0 Probe Port Visible
1 Probe State Visible
2 Detection Type Hidden; its data still exists
3 Coarse Speed Visible
4 Fine Speed Visible
5 Movement Speed Visible
6 Fine Detection Count Visible
7 X+ Distance Visible
8 X- Distance Visible
9 Y+ Distance Visible
10 Y- Distance Visible
11 Detection Retract Distance Visible

Although Fine Detection Count is the sixth row counted from the top, it still accesses #2050.item[6]. Do not change it to #2050.item[5]. Hiding an item means that this table chooses not to display it. It neither deletes the data nor renumbers subsequent items.

This UI explicitly uses itemversion as its display condition. That does not make itemversion a universal visibility setting for every page.

7. Where entered values are written

The following input example shows how entered values are written to parameters. Entering and submitting parameters is separate from starting a probing operation.

  1. Enter 4 in the value field for Fine Detection Count, then leave that field.
  2. Enter 4.5 for X+ Distance, then leave that field.
  3. Select Disconnected for Probe State. This checks the choice index only; the setting on a machine must match its actual wiring.

Figure 2: the original table after submitting count 4, X+ distance 4.500, and Disconnected

Click the screenshot to view the original image.

Figure 2. The heading and table area of the same native window after submitting the inputs, captured directly from the window.

Input Display in Figure 2 Field and value written
Fine Detection Count 4 #2050.item[6]=4
X+ Distance 4.500 #2050.item[7]=4.5
Probe State Disconnected #2050.item[1]=1

In this table, text fields submit when they lose focus; choices write back when the selection changes. These values can already be in the parameters before OK is clicked. The text submission method checked here is leaving the field. Do not treat text still being edited as a value that has necessarily been submitted.

Item 2 retains its original value, and item 5, Movement Speed, remains 1500. The hidden item has not caused the input to be written to the wrong position. Displaying 4.5 as 4.500 is real-number formatting; the stored value has not been multiplied by 1000.

8. Cancel, reopen, and enter the function again

Cancel closes the window, but this shared window does not automatically restore all values to their state before opening. After the inputs above were submitted and the window cancelled, count 4, distance 4.5, and state index 1 remained in memory.

There are also two different meanings of “open it again”:

Action Probe State Fine Detection Count and X+ Distance
Cancel, then rebuild only the window using the current #2050 Still Disconnected Still 4 and 4.500
Run the opening assignments from centerprobing.nc again, then build the window Copied again from #902.itemmax[42]; it shows Connected again in this check Those assignments do not overwrite these items, so they remain 4 and 4.500

The second case can look as if Cancel restored one value. In fact, the next entry assigned that value again. To determine whether an input is retained, check both its submission and the assignments at the entry, rather than relying on the button name.

This discussion concerns memory within the current process. Saving to a file, exiting the application, and loading it at the next startup is a separate process. Do not assume OK means “save to disk.”

If a customer function must discard all edits on Cancel, it needs a separate arrangement for temporary input, with validation and copying to the working data on confirmation. The current standard window does not provide this behavior automatically, and this chapter does not add it.

9. How the NC uses the completed inputs

The window itself does not perform inner-hole probing. The remainder of centerprobing.nc reads the same parameter group. For example, the original file contains:

IF^2500.item[6]<=0THEN^2500.item[6]=1

This changes a fine detection count of zero or less to 1. The subsequent repeated probing uses item 6 for the count, preset moves use items 7–10, and speeds come from items 3–5. This connects the input window to the macro program: the entered values are the parameters the later program will read.

One rule is essential between opening and the subsequent actions: this example uses MarcoDialog in NC. During NC planning execution, the current implementation waits for the window to be handled and processes the accepted or cancelled result. The exact pause/reset behavior on cancellation depends on the build branch. Cancel must not be understood as unconditional continuation into probing with the new values.

In an ordinary Qt configuration script, the command with the same name returns after requesting the window. Do not copy the sequence into Qt, put a calculation immediately after MarcoDialog, and assume the user has already finished entering values. A Qt page must arrange the later calculation through an operation after input is complete. See the two window-opening paths reference.

Range checking is another separate concern. A type selects the input method; it does not prove the value is suitable for the operation. The current shared table's numeric fields do not automatically enable numeric validation from itemmin/itemmax. Filling in minimum and maximum fields alone does not guarantee rejection of all out-of-range input. The count correction above is performed by the operation's program; it does not prove that every distance and speed has been checked.

Actual probing also depends on signals, collision protection, positions, and motion timing. This chapter did not execute those actions, so the input checks do not validate probing on a machine.

10. Why the Chinese and English text differs

The two language packs change text in the same parameter group. The English pack includes:

#2050.itemtitle[6]="Fine Detection Count"
#2050.itemtitle[7]="X+ Distance"

The English window therefore still reads and writes items 6 and 7, under the names Fine Detection Count and X+ Distance. Its heading is Inner Hole Detection Settings, and the state choices are Connected and Disconnected. This edition uses those actual interface names.

The current packs also have a difference that must be preserved accurately: Chinese distance units read mm, while English reads unit; speeds read mm/min and unit/min respectively. These are language-pack strings. They do not establish that changing language converts length or speed. The underlying numeric values were the same in both language checks.

To trace a current name, inspect the loaded parameters and the language pack that actually runs. center-install only records the original definition. Since it is no longer executed, changing a name in that historical file alone cannot affect the current page. If you change a name in the current parameters and the language pack later assigns the same field, the later assignment determines the displayed text.

11. Read the complete design for yourself

Complete these five checks without starting probing:

  1. Find #2500=2050 in centerprobing.nc and explain which parameter group is selected.
  2. Find items 6, 7, and 1 in the historical deployment script center-install; explain their original integer, real-number, and choice definitions, then compare them with the current parameters.
  3. Find tableWidget in macroParam.ui and map its columns to the number, name, value, description, and unit.
  4. Find item 2's itemversion and the UI filter; explain why number 2 is absent from the picture.
  5. Identify the destination of each input in Figure 2, then explain why entering the function again reloads Probe State from the system configuration while retaining the count and distance.

Use the symptom to guide troubleshooting:

Symptom First place to check
No InnerHole / Probe button Whether the function is assigned to this panel; a library definition alone does not place a button
Heading and inputs belong to another function #2500 before opening and any other script changing it while the window uses it
A defined item is absent Whether itemnum includes it and its itemversion passes this table's filter
Your program reads another value after a row is hidden Whether you incorrectly renumbered visible rows instead of retaining original item numbers
A choice becomes a numeric field Whether itemtype is 4 and itemunit contains the correct <<-separated choices
Values remain changed after Cancel Whether they were submitted; this window does not automatically undo submitted values
Only some values change on entering again Opening assignments; items 0 and 1 are copied from the system configuration in this example
A renamed item changes back later A later assignment from the active language pack or another preparation script
Editing center-install has no effect after restarting It is a leftover deployment file that is no longer called; editing it does not automatically update the current parameters
A value outside the specified bounds can still be submitted Validation before the value is used; do not rely on range fields alone

The next chapter continues with the standard function panel: how an existing function becomes a button, how a developer selects it, and how that button finds its script.

Previous: Text, values and status · Next: Function-key configuration · Reading guide