Skip to content

The Code Templates Page

The Code Templates page of the Driver Settings Editor manages a driver’s code template set. The page is the same for all three driver types, except that an IVI-C driver’s templates are for functions and attributes rather than methods and properties. An IVI.NET driver with a linked IVI-C driver has both; see Linked IVI-C drivers.

The page has two tabs:

  • Driver’s current set shows the driver’s own set, chooses its default templates, and creates, removes, or shares it.
  • Machine catalog shows the sets in the machine catalog, and switches the driver to one of them.

Both tabs show a set the same way. Its templates are listed on the left, with these columns:

ColumnMeaning
NameThe template’s name.
Applies toThe kind of member the template is for: Method or Property, or for IVI-C, Function or Attribute.
PreambleStandard when the template keeps Nimbus’s standard preamble, and None when it supplies the whole body. See The preamble setting.

To the right of the list, a preview shows the selected template inside a complete member, written by Nimbus’s own code generator with the driver’s real names. The member is a stand-in, never added to the driver: a method or function named ConfigureMeasurement with no parameters, or a read/write double property named Frequency (for IVI-C, a ViReal64 attribute named FREQUENCY). The template’s description heads the member as a comment. When the template keeps the standard preamble, the preview shows the preamble Nimbus writes, followed by the template’s text. A property or attribute template shows both accessors. The preview is read-only.

The page watches both the driver’s set and the machine catalog. A change to a manifest or template file, whether made in Visual Studio or elsewhere, shows on the page as soon as the file is saved.

If a set’s manifest.yaml file has an error, the error, with its file and line number, takes the place of the list, along with an Open manifest.yaml link to fix it. See What the manifest may contain.

This tab shows the set in the driver project’s CodeTemplateSet folder. A driver with no set shows the message “This driver has no code template set. Create a new one, or switch to one from the machine catalog.”

Default for methods and Default for properties (for IVI-C, Default for functions and Default for attributes) choose the template new members of each kind are created with. Each offers None and the set’s templates of that kind. Choosing one rewrites the default values in the driver’s manifest.yaml file, so the manifest remains the only record of the defaults. A new default affects only the members created afterward. Existing members are never changed. The defaults cannot be changed while the manifest has an error.

Double-clicking a template opens its file, or both of a property’s or attribute’s files, in the Visual Studio editor.

The Save to Machine Catalog… button publishes the driver’s set to the machine catalog, so that other drivers can use it.

  1. Click Save to Machine Catalog….

  2. In Set name, enter the name of the set in the machine catalog. The dialog lists the Sets on this machine and the Machine catalog folder.

    A set name cannot contain any of the characters \ / : * ? " < > |, cannot start or end with a space, and cannot end with a period.

  3. Click OK.

The driver’s set, default templates included, is copied into the machine catalog as the set’s part for the driver’s type:

  • If there is no set with that name, it is created with just this part.
  • If the set exists but has no part for the driver’s type, the part is added.
  • If the set already has a part for the driver’s type, a confirmation asks whether to replace it. This is how changes to a set are published.

A name that differs from an existing set’s only in case saves to that set. Nothing in the driver changes.

The Create New… button writes a working starter set into the driver’s CodeTemplateSet folder and adds its files to the driver project. It never writes to the machine catalog.

The starter set has a template for each member kind, each marked as the default, so editing the templates changes what the next new member gets. Their bodies report that the member is not implemented, like Nimbus’s own stubs, and they keep the standard preamble, so the set changes nothing until it is edited. See Template Set Format for what the files contain.

The Remove… button deletes the driver’s CodeTemplateSet folder and removes its files from the driver project. New members then get Nimbus’s usual code. Existing members are not changed.

This tab shows the sets in the machine catalog.

Location is the machine catalog’s folder, <ProgramData>\Pacific MindWorks\Nimbus\<version>\CodeTemplates. Clicking it opens the folder in Windows Explorer, creating the folder first if nothing has been saved to it yet, so that sets can also be copied into it by hand.

Template set lists the sets in the catalog that have a part for the driver’s type, or “(none available)” when there are none. The chosen set is shown read-only, so that it can be looked through before switching to it.

The Switch to this set… button copies the chosen set’s part for the driver’s type into the driver’s CodeTemplateSet folder, replacing the driver’s set, and shows the Driver’s current set tab. The set’s default templates become the driver’s defaults. A set whose manifest has an error cannot be switched to.

An IVI.NET driver with a linked IVI-C driver has two parts in its set: the IVI.NET part, in the IVI.NET driver project’s CodeTemplateSet folder, and the IVI-C part, in the IVI-C driver project’s. The page treats them as one set:

  • Driver’s current set lists the templates of both parts, and has four defaults: Default for methods, Default for properties, Default for functions, and Default for attributes. If either part’s manifest has an error, the error takes the place of the whole list, and Open manifest.yaml opens that part’s manifest.
  • Save to Machine Catalog… saves both parts under the one set name. A single confirmation names the parts the set already has, for example “IVI.NET and IVI-C”.
  • Create New… writes a starter part into each driver project, and Remove… deletes both parts.
  • Machine catalog lists the sets that have an IVI.NET part, and shows the chosen set’s IVI.NET and IVI-C parts together.
  • Switch to this set… replaces each part with the chosen set’s part of the same type. If the chosen set has no IVI-C part, the IVI-C driver’s part is removed.

See Linked IVI-C drivers for how the parts are used.