PVSS and c#

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
34 posts • Page 1 of 4
CyaNn
Posts:97
Joined: Tue Nov 23, 2010 9:48 am

PVSS and c#

Post by CyaNn »

Hello folks,

I have a question about PVSS interoperability with .net.
I have seen in HowTos forum that it's possible to develop a .net ActiveX. Well done.
But what about Drivers and Control Extensions.

I have developped some drivers and CLR extension in C++ and I have seen it is possible to configure VC8 with managed object support /CLR (.net framework)
But is it possible to developpe with c# these drivers.
I think it should be great and more efficient than C++. (maybe because I don't like c++ language)

Thanks by advance to take time to reply me.
Best regards
Yann

smass
Posts:41
Joined: Tue Sep 25, 2012 10:21 am

Re: PVSS and c#

Post by smass »

Hi Yann,

Sorry, but you'll have to use C++. :)

br
Sebastian

CyaNn
Posts:97
Joined: Tue Nov 23, 2010 9:48 am

Re: PVSS and c#

Post by CyaNn »

Ha Sebastian,

Thanks a lot for your reply.
Best
Yann

clicht
Posts:24
Joined: Tue Aug 03, 2010 8:11 am

Re: PVSS and c#

Post by clicht »

A possible alternative is a common description language between PVSS and .NET.
In PVSS a HTTP server and client is available. Also a CTRL extension called XML-RPC is available.
XML-RPC is a simple protocol based on HTTP.
Server and Client in several other languages (C++, C#, SilverLight, Java, JavaScript) exists.
Therefore, you can use this for communication of PVSS with other applications.

ETM use this concept in our add-on called ETOOL (written in C#). In this scenario PVSS is the XML-RPC server and the ETOOL is the client.

In your scenario you could write a XML-RPC server in C# and a XML-RPC client in Control. This script reads periodically new values from your server.
If you are able to write a PVSS-driver you could write a C++ XML-RPC driver with the driver framework.

Or write a simple XML-RPC-Server in PVSS with Control and write data from the XML-RPC-Client written in C# into the server.

Addidtional informtions:
XML-RPC: http://www.xml-rpc.com/
Client/Server in C#: http://www.xml-rpc.net/
PVSS Online Help: Special functions -> XML-RPC
Client: xmlrpcClient(), xmlrpcConnectToServer(), xmlrpcCall(), xmlrpcCloseServer()
Server: httpServer(), httpConnect(), xmlrpcHandler()

CyaNn
Posts:97
Joined: Tue Nov 23, 2010 9:48 am

Re: PVSS and c#

Post by CyaNn »

Hi Christian,

Thank you for your reply.
I knew this alternative. :P

The cons I found about this method are :
- XML-RPC are based on XML. XML is really verbose and really heavy for network.
- As it is heavy, it have poor performance. In the case of driver, the communication protocol should be as lightweight as possible to improve performances. Imagine that client have to sent a large amount of data. XML-RPC will "carry as bottleneck".
- XML-RPC is based on http protocol. This protocol is not defined to keep open any connection.
Over HTTP, the request open a connection, and this connection is closed afted data exchanged.

I think RPC is a good choice to reply to programm interoperability problem. But I don't think it is a good choice in case of a driver architectured program.
The only alternatives I imagine :

- Define a home made lightweight data exchange over TCP/IP socket architecture between a c++ driver and some managed components.
- Define a managed c# dll and call it from driver writted in c++. I thinks it's possible if the CLR option is turned on in driver VC8 configuration (see my first post).
It have to be tested to see if it is possible.

Best regards
Yann B)

clicht
Posts:24
Joined: Tue Aug 03, 2010 8:11 am

Re: PVSS and c#

Post by clicht »

You are right, XML-RPC is heavy. But in the described alternative XML-RPC components are only like a proxy on your local machine. And therefore network is not the problem. Further the XML content of the HTTP message is only large if you use all possibilities of XML-RPC. If you encode the values in one variable of data type string, the content size is OK.

You are further right, with HTTP it is not possible to do something like suscriptions. But in the internet several strategies are available which minimize this (e.g. long polling). But in the described scenario you could realize it in a other way. Both edges becomes server and client part. This means it is possible to implement a server-server communication.

One further alternative would be to use the tcp control commands. With this it is possible to implement your own communication protocol. This is also available in scripting. E.g. the communication of the “Console” with the “PMON” uses this mechanism.

In C++ you have further more alternatives than TCP:
-COM
-Shared Memory
-File tunnel
-Call managed code from unmanaged code (e.g. http://www.codeproject.com/KB/dotnet/bridge.aspx)
-Embeding Mono (http://www.mono-project.com/Embedding_Mono)

Please note in the alternative with change of the CLR option the driver is no longer an unmanaged C++ executable, it becomes a managed C++ executable. Please note further that only a windows compiler is available for C++ which uses managed and unmanaged code in same binary.

CyaNn
Posts:97
Joined: Tue Nov 23, 2010 9:48 am

Re: PVSS and c#

Post by CyaNn »

Hello Christian,

Thanks a lot for your detailed answer.
It is exactly the answer I expected.

So it is possible to call managed dll developped in c# from c++ managed driver.
Unfortunatly, I will not have any time to try it this year. But next year, I expect to try it.

Thanks again and best regards.
Yann

smass
Posts:41
Joined: Tue Sep 25, 2012 10:21 am

Re: PVSS and c#

Post by smass »

Hi Yann,

There is one brand new and fresh prototype in the LAB section that might be interesting for you.. B)

Just search for the article "C# in CTRL Code".

br
Sebastian

CyaNn
Posts:97
Joined: Tue Nov 23, 2010 9:48 am

Re: PVSS and c#

Post by CyaNn »

Hi Sebastian,

Thanks a lot for your feed-back.
It seems awesome.
I hope this new feature will be implemented into the next WinCC OA version.

In the meantime, I will try this feature.

Thanks again. ;)

mwerksma
Posts:19
Joined: Fri Jul 01, 2011 1:21 pm

Re: PVSS and c#

Post by mwerksma »

Hello,

I have a simple RPC server ctl script in PVSS, the example I got from ETM and a simple program
in C# in VS2010 which works. Ik can read and write values from and to the PVSS database.
Do you have an example how to create events in C# like you normally do with callbacks in CONTROL code?
I want to create an avent in C# when a value in the PVSS database changes.

Regards Marcel Werksma
Siemens Nerderland N.V.

34 posts • Page 1 of 4