| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /* *********************************************************** */
- // 创建: Macheng 2019/08/29.
- // 修改: Macheng 2025/09/10
- // Description:
- // 该文件定义了基站类Anchor。用于保存基站的配置数据。
- /* *********************************************************** */
- import BaseModel from './baseModel'
- class Anchor extends BaseModel {
- id = 0 // 基站ID
- imei = '' // 基站IMEI号
- iccid = '' // 基站ICCID号
- projId = 0 // 所属项目ID
- battery = 0 // 电池电量
- status = 0 // 基站状态 , bit0: 1-在线, 0-离线, bit1: 1-充电, 0-未充电
- x = 0 // 基站X坐标
- y = 0 // 基站Y坐标
- z = 0 // 基站Z坐标
- lastUpdateTime = 0 // 最后更新时间
- get addr() {
- return this.id
- }
- set addr(val) {
- this.id = val
- }
- get isOnline() {
- return (this.status & 0x1)
- }
- get isCharging() {
- return (this.status & 0x2)
- }
- get percentBattery() {
- let perBat = Math.floor((this.battery - 3700) / (4100 - 3700) * 100);
- if (perBat < 0) {
- perBat = 0;
- } else if (perBat > 100) {
- perBat = 100;
- }
- return perBat;
- }
- constructor(opts) {
- if (!opts) opts = {}
- super(opts)
- this.init(opts)
- }
- init(opts) {
- if (!opts) opts = {}
- super.init(opts)
- this.id = Number(opts.id) || Number(opts.addr) || this.id
- this.imei = opts.imei || this.imei
- this.iccid = opts.iccid || this.iccid
- this.projId = Number(opts.projId) || this.projId
- this.battery = Number(opts.battery) || this.battery
- this.status = Number(opts.status) || this.status
- this.x = Number(opts.x) || this.x
- this.y = Number(opts.y) || this.y
- this.z = Number(opts.z) || this.z
- this.lastUpdateTime = Number(opts.lastUpdateTime) || this.lastUpdateTime
- this.isEnable = opts.enable || opts.isEnable || false
- }
- toJson() {
- const obj1 = super.toJson()
- const obj2 = {
- id: this.id,
- addr: this.addr,
- imei: this.imei,
- iccid: this.iccid,
- projId: this.projId,
- battery: this.battery,
- status: this.status,
- x: this.x,
- y: this.y,
- z: this.z,
- lastUpdateTime: this.lastUpdateTime
- }
- return Object.assign({}, obj1, obj2)
- }
- }
- export default Anchor
|