-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrapper.js
112 lines (95 loc) · 2.27 KB
/
wrapper.js
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
/*
Usage:
var wrapper = require("wrapper.js");
var deeplet = {
"device_type": "deeplet",
"address": "163.22.32.59",
...
};
var connector = new wrapper(deeplet);
connector.method(input);
*/
/* IC method */
if (typeof(LOG) === "undefined") {
var LOG = {};
if (typeof(LOG.warn) === "undefined") {
LOG.warn = function (ret) {
console.warn(ret);
}
}
if (typeof(LOG.error) === "undefined") {
LOG.error = function (ret) {
console.error(ret);
}
}
if (typeof(LOG.stack) == "undefined") {
LOG.stack = function (ret) {
console.trace();
}
}
}
function wrapper(input) {
var wrapper_varA = "QAQ";
var wrapper_varB = "@Q@";
if (typeof(input) !== "undefined") {
LOG.warn("input defined");
this.setup(input);
}
return this;
}
wrapper.prototype.setup = function (input) {
if (typeof(input) !== "undefined") {
/* if (typeof(input.type) !== "undefined") {
input.device_type = input.type;
}
*/
if (typeof(input.type) !== "undefined") {
if (typeof(input.protocol) === "undefined") {
input.protocol = input.type;
}
}
if (typeof(input.device_type) !== "undefined") {
if (typeof(input.protocol) === "undefined") {
input.protocol = input.device_type;
}
}
// switch (input.device_type) {
switch (input.protocol) {
case "onvif":
var onvif = require("./devices/onvifc.js");
this.prototype = this.__proto__;
this.__proto__ = new onvif();
console.log("this.__proto__");
console.log(this.__proto__);
onvif.call(this);
this.init(input);
break;
case "deeplet":
LOG.warn("require deeplet wrapper");
var deeplet = require("./devices/deeplet.js");
this.prototype = this.__proto__;
this.__proto__ = new deeplet();
//~ deeplet.call(this, input);
deeplet.call(this);
this.setupConnector(input);
break;
case "dvr":
LOG.warn("require deeplet wrapper");
var deeplet = require("./devices/deeplet.js");
this.prototype = this.__proto__;
this.__proto__ = new deeplet();
deeplet.call(this);
this.setupConnector(input);
break;
default:
LOG.warn("not support protocol: " + input.protocol);
}
}
}
wrapper.prototype.scanDevice = function (input) {
// input.protocal
}
wrapper.prototype.wrapperMethod = function (input) {
console.log("wrapperMethod");
}
module.exports = wrapper;