Commit 4b91e069 authored by claes's avatar claes

HighTimeRes replaced by Options

parent fb346057
/* /*
* Proview $Id: rt_sevhistmon.cpp,v 1.2 2008-09-09 11:24:42 claes Exp $ * Proview $Id: rt_sevhistmon.cpp,v 1.3 2008-09-18 15:06:13 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "rt_sevhistmon.h" #include "rt_sevhistmon.h"
#include "rt_sev_net.h" #include "rt_sev_net.h"
#include "rt_sev_msg.h" #include "rt_sev_msg.h"
#include "rt_pwr_msg.h"
#define sevclient_cQix 121 #define sevclient_cQix 121
...@@ -45,8 +46,24 @@ int rt_sevhistmon::init() ...@@ -45,8 +46,24 @@ int rt_sevhistmon::init()
qcom_sQid qid; qcom_sQid qid;
qcom_sNode node; qcom_sNode node;
pwr_tNid nid; pwr_tNid nid;
pwr_tOid conf_oid;
pwr_sClass_SevHistMonitor *conf_p;
sts = gdh_Init( "rt_sevhistmon"); sts = gdh_Init( "rt_sevhistmon");
if ( EVEN(sts)) throw co_error(sts);
// Get the config object
sts = gdh_GetClassList( pwr_cClass_SevHistMonitor, &conf_oid);
if ( EVEN(sts)) {
errh_CErrLog( PWR__SRVNOTCONF, 0);
exit(0);
}
sts = gdh_ObjidToPointer( conf_oid, (void **)&conf_p);
if ( EVEN(sts)) throw co_error(sts);
m_scantime = conf_p->ScanTime;
if ( m_scantime < 0.02)
m_scantime = 0.02;
// Create a queue to server // Create a queue to server
qcom_sQattr attr; qcom_sQattr attr;
...@@ -60,9 +77,9 @@ int rt_sevhistmon::init() ...@@ -60,9 +77,9 @@ int rt_sevhistmon::init()
if ( sts == QCOM__QALLREXIST) { if ( sts == QCOM__QALLREXIST) {
if ( !qcom_AttachQ(&sts, &qid)) { if ( !qcom_AttachQ(&sts, &qid)) {
if ( !qcom_DeleteQ(&sts, &qid)) if ( !qcom_DeleteQ(&sts, &qid))
co_error(sts); throw co_error(sts);
if ( !qcom_CreateQ(&sts, &qid, &attr, "SevClient")) if ( !qcom_CreateQ(&sts, &qid, &attr, "SevClient"))
co_error(sts); throw co_error(sts);
} }
} }
else else
...@@ -159,7 +176,7 @@ int rt_sevhistmon::init() ...@@ -159,7 +176,7 @@ int rt_sevhistmon::init()
h.sevid.rix = m_next_rix++; h.sevid.rix = m_next_rix++;
h.storagetime = h_p->StorageTime; h.storagetime = h_p->StorageTime;
h.deadband = h_p->DeadBand; h.deadband = h_p->DeadBand;
h.hightimeres = h_p->HighTimeResolution; h.options = h_p->Options;
strncpy( h.description, h_p->Description, sizeof(h.description)); strncpy( h.description, h_p->Description, sizeof(h.description));
// Get unit from attribute object // Get unit from attribute object
...@@ -233,7 +250,7 @@ int rt_sevhistmon::send_data() ...@@ -233,7 +250,7 @@ int rt_sevhistmon::send_data()
int stime; int stime;
for ( unsigned int i = 0; i < m_hs.size(); i++) { for ( unsigned int i = 0; i < m_hs.size(); i++) {
stime = int(m_hs[i].scantime + 0.5); stime = int(m_hs[i].scantime / m_scantime + 0.5);
if ( !stime || m_loopcnt % stime != 0) if ( !stime || m_loopcnt % stime != 0)
continue; continue;
...@@ -357,7 +374,7 @@ int rt_sevhistmon::send_itemlist( pwr_tNid nid) ...@@ -357,7 +374,7 @@ int rt_sevhistmon::send_itemlist( pwr_tNid nid)
strcpy( ((sev_sMsgHistItems *)put.data)->Items[k].attr[0].aname, s + 1); strcpy( ((sev_sMsgHistItems *)put.data)->Items[k].attr[0].aname, s + 1);
((sev_sMsgHistItems *)put.data)->Items[k].storagetime = m_hs[i].sevhistlist[j].storagetime; ((sev_sMsgHistItems *)put.data)->Items[k].storagetime = m_hs[i].sevhistlist[j].storagetime;
((sev_sMsgHistItems *)put.data)->Items[k].deadband = m_hs[i].sevhistlist[j].deadband; ((sev_sMsgHistItems *)put.data)->Items[k].deadband = m_hs[i].sevhistlist[j].deadband;
((sev_sMsgHistItems *)put.data)->Items[k].hightimeres = m_hs[i].sevhistlist[j].hightimeres; ((sev_sMsgHistItems *)put.data)->Items[k].options = m_hs[i].sevhistlist[j].options;
((sev_sMsgHistItems *)put.data)->Items[k].attr[0].type = m_hs[i].sevhistlist[j].type; ((sev_sMsgHistItems *)put.data)->Items[k].attr[0].type = m_hs[i].sevhistlist[j].type;
((sev_sMsgHistItems *)put.data)->Items[k].attr[0].size = m_hs[i].sevhistlist[j].size; ((sev_sMsgHistItems *)put.data)->Items[k].attr[0].size = m_hs[i].sevhistlist[j].size;
((sev_sMsgHistItems *)put.data)->Items[k].sevid = m_hs[i].sevhistlist[j].sevid; ((sev_sMsgHistItems *)put.data)->Items[k].sevid = m_hs[i].sevhistlist[j].sevid;
...@@ -393,7 +410,7 @@ int rt_sevhistmon::send_itemlist( pwr_tNid nid) ...@@ -393,7 +410,7 @@ int rt_sevhistmon::send_itemlist( pwr_tNid nid)
int rt_sevhistmon::mainloop() int rt_sevhistmon::mainloop()
{ {
qcom_sQid qid; qcom_sQid qid;
int tmo = 1000; int tmo = int(1000 * m_scantime);
qcom_sGet get; qcom_sGet get;
void *mp; void *mp;
pwr_tStatus sts; pwr_tStatus sts;
...@@ -432,7 +449,13 @@ int main() ...@@ -432,7 +449,13 @@ int main()
{ {
rt_sevhistmon client; rt_sevhistmon client;
client.init(); try {
client.init();
}
catch ( co_error e) {
errh_Error( "SevHistMonitor terminating, %m", e.sts());
exit(0);
}
client.mainloop(); client.mainloop();
......
/* /*
* Proview $Id: rt_sevhistmon.h,v 1.2 2008-09-09 11:24:42 claes Exp $ * Proview $Id: rt_sevhistmon.h,v 1.3 2008-09-18 15:06:13 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -33,7 +33,7 @@ class sev_sevhist { ...@@ -33,7 +33,7 @@ class sev_sevhist {
void *datap; void *datap;
pwr_tDeltaTime storagetime; pwr_tDeltaTime storagetime;
pwr_tFloat32 deadband; pwr_tFloat32 deadband;
pwr_tBoolean hightimeres; pwr_tMask options;
pwr_eType type; pwr_eType type;
unsigned int size; unsigned int size;
pwr_tRefId sevid; pwr_tRefId sevid;
...@@ -69,6 +69,7 @@ class rt_sevhistmon { ...@@ -69,6 +69,7 @@ class rt_sevhistmon {
unsigned int m_msg_id; unsigned int m_msg_id;
unsigned int m_next_rix; unsigned int m_next_rix;
unsigned int m_loopcnt; unsigned int m_loopcnt;
float m_scantime;
int init(); int init();
int close(); int close();
......
/* /*
* Proview $Id: rt_sev_net.h,v 1.3 2008-09-09 11:27:32 claes Exp $ * Proview $Id: rt_sev_net.h,v 1.4 2008-09-18 15:06:13 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -60,7 +60,7 @@ typedef struct { ...@@ -60,7 +60,7 @@ typedef struct {
pwr_tString80 description; pwr_tString80 description;
pwr_tFloat32 scantime; pwr_tFloat32 scantime;
pwr_tFloat32 deadband; pwr_tFloat32 deadband;
pwr_tBoolean hightimeres; pwr_tMask options;
unsigned int attrnum; unsigned int attrnum;
sev_sHistAttr attr[1]; sev_sHistAttr attr[1];
} sev_sHistItem; } sev_sHistItem;
......
/* /*
* Proview $Id: rt_sevcli.c,v 1.3 2008-09-09 11:27:32 claes Exp $ * Proview $Id: rt_sevcli.c,v 1.4 2008-09-18 15:06:13 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -161,7 +161,7 @@ int sevcli_get_itemlist( pwr_tStatus *sts, sevcli_tCtx ctx, sevcli_sHistItem **l ...@@ -161,7 +161,7 @@ int sevcli_get_itemlist( pwr_tStatus *sts, sevcli_tCtx ctx, sevcli_sHistItem **l
strncpy( lp[i].oname, rmsg->Items[i].oname, sizeof(lp[0].oname)); strncpy( lp[i].oname, rmsg->Items[i].oname, sizeof(lp[0].oname));
lp[i].storagetime = rmsg->Items[i].storagetime; lp[i].storagetime = rmsg->Items[i].storagetime;
lp[i].deadband = rmsg->Items[i].deadband; lp[i].deadband = rmsg->Items[i].deadband;
lp[i].hightimeres = rmsg->Items[i].hightimeres; lp[i].options = rmsg->Items[i].options;
lp[i].creatime = rmsg->Items[i].creatime; lp[i].creatime = rmsg->Items[i].creatime;
lp[i].modtime = rmsg->Items[i].modtime; lp[i].modtime = rmsg->Items[i].modtime;
strncpy( lp[i].description, rmsg->Items[i].description, sizeof(lp[0].description)); strncpy( lp[i].description, rmsg->Items[i].description, sizeof(lp[0].description));
......
/* /*
* Proview $Id: rt_sevcli.h,v 1.3 2008-09-09 11:27:32 claes Exp $ * Proview $Id: rt_sevcli.h,v 1.4 2008-09-18 15:06:13 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -59,7 +59,7 @@ typedef struct { ...@@ -59,7 +59,7 @@ typedef struct {
pwr_tString80 description; pwr_tString80 description;
pwr_tFloat32 scantime; pwr_tFloat32 scantime;
pwr_tFloat32 deadband; pwr_tFloat32 deadband;
pwr_tBoolean hightimeres; pwr_tMask options;
unsigned int attrnum; unsigned int attrnum;
sevcli_sHistAttr attr[1]; sevcli_sHistAttr attr[1];
} sevcli_sHistItem; } sevcli_sHistItem;
......
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