УкраїнськаEnglishmRussian
Вхід/Новий
У темі багато повідомлень

Custom protocol


Автор Повідомлення
Повідомлення створено: 21. 12. 2010 [12:40]
EzioOstorero
Ezio Ostorero
Автор теми
Зареєстрован(а) с: 14.12.2010
Повідомлення: 9
Dear All,

I'm a newcomer to OSCADA and let me congratulate with the development team first: I want through all the "QuickStart" guide and found it very very helpful, the demo is just great and OSCADA is really a well engineered product.

Now I have to go on with some serious stuff of my own, that is writing a custom protocol to access data on electromechanical equipment, this equipment has a simple HTTP interface that provides text-based output.

What I wish is to implement this protocol on OSCADA and forward variables read from the HTTP-based equipment to attributes of OSCADA internal variables.

Going through the docs I feel there are many ways to skin the cat: JavaLikeCalc, LogicLev, User Protocol and so on.

What is the recommended, most efficient way way to patch these things together? Where should I start?

Thanks in advance,

Ezio


[Повідомлення редагувалось 1 раз(ів), останній раз 21.12.2010 в 12:41.]
Повідомлення створено: 21. 12. 2010 [15:22]
Maxim
Maxim Lisenko
Contributor
Зареєстрован(а) с: 18.08.2008
Повідомлення: 141
Hello! I think that you should write the protocol for your equipment using "User Protocol" to get the data and afterwards you may use JavaLikeCalc, BlockCacl and LogicLevel for further processing of the received data. JavaLikeCalc, BlockCacl and LogicLevel are widely used in the DEMO configuration, so you can look for the examples there.
Повідомлення створено: 10. 01. 2011 [17:37]
EzioOstorero
Ezio Ostorero
Автор теми
Зареєстрован(а) с: 14.12.2010
Повідомлення: 9
Thank you Maxim and Happy New Year.

So, I'll start building my "User Protocol" first.
I have a "philosophical" question first: how do I tell my User Protocol the coordinates of my HTTP server node (let's call it TLC).

Somehow I have to specify the user protocol to open a connection like TCP:TLC:8080; I believe this has to go through a configuration of an outgoing socket, correct?

So, I went into Transports->Sockets->Output transports and defined my protocol with the above Address: TCP:TLC:8080.

OK, but then how do I connect the "User Protocol" with the "Output transport" I just created?
In the Output transports Config screen there is no "Transport protocol" field (as it happens in the Input transport Config) where I can connect the User Protocol with the Output transport.

Thanks again,

Ezio

Повідомлення створено: 12. 01. 2011 [12:58]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
"EzioOstorero" wrote:

So, I'll start building my "User Protocol" first.
I have a "philosophical" question first: how do I tell my User Protocol the coordinates of my HTTP server node (let's call it TLC).

Why do you use "User Protocol" for HTTP? For HTTP allowed self protocol-module ( http://wiki.oscada.org/HomePageEn/Doc/HTTP ) and user API for send wrapped to it self-users requsts.
For use module "User Protocol", posible for chained call HTTP, read here: http://oscada.org/ru/forum/posts//opros_ustroistv_po_sobytiju. Sorry, but the link to Russian forum.

Learn, learn and learn better than work, work and work.
Повідомлення створено: 12. 01. 2011 [13:27]
EzioOstorero
Ezio Ostorero
Автор теми
Зареєстрован(а) с: 14.12.2010
Повідомлення: 9
Спасибо Roman,

RS> For HTTP allowed self protocol-module ( http://wiki.oscada.org/HomePageEn/Doc/HTTP ) and user API for send wrapped to it self-users requsts.

Thanks for the hint, I will try the built-in HTTP protocol
Повідомлення створено: 13. 01. 2011 [17:29]
EzioOstorero
Ezio Ostorero
Автор теми
Зареєстрован(а) с: 14.12.2010
Повідомлення: 9
Hi All,

I'm trying the builtin-HTTP way, I have some question though ... maybe the answers are in the russian forum, but my russian does not much go beyond "спасибо", "пожалуйста" and "до свидания" ... too bad for me ;-)

First I defined my own HTTP transport as an Outgoing transport, I called it XXXX_HTTP, with destination address "TCP:evk:8080", where "evk" is my http server node.
So far so good.

Next I tried to define my "Transport protocol".
I believe there is no way to define my own transport protocol, the only way is to define a new "User protocol" where to build the XML/HTTP logic, correct?
The goal is to implement my HTTP processing logic, as described in http://wiki.oscada.org/HomePageEn/Doc/HTTP ... is this the right way to operate?
So I defined my XXX_Protocol and I am starting to code the logic of the "Output" section using JavaLikeCalc.JavaScript and use OSCADA APIs, as suggested by Roman.

Referring to http://wiki.oscada.org/HomePageEn/Doc/HTTP , I wrote my Output code, but it is not clear to me how do I define the HTTP request parameter: hostname, URL, GET/POST parameter, the Wiki documentation is a little cryptic for me, sorry about that.

In Chapter 3, we have two XML snipped and one JavaScript snippet, the meaning of them is not so clear to me:

I understand the first XML snippet is the result of the JavaScript processing, and are the ones interpreted by the SYS.Transport.Sockets.out_testHTTP.messIO call.
So, my task is to write the code to correctly format an XML for implementing my request.

How do I specify host/port? A reference to the XXXX_HTTP Outgoing protocol? Or explicitly set host/port in the XML, like this?

req = SYS.XMLNode("GET");
req.setAttr("Host","evk");

Then, my URI would be like this:
req.setAttr("URI","/cgi-bin/oscada.sh");

And I submit my request:
SYS.Transport.Sockets.out_testHTTP.messIO(req,"HTTP");

Outstanding and really easy, if only I could make it work :-)
Question: where will the reply go? The "respVal" of the second XML snipped in Chap. 3?
Can I extract the content of "respVal" using some method of the SYS.XMLNode method? XMLNode.childGet? Is there a usage example?

Sorry for being so lengthy, maybe I'm not getting it the easy way? I really don't want to abuse of your patience,

Cheers,
Ezio
Повідомлення створено: 13. 01. 2011 [17:39]
EzioOstorero
Ezio Ostorero
Автор теми
Зареєстрован(а) с: 14.12.2010
Повідомлення: 9
P.S.
Roman, I checked the russian forum you pointed: http://oscada.org/ru/forum/posts//opros_ustroistv_po_sobytiju

It's very extensive ... but, if there is some section of it that deals with my problem, please, just point me to the relevant topic and I will try to have them translated by a russian-speking friend.

спасибо,

Ezio

[Повідомлення редагувалось 1 раз(ів), останній раз 13.01.2011 в 18:10.]
Повідомлення створено: 13. 01. 2011 [20:47]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
Simple take the code:
JAVASCRIPT
//GET request
req = SYS.XMLNode("GET");
req.setAttr("URI","/");
SYS.Transport.Sockets.out_testHTTP.messIO(req,"HTTP");
test = req.text();

and place it to JavaLikeCalc controller.

I have not any time for detailed explanation that. For consultation go to the link: http://oscada.org/en/services/training

Learn, learn and learn better than work, work and work.
Повідомлення створено: 14. 01. 2011 [17:53]
EzioOstorero
Ezio Ostorero
Автор теми
Зареєстрован(а) с: 14.12.2010
Повідомлення: 9
Outstanding!
Thank you Roman, this was the trick:

RS> and place it to JavaLikeCalc controller.

Yes, I created my own controller in "Data Acquisition->Java-like based calculator->Library->Controllers" and executed it.

I tracked my HTTP requests/replies using using Wireshark and found they were correct.
Now, the problem will be to access the response contents and process them using Java-like script.
Is the content of the response inside req.text() ?

Ciao,
Ezio
Повідомлення створено: 14. 01. 2011 [18:34]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
"EzioOstorero" wrote:

Is the content of the response inside req.text() ?

Yes. For process the response use "User API":
http://wiki.oscada.org/HomePageEn/Doc/ProgrammManual?v=ksv#h946-1
http://wiki.oscada.org/HomePageEn/Doc/JavaLikeCalc?v=hxx#h867-3
http://wiki.oscada.org/HomePageEn/Doc/FLibSYS

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



8795