13.06.2016, 13:09
(This post was last modified: 13.06.2016, 13:29 by Erwin van der Zwart.)
(13.06.2016, 12:21)buuuudzik Wrote: Maybe you can describe in very simple way how to:
- read from object database value of some group address,
- write to object database value of some group address(with or without write to the bus),
- read some additional object's info like "updatetime".
And also if there is a possibility to prepare the OR and AND gates for a few objects for calculating the room statuses and central statuses or something else.
Hi Buuuudzik,
All your questions are possible and are used in many of the custom JavaScript samples on this forum.
Please try to create some scripts based on those samples. I'm happy to give samples / solutions that are not on the forum yet.
The idea is that the users are helped with our samples, not to do the work for them (;
Why do you want to create the logic client side? The logic won't work when visu is not active. I would advice to keep logic server side with LUA
Here are the answers on your question:
// Look at possible values from objects (updatetime is not there) It's possible to get that info when using a APP with .lp files but not from Custom Javascript
console.log(objectStore.objects)
// Get values from object(s)
value = objectStore.objects[Scada.encodeGroupAddress('1/1/3')].value
value1 = objectStore.objects[Scada.encodeGroupAddress('1/1/3')].value
name = objectStore.objects[Scada.encodeGroupAddress('1/1/3')].name
console.log(value)
console.log(name)
// Write to object
var id = Scada.encodeGroupAddress('1/1/3'), obj = objectStore.objects[ id ], value = 10;
setObjectValue({ address: obj.address , rawdatatype: obj.rawdatatype }, value, "text");
// AND fuction
if ( value == 1 && value1 == 1 ) {
// dosomething)
}
// OR function
if ( value == 1 || value1 == 1 ) {
// dosomething)
}
BR,
Erwin