Appearance
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 controllergetValuesUsingOptimizer()uses theConfigurationOptimizerFileto 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;
}valueIdis currently only for informational purposesvalueIdHashcan be used if thevalueIndexis currently unknown and must be looked up firstvalueIndexis the index to access a certain value of the controller's menu parameterschangedValueis used to set the menu value of the controller if it is anumbercurrentValueis 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
getValuesUsingOptimizer(channel: number, address: number, file: ConfigurationOptimizerFile): Promise<ParameterizationValue[]>;
transceiveValues<T extends ParameterizationValue>(channel: number, address: number, values: T[]): Promise<T[]>;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
}
]