Time Pattern Functions
These functions are used for working with time patterns.
| Function | Versions | Description |
|---|---|---|
addPattern | 2.2+ | Adds a new time pattern to a project. |
deletePattern | 2.2+ | Deletes a time pattern from a project. |
getPatternIndex | 2.2+ | Retrieves the index of a time pattern given its ID name. |
getPatternId | 2.2+ | Retrieves the ID name of a time pattern given its index. |
setPatternId | 2.2+ | Changes the ID name of a time pattern given its index. |
getPatternLength | 2.2+ | Retrieves the number of time periods in a time pattern. |
getPatternValue | 2.2+ | Retrieves a time pattern’s factor for a given time period. |
setPatternValue | 2.2+ | Sets a time pattern’s factor for a given time period. |
getAveragePatternValue | 2.2+ | Retrieves the average of all pattern factors in a time pattern. |
setPattern | 2.2+ | Sets the pattern factors for a given time pattern. |
loadPatternFile | 2.3+ | Loads time pattern factors from an external file. |
addPattern 2.2+
Section titled “addPattern ”Adds a new time pattern to a project.
addPattern(id: string): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | the ID name of the pattern to add. |
The new pattern contains a single time period whose factor is 1.0.
deletePattern 2.2+
Section titled “deletePattern ”Deletes a time pattern from a project.
deletePattern(index: number): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | the time pattern’s index (starting from 1). |
getPatternIndex 2.2+
Section titled “getPatternIndex ”Retrieves the index of a time pattern given its ID name.
getPatternIndex(id: string): number;Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | the ID name of a time pattern. |
Returns
Number
the time pattern’s index (starting from 1).
getPatternId 2.2+
Section titled “getPatternId ”Retrieves the ID name of a time pattern given its index.
getPatternId(index: number): string;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a time pattern index (starting from 1). |
Returns
string
the time pattern’s ID name.
setPatternId 2.2+
Section titled “setPatternId ”Changes the ID name of a time pattern given its index.
setPatternId(index: number, id: string): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a time pattern index (starting from 1). |
| id | string | the time pattern’s new ID name. |
getPatternLength 2.2+
Section titled “getPatternLength ”Retrieves the number of time periods in a time pattern.
getPatternLength(index: number): number;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a time pattern index (starting from 1). |
Returns
Number
the number of time periods in the pattern.
getPatternValue 2.2+
Section titled “getPatternValue ”Retrieves a time pattern’s factor for a given time period.
getPatternValue(index: number, period: number): number;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a time pattern index (starting from 1). |
| period | number | a time period in the pattern (starting from 1). |
Returns
Number
the pattern factor for the given time period.
setPatternValue 2.2+
Section titled “setPatternValue ”Sets a time pattern’s factor for a given time period.
setPatternValue(index: number, period: number, value: number): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a time pattern index (starting from 1). |
| period | number | a time period in the pattern (starting from 1). |
| value | number | the new value of the pattern factor for the given time period. |
getAveragePatternValue 2.2+
Section titled “getAveragePatternValue ”Retrieves the average of all pattern factors in a time pattern.
getAveragePatternValue(index: number): number;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a time pattern index (starting from 1). |
Returns
Number
The average of all of the time pattern’s factors.
setPattern 2.2+
Section titled “setPattern ”Sets the pattern factors for a given time pattern.
setPattern(index: number, values: number[]): void;Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | a time pattern index (starting from 1). |
| values | number[] | 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.
loadPatternFile 2.3+
Section titled “loadPatternFile ”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
| Parameter | Type | Description |
|---|---|---|
| filename | string | path of the pattern file (relative to the workspace virtual filesystem). |
| id | number | the index of the pattern to overwrite (starting from 1). |