Category Archives: WinCC OA

WinCC OA HowTo get Stock-Quotes from Yahoo (HttpRequest)…

Using Yahoo-Stock-Quote Webservice.

dyn_float getQuote(string symbol)
{
  // http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=l1v"
  string request = "GET /d/quotes.csv?s=%s&f=l1v HTTP/1.1\r\n"
                   "Connection: keep-alive\r\n"
                   "Host: download.finance.yahoo.com\n\n";
  sprintf(request, request, symbol);
  DebugTN("getQuote", symbol);
  string response;
  int socket=tcpOpen("download.finance.yahoo.com", 80);
  tcpWrite(socket, request);
  tcpRead(socket, response, 3);
  tcpClose(socket);
  strreplace(response, "\r", "");
  dyn_string lines = strsplit(response, "\n");
  // print response lines (debug)
  for ( int i=1; i<=dynlen(lines); i++ )
    DebugTN(i, lines[i]);
  // extract the information we want
  if ( dynlen(lines) >= 13 ) {
    dyn_string cols=strsplit(lines[13], ",");
    float f1, f2;
    if ( dynlen(cols) > 0 ) sscanf(cols[1], "%f", f1);
    if ( dynlen(cols) > 1 ) sscanf(cols[2], "%f", f2);
    DebugTN(symbol, f1, f2);
    return makeDynFloat(f1, f2);
  }
}

WinCC OA 3.12 Proxy Configuration when a Public and Local Network is used…

Local IP/Name: vm1.rocworks-vm1.f1.internal.cloudapp.net
Public IP/Name: rocworks-vm1.cloudapp.net
Client will connect through the Public IP.

Server

[general]
dataHost = "vm1.rocworks-vm1.f1.internal.cloudapp.net"
eventHost = "vm1.rocworks-vm1.f1.internal.cloudapp.net"

[proxy]
server = "vm1.rocworks-vm1.f1.internal.cloudapp.net:4897"
server = "vm1.rocworks-vm1.f1.internal.cloudapp.net:4998"

Client

[general]
dataHost = "vm1.rocworks-vm1.f1.internal.cloudapp.net"
eventHost = "vm1.rocworks-vm1.f1.internal.cloudapp.net"

mxProxy = "vm1.rocworks-vm1.f1.internal.cloudapp.net rocworks-vm1.cloudapp.net:5678 cert"

Note: It is important that the proxy port is set! (even if this port is the default port of the proxy).

Client-Project/config/
host-cert.pem
host-key.pem
root-cert.pem

WinCC OA Push Notifications to iOS/Android…

Demo: http://youtu.be/aCE8-84lAg0

Install the Android-App: http://rocworks.at/project/push/rocworks.apk (it is a very simple Test-App) and get messages sent by my “SmartHome” WinCC OA system.

Or use it with your own WinCC OA project:

Download the program from here

ASCII-Import: RocVMessage.dpl
Ctrl-Script: RocVMessage.ctc (Port 9601 is used for communication)

On a Windows Host you have to start:
RocVMessage.exe <messageHost> <projectToken>

if no messageHost is passed then localhost is used (messageHost is the host where the ctrl is running)

if no project token is passed the messages will be send to the demo project/service.

if you wanna use your own distribution circle (with a projectToken) then you can generate a project token: http://rocworks.at/project/push/qrcode

Copy the project id/token and save the QR-Image.

Start RocVMessage.exe with this project token and scan the QR-Code with the Android-App (click on “PROJECT” at the top of the app). Barcode Scanner App must be installed: https://play.google.com/store/apps/details?id=com.google.zxing.client.android

Messages are sent to those devices using the same project token as the RocVMessage.exe uses.

Sending a Push Notification: dpSet(“RocVMessage.Message.Message”, “hello from WinCC OA”);
The message will be sent to all devices which are registered to the same project token (iOS and Android!).

(Note: RocVMessage.Notification currently only works with iPhone, there is another technology behind, not yet implemented in the Android-App).

WinCC OA Android App…

I now also built an Android App to visualize my Home-Automation data (powered by WinCC OA – www.etm.at).

Because i did the same for iOS and used C# for coding (Xamarin Framework) i was able to share about 70% of the code between both Apps (iOS and Android). So there was no need to re-implement the communication and business logic!! All i had to do is to get familiar with the Android-UI…

App: http://www.rocworks.at/wordpress/rocvmobile/

Android-App:

2013-09-23 12.55.05 Screenshot_2013-09-23-16-26-26 2013-09-22 07.09.00 test1 Screenshot_2013-09-22-14-09-48