@citrineos/base
Version:
The base module for OCPP v2.0.1 including all interfaces. This module is not intended to be used directly, but rather as a dependency for other modules.
91 lines (90 loc) • 3.01 kB
TypeScript
import { IMessageContext, OcppRequest, OcppResponse } from '../..';
import { CallAction, OCPPVersionType } from '../../ocpp/rpc/message';
import { EventGroup, MessageOrigin, MessageState } from '.';
/**
* Message
*
* The base interface for all messages traversing the system.
*
*/
export interface IMessage<T extends OcppRequest | OcppResponse> {
/**
* The event group of the source module
*/
get origin(): MessageOrigin;
set origin(value: MessageOrigin);
/**
* The event group of the target module
*/
get eventGroup(): EventGroup;
set eventGroup(value: EventGroup);
/**
* The event type (within the event group)
*/
get action(): CallAction;
set action(value: CallAction);
/**
* The message state representative of the roundtrip status
*/
get state(): MessageState;
set state(value: MessageState);
/**
* The context of the message (the module that sent the message)
*/
get context(): IMessageContext;
set context(value: IMessageContext);
/**
* The payload of the message (the data sent with the message)
*/
get payload(): T;
set payload(value: T);
/**
* The protocol of the message (ocpp1.6, ocpp2.0.1, etc)
*/
get protocol(): OCPPVersionType;
set protocol(value: OCPPVersionType);
}
/**
* Default implementation of IMessage
*/
export declare class Message<T extends OcppRequest | OcppResponse> implements IMessage<T> {
/**
* Fields
*/
protected _origin: MessageOrigin;
protected _eventGroup: EventGroup;
protected _action: CallAction;
protected _state: MessageState;
protected _context: IMessageContext;
protected _payload: T;
protected _protocol: OCPPVersionType;
/**
* Constructs a new instance of Message.
*
* @param {MessageOrigin} origin - The origin of the message.
* @param {EventGroup} eventGroup - The event group of the message.
* @param {CallAction} action - The action of the message.
* @param {MessageState} state - The state of the message.
* @param {IMessageContext} context - The context of the message.
* @param {T} payload - The payload of the message.
* @param {OCPPVersionType} [protocol] - The protocol of the message, example "ocpp1.6".
*/
constructor(origin: MessageOrigin, eventGroup: EventGroup, action: CallAction, state: MessageState, context: IMessageContext, payload: T, protocol: OCPPVersionType);
/**
* Getter & Setter
*/
get origin(): MessageOrigin;
get eventGroup(): EventGroup;
get action(): CallAction;
get state(): MessageState;
get context(): IMessageContext;
get payload(): T;
get protocol(): OCPPVersionType;
set origin(value: MessageOrigin);
set eventGroup(value: EventGroup);
set action(value: CallAction);
set state(value: MessageState);
set context(value: IMessageContext);
set payload(value: T);
set protocol(value: OCPPVersionType);
}