Commit f33c8fbb authored by Claes Sjofors's avatar Claes Sjofors

rt_post modifications

parent 815eb52e
......@@ -45,6 +45,7 @@
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "co_syi.h"
#include "rt_errh.h"
#include "rt_qcom.h"
#include "rt_ini_event.h"
......@@ -65,6 +66,15 @@ union alau_Event
mh_sBlock Block;
};
rt_post::rt_post() : scan_time(1), conf(0), udb(0), sent_sms_startidx(0), sent_sms_endidx(0),
sent_email_startidx(0), sent_email_endidx(0)
{
pwr_tStatus sts;
strcpy( systemgroup, "");
syi_NodeName( &sts, nodename, sizeof(nodename));
}
void rt_post::open()
{
pwr_tStatus sts;
......@@ -199,6 +209,7 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP)
pwr_tDeltaTime diff;
int rcvnum;
char rcv_array[10][80];
char text[400];
if ( !post || post->conf->Disable)
return 1;
......@@ -282,7 +293,8 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP)
ul->get_email( address, sizeof(address));
post->format_cmd( cmd, post->conf->EmailCmd, address, event->Msg.EventText);
post->format_email_text( MsgP, text, sizeof(text));
post->format_cmd( cmd, post->conf->EmailCmd, address, text);
if ( post->conf->Log)
errh_Info( "Email: %s", cmd);
......@@ -298,7 +310,8 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP)
ul->get_sms( sms, sizeof(sms));
post->format_cmd( cmd, post->conf->SMS_Cmd, sms, event->Msg.EventText);
post->format_sms_text( MsgP, text, sizeof(text));
post->format_cmd( cmd, post->conf->SMS_Cmd, sms, text);
if ( post->conf->Log)
errh_Info( "SMS: %s", cmd);
......@@ -330,6 +343,63 @@ pwr_tStatus rt_post::mh_clear_blocklist_bc( pwr_tNodeIndex nix)
return 1;
}
void rt_post::format_sms_text( mh_sMessage *MsgP, char *text, unsigned int size)
{
ala_uEvent *event = (ala_uEvent *) MsgP;
char prio[2];
switch ( event->Info.EventPrio) {
case mh_eEventPrio_A:
strcpy( prio, "A");
break;
case mh_eEventPrio_B:
strcpy( prio, "B");
break;
case mh_eEventPrio_C:
strcpy( prio, "C");
break;
case mh_eEventPrio_D:
strcpy( prio, "D");
break;
default:
strcpy( prio, "?");
}
snprintf( text, size, "Proview %s Prio %s,\n%s,\n%s", nodename, prio, event->Msg.EventText,
event->Msg.EventName);
}
void rt_post::format_email_text( mh_sMessage *MsgP, char *text, unsigned int size)
{
ala_uEvent *event = (ala_uEvent *) MsgP;
char prio[2];
pwr_tTime etime;
char timstr[40];
switch ( event->Info.EventPrio) {
case mh_eEventPrio_A:
strcpy( prio, "A");
break;
case mh_eEventPrio_B:
strcpy( prio, "B");
break;
case mh_eEventPrio_C:
strcpy( prio, "C");
break;
case mh_eEventPrio_D:
strcpy( prio, "D");
break;
default:
strcpy( prio, "?");
}
etime = net_NetTimeToTime( &event->Info.EventTime);
time_AtoAscii( &etime, time_eFormat_DateAndTime, timstr, sizeof(timstr));
snprintf( text, size, "Proview alarm from node %s\nPriority %s\nEvent time %s\n\nEvent text: %s\nEvent name: %s",
nodename, prio, timstr, event->Msg.EventText, event->Msg.EventName);
}
void rt_post::format_cmd( char *cmd, char *format, char *address, char *text)
{
char *s1;
......
......@@ -66,10 +66,7 @@ using namespace std;
class rt_post {
public:
rt_post() : scan_time(1), conf(0), udb(0), sent_sms_startidx(0), sent_sms_endidx(0),
sent_email_startidx(0), sent_email_endidx(0)
{ strcpy( systemgroup, ""); }
rt_post();
void init( qcom_sQid *qid);
void open();
void close();
......@@ -81,6 +78,8 @@ class rt_post {
void sms_register( mh_sEventId *id);
int email_check( mh_sEventId *id);
int sms_check( mh_sEventId *id);
void format_sms_text( mh_sMessage *MsgP, char *text, unsigned int size);
void format_email_text( mh_sMessage *MsgP, char *text, unsigned int size);
static pwr_tStatus mh_ack_bc( mh_sAck *MsgP);
static pwr_tStatus mh_return_bc( mh_sReturn *MsgP);
......@@ -94,6 +93,7 @@ class rt_post {
double scan_time;
pwr_sClass_PostConfig *conf;
GeUser *udb;
char nodename[80];
char systemgroup[80];
mh_sEventId sent_sms[200];
mh_sEventId sent_email[200];
......
......@@ -343,7 +343,16 @@ SObject pwrb:Class
EndObject
!/**
! Recipient for epost and mms alarms.
! The recipient is a user defined in the user database.
! The recipient is a user defined in the user database in the
! current system group.
! Recipient can also be a list of users separated by comma, eg
! 'dennis, jimmy'. Also symbols defined in the Symbol table in
! the PostConfig object can be used. Symbols should be referenced
! with a $ sign before the symbol name, eg '$on_duty'.
!
! The users should be defined in the current system group or in a
! subgroup to this, If a subgroup is used, the subgroup should
! be specified in the recipient name, eg 'sms.dennis'.
!*/
Object Recipient $Attribute 41
Body SysBody
......
......@@ -380,7 +380,16 @@ SObject pwrb:Class
EndObject
!/**
! Recipient for epost and mms alarms.
! The recipient is a user defined in the user database.
! The recipient is a user defined in the user database in the
! current system group.
! Recipient can also be a list of users separated by comma, eg
! 'dennis, jimmy'. Also symbols defined in the Symbol table in
! the PostConfig object can be used. Symbols should be referenced
! with a $ sign before the symbol name, eg '$on_duty'.
!
! The users should be defined in the current system group or in a
! subgroup to this, If a subgroup is used, the subgroup should
! be specified in the recipient name, eg 'sms.dennis'.
!*/
Object Recipient $Attribute 48
Body SysBody
......
......@@ -343,7 +343,16 @@ SObject pwrb:Class
EndObject
!/**
! Recipient for epost and mms alarms.
! The recipient is a user defined in the user database.
! The recipient is a user defined in the user database in the
! current system group.
! Recipient can also be a list of users separated by comma, eg
! 'dennis, jimmy'. Also symbols defined in the Symbol table in
! the PostConfig object can be used. Symbols should be referenced
! with a $ sign before the symbol name, eg '$on_duty'.
!
! The users should be defined in the current system group or in a
! subgroup to this, If a subgroup is used, the subgroup should
! be specified in the recipient name, eg 'sms.dennis'.
!*/
Object Recipient $Attribute 38
Body SysBody
......
......@@ -335,7 +335,16 @@ SObject pwrb:Class
EndObject
!/**
! Recipient for epost and mms alarms.
! The recipient is a user defined in the user database.
! The recipient is a user defined in the user database in the
! current system group.
! Recipient can also be a list of users separated by comma, eg
! 'dennis, jimmy'. Also symbols defined in the Symbol table in
! the PostConfig object can be used. Symbols should be referenced
! with a $ sign before the symbol name, eg '$on_duty'.
!
! The users should be defined in the current system group or in a
! subgroup to this, If a subgroup is used, the subgroup should
! be specified in the recipient name, eg 'sms.dennis'.
!*/
Object Recipient $Attribute 44
Body SysBody
......
......@@ -41,6 +41,28 @@ SObject pwrb:Class
! @Group Servers,NodeConfiguration
! @Summary Configuration of event post server.
! Configuration of event post server.
!
! The Post server receives alarm events from the event monitor
! and forwards them to SMS numbers and email addresses.
!
! Alarms forwarded should have SMS or Email in the Flags attribute
! of the DSup, ASup or CycleSup object. A Recipient is also specified
! in the sup object, and this recipient is search for in the user database
! under the current system group, and from the found user, the SMS number
! or email address is fetched. Also a list of recipients can be specifed,
! separated by comma, and the event is forwarded to the SMS number or
! email address of all these users.
!
! A recipient can, in the sup object, be specified by a symbol. The should
! be defined in the Symbol table in the PostConfig object. If for example
! the recipient is specified with '$on_duty', and a symbol with name 'on_duty'
! and value 'john, dennis' is defined in symbol table, the event will be
! forwarded to the users john and dennis.
!
! The command to send a SMS or email depeneds on the utility that is used,
! and you have to insert the shell command for the utility in the
! EmailCmd and SMS_Cmd attributes. Replace the email address or SMS number
! with the string '$address' and the message text with the string '$text'.
!*/
Object PostConfig $ClassDef 548
Body SysBody
......@@ -53,6 +75,10 @@ SObject pwrb:Class
EndBody
!/**
! Specifies the email shell command.
! The command should contain the strings $address and $text.
! $adderss will be replaced by the email address for the
! specified user, and $text will be replaced by a message
! text with event text and event name.
!*/
Object EmailCmd $Attribute 1
Body SysBody
......@@ -61,6 +87,10 @@ SObject pwrb:Class
EndObject
!/**
! Specifies the SMS shell command.
! The command should contain the strings $address and $text.
! $adderss will be replaced by the sms number for the specified
! user, and $text will be replaced by a message text with event
! text and event name.
!*/
Object SMS_Cmd $Attribute 2
Body SysBody
......@@ -85,7 +115,17 @@ SObject pwrb:Class
EndBody
EndObject
!/**
! Symbol definitions.
! @Summary Recipient symbol definitions.
! Recipients can be defined with symbols, and the symbols will be
! replaced by their value in this table.
! Symbols are referenced with a $ sign before the name. The $ sign
! should not be present in the definition.
!
! @b Example
! The Recipient attibute in a DSup is 'john, $on_duty'. A symbol is defined
! with the name 'on_duty' and the value 'dennis, jimmy'. The resultant
! recipient string will be 'john, dennis, jimmy' and the event will be posted
! to the address of these three.
!*/
Object Symbols $Attribute 4
Body SysBody
......@@ -96,6 +136,14 @@ SObject pwrb:Class
EndBody
EndObject
!/**
! Specifies language.
!*/
Object Language $Attribute 10
Body SysBody
Attr TypeRef = "pwrb:Type-LanguageEnum"
EndBody
EndObject
!/**
! Server status.
!*/
Object Status $Attribute 5
......@@ -127,6 +175,7 @@ SObject pwrb:Class
EndObject
!/**
! Disable post.
! When Disable is 0, no events are posted.
!*/
Object Disable $Attribute 8
Body SysBody
......@@ -144,6 +193,7 @@ SObject pwrb:Class
EndObject
Object Template PostConfig
Body RtBody
Attr EmailCmd = "mailto 'Proview' '$address' 'Proview alarm' '$text'"
EndBody
EndObject
EndObject
......
......@@ -218,6 +218,7 @@ palette NavigatorPalette
class Opc_ServerConfig
class PlcProcess
class PlcThread
class PostConfig
class RemoteConfig
class SysMonConfig
class StatusServerConfig
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment