Commit 6c660180 authored by Claes Sjofors's avatar Claes Sjofors

Sev, triggered storage and dynamic disable function added

parent d0f0e8a0
...@@ -196,20 +196,19 @@ int rt_sevhistmon::init_objects() ...@@ -196,20 +196,19 @@ int rt_sevhistmon::init_objects()
ODD(sts); ODD(sts);
sts = gdh_GetNextAttrRef( pwr_cClass_SevHist, &h_aref, &h_aref)) { sts = gdh_GetNextAttrRef( pwr_cClass_SevHist, &h_aref, &h_aref)) {
sev_sevhist h; sev_sevhist h;
pwr_sClass_SevHist *h_p;
int hs_idx; int hs_idx;
m_sts = gdh_AttrRefToPointer( &h_aref, (void **)&h_p); m_sts = gdh_DLRefObjectInfoAttrref( &h_aref, (void **)&h.hsp, &h.hs_refid);
if ( EVEN(m_sts)) throw co_error(m_sts); if ( EVEN(m_sts)) throw co_error(m_sts);
h.aref = h_p->Attribute; h.aref = h.hsp->Attribute;
m_sts = gdh_AttrrefToName( &h_aref, hname, sizeof(hname), cdh_mName_volumeStrict); m_sts = gdh_AttrrefToName( &h_aref, hname, sizeof(hname), cdh_mName_volumeStrict);
if ( EVEN(m_sts)) throw co_error(m_sts); if ( EVEN(m_sts)) throw co_error(m_sts);
hs_idx = -1; hs_idx = -1;
for ( int i = 0; i < (int) m_hs.size(); i++) { for ( int i = 0; i < (int) m_hs.size(); i++) {
if ( cdh_ObjidIsEqual( h_p->ThreadObject, m_hs[i].oid)) { if ( cdh_ObjidIsEqual( h.hsp->ThreadObject, m_hs[i].oid)) {
hs_idx = i; hs_idx = i;
break; break;
} }
...@@ -219,7 +218,7 @@ int rt_sevhistmon::init_objects() ...@@ -219,7 +218,7 @@ int rt_sevhistmon::init_objects()
continue; continue;
} }
m_sts = gdh_GetAttributeCharAttrref( &h_p->Attribute, &a_tid, &a_size, &a_offset, &a_dim); m_sts = gdh_GetAttributeCharAttrref( &h.hsp->Attribute, &a_tid, &a_size, &a_offset, &a_dim);
if ( EVEN(m_sts)) { if ( EVEN(m_sts)) {
errh_Error( "Invalid SevHist Attribute %s", hname); errh_Error( "Invalid SevHist Attribute %s", hname);
continue; continue;
...@@ -227,14 +226,14 @@ int rt_sevhistmon::init_objects() ...@@ -227,14 +226,14 @@ int rt_sevhistmon::init_objects()
h.sevid.nid = m_nodes[0].nid; h.sevid.nid = m_nodes[0].nid;
h.sevid.rix = m_next_rix++; h.sevid.rix = m_next_rix++;
h.storagetime = h_p->StorageTime; h.storagetime = h.hsp->StorageTime;
h.deadband = h_p->DeadBand; h.deadband = h.hsp->DeadBand;
h.options = h_p->Options; h.options = h.hsp->Options;
h.disabled = h_p->Disable; h.disabled = h.hsp->Disable;
strncpy( h.description, h_p->Description, sizeof(h.description)); strncpy( h.description, h.hsp->Description, sizeof(h.description));
// Get unit from attribute object // Get unit from attribute object
sts = gdh_ArefANameToAref( &h_p->Attribute, "Unit", &uaref); sts = gdh_ArefANameToAref( &h.hsp->Attribute, "Unit", &uaref);
if ( ODD(sts)) { if ( ODD(sts)) {
sts = gdh_GetObjectInfoAttrref( &uaref, &h.unit, sizeof(h.unit)); sts = gdh_GetObjectInfoAttrref( &uaref, &h.unit, sizeof(h.unit));
if ( EVEN(sts)) if ( EVEN(sts))
...@@ -252,7 +251,7 @@ int rt_sevhistmon::init_objects() ...@@ -252,7 +251,7 @@ int rt_sevhistmon::init_objects()
continue; continue;
} }
m_sts = gdh_AttrrefToName( &h_p->Attribute, h.aname, sizeof(h.aname), cdh_mName_volumeStrict); m_sts = gdh_AttrrefToName( &h.hsp->Attribute, h.aname, sizeof(h.aname), cdh_mName_volumeStrict);
if ( EVEN(m_sts)) throw co_error(m_sts); if ( EVEN(m_sts)) throw co_error(m_sts);
m_sts = gdh_RefObjectInfo( h.aname, &h.datap, &h.refid, h.size); m_sts = gdh_RefObjectInfo( h.aname, &h.datap, &h.refid, h.size);
...@@ -284,20 +283,19 @@ int rt_sevhistmon::init_sevhistobjects() ...@@ -284,20 +283,19 @@ int rt_sevhistmon::init_sevhistobjects()
ODD(sts); ODD(sts);
sts = gdh_GetNextAttrRef( pwr_cClass_SevHistObject, &h_aref, &h_aref)) { sts = gdh_GetNextAttrRef( pwr_cClass_SevHistObject, &h_aref, &h_aref)) {
sev_sevhistobject h; sev_sevhistobject h;
pwr_sClass_SevHistObject *h_p;
int hs_idx; int hs_idx;
m_sts = gdh_AttrRefToPointer( &h_aref, (void **)&h_p); m_sts = gdh_DLRefObjectInfoAttrref( &h_aref, (void **)&h.hsp, &h.hs_refid);
if ( EVEN(m_sts)) throw co_error(m_sts); if ( EVEN(m_sts)) throw co_error(m_sts);
h.aref = h_p->Object; h.aref = h.hsp->Object;
m_sts = gdh_AttrrefToName( &h_aref, hname, sizeof(hname), cdh_mName_volumeStrict); m_sts = gdh_AttrrefToName( &h_aref, hname, sizeof(hname), cdh_mName_volumeStrict);
if ( EVEN(m_sts)) throw co_error(m_sts); if ( EVEN(m_sts)) throw co_error(m_sts);
hs_idx = -1; hs_idx = -1;
for ( int i = 0; i < (int) m_hs.size(); i++) { for ( int i = 0; i < (int) m_hs.size(); i++) {
if ( cdh_ObjidIsEqual( h_p->ThreadObject, m_hs[i].oid)) { if ( cdh_ObjidIsEqual( h.hsp->ThreadObject, m_hs[i].oid)) {
hs_idx = i; hs_idx = i;
break; break;
} }
...@@ -307,17 +305,17 @@ int rt_sevhistmon::init_sevhistobjects() ...@@ -307,17 +305,17 @@ int rt_sevhistmon::init_sevhistobjects()
continue; continue;
} }
m_sts = gdh_GetAttributeCharAttrref( &h_p->Object, &a_tid, &a_size, &a_offset, &a_dim); m_sts = gdh_GetAttributeCharAttrref( &h.hsp->Object, &a_tid, &a_size, &a_offset, &a_dim);
if ( EVEN(m_sts)) { if ( EVEN(m_sts)) {
errh_Error( "Invalid SevHistObject Attribute %s", hname); errh_Error( "Invalid SevHistObject Attribute %s", hname);
continue; continue;
} }
h.storagetime = h_p->StorageTime; h.storagetime = h.hsp->StorageTime;
h.deadband = h_p->DeadBand; h.deadband = h.hsp->DeadBand;
h.options = h_p->Options; h.options = h.hsp->Options;
h.disabled = h_p->Disable; h.disabled = h.hsp->Disable;
strncpy( h.description, h_p->Description, sizeof(h.description)); strncpy( h.description, h.hsp->Description, sizeof(h.description));
h.scantime = m_hs[hs_idx].scantime; h.scantime = m_hs[hs_idx].scantime;
...@@ -325,7 +323,7 @@ int rt_sevhistmon::init_sevhistobjects() ...@@ -325,7 +323,7 @@ int rt_sevhistmon::init_sevhistobjects()
h.sevid.rix = m_next_rix++; h.sevid.rix = m_next_rix++;
//Time to fetch all attributes for the object and put them into a list //Time to fetch all attributes for the object and put them into a list
m_sts = gdh_AttrrefToName( &h_p->Object, hname, sizeof(hname), cdh_mName_volumeStrict); m_sts = gdh_AttrrefToName( &h.hsp->Object, hname, sizeof(hname), cdh_mName_volumeStrict);
if ( EVEN(m_sts)) throw co_error(m_sts); if ( EVEN(m_sts)) throw co_error(m_sts);
strcpy(h.aname, hname); strcpy(h.aname, hname);
get_sevhistobjectattributes(hname, &h.sevhistobjectattrlist, hs_idx, true); get_sevhistobjectattributes(hname, &h.sevhistobjectattrlist, hs_idx, true);
...@@ -580,8 +578,10 @@ bool rt_sevhistmon::correct_histtype(const pwr_eType type) ...@@ -580,8 +578,10 @@ bool rt_sevhistmon::correct_histtype(const pwr_eType type)
int rt_sevhistmon::close_objects() int rt_sevhistmon::close_objects()
{ {
for ( unsigned int i = 0; i < m_hs.size(); i++) { for ( unsigned int i = 0; i < m_hs.size(); i++) {
for ( unsigned int j = 0; j < m_hs[i].sevhistlist.size(); j++) for ( unsigned int j = 0; j < m_hs[i].sevhistlist.size(); j++) {
gdh_UnrefObjectInfo( m_hs[i].sevhistlist[j].hs_refid);
gdh_UnrefObjectInfo( m_hs[i].sevhistlist[j].refid); gdh_UnrefObjectInfo( m_hs[i].sevhistlist[j].refid);
}
gdh_UnrefObjectInfo( m_hs[i].refid); gdh_UnrefObjectInfo( m_hs[i].refid);
} }
m_hs.clear(); m_hs.clear();
...@@ -637,7 +637,13 @@ int rt_sevhistmon::send_data() ...@@ -637,7 +637,13 @@ int rt_sevhistmon::send_data()
dp = (sev_sHistData *) &msg->Data; dp = (sev_sHistData *) &msg->Data;
for ( unsigned int j = 0; j < m_hs[i].sevhistlist.size(); j++) { for ( unsigned int j = 0; j < m_hs[i].sevhistlist.size(); j++) {
if ( !m_hs[i].sevhistlist[j].disabled) { if ( !m_hs[i].sevhistlist[j].hsp->Disable) {
if ( m_hs[i].sevhistlist[j].hsp->Options & pwr_mSevOptionsMask_Event &&
m_hs[i].sevhistlist[j].hsp->Trigger)
m_hs[i].sevhistlist[j].hsp->Trigger = 0;
else
continue;
dp->sevid = m_hs[i].sevhistlist[j].sevid; dp->sevid = m_hs[i].sevhistlist[j].sevid;
dp->type = m_hs[i].sevhistlist[j].type; dp->type = m_hs[i].sevhistlist[j].type;
dp->size = m_hs[i].sevhistlist[j].size; dp->size = m_hs[i].sevhistlist[j].size;
...@@ -648,11 +654,17 @@ int rt_sevhistmon::send_data() ...@@ -648,11 +654,17 @@ int rt_sevhistmon::send_data()
void *dpp; void *dpp;
for ( unsigned int j = 0; j < m_hs[i].sevhistobjectlist.size(); j++) { for ( unsigned int j = 0; j < m_hs[i].sevhistobjectlist.size(); j++) {
if ( !m_hs[i].sevhistobjectlist[j].hsp->Disable) {
if ( m_hs[i].sevhistobjectlist[j].hsp->Options & pwr_mSevOptionsMask_Event &&
m_hs[i].sevhistobjectlist[j].hsp->Trigger)
m_hs[i].sevhistobjectlist[j].hsp->Trigger = 0;
else
continue;
dp->sevid = m_hs[i].sevhistobjectlist[j].sevid; dp->sevid = m_hs[i].sevhistobjectlist[j].sevid;
dp->size = m_hs[i].sevhistobjectlist[j].datasize; dp->size = m_hs[i].sevhistobjectlist[j].datasize;
dpp = &(dp->data); dpp = &(dp->data);
for ( unsigned int k = 0; k < m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist.size(); k++) { for ( unsigned int k = 0; k < m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist.size(); k++) {
if ( !m_hs[i].sevhistobjectlist[j].disabled) {
//dp->type = m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].type; //dp->type = m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].type;
//printf("sevhistobj[%d].attrlist[%d].aname: %s size:%d\n", j, k, m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].aname, m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].size); //printf("sevhistobj[%d].attrlist[%d].aname: %s size:%d\n", j, k, m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].aname, m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].size);
//if( m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].type == pwr_eType_String ) { //if( m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].type == pwr_eType_String ) {
...@@ -661,9 +673,9 @@ int rt_sevhistmon::send_data() ...@@ -661,9 +673,9 @@ int rt_sevhistmon::send_data()
memcpy( dpp, m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].datap, m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].size); memcpy( dpp, m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].datap, m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].size);
dpp = (sev_sHistData *)((char *)dpp + m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].size); dpp = (sev_sHistData *)((char *)dpp + m_hs[i].sevhistobjectlist[j].sevhistobjectattrlist[k].size);
} }
}
dp = (sev_sHistData *)((char *)dp + sizeof( *dp) - sizeof(dp->data) + dp->size); dp = (sev_sHistData *)((char *)dp + sizeof( *dp) - sizeof(dp->data) + dp->size);
} }
}
tgt.nid = m_hs[i].nid; tgt.nid = m_hs[i].nid;
tgt.qix = sev_eProcSevServer; tgt.qix = sev_eProcSevServer;
...@@ -869,8 +881,7 @@ int rt_sevhistmon::send_itemlist( pwr_tNid nid) ...@@ -869,8 +881,7 @@ int rt_sevhistmon::send_itemlist( pwr_tNid nid)
for ( unsigned int i = 0; i < m_hs.size(); i++) { for ( unsigned int i = 0; i < m_hs.size(); i++) {
if ( m_hs[i].configerror) if ( m_hs[i].configerror)
continue; continue;
if ( nid == m_hs[i].nid) if ( nid == m_hs[i].nid) {
{
item_cnt += m_hs[i].sevhistlist.size(); item_cnt += m_hs[i].sevhistlist.size();
attr_cnt += m_hs[i].sevhistlist.size(); attr_cnt += m_hs[i].sevhistlist.size();
objectitem_cnt += m_hs[i].sevhistobjectlist.size(); objectitem_cnt += m_hs[i].sevhistobjectlist.size();
......
...@@ -46,6 +46,8 @@ class sev_sevhist { ...@@ -46,6 +46,8 @@ class sev_sevhist {
public: public:
pwr_tAttrRef aref; pwr_tAttrRef aref;
pwr_tAName aname; pwr_tAName aname;
pwr_sClass_SevHist *hsp;
pwr_tRefId hs_refid;
pwr_tRefId refid; pwr_tRefId refid;
void *datap; void *datap;
pwr_tDeltaTime storagetime; pwr_tDeltaTime storagetime;
...@@ -76,6 +78,8 @@ class sev_sevhistobject { ...@@ -76,6 +78,8 @@ class sev_sevhistobject {
public: public:
pwr_tAttrRef aref; pwr_tAttrRef aref;
pwr_tAName aname; pwr_tAName aname;
pwr_sClass_SevHistObject *hsp;
pwr_tRefId hs_refid;
pwr_tDeltaTime storagetime; pwr_tDeltaTime storagetime;
pwr_tFloat32 deadband; pwr_tFloat32 deadband;
pwr_tMask options; pwr_tMask options;
......
...@@ -138,6 +138,19 @@ SObject pwrb:Class ...@@ -138,6 +138,19 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! Trigger a storage when event controlled storage is configured.
! Trigger can be set from the application or from a process graph,
! and when it has been detected by the rt_sevhistmon process, it
! will be reset by this process.
!
! To configure even controlled storage, set Event in Options.
!*/
Object Trigger $Attribute 8
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
EndObject EndObject
Object Template SevHist Object Template SevHist
Body RtBody Body RtBody
......
...@@ -133,6 +133,19 @@ SObject pwrb:Class ...@@ -133,6 +133,19 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
EndObject EndObject
!/**
! Trigger a storage when event controlled storage is configured.
! Trigger can be set from the application or from a process graph,
! and when it has been detected by the rt_sevhistmon process, it
! will be reset by this process.
!
! To configure even controlled storage, set Event in Options.
!*/
Object Trigger $Attribute 8
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
EndObject EndObject
Object Template SevHistObject Object Template SevHistObject
Body RtBody Body RtBody
......
...@@ -115,6 +115,17 @@ SObject pwrb:Type ...@@ -115,6 +115,17 @@ SObject pwrb:Type
Attr Value = 16 Attr Value = 16
EndBody EndBody
EndObject EndObject
!/**
! Event controlled storage. The attribute will only be stored
! one time when the trigger is activated.
!*/
Object Event $Bit
Body SysBody
Attr PgmName = "Event"
Attr Text = "Event"
Attr Value = 32
EndBody
EndObject
EndObject EndObject
EndSObject EndSObject
......
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