Basic: Basic information

更新时间:
2024-05-15
下载文档

Basic: Basic information

This module is the vehicle basic information module. This module is provided in EdgerOS 2.0.0 and later, and apps need to have vehicle.cockpit permission to use this module.

User can use the following code to import the Basic module.

var Basic = require('vehicle/basic');

Support

The following shows Basic module APIs available for each permissions.

 User ModePrivilege Mode
Basic
basic.request
basic.release
basic.chassis
basic.vehicle
basic.geolocation
basic.suspension
chassis.info
chassis.drive
chassis.power
vehicle.status
vehicle.gear
vehicle.epb
vehicle.steering
geolocation.mode 
geolocation.location
suspension.airspring
suspension.cdc
suspension.style
suspension.status

Basic Class

new Basic()

  • Returns: {Object} Basic object.

Create a basic object.

Basic Object

basic.request(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when the request is failed.

Request for vehicle basic information acquire. After the request is successful, the vehicle basic information can be obtained.

basic.release()

Release the current basic object, no operation is allowed after the object is released.

The object needs to be released as soon as possible when it is no longer used.

basic.chassis

  • {Object}

Get basic chassis object.

basic.vehicle

  • {Object}

Get basic vehicle object.

basic.geolocation

  • {Object}

Get basic geolocation object.

basic.suspension

  • {Object}

Get basic suspension object.

Chassis Object

chassis.info(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • info {Object} Chassis information.

Get chassis information. The info object contains the following members:

MemberTypeDescription
pmmSysStInteger0: INIT 1: LVPWRUP 2: HVPWRUP 3: NORMAL 4: TMOUT 5: PWRDWN
readyLightStIntegerReady light 0: OFF 1: ON
odometerIntegerTotal kilometers traveled
residualOdometerIntegerResidual kilometers
energyConsumptionIntegerAverage consumption per 100 kilometers.

Example

var Basic = require('vehicle/basic');

var basic   = new Basic();
var chassis = basic.chassis;

basic.request(error => {
  if (error == undefined) {
    chassis.info((error, info) => {
      if (info) {
        console.log(info);
      }
    });
  }
});

chassis.drive(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • drive {Object} Chassis drive information.

Get chassis drive information. The drive object contains the following members:

MemberTypeDescription
accelIntegerAccelerator pedal position (0 - 100)
brakeIntegerBrake pedal position (0 - 100)
steeringIntegerSteering wheel rotation (-780 R - 780 L)

chassis.power(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • power {Object} Chassis power information.

Get chassis power information. The power object contains the following members:

MemberTypeDescription
residualIntegerResidual power 0 - 100%
energyIntegerResidual energy (Kwh)
healthIntegerBattery health 0 - 100%
dischargeIntegerDischarge power (Kw)
workingModeInteger0: No mode 1: Standby 2: Discharge 3: AC charging 4: DC charging 5: External discharge 6: Battery warm 7: Power off cooling 8: Boost Charging 9: Battery self-heating
chargeStateInteger0: Normal 1: Slow Charging 2: Fast Charging 3: Heating 4: Heating while Charging 5: Heart Preservation 6: Charge Stop 7: Charge Fault 8: Charge Achieved

Chassis Object Events

The chassis object inherits from the EventEmitter class. The following events are thrown in some specific situations.

info

This event is emitted when info is updated.

Example

chassis.on('info', (info) => {
  console.log(info);
});

drive

This event is emitted when drive is updated.

Example

chassis.on('drive', (drive) => {
  console.log(drive);
});

power

This event is emitted when power is updated.

Example

chassis.on('power', (power) => {
  console.log(power);
});

Vehicle Object

vehicle.status(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • status {Object} Vehicle status.

Get basic vehicle status. The status object contains the following members:

MemberTypeDescription
speedIntegerCurrent speed
instPowerConsumIntegerInstantaneous energy consumption (Kwh)
acAnionStInteger0: OFF 1: ON
accLatVehIntegerLateral acceleration
accLonVehIntegerLongitudinal acceleration
accVertVehIntegerVertical acceleration

vehicle.gear(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • gear {Object} Gear status.

Get basic vehicle gear status. The gear object contains the following members:

MemberTypeDescription
posStringCurrent gear: 'P'|'R'|'N'|'D'|'S'

vehicle.epb(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • epb {Object} EPB status.

Get basic vehicle Electronic Parking Brake status. The epb object contains the following members:

MemberTypeDescription
statusInteger1: Released 2: Clamped 3: Clamping 4: Releasing 5: Dynamic braking via EPB 6: Full Released

vehicle.steering(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • steering {Object} Tire steering status.

Get vehicle body and tire steering information. The steering object contains the following members:

  • awsAngle {Number} Front wheel steering angle.
  • rwsAngle {Number} Rear wheel steering angle.
  • diameterDiff {Number} Turning diameter difference.
  • diameterDiffPcnt {Number} Turning diameter difference percentage.

Vehicle Object Events

The vehicle object inherits from the EventEmitter class. The following events are thrown in some specific situations.

status

This event is emitted when status is updated.

Example

vehicle.on('status', (status) => {
  console.log(status);
});

gear

This event is emitted when gear is changed.

Example

vehicle.on('gear', (gear) => {
  console.log(gear);
});

epb

This event is emitted when epb is changed.

Example

vehicle.on('epb', (epb) => {
  console.log(epb);
});

steering

This event is emitted when steering is changed.

Example

vehicle.on('steering', (steering) => {
  console.log(steering);
});

Geolocation Object

geolocation.mode([mode, ]callback)

  • mode {String} GPS mode to be set.
  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • mode {String} If it is get, it indicates the current GPS mode.

Set or get the current GPS mode. Possible mode include:

  • 'independent' Independent use of satellite positioning systems.
  • 'msb': Mobile Station Based.
  • 'msa': Mobile Station Assisted.
  • 'fast': Obtain positioning information as quickly as possible.

This method can only be used by privileged applications. This setting is a persistent setting.

geolocation.location(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • location {Object} Last location information.

Get last location information. location includes the following members:

  • lat {Number} Latitude.
  • lon {Number} Longitude.
  • alt {Number} Altitude.

App must have vehicle.geolocation permission.

Geolocation Object Events

The Geolocation object inherits from the EventEmitter class. The following events are thrown in some specific situations.

nmea

This event is emitted when position is updated. Comprehensive NMEA standards compliant positioning information is available here. This message parameter is a parsed object, please refer to: https://www.npmjs.com/package/gps

Example

const GPS = require('gps');

// Add an event listener on all protocols
gps.on('data', parsed => {
  console.log(JSON.stringify(parsed));
});

// Update position information
geolocation.on('nmea', nmea => {
  gps.update(nmea.raw);
});

Suspension Object

suspension.airspring([param, ]callback)

  • param {Object} Parameters.
  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • param {Object} If it is get, it indicates the current airspring settings.

Set or get the current suspension airspring settings.

suspension.cdc([param, ]callback)

  • param {Object} Parameters.
  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • param {Object} If it is get, it indicates the current CDC settings.

Set or get the current suspension CDC settings.

suspension.style([param, ]callback)

  • param {Object} Parameters.
  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • param {Object} If it is get, it indicates the current style settings.

Set or get the current suspension style settings.

suspension.status(callback)

  • callback {Function} Callback.
    • error {Error} Specify the error message when failed.
    • status {Object} Indicates the current suspension status.

Get the current suspension status.

Suspension Object Events

The Suspension object inherits from the EventEmitter class. The following events are thrown in some specific situations.

airspring

  • param {Object}

cdc

  • param {Object}

style

  • param {Object}

status

  • param {Object}
文档内容是否对您有所帮助?
有帮助
没帮助