Wednesday, 1 July 2015

Send SMS for WinCC Alarm

Dear All,
here is our answer, when a friend ask about: How to send SMS automatically when Alarm is active in WinCC?

Alarm Control Center (ACC) from Siemens is the best tool for this purpose, and many other functionalities for Alarm handling (escalation).

But, if you want to use another application (more cheap/simple), we create a little application called Send_SMS.
Please make sure that you already have a GSM modem for sending SMS and make sure this modem is working. Remember the serial (COM) port which is  used by the modem.

There are 3 kind of work we will do:
1) download the file
2) edit Alarm Logging
3) edit Global Script

1. DOWNLOAD FILES
Please follow these steps:
> download the zip file here.
> rename the file extension from .JPG to .ZIP, then extract the file.
> there are 2 application, send_sms_w.exe is Windows application and send_sms_c.exe is Console.
> test sending SMS using send_sms_w.exe

> edit Settings of Port number, Baud rate, destination Phone number, SMS center.
> click Connect button.
> write some text, then click SEND button.
> check incomming SMS on destination phone.
> if the test above is success, then put send_sms_c.exe to the specified location, like on C:\ drive

2. EDIT ALARM LOGGING
> open Alarm Logging from WinCC Explorer.
> select the alarm messages which is you want to send SMS.
> check the Trigger Action option.

3. EDIT SCRIPT
> open Global Script C.
> select Standard functions > Alarm > GMsgFunction
> open the script and edit, to be like this:



#include "apdefap.h"

BOOL GMsgFunction( char* pszMsgData)
{
char s_sms [200];

MSG_RTDATA_STRUCT mRT;
  memset( &mRT, 0, sizeof( MSG_RTDATA_STRUCT ) );

  if( pszMsgData != NULL )
  {
     printf( "Meldung : %s \r\n", pszMsgData );

    // Meldungsdaten einlesen
     sscanf( pszMsgData,  "%ld,%ld,%04d.%02d.%02d,%02d:%02d:%02d:%03d,%ld, %ld, %ld, %d,%d",
&mRT.dwMsgNr,  // Meldungsnummer
&mRT.dwMsgState,   // Status MSG_STATE_COME, .._GO, .._QUIT, .._QUIT_SYSTEM
&mRT.stMsgTime.wYear,  // Jahr
&mRT.stMsgTime.wMonth,  // Monat
&mRT.stMsgTime.wDay, // Tag
&mRT.stMsgTime.wHour,  // Stunde
&mRT.stMsgTime.wMinute, // Minute
&mRT.stMsgTime.wSecond,  // Sekunde
&mRT.stMsgTime.wMilliseconds, // Millisekunde
&mRT.dwTimeDiff, // Zeitdauer der anstehenden Meldung
&mRT.dwCounter, // Interner Meldungszähler
&mRT.dwFlags, // Flags( intern )
&mRT.wPValueUsed,
&mRT.wTextValueUsed );

      // Prozesswerte lesen, falls gewünscht
    } 

  printf("Nr : %d, St: %x, %d-%d-%d %d:%d:%d.%d, Dur: %d, Cnt %d, Fl %d\r\n" , 
  mRT.dwMsgNr, mRT.dwMsgState, mRT.stMsgTime.wDay, mRT.stMsgTime.wMonth, mRT.stMsgTime.wYear, 
  mRT.stMsgTime.wHour, mRT.stMsgTime.wMinute, mRT.stMsgTime.wSecond, mRT.stMsgTime.wMilliseconds, mRT.dwTimeDiff,
  mRT.dwCounter, mRT.dwFlags ) ;

if (mRT.dwMsgState == 1)
{
printf ("send sms..");
sprintf(s_sms, "C:\\send_sms_c.exe 1 9600 +6281234567890 +628100000 \"Test Alarm %d\"", mRT.dwMsgNr);
ProgramExecute(s_sms);
}

   return( TRUE );
}

* the red one is the additional script.
* edit path of file, port number, baud rate, phone number, SMS center

> you can modify the content of message, on the example above, we just send a message number of alarm.
> save and go test runtime WinCC.


Thank you. 

11 komentar:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. Replies
    1. we provide exe file only.
      the source code is not free. if you need the source code, please contact us by email to hadiScada@gmail.com
      Thanks.

      Delete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. Hello, can you send me the application? Because link doesnt work.
    Thank you!

    ReplyDelete
    Replies
    1. https://mega.nz/file/1npXCaJS#X5wnlVZ6P8I3CnYx5lauvEz6AJIoCy-WSRudOZlmhu4

      Delete
  6. Hi, example transmission of emergency messages via telegram channel?

    ReplyDelete
    Replies
    1. hi.. yes it is possible, but with different library and code.

      Delete
  7. Hi, this app does not work. But I really need this. Can you explain what might be wrong?

    ReplyDelete
    Replies
    1. hi.
      maybe your GSM modem have a different configuration.
      i use this one :
      https://www.tokopedia.com/drexellindo-shop/modem-m1306b-usb-wavecom-q24-plus?extParam=ivf%3Dfalse&src=topads

      Delete

 
Copyright © . HadiSCADA - Posts · Comments
Theme Template by BTDesigner · Powered by Blogger