Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "soef", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "library for ioBroker", | ||
@@ -33,6 +33,6 @@ "author": { | ||
"gitHead": "caa0e2c91a549537d27454ba48f847adc88186da", | ||
"_id": "soef@0.1.2", | ||
"_id": "soef@0.1.3", | ||
"scripts": {}, | ||
"_shasum": "076ee2158f2609aa28dafcca7bcfdd38353f13bf", | ||
"_from": "soef@>=0.1.1 <0.2.0" | ||
"_shasum": "f676d281a3ade4215155cff07bf7e98eb3f554f5", | ||
"_from": "soef@*" | ||
} |
264
soef.js
@@ -112,25 +112,2 @@ /** | ||
//forEachObjCB: function (objects, step, func, readyCallback) { | ||
// if(typeof step === 'function') { | ||
// readyCallback = func; | ||
// func = step; | ||
// step = 1; | ||
// } | ||
// var objs = []; | ||
// for (var obj of objects) { | ||
// objs.push(obj); | ||
// } | ||
// var pop = step == -1 ? objs.pop : objs.shift; | ||
// | ||
// function doit(ret) { | ||
// if (objs.length <= 0) { | ||
// return safeCallback(readyCallback, ret); | ||
// } | ||
// func(pop.call(objs), doit); | ||
// } | ||
// | ||
// doit(-1); | ||
//}, | ||
forEachObjSync: function (objects, step, func, readyCallback) { | ||
@@ -149,5 +126,2 @@ if(typeof step === 'function') { | ||
objs = objects; | ||
//for (var obj of objects) { | ||
// objs.push(obj); | ||
//} | ||
} | ||
@@ -224,3 +198,2 @@ var pop = step == -1 ? objs.pop : objs.shift; | ||
for (var fullId in states) { | ||
//adapter.deleteState(fullId); | ||
adapter.delState(fullId); | ||
@@ -244,3 +217,2 @@ } | ||
safeCallback(callback); | ||
//process.exit(); | ||
}); | ||
@@ -253,4 +225,2 @@ }); | ||
valtype: function (val) { | ||
@@ -350,150 +320,4 @@ switch (val) { | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
/* | ||
var DEVICE = 0; | ||
var CHANNEL = 1; | ||
var STATE = 2; | ||
var typeNames = ['device', 'channel', 'state']; | ||
function CDeviceQueue (options) { | ||
options = options || {}; | ||
var that = this; | ||
var newObjects = []; | ||
var o = [0,0,0]; | ||
var parent = { _id: '' }; | ||
var checkExists = options.checkExists || true; | ||
this.set = function (id, val, ack) { | ||
if (!objects[id]) { | ||
this.newObj(id, val); // add... | ||
return; | ||
} | ||
if (objects[id].val !== val) { | ||
setState(id, val, ack); | ||
} | ||
} | ||
this.add = function (_obj) { | ||
if (checkExists && objects[_obj._id]) { | ||
return; | ||
} | ||
var obj = Object.assign({}, _obj); | ||
delete obj.parent; | ||
objects[obj._id] = obj; //?? | ||
newObjects.push(obj); | ||
}; | ||
//function __id(_id) { | ||
// return (parent && parent['_id']) ? parent._id + '.' + _id : _id; | ||
//} | ||
function push(what) { | ||
if (what+1 < o.length) { | ||
push(what+1); | ||
} | ||
if (o[what]) { | ||
if (what) { | ||
//o[what].parent.children.push(o[what]._id); | ||
} | ||
that.add(o[what]); | ||
o[what] = 0; | ||
} | ||
} | ||
function _new (_id, name, what) { | ||
push(what); | ||
parent = o[what-1]; | ||
if (what === undefined) { | ||
what = name; | ||
name = null; | ||
} | ||
o[what] = { | ||
//_id: __id(_id), | ||
_id: dcs(parent['_id'], _id), | ||
type: typeNames [what], | ||
common: { | ||
name: name ? name : _id | ||
}, | ||
native: {}, | ||
//children: [], | ||
parent: parent | ||
}; | ||
parent = o[what]; | ||
return o[what]; | ||
} | ||
this.newDevice = function (_id, name) { | ||
return _new(_id, name, DEVICE); | ||
}; | ||
this.newChannel = function (_id, name) { | ||
return _new(_id, name, CHANNEL); | ||
}; | ||
this.newState = function (name) { | ||
push(STATE); | ||
o[STATE] = { | ||
//_id: __id(name), | ||
_id: dcs(parent['_id'], name), | ||
type: 'state', | ||
common: { | ||
name: name, | ||
role: 'state', | ||
read: true, | ||
write: false | ||
}, | ||
native: {}, | ||
parent: parent | ||
}; | ||
return o[STATE]; | ||
}; | ||
this.newObj = function(id, val) { | ||
var ar = id.split('.'); | ||
if (ar.length > 1) this.newDevice(ar.slice()); | ||
while (ar.length > 1) { | ||
this.newChannel(ar.slice()); | ||
} | ||
this.newState(ar[0]); | ||
//objects[id].val = val; | ||
} | ||
this.update = function () { | ||
push(DEVICE); | ||
function addObjects() { | ||
if (newObjects.length > 0) { | ||
var newObject = newObjects.pop(); | ||
//var val = undefined; | ||
//if (newObject['val'] !== undefined) { | ||
// val = newObject.val; | ||
// delete newObject.val; | ||
//} | ||
var val = newObject['val']; | ||
if (val !== undefined) { | ||
delete newObject.val; | ||
} | ||
setObject(newObject._id, newObject, {}, function (err, obj) { | ||
adapter.log.info('object ' + adapter.namespace + '.' + newObject._id + ' created'); | ||
if (val !== undefined) { | ||
//adapter.setState(obj._id, val, true); | ||
setState(obj._id, val, true); | ||
} | ||
addObjects(); | ||
}); | ||
} | ||
} | ||
addObjects(); | ||
}; | ||
this.ready = this.update; | ||
return this; | ||
} | ||
*/ | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
function Devices (_adapter, _callback) { | ||
@@ -508,3 +332,2 @@ | ||
this.list = []; | ||
//this.states = objects; | ||
@@ -525,13 +348,4 @@ this.setAdapter = function (_adapter) { | ||
}; | ||
//this.existState = function (id) { | ||
// return (this.has(id, 'exist') && this.states[id].exist === true); | ||
//}; | ||
//this.setExist = function (id, val) { | ||
// val = val || true; | ||
// if (!this.has(id)) this.states[id] = { exist: val }; | ||
// else this.states[id].exist = val; | ||
//}; | ||
this.setraw = function (id, obj) { | ||
objects[id] = obj; | ||
//this.states[id] = obj; | ||
}; | ||
@@ -555,6 +369,2 @@ | ||
//this.showName = function (id, name) { | ||
// return ((this.states[id] && this.states[id].showName) ? this.states[id].showName : name); | ||
//}; | ||
this.getKeys = function (pattern) { | ||
@@ -580,17 +390,4 @@ var r = new RegExp(pattern2RegEx(pattern)); | ||
//this.stateChanged = function (id, val, ack) { | ||
//}; | ||
this.createObjectNotExists = function (id, obj, callback) { | ||
var val; | ||
//var newobj = Object.assign({ | ||
// type: 'state', | ||
// common: { | ||
// name: id, | ||
// type: 'string', | ||
// role: obj.type || 'state', | ||
// enumerable: true | ||
// }, | ||
// native: { n: 1} | ||
//}, obj); | ||
var newobj = { | ||
@@ -612,12 +409,4 @@ type: 'state', | ||
val = obj.val; | ||
//newobj.common.role = 'state'; | ||
//newobj.type = 'state'; | ||
delete newobj.val; | ||
} | ||
//if (obj['showName'] !== undefined) { | ||
// newobj.common.name = obj.showName; | ||
// //!! | ||
// delete newobj.showName; | ||
//} | ||
//newobj = this.extendObject(id, newobj); | ||
setObjectNotExists(id, newobj, function(err, o) { | ||
@@ -640,3 +429,2 @@ if (!err) { | ||
setState(id, val, ack); | ||
//this.stateChanged(id, val, ack); | ||
}; | ||
@@ -656,3 +444,2 @@ | ||
} else { | ||
//if (that.states[id].val !== newObj.val) { | ||
if (objects[id].val !== newObj.val) { | ||
@@ -676,3 +463,2 @@ that.setState(id, newObj.val, ack); | ||
if (showName) { | ||
//Object.assign(obj, { common: { name: showName}}); | ||
_fullExtend(obj, { common: { name: showName}}); | ||
@@ -683,6 +469,2 @@ } | ||
//this.extendObject = function (fullName, obj) { | ||
// return obj; | ||
//}; | ||
this.updateAsync = function (list, callback) { | ||
@@ -720,3 +502,2 @@ if (typeof list === 'function') { | ||
if (that.root.list) that.root.list = that.list; | ||
//that.list.splice(0, that.list.length); //to preserve this.loot.list | ||
} | ||
@@ -747,3 +528,2 @@ if (!list || list.length == 0) return safeCallback(callback, -1); | ||
_setobjname(objects[id], ''); | ||
//fullExtend(objects[id], o); | ||
} | ||
@@ -816,3 +596,2 @@ if (objects[id].common.name !== name) { | ||
}); | ||
//safeCallback(callback, 0); | ||
}); | ||
@@ -848,3 +627,4 @@ }; | ||
}; | ||
this.setDevice(_name, showName ? { common : { name: showName}} : undefined); | ||
//this.setDevice(_name, showName ? { common : { name: showName}} : undefined); | ||
this.setDevice(_name, showName && typeof showName == 'string' ? {common: {name: showName}} : showName); | ||
@@ -854,9 +634,3 @@ this.setObjectName = function (id, showName) { | ||
if (self.list[i]._id == id) { | ||
//var o = self.list[i]; | ||
_setobjname(self.list[i], showName); | ||
//if (o['common'] === undefined) { | ||
// o['common'] = {}; | ||
//} | ||
//o.common['name'] = showName; | ||
//fullExtend (self.list[i], { common: { name: showName}}); | ||
return i; | ||
@@ -872,3 +646,2 @@ } | ||
channelName = name; | ||
//var id = dcs(this.name, channel); | ||
var id = dcs(deviceName, channelName); | ||
@@ -915,25 +688,2 @@ if (!that.has(id)) { | ||
//function _set (_id, id, newObj, showName) { | ||
// if (!objects[_id]) { | ||
// return add (id, newObj, showName); | ||
// } | ||
// var val = newObj['val'] !== undefined ? newObj.val : newObj; | ||
// if (objects[_id].val !== val) { | ||
// that.setState(_id, val, true); | ||
// } | ||
//}; | ||
// | ||
//this.dcset = function (d,c,s,v, showName) { | ||
// var _id = dcs(d, c, s); | ||
// _set(_id, v, showName); | ||
//}; | ||
//this.dset = function(d,s,v, showName) { | ||
// var _id = dcs(d, '', s); | ||
// _set(_id, v, showName); | ||
//}; | ||
//this.sset = function(s,v, showName) { | ||
// var _id = s; | ||
// _set(_id, v, showName); | ||
//}; | ||
function __setVal(_id, newObj) { | ||
@@ -961,3 +711,2 @@ var val = newObj['val'] !== undefined ? newObj.val : newObj; | ||
var _id = dcs(deviceName, channelName, id); | ||
//_set(_id, id, newObj, showName); | ||
if (newObj == undefined) return; | ||
@@ -974,6 +723,11 @@ if (!objects[_id]) { | ||
}; | ||
this.setex = function (id, newObj, showName) { | ||
if (adapter && id.substr(0, adapter.namespace.length) == adapter.namespace) { | ||
id = id.substr(adapter.namespace.length+1); | ||
} | ||
return this.set(id, newObj, showName); | ||
}; | ||
this.getobjex = function (id) { | ||
var id = dcs(deviceName, channelName, id); | ||
//return devices.getobjex(id); | ||
return that.getobjex(id); | ||
@@ -1146,2 +900,2 @@ }; | ||
exports.njs = njs; | ||
exports.extendGlobalNamespace = extendGlobalNamespace; | ||
exports.extendGlobalNamespace = extendGlobalNamespace; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30974
783