EnglishУкраїнськаРocсийский
Login/New
Topic with no new replies

AttrGet syntax


Author Message
Written on: 10. 01. 2017 [13:34]
wunker
Kamil Piecha
Topic creator
registered since: 28.09.2016
Posts: 8
Hello.

I have trivial problem with attrGet, but I simply cannot get this to work.
(Inside "for" loop):
JAVASCRIPT
IsEnabled[i] = this["Widget_" + i].attrGet("en");

Testing with:
JAVASCRIPT
messPut("arrayEn",1,IsEnabled);


As a result in system message, I only receive an array of bool filled with 0.
I assume my syntax is wrong?
Written on: 10. 01. 2017 [14:48]
roman
Roman Savochenko
Moderator
Contributor
Developer
registered since: 12.12.2007
Posts: 3402
Sure but that function isn't presented for widgets at all, see here!

Learn, learn and learn better than work, work and work.
Written on: 10. 01. 2017 [17:03]
wunker
Kamil Piecha
Topic creator
registered since: 28.09.2016
Posts: 8
I see, I was using deprecated syntax. Right now everything is working flawlessly. Thank You.
Written on: 17. 01. 2017 [13:18]
wunker
Kamil Piecha
Topic creator
registered since: 28.09.2016
Posts: 8
Hello,

I don't want to start a new thread, so I will continue in this one.
Right now I want to do something like this.
I have some code in DAQ:
Java-like based calculator (module) -> Controller -> Test (controller) -> Result (Parameters).

In Test (controller) I have some code, and I want to connect with (DAQ):
ModBUS -> Test -> List

in List I have attributes set as:
JAVASCRIPT
R:0:rw:reg0
R:1:rw:reg1
R:2:rw:reg2
R:3:rw:reg3

So, here is my syntax problem. I was reading :

http://wiki.oscada.org/HomePageEn/Doc/JavaLikeCalc

Point 1.1
"Attributes of the parameters of system OpenSCADA (starting from subsystem DAQ, as follows "{Type of DAQ module}.{Controller}.{Parameter}.{Attribute}")."


So, my syntax is (of course in Test (controller)):
JAVASCRIPT
parameter = SYS.DAQ.ModBUS.Test.List.("reg0");

This reads only 0 (instead of value of 321 which is passed by ModBUS protocol, and can be readed directly on the page that contains List.

This (according to point 1.1) doesn't work (it reads EVAL):
JAVASCRIPT
parameter = SYS.DAQ.ModBUS.Test.List.reg0;


Written on: 17. 01. 2017 [13:44]
roman
Roman Savochenko
Moderator
Contributor
Developer
registered since: 12.12.2007
Posts: 3402
RTFM again!

In last case you get the attribute's object but it isn't its value.
Again read here for attributes!

Learn, learn and learn better than work, work and work.
Written on: 17. 01. 2017 [16:35]
wunker
Kamil Piecha
Topic creator
registered since: 28.09.2016
Posts: 8
Well, I was reading this F manual very acutely...
I was struggling with this whole day. It turned out, that if I'm connecting with ModBus protocol and I have syntax error, then
controller (Name:Test as mentioned in post above) in Java-like based calculator can hang. Therefore, there is no possibility to put new changes, because it will simply not compile (without symptoms). That was main reason for creating this post and my strange syntax attempts.
Solution - restart OpenSCADA.
(I am running most recent 0.9+r2460)

Anyway, Thank You for help, because You said, that I should get attribute's object (so EVAL that I was getting was wrong).
Written on: 17. 01. 2017 [17:52]
roman
Roman Savochenko
Moderator
Contributor
Developer
registered since: 12.12.2007
Posts: 3402
"wunker" wrote:

Point 1.1
"Attributes of the parameters of system OpenSCADA (starting from subsystem DAQ, as follows "{Type of DAQ module}.{Controller}.{Parameter}.{Attribute}")."


That isn't related at all to the bottom samples!

"wunker" wrote:

So, my syntax is (of course in Test (controller)):
JAVASCRIPT
parameter = SYS.DAQ.ModBUS.Test.List.("reg0");


This sample wrong at all!

"wunker" wrote:

JAVASCRIPT
parameter = SYS.DAQ.ModBUS.Test.List.reg0;


And this into "parameter" will handle only the attribute "reg0" object, no value, if its accessible at all!
But you at last have an error into module id "ModBUS" but this module calls "ModBus"!

For "reg0" attribute's value get you need call to the object's function "get()", like that:
JAVASCRIPT
tvl = SYS.DAQ.ModBus.Test.List.reg0.get();


And sure for me that works always!
JAVASCRIPT
vl = SYS.DAQ.ModBus.testTCP.test.reg4.get();  //Dynamic call through this objects
vl = ModBus.testTCP.test.reg4;  //Static call by direct link at the compile.
SYS.messInfo("TEST","vl="+vl);

2017-01-17T17:49:16 1[TEST] vl=10138

Then RTFM and See The Multiple Examples into DemoDB!

Learn, learn and learn better than work, work and work.



5201