Skip to content

parameterization

A script providing helper functions to get and set controller menu values.

Description

Parameterization involves multiple steps that are described in the VBus Parameterization guide. This script aims to provide an easy service to perform those steps.

It provides two functions on its service:

  • transceiveValues() reads and writes the provided list of values from a given controller
  • getValuesUsingOptimizer() uses the ConfigurationOptimizerFile to determine a list of necessary values to then read out and return back to caller

Both functions work with a Value type that looks like this:

typescript
interface ValueInfo {
  valueId?: string | null;
  valueIdHash?: number | null;
  valueIndex?: number | null;
}

interface Value extends ValueInfo {
  changedValue?: number | null;
  currentValue?: number | null;
}
  • valueId is currently only for informational purposes
  • valueIdHash can be used if the valueIndex is currently unknown and must be looked up first
  • valueIndex is the index to access a certain value of the controller's menu parameters
  • changedValue is used to set the menu value of the controller if it is a number
  • currentValue is set to the read out current value after the functions finished

If changedValue is a number, it will be written to the controller and set to null afterwards.

Service

typescript
transceiveValues<T extends Value>(channel: number, address: number, values: T[]): Promise<T[]>;
getValuesUsingOptimizer(channel: number, address: number, file: ConfigurationOptimizerFile): Promise<Value[]>;

transceiveValues()

Reads and writes a list of values from/to a specific controller.

getValuesUsingOptimizer()

Reads all necessary values from a controller, using its configuration optimizer file.

Example

Config:

typescript
export default defineConfig({
  connections: [{
    kind: 'serialPort',
    path: '/dev/tty.usbmodem',
  }],
  scripts: [
    import('../scripts/parameterization'),

    defineScript(async ($) => {
      const parameterizationScript = await import('../scripts/parameterization');
      const parameterizationService = await parameterizationScript.default.requireService();

      await $.connect();

      const values = [{
        valueId: 'Systemdatum',
        valueIdHash: 0x6C0D9AE0,
        // valueIndex: null,
        changedValue: Math.round(Date.now() / 1000 - 978307200), // calculate current date/time
      }];

      await parameterizationService.transceiveValues(0, 0x1911, values);

      console.log(values);
    }),
  ],
});

Run it in the toolbox:

❯ bin/resol-vbus-core-toolbox.ts --config configs/above-config-saved-to-file.ts
[
  {
    valueId: 'Systemdatum',
    valueIdHash: 1812830944,
    changedValue: null,
    valueIndex: 78,
    currentValue: 766347420
  }
]