Пример #1
0
void ra_result::setPointer(int resultNo, const char *pointer)
// Set pointer to result
{
  pwr_sAttrRef    attrref;
  pwr_tDlid       refid;
  pwr_tStatus     sts;
  
  resultNo_ = resultNo;
  
  sts = gdh_NameToAttrref( pwr_cNObjid, pointer, &attrref);
  if ( EVEN(sts)) throw co_error(sts);

  sts = gdh_DLRefObjectInfoAttrref( &attrref, (void**)&pointer_, &refid);
  if ( EVEN(sts)) throw co_error(sts);

  dlid_ = &refid;
}
Пример #2
0
pwr_tStatus wsx_error_msg( 
    ldh_tSesContext	sesctx,
    pwr_tStatus 	sts,
    pwr_tAttrRef	aref,
    int			*errorcount,
    int			*warningcount
)
{
  static char 	msg[256];
  int		status, size;
  pwr_tAName	name;
  char		*namep;
  FILE 		*logfile;
  
  logfile = NULL;
  
  if (EVEN(sts)) {
    
    msg_GetMsg( sts, msg, sizeof(msg));
    
    if (logfile != NULL)
      fprintf(logfile, "%s\n", msg);
    else
      printf("%s\n", msg);
    if ( cdh_ObjidIsNull( aref.Objid))
      MsgWindow::message( co_error(sts), 0, 0);
    else {
      /* Get the full hierarchy name for the node */
      status = ldh_AttrRefToName( sesctx, &aref,
				  cdh_mNName, &namep, &size);
      if( EVEN(status)) return status;
      
      strncpy( name, namep, sizeof(name));
      if (logfile != NULL)
	fprintf(logfile, "        in object  %s\n", name);
      else
	printf("        in object  %s\n", name);
      MsgWindow::message( co_error(sts), "   in object", name, aref.Objid);
    }
    if ( (sts & 2) && !(sts & 1))
      (*errorcount)++;
    else if ( !(sts & 2) && !(sts & 1))
      (*warningcount)++;
  }
  return WSX__SUCCESS;
}
Пример #3
0
void ra_mean::open()
// ra_mean::open calls every program start
{
  pwr_tStatus	sts;
  pwr_tUInt32	num;
  pwr_tObjid	aoid;
  string	line, tmpSystem, tmpPointer, tmpTime;
  pwr_tBoolean	newResult = TRUE;
  pwr_tInt32	nValues = 0;
  
  isActive_ = 0;
  nResultsMax_ = 5;
  nResults_ = 0;
  resultsList_ = new ra_result[nResultsMax_]; // Allocate memory for resultsList_
  
  ifstream setup_file("ra_mean_setup.txt"); // Setup file
  
  if(setup_file.is_open() ) { // Open setup file
    
    while ( getline (setup_file, line) ) { // Get lines i setup file
      
      if(line.substr(0,1) != "#") { // Check if line don't start with #, then read info
	tmpSystem = line.substr(0, line.find(' ') );
	tmpPointer = line.substr((line.find(' ') + 1), line.length() - line.find(' ') );
	
	if(tmpPointer.find(' ') != string::npos)
	  tmpPointer = tmpPointer.substr(0, tmpPointer.find(' '));
	
	if(newResult) { // If it's the first row in description, create a new result
	  addResult( tmpSystem.c_str(), tmpPointer.c_str() );
	  newResult = FALSE;
	}
	else { // Else we create a new value to the current result 
	  resultsList_[nResults_].addValue(tmpPointer.c_str());
	  nValues++;
	}
      }
      else { // If we encounter a #, then we shall prepare for a new result entry
	nValues = 0;
	
	if(newResult == FALSE) {
	  newResult = TRUE;
	  nResults_++;
	}
      }
    }
    setup_file.close(); // When there are no more lines, close the file
  }
  else 
    alarm("ra_mean", "Unable to open file");
    
  sts = mh_ApplConnect( aoid, mh_mApplFlags(0), "", mh_eEvent_Info, mh_eEventPrio_A, mh_mEventFlags_Bell, "", &num);
    if (EVEN (sts)) throw co_error(sts);
}
Пример #4
0
void sysmon_object::open( double base_scantime)
{
  pwr_tStatus sts;

  // Link to object
  sts = gdh_DLRefObjectInfoAttrref( &aref, (void **)&p, &p_dlid); 
  if ( EVEN(sts)) throw co_error(sts);

  sts = gdh_GetAttrRefTid( &aref, &cid);
  if ( EVEN(sts)) throw co_error(sts);

  switch ( cid) {
  case pwr_cClass_DiskSup:
    if ( ((pwr_sClass_DiskSup *)p)->ScanTime)
      scan_div = int( ((pwr_sClass_DiskSup *)p)->ScanTime / base_scantime + 0.5);
    else
      scan_div = 1;
    break;
  default: ;
  }
  
}
Пример #5
0
int main(int argc, char* argv[])
{
  pwr_tStatus sts;
  qcom_sAid aid;
  sevcli_tCtx sevcli;
  sevcli_sHistItem* items;
  unsigned int itemcnt;
  char servername[40] = "";

  // Get options
  for (int i = 1; i < argc; i++) {
    if (streq(argv[i], "-s") && i + 1 < argc) {
      strncpy(servername, argv[i + 1], sizeof(servername));
      i++;
    }
  }

  sts = qcom_Init(&sts, &aid, "sev_xtt");
  if (EVEN(sts)) {
    co_error(sts);
  }

  sevcli_init(&sts, &sevcli);
  if (EVEN(sts)) {
    printf("Sev client init error %u\n", sts);
    debug_print("Shutting down...\n"); exit(0);
  }

  if (!streq(servername, "")) {
    sevcli_set_servernode(&sts, sevcli, servername);
  }

  sevcli_get_itemlist(&sts, sevcli, &items, &itemcnt);
  if (EVEN(sts)) {
    printf("Sev client get itemlist error %u\n", sts);
    debug_print("Shutting down...\n"); exit(0);
  }

  QApplication app(argc, argv);
  QApplication::setStyle(new PwrStyle());

  setlocale(LC_NUMERIC, "POSIX");
  setlocale(LC_TIME, "en_US");

  XttTblQt* tbl = new XttTblQt(0, 0, sevcli, items, itemcnt);
  tbl->close_cb = tbl_close_cb;

  return app.exec();
}
Пример #6
0
void rt_sysmon::open()
{
  pwr_tStatus sts;
  pwr_sAttrRef aref;
  pwr_tObjid oid;

  // Open server configuration object SysMonConfig
  sts = gdh_GetClassList( pwr_cClass_SysMonConfig, &oid);
  if ( ODD(sts)) {
    aref = cdh_ObjidToAref( oid);
    sts = gdh_DLRefObjectInfoAttrref( &aref, (void **)&conf, &conf_dlid); 
    if ( EVEN(sts)) throw co_error(sts);
  }

  if ( ODD(sts)) {
    scan_time = 1.0 / conf->ScanTime;
  }
  else {
    scan_time = 1;
    errh_Info( "No sysmon configuration, using base frequency 1 Hz");
    oid = pwr_cNObjid;
    conf = 0;
  }

  aproc_RegisterObject( oid);

  // Open DiskSup objects
  for ( sts = gdh_GetClassListAttrRef( pwr_cClass_DiskSup, &aref);
	ODD(sts);
	sts = gdh_GetNextAttrRef( pwr_cClass_DiskSup, &aref, &aref)) {
    disksup_object *o = new disksup_object( &aref);
    objects.push_back( o);
    try {
      o->open( scan_time);
      if ( conf)
	conf->DiskSupObjects[sysmon_cnt] = aref.Objid;
      sysmon_cnt++;
    }    
    catch ( co_error& e) {
      delete o;
      objects.pop_back();
      errh_Error( "DiskSup configuration error: &s", (char *)e.what().c_str());
    }
  }
}
Пример #7
0
void ra_mean::alarm( const char *description, const char *text)
// Send alarm to proview
{
    mh_sApplMessage	msg;
    pwr_tUInt32		msgid;
    pwr_tStatus		sts;
    
    memset(&msg, 0, sizeof(msg));
    msg.EventFlags = mh_mEventFlags(mh_mEventFlags_Returned |
		      mh_mEventFlags_NoObject |
		      mh_mEventFlags_Bell);
    clock_gettime( CLOCK_REALTIME, (timespec *)&msg.EventTime);
    strcpy( msg.EventName, description);
    sprintf( msg.EventText, text);
    msg.EventType = mh_eEvent_Alarm;
    msg.EventPrio = mh_eEventPrio_B;
    sts = mh_ApplMessage( &msgid, &msg);
      if (EVEN (sts)) throw co_error(sts);
}
Пример #8
0
void rt_fast::open()
{
  pwr_tStatus sts;
  pwr_sAttrRef aref;
  pwr_tObjid oid;
  pwr_sClass_DsFastConf *conf_p;

  // Open server configuration object DsFastConf
  sts = gdh_GetClassList( pwr_cClass_DsFastConf, &oid);
  if ( ODD(sts)) {
    sts = gdh_ObjidToPointer( oid, (void **)&conf_p);
    if ( EVEN(sts)) throw co_error( sts);

    scan_time = 1.0 / conf_p->BaseFrequency;
  }
  else {
    scan_time = 0.1;
    errh_Info( "No fast configuration, using base frequency 10 Hz");
    oid = pwr_cNObjid;
  }

  aproc_RegisterObject( oid);

  // Open FastCurve object
  for ( sts = gdh_GetClassListAttrRef( pwr_cClass_DsFastCurve, &aref);
	ODD(sts);
	sts = gdh_GetNextAttrRef( pwr_cClass_DsFastCurve, &aref, &aref)) {
    fastobject *o = new fastobject( &aref);
    objects.push_back( o);
    try {
      o->open( scan_time);
      fast_cnt++;
    }    
    catch ( co_error& e) {
      delete o;
      objects.pop_back();
      errh_Error( "DsFastCurve configuration error: &s", (char *)e.what().c_str());
    }
  }
}
Пример #9
0
void msgw_message_plcobject( pwr_tStatus sts, const char *text1, const char *text2, pwr_tOid oid)
{
  MsgWindow::message( co_error(sts), text1, text2, oid, true);
}
Пример #10
0
void msgw_message_sts( pwr_tStatus sts, const char *text1, const char *text2)
{
  MsgWindow::message( co_error(sts), text1, text2);
}
Пример #11
0
void fastobject::open( double base_scantime)
{
  pwr_tStatus sts;
  pwr_tUInt32 size, offs, elem;
  pwr_tTypeId type_id;
  pwr_tAName name;

  // Link to object
  sts = gdh_DLRefObjectInfoAttrref( &aref, (void **)&p, &p_dlid); 
  if ( EVEN(sts)) throw co_error(sts);

  // Link to trigg object
  if ( cdh_ObjidIsNotNull( p->TriggObject.Objid)) {
    sts = gdh_DLRefObjectInfoAttrref( &p->TriggObject, (void **)&trigg, &trigg_dlid); 
    if ( EVEN(sts)) {
      if ( p->Function & fast_mFunction_ManTrigg || 
	   p->Function & fast_mFunction_LevelTrigg)
	trigg = 0;
      else
	throw co_error(sts);
    }
  }

  // Link to attributes
  for ( int i = 0; i < FAST_CURVES; i++) {
    if ( cdh_ObjidIsNotNull( p->Attribute[i].Objid)) {
      sts = gdh_DLRefObjectInfoAttrref( &p->Attribute[i], (void **)&attributes[i], &attributes_dlid[i]);
      if ( EVEN(sts)) throw co_error(sts);

      // Get attribute type
      sts = gdh_AttrrefToName( &p->Attribute[i], name, sizeof( name), cdh_mName_volumeStrict);
      if ( EVEN(sts)) throw co_error(sts);
      
      sts = gdh_GetAttributeCharacteristics( name, &p->AttributeType[i],
					     &attributes_size[i], &offs, &elem);
      if ( EVEN(sts)) throw co_error(sts);

      p->CurveValid[i] = true;
    }
  }

  // Link to time buffer
  if ( cdh_ObjidIsNotNull( p->TimeBuffer.Objid)) {
    sts = gdh_DLRefObjectInfoAttrref( &p->TimeBuffer, (void **)&time_buffer, &time_buffer_dlid); 
    if ( EVEN(sts)) throw co_error(sts);

    // Get buffer size
    sts = gdh_AttrrefToName( &p->TimeBuffer, name, sizeof( name), cdh_mName_volumeStrict);
    if ( EVEN(sts)) throw co_error(sts);

    sts = gdh_GetAttributeCharacteristics( name, &type_id, &size, &offs, &elem);
    if ( EVEN(sts)) throw co_error(sts);

    if ( size < p->NoOfPoints * sizeof(pwr_tFloat32))
      p->NoOfPoints = size / sizeof(pwr_tFloat32);
  }

  // Link to attribute buffers
  for ( int i = 0; i < FAST_CURVES; i++) {
    if ( cdh_ObjidIsNotNull( p->Buffers[i].Objid) && p->CurveValid[i]) {
      p->CurveValid[i] = false;
      sts = gdh_DLRefObjectInfoAttrref( &p->Buffers[i], (void **)&buffers[i], &buffers_dlid[i]); 
      if ( EVEN(sts)) throw co_error(sts);

      p->CurveValid[i] = true;

      // Get buffer size
      sts = gdh_AttrrefToName( &p->Buffers[i], name, sizeof( name), cdh_mName_volumeStrict);
      if ( EVEN(sts)) throw co_error(sts);

      sts = gdh_GetAttributeCharacteristics( name, &type_id, &size, &offs, &elem);
      if ( EVEN(sts)) throw co_error(sts);

      if ( size < p->NoOfPoints * attributes_size[i])
	p->NoOfPoints = size / attributes_size[i];
    }
  }

  p->TriggMan = 0;
  p->Active = 0;
  p->Prepare = 0;
  p->TriggIndex = 0;
  if ( trigg)
    *trigg = 0;

  if ( p->ScanTime)
    scan_div = int( p->ScanTime / base_scantime + 0.5);
  else
    scan_div = 1;
  scan_base = base_scantime;
}
Пример #12
0
void rt_post::open()
{
  pwr_tStatus sts;
  pwr_tObjid oid;
  pwr_tFileName filename;

  // Open server configuration object PostConfig
  sts = gdh_GetClassList( pwr_cClass_PostConfig, &oid);
  if ( ODD(sts)) {
    sts = gdh_ObjidToPointer( oid, (void **)&conf);
    if ( EVEN(sts)) throw co_error( sts);

    aproc_RegisterObject( oid);
  }
  else {
    errh_Info( "No Post configuration");
    errh_SetStatus( 0);
    exit(0);
  }

  conf->Status = PWR__SRVSTARTUP;

  // Connect to mh
  mh_UtilWaitForMh();

  sts = mh_OutunitConnect(
		oid,
		mh_eOutunitType_Post,
		0,
		mh_ack_bc,
		mh_alarm_bc,
		mh_block_bc,
		mh_cancel_bc,
		mh_clear_alarmlist_bc,
		mh_clear_blocklist_bc,
		mh_info_bc,
		mh_return_bc,
		NULL
		);
  if ( EVEN(sts)) {
    errh_Error( "Post terminated: %m", sts);
    conf->Status = sts;
    exit(0);
  }

  // Load user database
	
  sts = gdh_GetObjectInfo( "pwrNode-System.SystemGroup", &systemgroup, 
			   sizeof(systemgroup));
  if ( EVEN(sts)) {
    errh_Error( "Post terminated: %m", sts);
    conf->Status = sts;
    exit(0);
  }

  udb = new GeUser();
  sts = dcli_get_defaultfilename( user_cFilename, filename, "");
  udb->load( filename);

  conf->Status = PWR__SRUN;

}