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);
}
Beispiel #2
0
int rt_sysmon::connect_alarm() 
{
  static int	alarm_connected = 0;
  int		sts; 
  mh_eEvent	AbortEventType = mh_eEvent_Alarm;
  mh_eEventPrio   AbortEventPrio = mh_eEventPrio_A;
  pwr_tUInt32	NoOfActMessages;

  if ( alarm_connected)
    /* We are already connected */
    return SMON__SUCCESS;

  sts = mh_ApplConnect( pwr_cNObjid, (mh_mApplFlags)0,
	   "AbortEventName",
	   AbortEventType,
	   AbortEventPrio,
	   (mh_mEventFlags)(mh_mEventFlags_Bell | mh_mEventFlags_Ack | mh_mEventFlags_Return),
	   "AbortEventText",
	   &NoOfActMessages);
  if( EVEN(sts)) return sts;

  alarm_connected = 1;
  return SMON__SUCCESS;    
}