UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

215 lines (214 loc) 9.17 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LocalCarSwitches = exports.LocalCarLights = exports.SENDABLE_SMALL_TYPES = exports.SmallType = exports.IS_SMALL = void 0; var decorators_1 = require("../decorators"); var base_1 = require("./base"); var enums_1 = require("./enums"); /** * General purpose 8 byte packet */ var IS_SMALL = /** @class */ (function (_super) { __extends(IS_SMALL, _super); function IS_SMALL(data) { var _this = _super.call(this) || this; _this.Size = 8; _this.Type = enums_1.PacketType.ISP_SMALL; /** 0 unless it is an info request or a reply to an info request */ _this.ReqI = 0; /** Subtype */ _this.SubT = SmallType.SMALL_NONE; /** Value (e.g. for {@link SMALL_SSP} this would be the OutSim packet rate) */ _this.UVal = 0; _this.initialize(data); return _this; } /** Stop sending positions */ IS_SMALL.SSP_STOP_SENDING = 0; /** Stop sending gauges */ IS_SMALL.SSG_STOP_SENDING = 0; /** Stop time */ IS_SMALL.TMS_STOP = 1; /** Start time */ IS_SMALL.TMS_CONTINUE = 0; /** Stop sending {@link IS_NLP} or {@link IS_MCI} packets */ IS_SMALL.NLI_STOP = 0; __decorate([ (0, decorators_1.byte)() ], IS_SMALL.prototype, "Size", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SMALL.prototype, "Type", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SMALL.prototype, "ReqI", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SMALL.prototype, "SubT", void 0); __decorate([ (0, decorators_1.unsigned)() ], IS_SMALL.prototype, "UVal", void 0); return IS_SMALL; }(base_1.SendablePacket)); exports.IS_SMALL = IS_SMALL; var SmallType; (function (SmallType) { /** Not used */ SmallType[SmallType["SMALL_NONE"] = 0] = "SMALL_NONE"; /** Instruction: start sending positions */ SmallType[SmallType["SMALL_SSP"] = 1] = "SMALL_SSP"; /** Instruction: start sending gauges */ SmallType[SmallType["SMALL_SSG"] = 2] = "SMALL_SSG"; /** Report: vote action */ SmallType[SmallType["SMALL_VTA"] = 3] = "SMALL_VTA"; /** Instruction: time stop */ SmallType[SmallType["SMALL_TMS"] = 4] = "SMALL_TMS"; /** Instruction: time step */ SmallType[SmallType["SMALL_STP"] = 5] = "SMALL_STP"; /** Info: race time packet (reply to {@link TINY_GTM}) */ SmallType[SmallType["SMALL_RTP"] = 6] = "SMALL_RTP"; /** Instruction: set node lap interval */ SmallType[SmallType["SMALL_NLI"] = 7] = "SMALL_NLI"; /** Both ways: set or get allowed cars ({@link TINY_ALC}) */ SmallType[SmallType["SMALL_ALC"] = 8] = "SMALL_ALC"; /** Instruction: set local car switches (flash, horn, siren) */ SmallType[SmallType["SMALL_LCS"] = 9] = "SMALL_LCS"; /** Instruction: set local car lights */ SmallType[SmallType["SMALL_LCL"] = 10] = "SMALL_LCL"; /** Info: Get local AI info */ SmallType[SmallType["SMALL_AII"] = 11] = "SMALL_AII"; })(SmallType || (exports.SmallType = SmallType = {})); exports.SENDABLE_SMALL_TYPES = [ 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, ]; var LCL_SET_SIGNALS = 1; var LCL_SET_LIGHTS = 4; var LCL_SET_FOG_REAR = 16; var LCL_SET_FOG_FRONT = 32; var LCL_SET_EXTRA = 64; var LocalCarLights; (function (LocalCarLights) { /** Turn all signals off */ LocalCarLights[LocalCarLights["SIGNALS_OFF"] = 1] = "SIGNALS_OFF"; /** Turn left signals on */ LocalCarLights[LocalCarLights["SIGNALS_LEFT"] = 65537] = "SIGNALS_LEFT"; /** Turn right signals on */ LocalCarLights[LocalCarLights["SIGNALS_RIGHT"] = 131073] = "SIGNALS_RIGHT"; /** Turn hazards on */ LocalCarLights[LocalCarLights["SIGNALS_HAZARD"] = 196609] = "SIGNALS_HAZARD"; /** Turn lights off */ LocalCarLights[LocalCarLights["LIGHTS_OFF"] = 4] = "LIGHTS_OFF"; /** Turn side lights on */ LocalCarLights[LocalCarLights["LIGHTS_SIDE"] = 262148] = "LIGHTS_SIDE"; /** Turn low beam on */ LocalCarLights[LocalCarLights["LIGHTS_LOW"] = 524292] = "LIGHTS_LOW"; /** Turn high beam on */ LocalCarLights[LocalCarLights["LIGHTS_HIGH"] = 786436] = "LIGHTS_HIGH"; /** Turn rear fog light off */ LocalCarLights[LocalCarLights["FOG_REAR_OFF"] = 16] = "FOG_REAR_OFF"; /** Turn rear fog light on */ LocalCarLights[LocalCarLights["FOG_REAR"] = 1048592] = "FOG_REAR"; /** Turn front fog light off */ LocalCarLights[LocalCarLights["FOG_FRONT_OFF"] = 32] = "FOG_FRONT_OFF"; /** Turn front fog light on */ LocalCarLights[LocalCarLights["FOG_FRONT"] = 2097184] = "FOG_FRONT"; /** Turn extra light off */ LocalCarLights[LocalCarLights["EXTRA_OFF"] = 64] = "EXTRA_OFF"; /** Turn extra light on */ LocalCarLights[LocalCarLights["EXTRA"] = 4194368] = "EXTRA"; })(LocalCarLights || (exports.LocalCarLights = LocalCarLights = {})); var LCS_SET_SIGNALS = 1; var LCS_SET_FLASH = 2; var LCS_SET_HEADLIGHTS = 4; var LCS_SET_HORN = 8; var LCS_SET_SIREN = 16; var LocalCarSwitches; (function (LocalCarSwitches) { /** * Turn all signals off * * @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.SIGNALS_OFF} */ LocalCarSwitches[LocalCarSwitches["SIGNALS_OFF"] = 1] = "SIGNALS_OFF"; /** * Turn left signals on * * @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.SIGNALS_LEFT} */ LocalCarSwitches[LocalCarSwitches["SIGNALS_LEFT"] = 257] = "SIGNALS_LEFT"; /** * Turn right signals on * * @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.SIGNALS_RIGHT} */ LocalCarSwitches[LocalCarSwitches["SIGNALS_RIGHT"] = 513] = "SIGNALS_RIGHT"; /** * Turn hazards on * * @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.SIGNALS_HAZARD} */ LocalCarSwitches[LocalCarSwitches["SIGNALS_HAZARD"] = 769] = "SIGNALS_HAZARD"; /** Stop flashing lights */ LocalCarSwitches[LocalCarSwitches["FLASH_OFF"] = 2] = "FLASH_OFF"; /** Start flashing lights */ LocalCarSwitches[LocalCarSwitches["FLASH_ON"] = 1026] = "FLASH_ON"; /** * Turn headlights off * * @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.LIGHTS_OFF} */ LocalCarSwitches[LocalCarSwitches["HEADLIGHTS_OFF"] = 4] = "HEADLIGHTS_OFF"; /** * Turn headlights on * * @deprecated Use {@link SMALL_LCL} with {@link LocalCarLights.LIGHTS_SIDE}, {@link LocalCarLights.LIGHTS_LOW} or * {@link LocalCarLights.LIGHTS_HIGH} */ LocalCarSwitches[LocalCarSwitches["HEADLIGHTS_ON"] = 2052] = "HEADLIGHTS_ON"; /** Turn horn off */ LocalCarSwitches[LocalCarSwitches["HORN_OFF"] = 8] = "HORN_OFF"; /** Turn on horn sound 1 */ LocalCarSwitches[LocalCarSwitches["HORN_1"] = 65544] = "HORN_1"; /** Turn on horn sound 2 */ LocalCarSwitches[LocalCarSwitches["HORN_2"] = 131080] = "HORN_2"; /** Turn on horn sound 3 */ LocalCarSwitches[LocalCarSwitches["HORN_3"] = 196616] = "HORN_3"; /** Turn on horn sound 4 */ LocalCarSwitches[LocalCarSwitches["HORN_4"] = 262152] = "HORN_4"; /** Turn on horn sound 5 */ LocalCarSwitches[LocalCarSwitches["HORN_5"] = 327688] = "HORN_5"; /** Turn siren off */ LocalCarSwitches[LocalCarSwitches["SIREN_OFF"] = 16] = "SIREN_OFF"; /** Turn fast siren on */ LocalCarSwitches[LocalCarSwitches["SIREN_FAST"] = 1048592] = "SIREN_FAST"; /** Turn slow siren on */ LocalCarSwitches[LocalCarSwitches["SIREN_SLOW"] = 2097168] = "SIREN_SLOW"; })(LocalCarSwitches || (exports.LocalCarSwitches = LocalCarSwitches = {}));