node-insim
Version:
An InSim library for NodeJS with TypeScript support
217 lines (216 loc) • 6.75 kB
TypeScript
import { SendablePacket } from './base';
import type { CarFlags } from './enums';
import { PacketType } from './enums';
/**
* General purpose 8 byte packet
*/
export declare class IS_SMALL extends SendablePacket {
/** Stop sending positions */
static readonly SSP_STOP_SENDING = 0;
/** Stop sending gauges */
static readonly SSG_STOP_SENDING = 0;
/** Stop time */
static readonly TMS_STOP = 1;
/** Start time */
static readonly TMS_CONTINUE = 0;
/** Stop sending {@link IS_NLP} or {@link IS_MCI} packets */
static readonly NLI_STOP = 0;
readonly Size = 8;
readonly Type = PacketType.ISP_SMALL;
/** 0 unless it is an info request or a reply to an info request */
ReqI: number;
/** Subtype */
SubT: SmallType;
/** Value (e.g. for {@link SMALL_SSP} this would be the OutSim packet rate) */
UVal: number;
constructor(data?: IS_SMALL_Data);
}
export declare enum SmallType {
/** Not used */
SMALL_NONE = 0,
/** Instruction: start sending positions */
SMALL_SSP = 1,
/** Instruction: start sending gauges */
SMALL_SSG = 2,
/** Report: vote action */
SMALL_VTA = 3,
/** Instruction: time stop */
SMALL_TMS = 4,
/** Instruction: time step */
SMALL_STP = 5,
/** Info: race time packet (reply to {@link TINY_GTM}) */
SMALL_RTP = 6,
/** Instruction: set node lap interval */
SMALL_NLI = 7,
/** Both ways: set or get allowed cars ({@link TINY_ALC}) */
SMALL_ALC = 8,
/** Instruction: set local car switches (flash, horn, siren) */
SMALL_LCS = 9,
/** Instruction: set local car lights */
SMALL_LCL = 10,
/** Info: Get local AI info */
SMALL_AII = 11
}
export type IS_SMALL_Data = SMALL_SSP_Data | SMALL_SSG_Data | SMALL_TMS_Data | SMALL_STP_Data | SMALL_NLI_Data | SMALL_ALC_Data | SMALL_LCS_Data | SMALL_LCL_Data | SMALL_AII_Data;
type SMALL_SSP_Data = Data<{
ReqI?: never;
/** Instruction: start sending car positions via OutSim */
SubT: SmallType.SMALL_SSP;
/** Time between updates in milliseconds - zero means stop sending */
UVal: number | typeof IS_SMALL.SSP_STOP_SENDING;
}>;
type SMALL_SSG_Data = Data<{
ReqI?: never;
/** Instruction: start sending gauges */
SubT: SmallType.SMALL_SSG;
/** Time between updates in milliseconds - zero means stop sending */
UVal: number | typeof IS_SMALL.SSG_STOP_SENDING;
}>;
type SMALL_TMS_Data = Data<{
ReqI?: never;
/** Instruction: time stop */
SubT: SmallType.SMALL_TMS;
/** 1 - stop / 0 - carry on */
UVal: typeof IS_SMALL.TMS_STOP | typeof IS_SMALL.TMS_CONTINUE;
}>;
type SMALL_STP_Data = Data<{
ReqI?: never;
/** Instruction: time step */
SubT: SmallType.SMALL_STP;
/** Number of milliseconds to update */
UVal: number;
}>;
type SMALL_NLI_Data = Data<{
ReqI?: never;
/** Instruction: set the rate of {@link IS_NLP} or {@link IS_MCI} after initialization */
SubT: SmallType.SMALL_NLI;
/** 0 means stop, otherwise time interval: 40, 50, 60... 8000 ms */
UVal: number | typeof IS_SMALL.NLI_STOP;
}>;
type SMALL_ALC_Data = Data<{
ReqI?: never;
/** Instruction: set allowed cars on the host (like /cars command) */
SubT: SmallType.SMALL_ALC;
/** Allowed cars */
UVal: CarFlags;
}>;
type SMALL_LCS_Data = Data<{
ReqI?: never;
/** Instruction: set local car switches (flash, horn, siren) */
SubT: SmallType.SMALL_LCS;
/** Switches */
UVal: LocalCarSwitches;
}>;
type SMALL_LCL_Data = Data<{
ReqI?: never;
/** Instruction: set local car lights */
SubT: SmallType.SMALL_LCL;
/** Switches */
UVal: LocalCarLights;
}>;
type SMALL_AII_Data = Data<{
ReqI: number;
/** Info: Get local AI info */
SubT: SmallType.SMALL_AII;
/** PLID to receive current information about a local car */
UVal: number;
}>;
type Data<TData extends {
ReqI?: number;
SubT: SendableSmallType;
UVal: number;
}> = TData;
export declare const SENDABLE_SMALL_TYPES: readonly [SmallType.SMALL_SSP, SmallType.SMALL_SSG, SmallType.SMALL_TMS, SmallType.SMALL_STP, SmallType.SMALL_NLI, SmallType.SMALL_ALC, SmallType.SMALL_LCS, SmallType.SMALL_LCL, SmallType.SMALL_AII];
export type SendableSmallType = (typeof SENDABLE_SMALL_TYPES)[number];
export declare enum LocalCarLights {
/** Turn all signals off */
SIGNALS_OFF = 1,
/** Turn left signals on */
SIGNALS_LEFT = 65537,
/** Turn right signals on */
SIGNALS_RIGHT = 131073,
/** Turn hazards on */
SIGNALS_HAZARD = 196609,
/** Turn lights off */
LIGHTS_OFF = 4,
/** Turn side lights on */
LIGHTS_SIDE = 262148,
/** Turn low beam on */
LIGHTS_LOW = 524292,
/** Turn high beam on */
LIGHTS_HIGH = 786436,
/** Turn rear fog light off */
FOG_REAR_OFF = 16,
/** Turn rear fog light on */
FOG_REAR = 1048592,
/** Turn front fog light off */
FOG_FRONT_OFF = 32,
/** Turn front fog light on */
FOG_FRONT = 2097184,
/** Turn extra light off */
EXTRA_OFF = 64,
/** Turn extra light on */
EXTRA = 4194368
}
export declare enum LocalCarSwitches {
/**
* Turn all signals off
*
* @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.SIGNALS_OFF}
*/
SIGNALS_OFF = 1,
/**
* Turn left signals on
*
* @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.SIGNALS_LEFT}
*/
SIGNALS_LEFT = 257,
/**
* Turn right signals on
*
* @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.SIGNALS_RIGHT}
*/
SIGNALS_RIGHT = 513,
/**
* Turn hazards on
*
* @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.SIGNALS_HAZARD}
*/
SIGNALS_HAZARD = 769,
/** Stop flashing lights */
FLASH_OFF = 2,
/** Start flashing lights */
FLASH_ON = 1026,
/**
* Turn headlights off
*
* @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.LIGHTS_OFF}
*/
HEADLIGHTS_OFF = 4,
/**
* Turn headlights on
*
* @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.LIGHTS_SIDE}, {@link LocalCarLights.LIGHTS_LOW} or
* {@link LocalCarLights.LIGHTS_HIGH}
*/
HEADLIGHTS_ON = 2052,
/** Turn horn off */
HORN_OFF = 8,
/** Turn on horn sound 1 */
HORN_1 = 65544,
/** Turn on horn sound 2 */
HORN_2 = 131080,
/** Turn on horn sound 3 */
HORN_3 = 196616,
/** Turn on horn sound 4 */
HORN_4 = 262152,
/** Turn on horn sound 5 */
HORN_5 = 327688,
/** Turn siren off */
SIREN_OFF = 16,
/** Turn fast siren on */
SIREN_FAST = 1048592,
/** Turn slow siren on */
SIREN_SLOW = 2097168
}
export {};