@corvina/device-client
Version:
Corvina NodeJS Device Client
91 lines • 3.48 kB
TypeScript
import { PacketFormatEnum } from "./../common/types";
import LicensesAxiosInstance, { LicenseData } from "./licensesaxiosinstance";
import { MqttClient } from "mqtt";
import { TagDesc, AlarmDesc, DataPoint, AlarmData } from "../common/types";
import CorvinaDataInterface from "./corvinadatainterface";
import { InternalMessageSenderOptions, MessageSenderOptions } from "./messagesender";
import { MessageSubscriber } from "./messagesubscriber";
import { EventEmitter } from "stream";
import levelStore from "mqtt-level-store";
export { PostCallback } from "./corvinadatainterface";
export interface DeviceConfig {
activationKey?: string;
pairingEndpoint?: string;
availableTagsFile?: string;
availableTags?: Map<string, TagDesc>;
dynamicTags?: Map<string, TagDesc>;
simulateTags?: boolean;
availableAlarmsFile?: string;
availableAlarms?: Map<string, AlarmDesc>;
simulateAlarms?: boolean;
packetFormat?: PacketFormatEnum;
}
export interface DeviceStatus {
msgSent: number;
bytesSent: number;
inited: boolean;
connected: boolean;
ready: boolean;
}
export declare class DeviceService extends EventEmitter {
protected inited: boolean;
protected initPending: Promise<boolean>;
protected readyToTransmit: boolean;
protected licenseData: LicenseData;
protected mqttClient: MqttClient;
protected msgSentStats: number;
protected byteSentStats: number;
protected lastDateStats: number;
protected lastTriedBrokerEndpoint: number;
protected empyCacheTopic: string;
protected introspectionTopic: string;
protected static baseIntrospection: string;
protected customIntrospections: string;
protected applyConfigTopic: string;
protected consumerPropertiesTopic: string;
protected actionAlarmTopic: string;
protected configTopic: string;
protected availableTagsTopic: string;
protected lastConfig: string;
protected _deviceConfig: DeviceConfig;
protected axios: LicensesAxiosInstance;
protected dataInterface: CorvinaDataInterface;
protected messageStore: levelStore;
protected defaultQoS: number;
constructor();
get status(): DeviceStatus;
get deviceConfig(): DeviceConfig;
getMsgSent(): number;
getBytesSent(): number;
getAppliedConfig(): DeviceConfig;
getDeviceConfig(): DeviceConfig;
getLicenseData(): LicenseData;
setCycleTime(cycleTime: number): void;
reinit(deviceConfig: DeviceConfig, doInit?: boolean): DeviceConfig;
isInited(): boolean;
isReady(): boolean;
isConnected(): boolean;
private setReady;
private createCSR;
applyConfig(config: any): Promise<void>;
private serializeMessage;
private getCA;
private connectClient;
private subscribeChannel;
sendStringMessage(channel: string, message: string, options?: any): Promise<any>;
sendMessage(topic: string, payload: {
t: number;
v: unknown;
}, options?: InternalMessageSenderOptions): Promise<any>;
private _asyncInit;
private init;
private throttledUpdateAvailableTags;
private jsToCorvinaType;
private applyBackToSimulation;
private recurseNotifyObject;
post(dataPoints: Array<DataPoint>, options?: MessageSenderOptions): Promise<boolean>;
private _internalPost;
postAlarm(alarmData: AlarmData): Promise<boolean>;
protected onWrite(subscriber: MessageSubscriber, message: any): void;
}
//# sourceMappingURL=device.service.d.ts.map