import drugCDMonitor from "./DrugCDMonitor";
import { Injectable } from "../../container/Injectable";
import ClassName from "../../container/ClassName";
import LocalConfigWrapper from "../LocalConfigWrapper";
import IntervalSwitch from "./IntervalSwitch";

export default interface IntervalType {
    handler: () => void
    switcher: (s: IntervalSwitch) => void
    getId: () => number
    setId: (id: number) => void
    getMs: () => number
    setMs: (ms: number) => void
}

export const intervalUnits: { [key: string]: IntervalType } = {
    drugCDMonitor,
}

@Injectable()
@ClassName('WHIntervalLoader')
export class WHIntervalLoader {
    constructor(
        private readonly localConfigWrapper: LocalConfigWrapper,
    ) {
    }

    init() {
        const list = this.localConfigWrapper.config.monitorOn
        for (let i = 0; i < list.length; i++) {
            intervalUnits[list[i]].switcher(IntervalSwitch.ON)
        }
    }
}
