Commit f33c8fbb authored by Claes Sjofors's avatar Claes Sjofors

rt_post modifications

parent 815eb52e
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "co_cdh.h" #include "co_cdh.h"
#include "co_time.h" #include "co_time.h"
#include "co_dcli.h" #include "co_dcli.h"
#include "co_syi.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_qcom.h" #include "rt_qcom.h"
#include "rt_ini_event.h" #include "rt_ini_event.h"
...@@ -65,6 +66,15 @@ union alau_Event ...@@ -65,6 +66,15 @@ union alau_Event
mh_sBlock Block; 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() void rt_post::open()
{ {
pwr_tStatus sts; pwr_tStatus sts;
...@@ -199,6 +209,7 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP) ...@@ -199,6 +209,7 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP)
pwr_tDeltaTime diff; pwr_tDeltaTime diff;
int rcvnum; int rcvnum;
char rcv_array[10][80]; char rcv_array[10][80];
char text[400];
if ( !post || post->conf->Disable) if ( !post || post->conf->Disable)
return 1; return 1;
...@@ -282,7 +293,8 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP) ...@@ -282,7 +293,8 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP)
ul->get_email( address, sizeof(address)); 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) if ( post->conf->Log)
errh_Info( "Email: %s", cmd); errh_Info( "Email: %s", cmd);
...@@ -298,7 +310,8 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP) ...@@ -298,7 +310,8 @@ pwr_tStatus rt_post::mh_alarm_bc( mh_sMessage *MsgP)
ul->get_sms( sms, sizeof(sms)); 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) if ( post->conf->Log)
errh_Info( "SMS: %s", cmd); errh_Info( "SMS: %s", cmd);
...@@ -330,6 +343,63 @@ pwr_tStatus rt_post::mh_clear_blocklist_bc( pwr_tNodeIndex nix) ...@@ -330,6 +343,63 @@ pwr_tStatus rt_post::mh_clear_blocklist_bc( pwr_tNodeIndex nix)
return 1; 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) void rt_post::format_cmd( char *cmd, char *format, char *address, char *text)
{ {
char *s1; char *s1;
......
...@@ -66,10 +66,7 @@ using namespace std; ...@@ -66,10 +66,7 @@ using namespace std;
class rt_post { class rt_post {
public: public:
rt_post() : scan_time(1), conf(0), udb(0), sent_sms_startidx(0), sent_sms_endidx(0), rt_post();
sent_email_startidx(0), sent_email_endidx(0)
{ strcpy( systemgroup, ""); }
void init( qcom_sQid *qid); void init( qcom_sQid *qid);
void open(); void open();
void close(); void close();
...@@ -81,6 +78,8 @@ class rt_post { ...@@ -81,6 +78,8 @@ class rt_post {
void sms_register( mh_sEventId *id); void sms_register( mh_sEventId *id);
int email_check( mh_sEventId *id); int email_check( mh_sEventId *id);
int sms_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_ack_bc( mh_sAck *MsgP);
static pwr_tStatus mh_return_bc( mh_sReturn *MsgP); static pwr_tStatus mh_return_bc( mh_sReturn *MsgP);
...@@ -94,6 +93,7 @@ class rt_post { ...@@ -94,6 +93,7 @@ class rt_post {
double scan_time; double scan_time;
pwr_sClass_PostConfig *conf; pwr_sClass_PostConfig *conf;
GeUser *udb; GeUser *udb;
char nodename[80];
char systemgroup[80]; char systemgroup[80];
mh_sEventId sent_sms[200]; mh_sEventId sent_sms[200];
mh_sEventId sent_email[200]; mh_sEventId sent_email[200];
......
...@@ -343,7 +343,16 @@ SObject pwrb:Class ...@@ -343,7 +343,16 @@ SObject pwrb:Class
EndObject EndObject
!/** !/**
! Recipient for epost and mms alarms. ! 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 Object Recipient $Attribute 41
Body SysBody Body SysBody
......
...@@ -380,7 +380,16 @@ SObject pwrb:Class ...@@ -380,7 +380,16 @@ SObject pwrb:Class
EndObject EndObject
!/** !/**
! Recipient for epost and mms alarms. ! 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 Object Recipient $Attribute 48
Body SysBody Body SysBody
......
...@@ -343,7 +343,16 @@ SObject pwrb:Class ...@@ -343,7 +343,16 @@ SObject pwrb:Class
EndObject EndObject
!/** !/**
! Recipient for epost and mms alarms. ! 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 Object Recipient $Attribute 38
Body SysBody Body SysBody
......
...@@ -335,7 +335,16 @@ SObject pwrb:Class ...@@ -335,7 +335,16 @@ SObject pwrb:Class
EndObject EndObject
!/** !/**
! Recipient for epost and mms alarms. ! 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 Object Recipient $Attribute 44
Body SysBody Body SysBody
......
...@@ -41,6 +41,28 @@ SObject pwrb:Class ...@@ -41,6 +41,28 @@ SObject pwrb:Class
! @Group Servers,NodeConfiguration ! @Group Servers,NodeConfiguration
! @Summary Configuration of event post server. ! @Summary Configuration of event post server.
! 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 Object PostConfig $ClassDef 548
Body SysBody Body SysBody
...@@ -53,6 +75,10 @@ SObject pwrb:Class ...@@ -53,6 +75,10 @@ SObject pwrb:Class
EndBody EndBody
!/** !/**
! Specifies the email shell command. ! 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 Object EmailCmd $Attribute 1
Body SysBody Body SysBody
...@@ -61,6 +87,10 @@ SObject pwrb:Class ...@@ -61,6 +87,10 @@ SObject pwrb:Class
EndObject EndObject
!/** !/**
! Specifies the SMS shell command. ! 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 Object SMS_Cmd $Attribute 2
Body SysBody Body SysBody
...@@ -85,7 +115,17 @@ SObject pwrb:Class ...@@ -85,7 +115,17 @@ SObject pwrb:Class
EndBody EndBody
EndObject 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 Object Symbols $Attribute 4
Body SysBody Body SysBody
...@@ -96,6 +136,14 @@ SObject pwrb:Class ...@@ -96,6 +136,14 @@ SObject pwrb:Class
EndBody EndBody
EndObject EndObject
!/** !/**
! Specifies language.
!*/
Object Language $Attribute 10
Body SysBody
Attr TypeRef = "pwrb:Type-LanguageEnum"
EndBody
EndObject
!/**
! Server status. ! Server status.
!*/ !*/
Object Status $Attribute 5 Object Status $Attribute 5
...@@ -127,6 +175,7 @@ SObject pwrb:Class ...@@ -127,6 +175,7 @@ SObject pwrb:Class
EndObject EndObject
!/** !/**
! Disable post. ! Disable post.
! When Disable is 0, no events are posted.
!*/ !*/
Object Disable $Attribute 8 Object Disable $Attribute 8
Body SysBody Body SysBody
...@@ -144,6 +193,7 @@ SObject pwrb:Class ...@@ -144,6 +193,7 @@ SObject pwrb:Class
EndObject EndObject
Object Template PostConfig Object Template PostConfig
Body RtBody Body RtBody
Attr EmailCmd = "mailto 'Proview' '$address' 'Proview alarm' '$text'"
EndBody EndBody
EndObject EndObject
EndObject EndObject
......
...@@ -218,6 +218,7 @@ palette NavigatorPalette ...@@ -218,6 +218,7 @@ palette NavigatorPalette
class Opc_ServerConfig class Opc_ServerConfig
class PlcProcess class PlcProcess
class PlcThread class PlcThread
class PostConfig
class RemoteConfig class RemoteConfig
class SysMonConfig class SysMonConfig
class StatusServerConfig 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