Skip to content

Commit d24b69c

Browse files
author
extracold1209
committed
[neobot] add nedobot_robot_theme module
1 parent dd88982 commit d24b69c

File tree

3 files changed

+159
-0
lines changed

3 files changed

+159
-0
lines changed

app/modules/neobot_robot_theme.js

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
function Module() {
2+
this.localBuffer = new Array(8);
3+
this.remoteBuffer = new Array(5);
4+
5+
this.LOCAL_MAP = [
6+
'IN1',
7+
'IN2',
8+
'IN3',
9+
'IR',
10+
'IN4' // 기존 배터리값을 IN4로 사용('180905 이동영)
11+
];
12+
13+
this.REMOTE_MAP = [
14+
'OUT1',
15+
'OUT2',
16+
'OUT3',
17+
'DCL',
18+
'DCR',
19+
'SND',
20+
'LED', // 기존 FND를 LED로 사용 ('180905 이동영)
21+
'OPT'
22+
];
23+
}
24+
25+
Module.prototype.init = function(handler, config) {
26+
};
27+
28+
Module.prototype.requestInitialData = function() {
29+
return null;
30+
};
31+
32+
Module.prototype.checkInitialData = function(data, config) {
33+
return true;
34+
};
35+
36+
Module.prototype.validateLocalData = function(data) {
37+
var state = false;
38+
39+
for(var i = 0; i < data.length - 1; i++) {
40+
if(data[i] === 171 && data[i + 1] === 205 ) {
41+
var dataSet = data.slice(i, i + 8);
42+
var dataSum = dataSet.reduce(function (result, value, idx) {
43+
if(idx < 2 || idx >= dataSet.length-1) {
44+
return result;
45+
}
46+
return result + value;
47+
}, 0);
48+
if((dataSum & 255) === dataSet[dataSet.length-1]) {
49+
state = true;
50+
}
51+
break;
52+
}
53+
}
54+
55+
return state;
56+
};
57+
58+
//로컬 데이터 처리
59+
// data: Native Buffer
60+
Module.prototype.handleLocalData = function(data) {
61+
var buffer = this.remoteBuffer;
62+
for(var i = 0; i < data.length - 1; i++) {
63+
if(data[i] === 171 && data[i + 1] === 205 ) {
64+
var dataSet = data.slice(i + 2, i + 7);
65+
66+
dataSet.forEach(function (value, idx) {
67+
buffer[idx] = value;
68+
});
69+
70+
break;
71+
}
72+
}
73+
};
74+
75+
//리모트 데이터 전송
76+
Module.prototype.requestRemoteData = function(handler) {
77+
var buffer = this.remoteBuffer;
78+
for(var i = 0; i < 5; i++) {
79+
handler.write(this.LOCAL_MAP[i], buffer[i]);
80+
}
81+
};
82+
83+
//리모트 데이처 처리
84+
Module.prototype.handleRemoteData = function(handler) {
85+
var buffer = this.localBuffer;
86+
87+
this.REMOTE_MAP.forEach(function (key, idx) {
88+
buffer[idx] = handler.read(key);
89+
});
90+
};
91+
92+
//로컬 데이터 전송
93+
Module.prototype.requestLocalData = function() {
94+
var requestData = [];
95+
var buffer = this.localBuffer;
96+
97+
// 시작 바이트
98+
requestData.push(0xEF); // TODO change to EF
99+
requestData.push(0xAB);
100+
101+
var checksum = 0;
102+
var isLed = false; // for adding option bit 181013
103+
buffer.forEach(function (value, idx) {
104+
if(idx === 6 && value > 0) {
105+
isLed = true;
106+
} else if(idx === 7 && isLed) {
107+
value = value | 8;
108+
}
109+
requestData.push(value);
110+
checksum += value;
111+
});
112+
113+
checksum = checksum & 255;
114+
//체크썸
115+
requestData.push(checksum);
116+
117+
return requestData;
118+
};
119+
120+
Module.prototype.reset = function() {
121+
};
122+
123+
module.exports = new Module();
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"id": "050301",
3+
"name": {
4+
"en": "NEOBOT Robot Theme",
5+
"ko": "네오봇 로봇 테마"
6+
},
7+
"platform": ["win32", "darwin"],
8+
"icon" : "neobot_robot_theme.png",
9+
"module": "neobot_robot_theme.js",
10+
"url": "http://neobot.co.kr/",
11+
"email": "[email protected]",
12+
"video": "https://goo.gl/hAXFZT",
13+
"reconnect" : true,
14+
"entry": {
15+
"protocol": "json"
16+
},
17+
"driver": [
18+
{
19+
"win32-ia32": "NEOBOT/VCP_V1.5.0_Setup_W8_x64_32bits.exe",
20+
"win32-x64": "NEOBOT/VCP_V1.5.0_Setup_W8_x64_64bits.exe",
21+
"translate": "Win8용 드라이버"
22+
},
23+
{
24+
"win32-ia32": "NEOBOT/VCP_V1.5.0_Setup_W7_x86_32bits.exe",
25+
"win32-x64": "NEOBOT/VCP_V1.5.0_Setup_W7_x64_64bits.exe",
26+
"translate": "Win7용 드라이버"
27+
}
28+
],
29+
"hardware": {
30+
"type": "serial",
31+
"control": "master",
32+
"vendor": ["Microsoft", "STMicroelectronics"],
33+
"duration": 32,
34+
"baudRate": 115200
35+
}
36+
}

app/modules/neobot_robot_theme.png

309 KB
Loading

0 commit comments

Comments
 (0)