Sequence file format

From SweepMe! Wiki
Jump to navigation Jump to search

Available from SweepMe! 1.6.1.6. Before, measurement procedures were saved as settings (.set), see Sequences.

A sequence describes a complete measurement: the Sequencer tree with the configuration of all modules and drivers, the Dashboard widgets and the window layout. SweepMe! saves sequences as JSON files with the extension .seq. JSON is plain text, so you can open a sequence in a text editor, compare two versions, copy parts from one sequence to another, or let scripts and AI assistants create sequences (see Creating sequences with AI).

Saving, loading and compatibility

How to save and load sequences, where they are stored, and how they work together with SweepMe! 1.5 is described in Sequences. This page only covers the content of the file.

SweepMe! reads the file only when it is loaded. If you change the file in an editor, load it again.

Structure

A .seq file is a JSON object with these top-level keys:

Key Content
data_type Always "Sequence".
version Version of the file structure, currently "v1". This is not the SweepMe! version. It only changes if the structure changes, and SweepMe! refuses files with a structure version that it does not know.
sweepme_version SweepMe! version that wrote the file, e.g. "1.6.1.7". It is used for the version check when the file is loaded.
sequence The sequencer tree: an object with the list child_items.
widgets List of the Dashboard widgets with their settings. Each widget has a type (e.g. "Plot"), a label (e.g. "Plot1") and its own fields.
layout Window layout: main_window (window geometry, folder and file name for saving data, and more) and dashboard (arrangement of the Dashboard and the properties of each widget as set in the Widget Overview).

Tree

Each entry of child_items is a module of the sequencer:

Key Content
is_checked Whether the module is checked in the sequencer (true or false).
is_expanded Whether the module is expanded in the sequencer.
module_details The configuration of the module, see below.
child_items The modules nested below this module (child modules). Use an empty list [] for a module without children.

Modules in the same child_items list are siblings. Each sibling starts a new branch of the sequencer. The order in the list is the order in the sequencer. The invisible root module Time is not stored in the file.

Module configuration

module_details always contains:

  • module_type: the module, e.g. "Loop", "Calc" or "SMU".
  • Label: the name of the module in the sequencer, e.g. "Loop1".
  • value: the text in the column Value of the sequencer.

All other keys are the fields of the module. Their names are internal keys and not always the same as the labels in the user interface, e.g. Repetitions of the Loop module or Device, Port, SweepMode and Compliance of the SMU module. Typical values are:

  • text fields as strings, also for numbers, e.g. "Repetitions": "5",
  • check boxes as true or false,
  • selection boxes as the text of the selected item, e.g. "SweepMode": "Voltage in V",
  • the driver in Device with its name as shown in the Version manager, e.g. "SMU-Simulation_Diode",
  • nested objects for groups of settings, e.g. the driver specific fields in Parameters or the sweep editor in SweepEditor.

Example of a MakeFile module with a Calc module and a Loop module below it (shortened, some fields left out):

{
  "data_type": "Sequence",
  "version": "v1",
  "sweepme_version": "1.6.1.7",
  "sequence": {
    "child_items": [
      {
        "is_checked": true,
        "is_expanded": true,
        "module_details": {
          "module_type": "MakeFile",
          "Label": "MakeFile1",
          "value": "ID",
          "FileID": "ID"
        },
        "child_items": [
          {
            "is_checked": true,
            "is_expanded": true,
            "module_details": {
              "module_type": "Calc",
              "Label": "Calc1",
              "value": "",
              "Variable": "My Calc Parameter",
              "Unit": "some unit",
              "Function": "x1 * x1",
              "x1": "Loop1 Index"
            },
            "child_items": [
              {
                "is_checked": true,
                "is_expanded": true,
                "module_details": {
                  "module_type": "Loop",
                  "Label": "Loop1",
                  "value": "5",
                  "Repetitions": "5"
                },
                "child_items": []
              }
            ]
          }
        ]
      }
    ]
  },
  "widgets": [],
  "layout": {}
}

Copy and paste

Modules that you copy in the sequencer (Ctrl+C, see Copy&Paste modules) are JSON text with the same structure: an object with "data_type": "Sequencer" and a list child_items. To paste modules from a .seq file into the sequencer, put their entries into such an object, e.g. {"data_type": "Sequencer", "version": "v1", "child_items": [ ... ]}, copy it and paste it with Ctrl+V.

Editing sequences by hand or with tools

You can create or change .seq files with a text editor, a script or an AI assistant. Please consider:

  • Start from a sequence saved by SweepMe! The easiest way to learn the keys of a module is to configure the module in SweepMe!, save the sequence and look at the file. You can also load an example via Sequences → Load Example and save it as .seq.
  • Keep the header. Keep data_type, version and sweepme_version. The file cannot be loaded without sweepme_version, or if it names a newer SweepMe! version than the installed one.
  • Change the fields, not the value. The behavior of a module is defined by its fields, e.g. Repetitions of a Loop. The key value is only the text in the sequencer.
  • Use exact texts. Use the texts of selection boxes exactly as shown in SweepMe!, including units. Use driver names of drivers that are installed.
  • Use unique labels. Other modules refer to values by the label of the module, e.g. "x1": "Loop1 Index" in the Calc module above.
  • Missing fields get the default value of the module when the sequence is loaded. If a value has the wrong type, e.g. a number instead of a string, SweepMe! tries to convert it.
  • Valid JSON. Save the file as UTF-8. JSON does not allow comments or a comma after the last entry of a list.
  • Check before running. Load the sequence, check the sequencer and the fields of all modules, especially limits such as the compliance of a source, before you start a measurement.

If a file cannot be loaded, SweepMe! shows the reason, e.g. "is not valid JSON" with line and column, or "does not match the .seq schema" with up to five faulty entries.

As .seq files are text files, you can track their changes with a version control system such as git and compare two versions with any diff tool.

See also