config.js
5.26 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**
* @fileOverview 读写器配置类
* @author qiqi.zhou@yoho.cn
*/
import Base from './base';
import _ from 'lodash';
import {
log, tenToHex
}
from '../util';
import info from '../interface';
/**
* @class 配置读写器信息
* @description 频率,功率,灵敏度过滤
* @module lib/directive/Config
* @extends {Base}
* @member @see {@link Base}
*/
class Config extends Base {
/**
* 初始化和配置输入处理
* @return {void}
*/
constructor() {
super(null);
let power = info.setPower.input,
filter = info.setFilter.input,
stayTime = info.setAntStayTime.input,
frequency = info.setFrequency.input,
frequencyRegion = info.setFrequencyRegion.input,
speedMode = info.setSpeedMode.input,
tagGroup = info.setTagGroup.input;
this.reproc[power] = this.prePower;
this.reproc[filter] = this.preFilter;
this.reproc[stayTime] = this.preStayTime;
this.reproc[frequency] = this.preFrequency;
this.reproc[frequencyRegion] = this.preFrequencyRegion;
this.reproc[speedMode] = this.preSpeedMode;
this.reproc[tagGroup] = this.preTagGroup;
}
/**
* @method prePower
* @description 设置功率输入预处理
* @param {Array} param 天线功率,eg.[15,15,0,0]分别对应0-3天线
* @return {String} 指令
*/
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('');
}
/**
* @method preFilter
* @description 设置灵敏度过滤预处理
* @param {Object} param 配置1表示开启,0表示关闭,eg. {on:'1',rssi:-27.5}
*/
preFilter(param) {
let rssi = tenToHex(param.rssi * 10);
rssi = rssi.replace('ffff', '').toLocaleUpperCase();
return info.setFilter.input + '0' + param.on + rssi + '00';
}
/**
* @method preStayTime
* @description 设置天线驻留时间预处理
* @param {Object} param param 读写时长 eg 100 (单位:ms)
* @return {String} 指令
*/
preStayTime(param) {
let time = tenToHex(param).toLocaleUpperCase();
time = _.padLeft(time, 8, '0');
return info.setAntStayTime.input + time;
}
/**
* @method preFrequency
* @description 设置频率预处理
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
* @param {Number} param ant标示天线的端口,freq标示频率(使用枚举值)
*/
preFrequency(param) {
let freq = tenToHex(param).toLocaleUpperCase();
freq = freq.length < 2 ? ('0' + freq) : freq;
return info.setFrequency.input + freq + '000000';
}
/**
* @method preFrequencyRegion
* @description 设置频率区域
* @param {Object} param 频率区域的值 eg: 0:FCC,1:CCC,2:NCC,3:JPN
*/
preFrequencyRegion(param) {
return info.setFrequencyRegion.input + '0' + tenToHex(param).toLocaleUpperCase() + '000000';
}
/**
* @method preSpeedMode
* @description 设置速度模式
* @param {Object} param 速度模式的值 eg: 0:高速,1:正常速度,2:省电模式
*/
preSpeedMode(param) {
return info.setSpeedMode.input + '0' + tenToHex(param).toLocaleUpperCase() + '000000';
}
/**
* @method preTagGroup
* @description 设置标签组预处理
* @param {Object} param 标签组的值 eg: {'session':0,'target':0,'search_mode':1}
* 其中session:0代表S0,1代表S1,2代表S2,3代表S3
* target:0代表A,1代表B
* search_mode:0代表DUAL_TARGET,1代表SINGLE_TARGET,2代表SINGLE_TARGET_WITH_SUPPRESSION
*/
preTagGroup(param) {
let session = '0'+tenToHex(param.session * 10).toLocaleUpperCase(),
target = '0'+tenToHex(param.target).toLocaleUpperCase(),
search_mode = '0'+tenToHex(param.search_mode).toLocaleUpperCase();
return info.setTagGroup.input + session +target + search_mode + '00';
}
}
/**
* @exports lib/directive/Config
*/
export default Config;