Time Pattern Functions
These functions are used for working with time patterns.
| Function | Description |
|---|---|
addPattern | Adds a new time pattern to a project. |
deletePattern | Deletes a time pattern from a project. |
getPatternIndex | Retrieves the index of a time pattern given its ID name. |
getPatternId | Retrieves the ID name of a time pattern given its index. |
setPatternId | Changes the ID name of a time pattern given its index. |
getPatternLength | Retrieves the number of time periods in a time pattern. |
getPatternValue | Retrieves a time pattern’s factor for a given time period. |
setPatternValue | Sets a time pattern’s factor for a given time period. |
getAveragePatternValue | Retrieves the average of all pattern factors in a time pattern. |
setPattern | Sets the pattern factors for a given time pattern. |
addPattern
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
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
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
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
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
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
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
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
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
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.