Exemplo n.º 1
0
// ------------------------------------------------------------------------------------------------
EXPORT_C void CWBXMLGenerator::BeginDocumentL( TUint8 aVersion, TInt32 aPublicId, TUint32 aCharset, const TDesC8& aStringTbl )
	{
	Workspace()->WriteL(aVersion);

	if( aPublicId <= 0 )
		{
		Workspace()->WriteL(0);
		WriteMUint32L(-aPublicId);
		}
	else
		{
		WriteMUint32L(aPublicId);
		}
	WriteMUint32L(aCharset);
	WriteMUint32L(aStringTbl.Size());
	Workspace()->WriteL(aStringTbl);
	}
Exemplo n.º 2
0
// ------------------------------------------------------------------------------------------------
EXPORT_C TInt CWBXMLGenerator::HandleResult( TInt aResult, TInt aTreshold )
	{
	switch( aResult )
		{
		case KErrNone:
			if( Workspace()->FreeSize() < aTreshold )
				{				
				Workspace()->Rollback();
				return KWBXMLGeneratorBufferFull;
				}
			Workspace()->Commit();
			return KWBXMLGeneratorOk;

		case KErrTooBig:
			Workspace()->Rollback();
			return KWBXMLGeneratorBufferFull;

		default:
			return KErrGeneral;
		}
	}
    Workspace* Workspace::GetInstance()
    {
        if (ms_instance == NULL)
        {
            //if new  an Workspace class ,then the staict variable will be set value
            Workspace* _workspace = BEHAVIAC_NEW Workspace();
            BEHAVIAC_UNUSED_VAR(_workspace);
            BEHAVIAC_ASSERT(ms_instance != NULL);
        }

        return ms_instance;
    }
Exemplo n.º 4
0
// ------------------------------------------------------------------------------------------------
void CWBXMLGenerator::WriteMUint32L( TUint32 aValue )
	{
	TUint8 temp[5];
	TInt i(4);
	
	temp[i--] = TUint8(aValue & 0x7F);
	aValue >>= 7;
	while( aValue > 0 )
		{
		temp[i--] = TUint8((aValue & 0x7F) | 0x80);
		aValue >>= 7;
		}
			
	while( i < 4 )
		{
		Workspace()->WriteL(temp[++i]);
		}
	}
Exemplo n.º 5
0
	Workspace* Workspace::GetInstance(const char* version_str)
    {
        if (ms_instance == NULL)
        {
			if (version_str && !StringUtils::StrEqual(version_str, BEHAVIAC_BUILD_CONFIG_STR))
			{
				BEHAVIAC_LOGERROR("lib is built with '%s', while the executable is built with '%s'! please use the same define for '_DEBUG' and 'BEHAVIAC_RELEASE' in both the lib and executable's make.\n", BEHAVIAC_BUILD_CONFIG_STR, version_str);
				BEHAVIAC_ASSERT(false);
				return 0;
			}

            //if new  an Workspace class ,then the staict variable will be set value
            Workspace* _workspace = BEHAVIAC_NEW Workspace();
            BEHAVIAC_UNUSED_VAR(_workspace);
            BEHAVIAC_ASSERT(ms_instance != NULL);
        }

        return ms_instance;
    }
Exemplo n.º 6
0
	Workspace* Workspace::GetInstance(const char* version_str)
    {
        if (ms_instance == NULL)
        {
			if (version_str && !StringUtils::StrEqual(version_str, BEHAVIAC_VERSION_STR))
			{
				BEHAVIAC_LOGERROR("lib is built with '%s', while the app is built with '%s'!\n", BEHAVIAC_VERSION_STR, version_str);
				BEHAVIAC_ASSERT(false);
				return 0;
			}

            //if new  an Workspace class ,then the staict variable will be set value
            Workspace* _workspace = BEHAVIAC_NEW Workspace();
            BEHAVIAC_UNUSED_VAR(_workspace);
            BEHAVIAC_ASSERT(ms_instance != NULL);
        }

        return ms_instance;
    }
Exemplo n.º 7
0
  openstudio::path saveModel(openstudio::model::Model model, const openstudio::path& osmPath, const openstudio::path& modelTempDir)
  {

    openstudio::path modelPath = osmPath;

    if (getFileExtension(osmPath).empty()) {
      modelPath = setFileExtension(osmPath,modelFileExtension(),false,true);
    }

    // save osm to temp directory, saveModelTempDir will copy to real location
    openstudio::path tempModelPath = modelTempDir / toPath("in.osm");
    Workspace(model).save(tempModelPath,true); 

    LOG_FREE(Debug, "saveModel", "Saved model to '" << toString(tempModelPath) << "'");

    // DLM: eventually put saveRunManagerDatabase here, needs to happen before saveModelTempDir

    // DLM: eventually add this back in too
    // DLM: for now this is accomplished by calling saveModelTempDir after saveModel in all cases
    //saveModelTempDir(modelTempDir, modelPath);

    return modelPath;
  }
