Fetch data from a storage station


Data stored in a ProviewR storage station can be fetched by the client interface sevcli.
First you initiate sevcli with sevcli_init() and state which storage station you want to
fetch the data from with sevcli_set_servernode().

sevcli_tCtx sevctx;
char server_node[40] = "MyStorageStation";

if ( !sevcli_init( &sts, &sevctx))
   throw co_error(sts);

if ( !sevcli_set_servernode( &sts, sevctx, server_node))
   throw co_error(sts);

Then you can fetch data with sevcli_get_itemdata(). Data is identified by object identity and
attribute name. You also state the time range for the data that is to be fetched and
maximum number of points.

pwr_tTime *time_buf;
void *value_buf;
pwr_tTime from = pwr_cNTime;
pwr_tTime to = pwr_cNTime;
int rows;
pwr_eType vtype;
unsigned int vsize;
pwr_tOName name = "H1-H2-Temperature";
pwr_tOName aname = "ActualValue";
pwr_tObjid oid;
char timstr[40];

sts = gdh_NameToObjid( name, &oid);
if (EVEN(sts)) throw co_error(sts);

if ( !sevcli_get_itemdata( &sts, sevctx, oid, aname, from, to, 1000, &time_buf, &value_buf,
                            &rows, &vtype, &vsize))
   throw co_error(sts);

for ( int i = 0; i < rows; i++) {
   time_AtoAscii( &time_buf[i], time_eFormat_DateAndTime, timstr, sizeof(timstr));

   cout << timstr << " " << ((pwr_tFloat32 *)value_buf)[i] << endl;
}

free( time_buf);
free( value_buf);

Finally you call sevcli_close() to disconnect the server node.

sevcli_close( &sts, sevctx);