IMDTouchKnowledge BaseShop main store

How-to

Searching Vijeo Designer Recipes by Label Code

HMI and touchscreens Published 9 min read

Short answer

Vijeo Designer addresses recipes by number only, so resolve an incoming label code through a table your scripts maintain: mirror every label in a STRING array, pack one 8-bit hash character per recipe into a 100-character STRING, seed both at power-up through a Status listener, and search with one native string scan confirmed by equals(). The method holds 100 recipes in one group; beyond that, split the hash string or search in the PLC.

On this page
  1. Why can't the recipe manager find a recipe from its label code?
  2. Which search method fits the Vijeo script dialect?
  3. Which variables do I declare for the label table and hash string?
  4. How do I seed the table when the HMI powers up?
  5. How does the Status listener fill the table and chain the next load?
  6. How do I search the hash string for an incoming label code?
  7. How many recipes can the packed hash string handle?
  8. When should the recipes move into the PLC instead?
  9. Questions asked

Vijeo Designer's recipe manager cannot find a recipe from its label code: the _RecipeControlDefault group is addressed by recipe number, so a label arriving over a communication link has to be translated into a number before anything loads. The translation belongs in a second table your scripts maintain. This article builds one: a Labels array mirroring every recipe label, a 100-character HashCodes STRING holding one 8-bit hash character per recipe, a startup chain that seeds both by loading recipes 1, 2, 3 and so on through a Status listener, and a search that resolves an incoming code with one indexOf() scan confirmed by equals(). The method holds 100 recipes in one group; beyond that, split the hash string or search in the PLC.

Why can't the recipe manager find a recipe from its label code? #

The recipe manager is addressed by number only: you write the target into RecipeNumber, order the operation with Operation, and read the finished label from RecipeLabel — no variable in the _RecipeControlDefault group maps a label back to a number.

The group works as a contract. The script writes an order into Operation with RecipeNumber selecting the target, and reads the outcome later in Status and Error. There is no read path for recipe data that bypasses selection, because the display and edit fields on the panel are bound to the currently selected recipe: a script cannot look at the label of recipe N without making recipe N the selected recipe.

Two consequences follow:

  • Searching by loading candidates costs one full load per recipe, worst case the last entry in the group, and every attempt changes what the panel displays and edits.
  • Any faster search needs a parallel number-to-label mapping you build yourself, refreshed every time a label is edited.

The reference material lives in the tool's own Help menu: recipe control variables in section 17.3.5 and script programming in section 18.1.

Which search method fits the Vijeo script dialect? #

Use a mirrored label table plus an 8-bit hash packed into a single STRING: the search becomes one native indexOf() scan confirmed by equals() on the full labels, and the only build cost is one recipe load per entry at startup.

The script language is a restricted Java dialect. It has String, StringBuffer, hashCode(), indexOf() and equals(), but no HashMap or HashTable, so a true hash table cannot be built. What remains is choosing where the scan happens:

Approach Search cost Build cost Limit
Load recipes one by one until the label matches One load per candidate None Disturbs the displayed recipe on every attempt
STRING array of labels, linear compare Up to 100 string compares Fill by loading each recipe once Refresh needed after every label edit; string compares are the slow operation
Integer array of full 32-bit hashCode() values Up to 100 integer compares Same seeding pass Collisions still possible, so equals() confirmation is still required
Label array plus 8-bit hash packed in one STRING One native indexOf() call plus a few equals() tests Same seeding pass, event-chained 100 recipes maximum in one group
Recipes held in PLC data, search done in the PLC Controller-side search Moves recipe storage off the panel Needs a real PLC and the customer's agreement

The decision is the packed-hash row: the scan runs in one native call, the design stays correct when two labels collide because equals() decides, and its seeding cost is paid by every alternative except the slowest one.

Which variables do I declare for the label table and hash string? #

