import { VantPro2Interface, VantVueInterface } from "vantjs/interfaces"; import RecorderSettings from "./settings/RecorderSettings"; import MinimumRecorderSettings, { MinimumCurrentConditionsTaskSettings } from "./settings/MinimumRecorderSettings"; import { DeepReadonly } from "ts-essentials"; /** * The recorder is the counter-part to the `startVantageAPI()` function. * It repeatedly sends weather data to a running vant-api instance via _HTTP requests_. * * To get the weather data is utilizes a {@link VantPro2Interface} or a {@link VantVueInterface}. * Only works on Vantage Pro 2 and Vue (having firmware dated after April 24, 2002 / v1.90 or above). * * The recorder is structured in multiple _tasks_ which are responsibly for different kinds of weather data. * Currently there are following tasks: * - **Current Conditions**: Uploads rich realtime data very often (configurable, default: every `1s`) [route: `api/v1/current`] * * To create a recorder write: * ```ts * const recorder = await Recorder.create(...); * ``` * * To configure the current conditions task write: * ```ts * recorder.configureCurrentConditionsTask(...); * ``` * * To start the recorder write: * ```ts * recorder.start(); * ``` */ declare class Recorder { readonly settings: DeepReadonly; readonly interface: VantVueInterface | VantPro2Interface; private currentConditionsTaskSettings?; private realtimeRecorderTimeout?; private running; private constructor(); /** * Creates a new recorder with the passed settings. Throws an {@link InvalidRecorderConfigurationError} if the settings are invalid. * * It is also possible to configure your recorder using a `.env` file. To enable this feature pass `useEnvironmentVariables: true`. * * **Example**: * ```ts * // create recorder * const recorder = await Recorder.create({ * path: "COM5", * api: "http://localhost:8000/api", * rainCollectorSize: "0.2mm", * model: "Pro2", * .... * }); * * // configure realtime recordings * recorder.configureRealtimeRecording({ interval: 10 }); * * // start recorder * recorder.start(); * ``` * @param settings * @returns a recorder instance * @throws {@link InvalidRecorderConfigurationError} if the settings are invalid */ static create: (recorderSettings: MinimumRecorderSettings) => Promise; private static createDeviceInterface; private static loadEnvironmentVariablesAndConfigureLogger; private static validateSettings; /** * Configures the current conditions task. This is related to the `/api/v1/current` route. * Pass your desired settings to configure and enable the task, pass `false` to disable it. * * It is also possible to configure your recorder using a `.env` file. To enable this feature pass `useEnvironmentVariables: true`. * * To start all your configured tasks run `start()`. * @param settings * @throws {@link InvalidRecorderConfigurationError} if the settings are invalid */ configureCurrentConditionsTask: (settings: MinimumCurrentConditionsTaskSettings | false) => void; /** * Return whether the current conditions task is configured. * @returns whether the current conditions task is configured */ currentConditionsConfigured: () => boolean; /** * Return the set up current conditions task's interval. * @returns the set up current conditions task's interval */ currentConditionsInterval: () => number | undefined; /** Starts the recorder. Tasks that have * been configured using `configure*Task(...)` will be started. * * Does nothing if the recorder already has been started. */ start: () => void; /** Stops the recorder. Clears all currently running recording tasks. * * Does nothing if the recorder already has been stopped. */ stop: () => void; /** * Restarts the recorder. Useful if you changed the recorder's settings while it was already running. */ restart: () => void; /** * Updates the current conditions. * This is done by getting a rich realtime data package using the interface and sending it to the api using a `POST` request. * @hidden */ protected updateCurrentConditions: () => Promise; } export default Recorder;