Exemplo n.º 8
0
boost::optional<model::Model> ReverseTranslator::loadModel(const openstudio::path& path, ProgressBar* progressBar)
{
  m_model = Model();
  m_model.setFastNaming(true);

  m_workspace = Workspace(StrictnessLevel(StrictnessLevel::None),
                          IddFileType(IddFileType::EnergyPlus));

  m_workspaceToModelMap.clear();

  m_untranslatedIdfObjects.clear();

  m_logSink.resetStringStream();

  m_logSink.setThreadId(QThread::currentThread());

  m_logSink.setChannelRegex(boost::regex("openstudio\\.IdfFile"));

  //load idf and convert to a workspace
  boost::optional<openstudio::IdfFile> idfFile = IdfFile::load(path, IddFileType::EnergyPlus, progressBar);

  m_logSink.setChannelRegex(boost::regex("openstudio\\.energyplus\\.ReverseTranslator"));

  // energyplus idfs may not be draft level strictness, eventually need a fixer
  if (!idfFile){

    LOG(Error, "Could not read idf file at path ='" << toString(path) << "'");

  }else{

    if (!idfFile->isValid(StrictnessLevel::Draft)){

      LOG(Error, "Idf file at path ='" << toString(path) << "' is not valid to draft strictness");
      LOG(Error, idfFile->validityReport(StrictnessLevel::Draft));
      return boost::none;

    }

    if (progressBar){
      progressBar->setWindowTitle(toString("Creating EnergyPlus Workspace"));
    }

    Workspace workspace(StrictnessLevel::None,
                        IddFileType(IddFileType::EnergyPlus));

    if (progressBar){
      workspace.connectProgressBar(progressBar);
    }

    workspace.addObjects(idfFile->objects());

    if (progressBar){
      workspace.disconnectProgressBar(progressBar);
    }

    return this->translateWorkspace(workspace, progressBar);

  }

  return boost::none;
}
Exemplo n.º 9
0
// ------------------------------------------------------------------------------------------------
EXPORT_C void CWBXMLGenerator::Reset()
	{
	Workspace()->Reset();
	}
Exemplo n.º 10
0
// ------------------------------------------------------------------------------------------------
// CWBXMLGenerator
// ------------------------------------------------------------------------------------------------
EXPORT_C TPtrC8 CWBXMLGenerator::Document()
	{
	return Workspace()->Buffer();
	}
Exemplo n.º 11
0
// ------------------------------------------------------------------------------------------------
void CWBXMLGenerator::WriteInlineStringL( const TDesC8& aData )
	{
	Workspace()->WriteL(STR_I);
	Workspace()->WriteL(aData);
	Workspace()->WriteL(0);
	}
Exemplo n.º 12
0
// ------------------------------------------------------------------------------------------------
void CWBXMLGenerator::WriteOpaqueDataL( const TDesC8& aData )
	{
	Workspace()->WriteL(OPAQUE);
	WriteMUint32L(aData.Size());
	Workspace()->WriteL(aData);
	}
Exemplo n.º 13
0
// ------------------------------------------------------------------------------------------------
EXPORT_C void CWBXMLGenerator::SwitchCodePageL( TUint8 aNewCodePage )
	{
	Workspace()->WriteL(SWITCH_PAGE);
	Workspace()->WriteL(aNewCodePage);
	}
Exemplo n.º 14
0
// ------------------------------------------------------------------------------------------------
EXPORT_C void CWBXMLGenerator::AddExtL( TInt aExtNum )
	{
	Workspace()->WriteL(TUint8(EXT_0 + aExtNum));
	}
Exemplo n.º 15
0
// ------------------------------------------------------------------------------------------------
EXPORT_C void CWBXMLGenerator::AddExt_TL( TInt aExtNum, TUint32 aContent )
	{
	Workspace()->WriteL(TUint8(EXT_T_0 + aExtNum));
	WriteMUint32L(aContent);
	}
Exemplo n.º 16
0
// ------------------------------------------------------------------------------------------------
EXPORT_C void CWBXMLGenerator::AddExt_IL( TInt aExtNum, const TDesC8& aContent )
	{
	Workspace()->WriteL(TUint8(EXT_I_0 + aExtNum));
	WriteInlineStringL(aContent);
	}
Exemplo n.º 17
0
// ------------------------------------------------------------------------------------------------
EXPORT_C void CWBXMLGenerator::AddEntityL( TUint32 aEntity )
	{
	Workspace()->WriteL(ENTITY);
	WriteMUint32L(aEntity);
	}
Exemplo n.º 18
0
// ------------------------------------------------------------------------------------------------
EXPORT_C void CWBXMLGenerator::EndElementL()
	{
	Workspace()->WriteL(END);
	}