Declare six internal items: a Labels array of 100 STRINGs of 32 characters, a HashCodes STRING of 100 characters, a BOOT boolean that fires the seeding, a Seeded integer that marks the table complete, and the search pair LabelToFind (STRING) and Result (integer).

Variable Type and storage Initial value Purpose
Labels Array of 100 STRING, 32 characters, internal, not persistent Empty Label of recipe N at index N − 1
HashCodes STRING, 100 characters, internal, not persistent 100 NUL characters One hash character per recipe
BOOT Boolean, internal 0 Fires the seeding script at power-up
Seeded Integer, internal 0 Set to 1 when the whole group has been read
LabelToFind STRING, 32 characters Empty The code to resolve
Result Integer, internal 0 Recipe number found, 0 if the code is absent

The bounds come from the scripting constraints, not the manager: a label is at most 32 characters, one recipe group is used, and no more than 100 recipes exist. The recipe manager itself allows 256 recipes per group; the 100-character STRING is what caps this method at 100.

How do I seed the table when the HMI powers up? #

Set BOOT to 1 at startup and let a script triggered by that rising edge clear HashCodes to 100 NUL characters and order the first load — a load order written directly by a script that runs at HMI startup does not execute.

  1. Set BOOT to 1 from the startup mechanism, then confirm in the runtime that BOOT reads 1 after power-up.
  2. Create a script triggered by BOOT changing to 1 and give it the body below.
  3. Power up and confirm two things: recipe 1 is the loaded recipe afterward, and HashCodes reads as 100 NUL characters.
  4. Watch the first load specifically. On the bench setup this design was tested on, the Status listener did not fire for that first load; if yours behaves the same, capture recipe 1 from a script triggered by the label variable changing instead — it changes exactly when a load lands — and let the listener carry the chain from recipe 2.
// Trigger: BOOT changing to 1. Script variable names are illustrative;
// the _RecipeControlDefault members are the documented objects.
StringBuffer buffer = new StringBuffer();
buffer.setLength(100);                            // fills with NUL characters
HashCodes.write(buffer.toString());
Seeded.write(0);
_RecipeControlDefault.RecipeGroupNumber.write(1); // single-group design
_RecipeControlDefault.RecipeNumber.write(1);      // recipe no. 1
_RecipeControlDefault.Operation.write(4);         // 4 = load

How does the Status listener fill the table and chain the next load? #

Trigger one script on every value change of _RecipeControlDefault.Status: a load calls it with Status at 1025 while the operation runs and with Status at 0 when it finishes, so on the return to 0 you store the label and order the next recipe.

Treat bit 0 as busy and bit 1 as error, and read the full bit list in the description of the Status variable before adding any other handling. An invalid recipe number arrives as bit 1 set with Error at 4, which is the signal that the group is exhausted.

// Trigger: value change of _RecipeControlDefault.Status
int status = _RecipeControlDefault.Status.getIntValue();
if (status % 2 == 0) {                            // bit 0 clear: idle
    if (status % 4 == 2) {                        // bit 1 set: failed operation
        if (_RecipeControlDefault.Error.getIntValue() == 4) {
            Seeded.write(1);                      // invalid recipe number: group exhausted
        }
    } else {                                      // Status returned to 0: success
        int n = _RecipeControlDefault.RecipeNumber.getIntValue();
        String label = _RecipeControlDefault.RecipeLabel.getStringValue();
        Labels[n - 1].write(label);
        char hash = (char)(label.hashCode() % 127 + 127);
        StringBuffer sb = new StringBuffer(HashCodes.getStringValue());
        sb.setCharAt(n - 1, hash);                // verify this method name in the script reference
        HashCodes.write(sb.toString());
        if (Seeded.getIntValue() == 0) {          // still seeding: order the next recipe
            _RecipeControlDefault.RecipeNumber.write(n + 1);
            _RecipeControlDefault.Operation.write(4);
        }
    }
}

If your script reference lists no character-replacement method on StringBuffer, rebuild the position by joining the two pieces with the string-concatenation pattern the tool documents.

