config.js
2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import Base from './base';
import _ from 'lodash';
import {
log, tenToHex
}
from '../util';
import info from '../interface';
/**
* 配置读写器信息
* 频率,功率,灵敏度过滤
*/
class Config extends Base {
constructor() {
super(null);
let power = info.setPower.input,
filter = info.setFilter.input,
frequency = info.setFrequency.input;
this.reproc[power] = this.prePower;
this.reproc[filter] = this.preFilter;
this.reproc[frequency] = this.preFrequency;
}
/**
* 设置功率输入预处理
* param: [15,15,0,0]
* 分别对应0-3天线
*/
prePower(param) {
let ret = [];
_.forIn(param, function (val, key) {
val = tenToHex(val).toLocaleUpperCase();
val = (val.length < 2) ? ('0' + val) : val;
ret.push(val);
});
return info.setPower.input + ret.join('');
}
/**
* 设置灵敏度过滤预处理
* param:{on:'1',rssi:-275}
*/
preFilter(param) {
let rssi = tenToHex(param.rssi).replace('ffff', '').toLocaleUpperCase();
return info.setFilter.input + '0' + param.on + rssi + '00';
}
/**
* 设置频率预处理
0 915.75
1 915.25
2 903.25
3 926.75
4 926.25
5 904.25
6 927.25
7 920.25
8 919.25
9 909.25
10 918.75
11 917.75
12 905.25
13 904.75
14 925.25
15 921.75
16 914.75
17 906.75
18 913.75
19 922.25
20 911.25
21 911.75
22 903.75
23 908.75
24 905.75
25 912.25
26 906.25
27 917.25
28 914.25
29 907.25
30 918.25
31 916.25
32 910.25
33 910.75
34 907.75
35 924.75
36 909.75
37 919.75
38 916.75
39 913.25
40 923.75
41 908.25
42 925.75
43 912.75
44 924.25
45 921.25
46 920.75
47 922.75
48 902.75
49 923.25
* ant:1
* freq:1
*/
preFrequency(param) {
let ant = param.ant < 10 ? ('0' + param.ant) : param.ant,
freq = tenToHex(param.freq).toLocaleUpperCase();
freq = freq.length < 2 ? ('0' + freq) : freq;
return info.setFrequency.input + ant + '0000' + freq;
}
}
export default Config;