Skip to content

Time Pattern Functions

These functions are used for working with time patterns.

FunctionVersionsDescription
addPattern2.2+Adds a new time pattern to a project.
deletePattern2.2+Deletes a time pattern from a project.
getPatternIndex2.2+Retrieves the index of a time pattern given its ID name.
getPatternId2.2+Retrieves the ID name of a time pattern given its index.
setPatternId2.2+Changes the ID name of a time pattern given its index.
getPatternLength2.2+Retrieves the number of time periods in a time pattern.
getPatternValue2.2+Retrieves a time pattern’s factor for a given time period.
setPatternValue2.2+Sets a time pattern’s factor for a given time period.
getAveragePatternValue2.2+Retrieves the average of all pattern factors in a time pattern.
setPattern2.2+Sets the pattern factors for a given time pattern.
loadPatternFile2.3+Loads time pattern factors from an external file.

Adds a new time pattern to a project.

addPattern(id: string): void;

Parameters

ParameterTypeDescription
idstringthe ID name of the pattern to add.

The new pattern contains a single time period whose factor is 1.0.


Deletes a time pattern from a project.

deletePattern(index: number): void;

Parameters

ParameterTypeDescription
indexnumberthe time pattern’s index (starting from 1).

Retrieves the index of a time pattern given its ID name.

getPatternIndex(id: string): number;

Parameters

ParameterTypeDescription
idstringthe ID name of a time pattern.

Returns

Number the time pattern’s index (starting from 1).


Retrieves the ID name of a time pattern given its index.

getPatternId(index: number): string;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).

Returns

string the time pattern’s ID name.


Changes the ID name of a time pattern given its index.

setPatternId(index: number, id: string): void;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).
idstringthe time pattern’s new ID name.

Retrieves the number of time periods in a time pattern.

getPatternLength(index: number): number;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).

Returns

Number the number of time periods in the pattern.


Retrieves a time pattern’s factor for a given time period.

getPatternValue(index: number, period: number): number;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).
periodnumbera time period in the pattern (starting from 1).

Returns

Number the pattern factor for the given time period.


Sets a time pattern’s factor for a given time period.

setPatternValue(index: number, period: number, value: number): void;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).
periodnumbera time period in the pattern (starting from 1).
valuenumberthe new value of the pattern factor for the given time period.

Retrieves the average of all pattern factors in a time pattern.

getAveragePatternValue(index: number): number;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).

Returns

Number The average of all of the time pattern’s factors.


Sets the pattern factors for a given time pattern.

setPattern(index: number, values: number[]): void;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).
valuesnumber[]an array of new pattern factor values.

Use this function to redefine (and resize) a time pattern all at once; use setPatternValue to revise pattern factors one at a time.


Replaces a pattern’s factors with the values read from an external text file written into the virtual filesystem.

loadPatternFile(filename: string, id: number): void;

Parameters

ParameterTypeDescription
filenamestringpath of the pattern file (relative to the workspace virtual filesystem).
idnumberthe index of the pattern to overwrite (starting from 1).