The hash reduction follows from Java semantics: hashCode() returns a signed 32-bit value, x % 127 keeps the sign of x (a range of −126 to 126), and adding 127 gives 1 to 253. Character 0 is never produced, so it stays free as the not-yet-seeded marker, and the prime modulus spreads the values.

The Seeded gate matters after startup. Once it reads 1, the listener still refreshes Labels[n − 1] and its hash character whenever recipe N is saved — a save is a recipe-manager operation too — but it stops ordering loads, so the load a search orders cannot restart the chain. Chaining work on a variable event is the same discipline as counting PLC bit changes with an HMI script: the script is called for transitions it must ignore, and it acts only in the state it wants.

Keep operators out of recipe editing until Seeded reads 1: the seeding pass cycles whichever recipe the panel has selected.

How do I search the hash string for an incoming label code? #

Reduce the incoming label with the same expression, scan HashCodes with indexOf() from position 0, and test every hit with equals() against the Labels array — the matching index plus one is the recipe number, and Result 0 means the code is absent.

LabelToFind is whatever feeds the code into the panel: an operator entry field, or an external variable mapped by a driver — the same setup as adding a Modbus RTU driver and external variables in Vijeo Designer.

// Trigger: value change of LabelToFind
String target = LabelToFind.getStringValue();
char tHash = (char)(target.hashCode() % 127 + 127);
String hashes = HashCodes.getStringValue();
int pos = hashes.indexOf(tHash, 0);
int found = 0;
boolean more = (pos != -1);
while (more) {
    if (Labels[pos].getStringValue().equals(target)) {
        found = pos + 1;                          // recipe numbers start at 1
        more = false;
    } else {
        pos = hashes.indexOf(tHash, pos + 1);
        more = (pos != -1);
    }
}
Result.write(found);

Worked example with the arithmetic shown. Take the label ABCD. Java's String.hashCode() computes a 31-based polynomial over the character codes (A = 65, B = 66, C = 67, D = 68):

31³ × 65 + 31² × 66 + 31 × 67 + 68 = 1,936,415 + 63,426 + 2,077 + 68 = 2,001,986

Reduce it: 2,001,986 % 127 = 85, and 85 + 127 = 212, so character 212 sits at index N − 1 of HashCodes once recipe N is seeded. A search for ABCD recomputes 212. If indexOf() first lands on position 17 because a different label there also reduced to 212, equals() rejects it; the next call indexOf(tHash, 18) lands on position 41, equals() accepts Labels[41], and Result = 41 + 1 = 42. Writing 42 into RecipeNumber and 4 into Operation loads the recipe — the one load this structure exists to order.

The confirmation is not optional at this scale. Packing 100 labels into 253 possible characters gives an expected 100 × 99 / 2 / 253 ≈ 19.6 colliding pairs — call it 20 — so collisions are the normal case, and each one costs a single extra string compare. And never search the packed string with a substring: indexOf() returns the first occurrence, so searching for the text ABCD would also find ABCDEFGH. The packed string holds single characters by design, and the decision is always equals() on the full label.

Gate the search on Seeded reading 1, so a code arriving during the power-up pass is not answered from a half-filled table. If Result reads 0, no recipe carries that code: raise the operator message and order nothing.

How many recipes can the packed hash string handle? #

One hundred recipes in one group: the STRING type holds 100 characters at one per recipe, and that — not the recipe manager's per-group allowance — is what caps the method.

The seeding pass costs one recipe load per entry. A reported figure from a comparable operator panel: reading 500 recipe names at startup took about 15 seconds, roughly 30 ms per name, which puts 100 recipes at about 3 seconds. Treat that as a sizing estimate, not a specification.

Past 100, in order of preference: split the hash across several 100-character STRING variables and search them in turn, with each additional string adding 100 recipes; accept a script-loop scan over an Integer array of full hashCode() values; or move the recipes into the PLC. Labels longer than 32 characters only enlarge the mirror array's STRING size — the packed hash stays one character per recipe.

