1 | 'use strict';
|
2 | const patterns = {
|
3 | MVT380SMS: /^(Interval),(\d{6})[\r|\n|\ ](\d{2}:\d{2}),(A|V),(\d+),(\d+)Km\/h,(\d+)%,http?\:\/\/?maps.google\.[a-z]+\/maps\?[f]\=q&hl=en&q=([-]?\d+\.\d+),([-]?\d+\.\d+)/,
|
4 | MVT380GPRS: /^\$\$([\x41-\x7A])(\d{1,3}),(\d{15}),([0-9A-F]{3}),(\d{1,3}),([-]?\d+\.\d+),([-]?\d+\.\d+),(\d{12}),([AV]),(\d{1,3}),(\d{1,2}),(\d+(\.\d+)?),(\d+(\.\d+)?),(\d+(\.\d+)?),(\d+(\.\d+)?),(\d+(\.\d+)?),(\d+),(\d{3})\|(\d{1,3})\|([0-9A-F]{4})\|([0-9A-F]{4}),([0-9A-F]{4}),([0-9A-F]{1,4})?\|([0-9A-F]{1,4})?\|([0-9A-F]{1,4})?\|([0-9A-F]{1,4})\|([0-9A-F]{1,4}),([0-9A-F]{8})?,?([0-9A-F]+)?,?(\d{1,2})?,?([0-9A-F]{4})?,?([0-9A-F]{6})?\|?([0-9A-F]{6})?\|?([0-9A-F]{6})?\|?\*([0-9A-F]{2})\r\n$/,
|
5 | ok: /^\$\$([\x41-\x7A])(\d{1,3}),(\d{15}),([0-9A-F]{3}),OK\*([0-9A-F]{2})\r\n$/,
|
6 | };
|
7 |
|
8 |
|
9 |
|
10 | const parseAlarm = event => {
|
11 | const alarms = {
|
12 | '1': {AlertType: 'SOS_Button'},
|
13 | '2': {AlertType: 'DI', number: 2, status: true},
|
14 | '3': {AlertType: 'DI', number: 3, status: true},
|
15 | '4': {AlertType: 'DI', number: 4, status: true},
|
16 | '5': {AlertType: 'DI', number: 5, status: true},
|
17 | '9': {AlertType: 'DI', number: 1, status: false},
|
18 | '10': {AlertType: 'DI', number: 2, status: false},
|
19 | '11': {AlertType: 'DI', number: 3, status: false},
|
20 | '12': {AlertType: 'DI', number: 4, status: false},
|
21 | '13': {AlertType: 'DI', number: 5, status: false},
|
22 | '17': {AlertType: 'DI', number: 2, status: false},
|
23 | '18': {AlertType: 'lowExternalBattery'},
|
24 | '19': {AlertType: 'Over_Speed', status: true},
|
25 | '20': {AlertType: 'Geo_Fence', status: true},
|
26 | '21': {AlertType: 'Geo_Fence', status: false},
|
27 | '22': {AlertType: 'Charge', status: true},
|
28 | '23': {AlertType: 'Charge', status: false},
|
29 | '24': {AlertType: 'gpsSignal', status: false},
|
30 | '25': {AlertType: 'gpsSignal', status: true},
|
31 | '26': {AlertType: 'Sleep', status: true},
|
32 | '27': {AlertType: 'Sleep', status: false},
|
33 | '28': {AlertType: 'gpsAntennaCut'},
|
34 | '29': {AlertType: 'deviceReboot'},
|
35 | '31': {AlertType: 'Heartbeat'},
|
36 | '32': {AlertType: 'Angle'},
|
37 | '33': {AlertType: 'distanceIntervalTracking'},
|
38 | '34': {AlertType: 'replyCurrent'},
|
39 | '35': {AlertType: undefined},
|
40 | '36': {AlertType: 'tow'},
|
41 | '37': {AlertType: 'Rfid'},
|
42 | '39': {AlertType: 'picture'},
|
43 | '40': {AlertType: 'powerOff'},
|
44 | '41': {AlertType: 'Moving', status: false},
|
45 | '42': {AlertType: 'Moving', status: true},
|
46 | '44': {AlertType: 'jamming', status: true},
|
47 | '50': {AlertType: 'temperature', status: true},
|
48 | '51': {AlertType: 'temperature', status: false},
|
49 | '52': {AlertType: 'fuelFulled'},
|
50 | '53': {AlertType: 'fuelEmpty'},
|
51 | '54': {AlertType: 'fuelStolen'},
|
52 | '56': {AlertType: 'armed'},
|
53 | '57': {AlertType: 'disarmed'},
|
54 | '58': {AlertType: 'stealing'},
|
55 | '63': {AlertType: 'jamming', status: false},
|
56 | '65': {AlertType: 'pressInput1ToCall'},
|
57 | '66': {AlertType: 'pressInput2ToCall'},
|
58 | '67': {AlertType: 'pressInput3ToCall'},
|
59 | '68': {AlertType: 'pressInput4ToCall'},
|
60 | '69': {AlertType: 'pressInput5ToCall'},
|
61 | '70': {AlertType: 'rejectIncomingCall'},
|
62 | '71': {AlertType: 'getLocationByCall'},
|
63 | '72': {AlertType: 'autoAnswerIncomingCall'},
|
64 | '73': {AlertType: 'listenIn'},
|
65 | '79': {AlertType: 'fall'},
|
66 | '80': {AlertType: 'install'},
|
67 | '81': {AlertType: 'dropOff'},
|
68 | '139': {AlertType: 'maintenance'}
|
69 | };
|
70 | return event in alarms ? alarms[event] : null;
|
71 | };
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | const mapIndex = {
|
78 | MVT380SMS: {
|
79 | date: 2,
|
80 | time: 3,
|
81 | GPSPosition:4,
|
82 | GPSSIgnal:5,
|
83 | speed: 6,
|
84 | vehicleBattery: 7,
|
85 | latitude: 8,
|
86 | longitude: 9
|
87 | },
|
88 | MVT380GPRS: {
|
89 | IMEI: 3,
|
90 | command: 4,
|
91 | alert: 5,
|
92 | latitude: 7,
|
93 | longitude: 6
|
94 |
|
95 | }
|
96 |
|
97 | };
|
98 |
|
99 | module.exports = {
|
100 | parseAlarm: parseAlarm,
|
101 | patterns: patterns,
|
102 | mapIndex: mapIndex
|
103 | };
|