Exemplo n.º 1
0
int main( int argc, char* argv[] )
{
	try
	{
		AppClient appClient;
		dataDictionary.loadFieldDictionary( "RDMFieldDictionary" );
		dataDictionary.loadEnumTypeDictionary( "enumtype.def" );

		OmmProvider provider( OmmIProviderConfig().adminControlDictionary( OmmIProviderConfig::UserControlEnum ), appClient );
		
		while ( itemHandle == 0 ) sleep( 1000 );

		for (Int32 i = 0; i < 60; i++)
		{
			provider.submit( UpdateMsg().payload( FieldList().
				addReal( 22, 3391 + i, OmmReal::ExponentNeg2Enum ).
				addReal( 30, 10 + i, OmmReal::Exponent0Enum ).
				complete() ), itemHandle );

			sleep( 1000 );
		}
	}
	catch ( const OmmException& excp )
	{
		cout << excp << endl;
	}
	
	return 0;
}
Exemplo n.º 2
0
void AppClient::processDictionaryRequest(const ReqMsg& reqMsg, const OmmProviderEvent& event)
{
	result = false;
	refreshMsg.clear().clearCache( true );

	if ( reqMsg.getName() == "RWFFld" )
	{
		currentValue = dataDictionary.getMinFid();

		while ( !result )
		{
			result = dataDictionary.encodeFieldDictionary( series, currentValue, reqMsg.getFilter(), fragmentationSize );

			event.getProvider().submit( refreshMsg.name( reqMsg.getName() ).serviceName( reqMsg.getServiceName() ).domainType( MMT_DICTIONARY ).
				filter( reqMsg.getFilter() ).payload( series ).complete( result ).solicited( true ), event.getHandle() );

			refreshMsg.clear();
		}
	}
	else if ( reqMsg.getName() == "RWFEnum" )
	{
		currentValue = 0;

		while ( !result )
		{
			result = dataDictionary.encodeEnumTypeDictionary( series, currentValue, reqMsg.getFilter(), fragmentationSize );

			event.getProvider().submit( refreshMsg.name( reqMsg.getName() ).serviceName( reqMsg.getServiceName() ).domainType( MMT_DICTIONARY ).
				filter( reqMsg.getFilter() ).payload( series ).complete( result ).solicited( true ), event.getHandle() );

			refreshMsg.clear();
		}
	}
}
Exemplo n.º 3
0
const DataDictionary * SessionFactory::createDataDictionary(const SessionID& sessionID, 
                                                    const Dictionary& settings, 
                                                    const std::string& settingsKey) throw(ConfigError)
{
  DataDictionary * pDD = 0;
  std::string path = settings.getString( settingsKey );
  Dictionaries::iterator i = m_dictionaries.find( path );
  if ( i != m_dictionaries.end() )
  {
    pDD = i->second;
  }
  else
  {
    pDD = new DataDictionary( path );
    m_dictionaries[ path ] = pDD;
  }

  DataDictionary * pCopyOfDD = new DataDictionary(*pDD);

  if( settings.has( VALIDATE_FIELDS_OUT_OF_ORDER ) )
    pCopyOfDD->checkFieldsOutOfOrder( settings.getBool( VALIDATE_FIELDS_OUT_OF_ORDER ) );
  if( settings.has( VALIDATE_FIELDS_HAVE_VALUES ) )
    pCopyOfDD->checkFieldsHaveValues( settings.getBool( VALIDATE_FIELDS_HAVE_VALUES ) );
  if( settings.has( VALIDATE_USER_DEFINED_FIELDS ) )
    pCopyOfDD->checkUserDefinedFields( settings.getBool( VALIDATE_USER_DEFINED_FIELDS ) );

  return pCopyOfDD;
}
void  MTConnectStreamsParser::DumpData(DataDictionary data)
{
	for(DataDictionary::iterator it = data.begin(); it!=data.end(); it++)
	{
		AtlTrace("%s = %s\n", (*it).first.c_str(), (*it).second.c_str());
	}
}
// Replace into data with newer from data
static DataDictionary  Merge(DataDictionary &into, DataDictionary &from)
{
	DataDictionary newdata = into;
	for(DataDictionary::iterator it=from.begin(); it!=from.end(); it++)
	{
		into[(*it).first]=(*it).second;
	}
	return newdata;
}
Exemplo n.º 6
0
void AppClient::decode(const Msg& msg, bool complete)
{
	switch (msg.getPayload().getDataType())
	{
		case DataType::SeriesEnum:
		{
			if (msg.getName() == "RWFFld")
			{
				//APIQA	
				dataDictionary.decodeFieldDictionary(msg.getPayload().getSeries(), filter);

				if (complete)
				{
					fldComplete = true;
				}
			}

			else if (msg.getName() == "RWFEnum")
			{
				//APIQA	
				dataDictionary.decodeEnumTypeDictionary(msg.getPayload().getSeries(), filter);

				if (complete)
				{
					enumComplete = true;
				}
			}

			if (fldComplete && enumComplete)
			{
				cout << endl << "Dictionary download complete" << endl;
				cout << "Dictionary Id : " << dataDictionary.getDictionaryId() << endl;
				cout << "Dictionary field version : " << dataDictionary.getFieldVersion() << endl;
				cout << "Number of dictionary entries : " << dataDictionary.getEntries().size() << endl;

				if ( dumpDictionary )
					cout << dataDictionary << endl;
			}
		}
	}
}
std::string  MTConnectStreamsParser::CreateHtmlTable(DataDictionary data)
{
	std::string updatetable;
	std::string style;

	updatetable += "<TABLE>\n";
	updatetable +=   "<TR>";
	std::string skip( "estop,controllermode,PartCountActual,avail,PartCountBad,power,probed,ProbeNumber,probe,path_feedratefrt" );
	for(DataDictionary::iterator it = data.begin(); it!=data.end(); it++)
	{
		if(skip.find((*it).first) != std::string::npos)
			continue;
		updatetable +=   "<TH> " + (*it).first    + "</TH> ";
	}
	updatetable +=   "</TR>\n";
	updatetable +=   "<TR>\n";
	for(DataDictionary::iterator it = data.begin(); it!=data.end(); it++)
	{
		style.clear();
		if(skip.find((*it).first) != std::string::npos)
			continue;
		if((*it).first == "Outtol")
		{

		}
		if((*it).first == "execution")
		{	
			if((*it).second == "READY")  
				style =   "style=\"background-color:lightblue;\"";
			if((*it).second == "ACTIVE")  
				style =    "style=\"background-color:lightgreen;\"";
		}

		updatetable +=   "<TD " + style + "> "+ (*it).second + "</TD>" ;
	}
	updatetable +=   "</TR>\n";

	updatetable += "</TABLE>\n";
	return updatetable;
}
Exemplo n.º 8
0
void AppClient::decode(const Msg& msg, bool complete)
{
	switch (msg.getPayload().getDataType())
	{
		case DataType::FieldListEnum:
			decode(msg.getPayload().getFieldList());
			break;

		case DataType::SeriesEnum:
		{
			if (msg.getName() == "RWFFld")
			{
				dataDictionary.decodeFieldDictionary(msg.getPayload().getSeries(), DICTIONARY_NORMAL);

				if (complete)
				{
					fldDictComplete = true;
				}
			}

			else if (msg.getName() == "RWFEnum")
			{
				dataDictionary.decodeEnumTypeDictionary(msg.getPayload().getSeries(), DICTIONARY_NORMAL);

				if (complete)
				{
					enumTypeComplete = true;
				}
			}

			if (fldDictComplete && enumTypeComplete)
			{
				cout << dataDictionary << endl;
			}
		}
	}
}
Exemplo n.º 9
0
DataDictionary SessionFactory::createDataDictionary(const SessionID& sessionID, 
                                                     const Dictionary& settings, 
                                                     const std::string& settingsKey) throw(ConfigError)
{

  DataDictionary dataDictionary;
  std::string path = settings.getString( settingsKey );
  Dictionaries::iterator i = m_dictionaries.find( path );
  if ( i != m_dictionaries.end() )
    dataDictionary = *i->second;
  else
  {
    DataDictionary* p = CreateDictionaryFromResourceID( path );
    dataDictionary = *p;
    m_dictionaries[ path ] = p;
  }

  if( settings.has( VALIDATE_FIELDS_OUT_OF_ORDER ) )
  {
    dataDictionary.checkFieldsOutOfOrder
    ( settings.getBool( VALIDATE_FIELDS_OUT_OF_ORDER ) );
  }
  if( settings.has( VALIDATE_FIELDS_HAVE_VALUES ) )
  {
    dataDictionary.checkFieldsHaveValues
    ( settings.getBool( VALIDATE_FIELDS_HAVE_VALUES ) );
  }
  if( settings.has( VALIDATE_USER_DEFINED_FIELDS ) )
  {
    dataDictionary.checkUserDefinedFields
    ( settings.getBool( VALIDATE_USER_DEFINED_FIELDS ) );
  }

  return dataDictionary;    

  
}
Exemplo n.º 10
0
void DataDictionary::addXMLGroup( DOMDocument* pDoc, DOMNode* pNode,
                                  const std::string& msgtype,
                                  DataDictionary& DD, bool groupRequired  )
{
  DOMAttributesPtr attrs = pNode->getAttributes();
  std::string name;
  if(!attrs->get("name", name))
    throw ConfigError("No name given to group");
  int group = lookupXMLFieldNumber( pDoc, name );
  int delim = 0;
  int field = 0;
  DataDictionary groupDD;
  DOMNodePtr node = pNode->getFirstChildNode();
  while(node.get())
  {
    if( node->getName() == "field" )
    {
      field = lookupXMLFieldNumber( pDoc, node.get() );
      groupDD.addField( field );

      DOMAttributesPtr attrs = node->getAttributes();
      std::string required;
      if( attrs->get("required", required)
         && ( required == "Y" || required =="y" )
         && groupRequired )
      {
        groupDD.addRequiredField(msgtype, field);
      }
    }
    else if( node->getName() == "component" )
    {
      field = addXMLComponentFields( pDoc, node.get(), msgtype, groupDD, false );
    }
    else if( node->getName() == "group" )
    {
      field = lookupXMLFieldNumber( pDoc, node.get() );
      groupDD.addField( field );
      DOMAttributesPtr attrs = node->getAttributes();
      std::string required;
      if( attrs->get("required", required )
         && ( required == "Y" || required =="y" )
         && groupRequired)
      {
        groupDD.addRequiredField(msgtype, field);
      }
      bool isRequired = false;
      if( attrs->get("required", required) )
      isRequired = (required == "Y" || required == "y");
      addXMLGroup( pDoc, node.get(), msgtype, groupDD, isRequired );
    }
    if( delim == 0 ) delim = field;
    RESET_AUTO_PTR(node, node->getNextSiblingNode());
  }

  if( delim ) DD.addGroup( msgtype, group, delim, groupDD );
}
Exemplo n.º 11
0
void Message::setGroup( const std::string& msg, const FieldBase& field,
                        const std::string& string,
                        std::string::size_type& pos, FieldMap& map,
                        const DataDictionary& dataDictionary )
{
  int group = field.getTag();
  int delim;
  const DataDictionary* pDD = 0;
  if ( !dataDictionary.getGroup( msg, group, delim, pDD ) ) return ;
  std::unique_ptr<Group> pGroup;

  while ( pos < string.size() )
  {
    std::string::size_type oldPos = pos;
    FieldBase field = extractField( string, pos, &dataDictionary, &dataDictionary, pGroup.get() );
       
    // Start a new group because...
    if (// found delimiter
    (field.getTag() == delim) ||
    // no delimiter, but field belongs to group OR field already processed
    (pDD->isField( field.getTag() ) && (pGroup.get() == 0 || pGroup->isSetField( field.getTag() )) ))
    {
      if ( pGroup.get() )
      {
        map.addGroupPtr( group, pGroup.release(), false );
      }
      pGroup.reset( new Group( field.getTag(), delim, pDD->getOrderedFields() ) );
    }
    else if ( !pDD->isField( field.getTag() ) )
    {
      if ( pGroup.get() )
      {
        map.addGroupPtr( group, pGroup.release(), false );
      }
      pos = oldPos;
      return ;
    }

    if ( !pGroup.get() ) return ;
    pGroup->setField( field, false );
    setGroup( msg, field, string, pos, *pGroup, *pDD );
  }
}
Exemplo n.º 12
0
int DataDictionary::addXMLComponentFields( DOMDocument* pDoc, DOMNode* pNode,
                                            const std::string& msgtype,
                                            DataDictionary& DD,
                                            bool componentRequired )
{
  int firstField = 0;

  DOMAttributesPtr attrs = pNode->getAttributes();
  std::string name;
  if(!attrs->get("name", name))
    throw ConfigError("No name given to component");

  DOMNodePtr pComponentNode =
    pDoc->getNode("/fix/components/component[@name='" + name + "']");
  if(pComponentNode.get() == 0)
    throw ConfigError("Component not found: " + name);

  DOMNodePtr pComponentFieldNode = pComponentNode->getFirstChildNode();
  while(pComponentFieldNode.get())
  {
    if(pComponentFieldNode->getName() == "field"
       || pComponentFieldNode->getName() == "group")
    {
      DOMAttributesPtr attrs = pComponentFieldNode->getAttributes();
      std::string name;
      if(!attrs->get("name", name))
        throw ConfigError("No name given to field");
      int field = lookupXMLFieldNumber(pDoc, name);
      if( firstField == 0 ) firstField = field;

      std::string required;
      if(attrs->get("required", required)
         && (required == "Y" || required =="y")
         && componentRequired)
      {
        addRequiredField(msgtype, field);
      }

      DD.addField(field);
      DD.addMsgField(msgtype, field);
    }
    if(pComponentFieldNode->getName() == "component")
    {
      DOMAttributesPtr attrs = pComponentFieldNode->getAttributes();
      std::string required;
      attrs->get("required", required);
      bool isRequired = (required == "Y" || required == "y");
      addXMLComponentFields(pDoc, pComponentFieldNode.get(),
                            msgtype, DD, isRequired);
    }
    if(pComponentFieldNode->getName() == "group")
    {
      DOMAttributesPtr attrs = pComponentFieldNode->getAttributes();
      std::string required;
      attrs->get("required", required);
      bool isRequired = (required == "Y" || required == "y");
      addXMLGroup(pDoc, pComponentFieldNode.get(), msgtype, DD, isRequired);
    }
    RESET_AUTO_PTR(pComponentFieldNode,
      pComponentFieldNode->getNextSiblingNode());
  }
  return firstField;
}
Exemplo n.º 13
0
std::string CAlarmHandler::CheckFault(DataDictionary datum)
{
	_lastfault=_currentfault;
	_currentfault.clear();
	// what if multiple faults?
	for(int i=0; i< _faults.size(); i++)
	{
		if(datum.find(_faults[i]) == datum.end())
			continue;
		int npos  =  datum[_faults[i]].find('.');
		std::string level = datum[_faults[i]];
		std::string msg = datum[_faults[i]];

		if(npos!= std::string::npos) level =  Trim(datum[_faults[i]].substr(0,npos));
		if(npos!= std::string::npos) msg =  Trim(datum[_faults[i]].substr(npos+1));

		// FIXME: just grabs the first fault and leaves.
		if( (level != "Normal") && (stricmp(level.c_str(), "Unavailable")!=0))
		{	
			_currentfault=_faults[i]+ " " + datum[_faults[i]];

			if(_currentfault != _lastfault)
			{
				// cant continually reset
				_alarmdatum.clear();
				_alarmdatum["RaisedAt"] = datum["Timestamp"];
				_alarmdatum["Shift"] = datum["Shift"];
				_alarmdatum["RaisedBy"] = datum["Machine"];
				_alarmdatum["Severity"] = level;
				_alarmdatum["Description"] =_faults[i] + "-" + msg;
				_alarmdatum["ResolvedAt"] = datum["Timestamp"];
				_alarmdatum["Program"] = datum["program"];
				double dTBF = _tbftimer.elapsed();
				_tbftimer.restart();
				WriteRegistryTimeFailure(0);
				_alarmdatum["TBF"]=DataDictionary::HrMinSecFormat((double)dTBF); 
			}

			return _currentfault;
		}
	}
	if(!_lastfault.empty() && _currentfault.empty())
	{
		_alarmdatum["ResolvedAt"] = datum["Timestamp"];
		
		ptime start = GetDateTime(_alarmdatum["RaisedAt"]);
		ptime done = GetDateTime(_alarmdatum["ResolvedAt"]);
		time_duration duration = done - start;
		_alarmdatum["TTR"] = DataDictionary::HrMinSecFormat((double)duration.total_seconds()); 


		// FIXME: there can be multiple alarms simulataneously ...
		_allfaultdatum.push_back(_alarmdatum);
		_myfaultdatum.push_back(_alarmdatum);
		LogFault(_alarmdatum);

		if(_alarmdatum["Severity"] == "Fault")
		{

		}
	}
	return _currentfault;
}