When should the recipes move into the PLC instead? #

Move the recipes into controller data when you pass 100 entries, when labels are maintained anywhere but the panel, or when a code can arrive during the power-up pass: the PLC searches its own table and hands the panel a number.

On that architecture the controller holds the recipes as plain data, runs the search itself, and writes the recipe number to a panel variable; the panel loads or merely displays it. You give up the HMI recipe manager's built-in edit and transfer screens, or rebuild them, and the change needs the customer's agreement because it moves storage off the panel.

The decision rule: at or under 100 recipes with labels edited at the panel, keep the packed-hash design on the HMI. Over 100 recipes, labels maintained offline, or a search that must answer during power-up — put the table in the PLC and keep the panel a display.

Questions asked

Does the label search disturb the recipe an operator is viewing?

Only at power-up and at the end of a successful search. The seeding pass loads recipes in order, so the panel's displayed recipe cycles once while the table fills; keep operators out of recipe editing until the Seeded flag reads 1. The search itself only reads internal variables, and the single load it triggers is the matched recipe, which is the load you wanted.

What happens when two labels produce the same hash character?

The equals() comparison settles it. Packing 100 labels into 253 possible characters makes collisions the normal case — about 20 colliding pairs are expected — so every indexOf() hit is tested against the full label before acceptance, and a collision costs one extra string compare. Dropping that confirmation is the one change that turns this into a wrong-recipe loader.

Can I send just one ingredient of the matched recipe to the controller?

No. In Vijeo Designer, a recipe that defines multiple ingredients transfers as a whole: you cannot send only one ingredient of a single recipe to the PLC. If a job needs partial transfers, split the data across separate recipes, or hold those values in plain variables the scripts write individually.

Do label changes made on the panel break the mirrored table?

Renames done at the panel refresh it. Saving a recipe is a recipe-manager operation, so the same Status event fires and the listener re-stores that entry with its new hash character. Edits downloaded from the engineering PC fire nothing at runtime: reboot the panel, or toggle BOOT by hand, to reseed once after a download.

Why not store the full 32-bit hashCode in an Integer array instead?

That variant works and is the simpler script: an Integer table filled with label.hashCode() values and scanned in a loop. A collision there is about one chance in 4 billion per label pair, so it is near-certain to be unique, but the scan is a script loop rather than one native call, and you still confirm hits with equals() because rare is not never.

Does the recipe object work over Webgate as well?

Only with data sharing closed. The documented condition for using the recipe object from Webgate is Data Sharing set to None on the _RecipeControlDefault variable, with the internal ingredient variables following the same rule. Test the listener and the search on that client before relying on them there.

Keep reading

  • Troubleshooting

    Displaying Negative Drive Values and Script Writes in Vijeo Designer

    The reverse readings failed because the Vijeo Designer variables were typed UINT, which cannot show a value below zero; set them to INT and the same drive words display negative. The script write is a separate fault: point the script's write at the setpoint variable the keypad uses, clamp the result to the drive's documented setpoint range, and verify the write on the connected panel, not in the simulator.

    HMI and touchscreens

  • Troubleshooting

    Vijeo Designer Limited Edition blocks HMI download

    A standalone Vijeo Designer 6.2 session shows Limited Edition because it has no Vijeo Designer license of its own, and that unlicensed session refuses the panel download. A licensed SoMachine 4.3 environment covers HMI modules inside its machine projects, so add the HMI there and download it from SoMachine; standalone-only HMI work needs a Vijeo Designer license.

    HMI and touchscreens

  • Troubleshooting

    Fixing a Vijeo Designer USB transfer filesystem path error

    The [HMIS] filesystem path error means the software resolved the wrong transfer destination, and the connection-abort line is only its consequence. Because the failure sits on one workstation, compare that PC's target selection, transfer method and installed version against a working one before touching the Runtime installer, and keep the two-to-three-times-slower USB-key route as a fallback.

    HMI and touchscreens