1/* 2schedulerState.mjs - Module to pipe out various parameters from the scheduler for global consumption 3Copyright (C) 2026 Strudel contributors - see <https://codeberg.org/uzu/strudel/src/branch/main/packages/core/schedulerState.mjs> 4This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. 5*/ 6 7let time; 8let cpsFunc; 9let pattern; 10let triggerFunc; 11let isStarted; 12export function getTime() { 13 if (!time) { 14 throw new Error('no time set! use setTime to define a time source'); 15 } 16 return time(); 17} 18 19export function setTime(func) { 20 time = func; 21} 22 23export function setCpsFunc(func) { 24 cpsFunc = func; 25} 26 27export function getCps() { 28 return cpsFunc?.(); 29} 30 31export function setPattern(pat) { 32 pattern = pat; 33} 34 35export function getPattern() { 36 return pattern; 37} 38 39export function setTriggerFunc(func) { 40 triggerFunc = func; 41} 42 43export function getTriggerFunc() { 44 return triggerFunc; 45} 46 47export function setIsStarted(val) { 48 isStarted = !!val; 49} 50 51export function getIsStarted() { 52 return isStarted; 53}