OptionalModelObject ReverseTranslator::translateZoneList( const WorkspaceObject & workspaceObject )
{
   if( workspaceObject.iddObject().type() != IddObjectType::Zone ){
    LOG(Error, "WorkspaceObject is not IddObjectType: Zone");
    return boost::none;
  }

  openstudio::model::SpaceType spaceType( m_model );

  OptionalString s = workspaceObject.name();
  if(s){
    spaceType.setName(*s);
  }

  for (const IdfExtensibleGroup& idfGroup : workspaceObject.extensibleGroups()){
    WorkspaceExtensibleGroup workspaceGroup = idfGroup.cast<WorkspaceExtensibleGroup>();
    
    OptionalWorkspaceObject target = workspaceGroup.getTarget(0);
    if (target){
      OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
      if (modelObject){
        if (modelObject->optionalCast<Space>()){
          Space space = modelObject->cast<Space>();

          if (space.spaceType()){
            LOG(Warn, "Overriding previously assigned SpaceType for Space '" << space.name().get() << "'");
          }

          space.setSpaceType(spaceType);

        }
      }
    }
  }

  return spaceType;
}
Exemple #2
0
bool CreateDesertSpace(Space &sp, Element &e, UdmDesertMap &des_map, DesertUdmMap &inv_des_map, UdmElementSet &elements, bool root)
{
	static long parent;			//id of the parent element
	long old_parent;			//save old parent
	static long space;			//id of the space
	short decomposition;		//0:leaf, 1: and, 2: or
	//element.decomposition():	
	//			has no children: leaf
	//			has children and decomposition is false:	or node
	//			has children and decomposition is true:		and node

	set<Element> ev_set;

	//static and non-static variables
	//for progress indication 
	//(this is weird in case of a recursive function)
	//CDesertStatusDlg * st_dlg = GetStatusDlg(NULL);
	static short percent_done;
	static short percent_to_do;
	short percent_to_do_save;
	if (root) 
	{
		percent_done = 0;
		percent_to_do = 100;
	}

	
	if (root)
	{
		
		//compute decomposition value
		//mapping from boolean decomposition value
		//to desert style short decomposition
		set<Element> e_children = sp.Element_kind_children();
		set<Element>::iterator i;
		
		if (e_children.empty()) decomposition = 0;
		else
		{
			if (sp.decomposition()) decomposition  = 1;
			else decomposition = 2;
		}

		//debug trace
		TRACE ("CreateDesertSpace invoked: parent: %d, Space: %s , decomposition: %d\n", parent, ((string)sp.name()).c_str(), decomposition);

		//
		//create the space & the root element in the space
		//
		space =  CreateSpace(utf82cstring((string)sp.name()));
		//space =  CreateSpace(((string)sp.name()).c_str(), sp.id(), sp.externalID());
		
/*
		parent = CreateElement(
			((string)sp.name()).c_str(), 
			space, 
			decomposition, 
			-1, 
			sp.id(),
			sp.externalID());
*/
				
		parent = CreateElement(
			utf82cstring((string)sp.name()),
			space, 
			decomposition, 
			-1, 
			sp.externalID());

		//map the UDM, desert object pairs
		
		DoMap(sp, des_map, inv_des_map, parent);

		
		//recursion here
		
		//update progress bar
		if (e_children.empty())
		{
			//leaf node
			percent_done += percent_to_do;
			//st_dlg->StepInState(percent_done);
		}//eo if (e_children.empty())

		else
		{

			//recursive hack for overall performance
			//percent to done is always smaller
			int no_of_children = e_children.size();
			percent_to_do_save = percent_to_do;
			percent_to_do = (short)((float)percent_to_do / (float)no_of_children);
				

			//recursive step
			for (i = e_children.begin(); i != e_children.end(); i++)
			{
				Element new_e = *i;
				CreateDesertSpace(sp, new_e, des_map, inv_des_map, elements, false);
			};//eo for (i...)

			//still part of the recursive hack
			//set back the percent_to_do when a recursive loop is done

			percent_to_do = percent_to_do_save;
		}//eo else if (e_children.begin() == e_children.end() )
		
	}//eo if (root)
	else
	{
		
		//compute decomposition value
		//mapping boolean decomposition value
		//to desert style decomposition value
		set<Element> e_children = e.Element_kind_children();
		set<Element>::iterator i;
		
		if (e_children.empty()) decomposition = 0;
		else
		{
			if (e.decomposition()) decomposition  = 1;
			else decomposition = 2;
		}

		//debug trace
		TRACE ("CreateDesertSpace invoked: parent: %d, Element: %s \n", parent, ((string)e.name()).c_str());

		//create new elenent
		long new_parent = CreateElement(
			utf82cstring((string)e.name()),
			space,
			decomposition,
			parent,
			e.externalID());

	/*	long new_parent = CreateElement(
			((string)e.name()).c_str(),
			space,
			decomposition,
			parent,
			e.id(),
			e.externalID());*/

		//insert association in the map
		DoMap(e, des_map, inv_des_map, new_parent);
		//2nd set of elements, we need when mapping associations
		elements.insert(e);

		
		//recursion here
		
		if (e_children.empty() )
		{
			//leaf node
			percent_done += percent_to_do;
			//st_dlg->StepInState(percent_done);
		}//eo if (e_children.empty())
		else
		{

			//recursive hack for overall performance
			//percent to done is always smaller
			int no_of_children = e_children.size();
			percent_to_do_save = percent_to_do;
			percent_to_do = (short)((float)percent_to_do / (float)no_of_children);

			//saving old parent and setting the new parent for Create() calls 
			//when invoking myself recursively
			old_parent = parent;
			parent = new_parent;

			//check recursively all the children
		
			for (i = e_children.begin(); i != e_children.end(); i++)
			{
				Element new_e = *i;
				CreateDesertSpace(sp, new_e, des_map, inv_des_map, elements, false);
			};//eo for (i...)
			//recursive & static hack
			//setting back parent&percent_to_do

			parent = old_parent;
			percent_to_do = percent_to_do_save;

		}//eo else if (e_children.empty())
		
		
	}//eo else if (root) 
	return true;
};
Exemple #3
0
BOOL CDesertToolApp::InitInstance()
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif


	//this hack is offered gratiously by our very talented grad. student, Tihamer Levendovszky)

	SetRegistryKey(_T("ISIS"));
	CString str(m_pszHelpFilePath);
	WriteProfileString(_T("Data"),_T("Path"), str.Left(str.GetLength()-3) +CString(_T("exe")));

	//end of the hack offered by our very gifted, talented, and I could continue... grad student

	//check for command line
	//if an argument is received, and actually ends up with stg. like
	// "xml", "mga", or "mem", we will use that one.
	bool command_arg_ok = false;
	bool cancel_input = false;
	bool cancel_output = false;
	bool isSilent= false;
	bool multiRun = false;
	CString consList;
	TCHAR** consGroupNames = NULL;
	TCHAR** consGroups = NULL;
	int numConsGroups = 0;
	TCHAR input_file[_MAX_PATH];
	TCHAR output_file[_MAX_PATH];
	tstring desert_config_info_file = _T("");
	FILE* fdDcif = 0;
	
	static TCHAR szFilterUDM[] = _T("XML Backend Files (*.xml)|*.xml|MEM Backend Files (*.mem)|*.mem|MGA Backend Files (*.mga)|*.mga|All Files (*.*)|*.*||");
	
	bool hasInputFile = false;
	bool hasOutputFile = false;
	
	if (m_lpCmdLine)
	{
		if (_tcslen(m_lpCmdLine))
		{
			if (_tcsstr(m_lpCmdLine, _T("/?")) || _tcsstr(m_lpCmdLine, _T("/help")) || _tcsstr(m_lpCmdLine, _T("--help")) || _tcsstr(m_lpCmdLine, _T("/h")))
			{
				CString usage(_T("Usage: deserttool.exe [<DesertInput xml>] [/o <Output Filename>] [/c \"constraint1:constraint2\"] [/m \"__CG__GroupA:constraint1:constraint2:__CG__GroupB:constraint1:constraint3\"\r\n\r\nArgument details:\r\n"));
				usage.Append(_T("DesertInput xml: input desert xml file\r\n"));
				usage.Append(_T("/c \"constraint1 : constraint2\": apply the constraint list directly without GUI shown up\r\n"));
				usage.Append(_T("/c \"applyAll\": apply all constraints directly without GUI shown up\r\n"));
				usage.Append(_T("/c \"none\": does not apply any constraint and computes total no. of configurations, without GUI shown up\r\n"));
				usage.Append(_T("/m : when used calls desert process for \"none\", \"applyAll\", and all given constraint groups (with names using '__CG__' prefix) one by one, without GUI shown up\r\n"));
				std::cout << usage;
				AfxMessageBox(usage,MB_ICONINFORMATION);
				return TRUE;
			}
			if (_tcsstr(m_lpCmdLine, _T(".xml")) || _tcsstr(m_lpCmdLine, _T(".mem")) || _tcsstr(m_lpCmdLine, _T(".mga"))  
				|| _tcsstr(m_lpCmdLine, _T(".XML")) || _tcsstr(m_lpCmdLine, _T(".MEM")) || _tcsstr(m_lpCmdLine, _T(".MGA")))
			{
				CWzdCommandLineInfo cmdInfo;
				ParseCommandLine(cmdInfo);

				//seems to be a valid file name
				command_arg_ok = true;
				_tcscpy(input_file, cmdInfo.desert_file);				
				hasInputFile = !(cmdInfo.desert_file).IsEmpty();

				_tcscpy(output_file, cmdInfo.desert_output_file);
				hasOutputFile = !(cmdInfo.desert_output_file).IsEmpty();
				
				isSilent = cmdInfo.silent;
				if (cmdInfo.applyCons)
					consList = cmdInfo.consList;

				if(cmdInfo.multiRun) {
					int ncgs = cmdInfo.consGroupNames.GetCount();
					numConsGroups = ncgs;
					if(ncgs > 0) {
						consGroupNames = new TCHAR* [ncgs];
						consGroups = new TCHAR* [ncgs];
					}
					POSITION p1 = cmdInfo.consGroupNames.GetHeadPosition();
					int cIdx = 0;
					while (p1 != NULL) {
						CString s = cmdInfo.consGroupNames.GetNext(p1);
						consGroupNames[cIdx++] = _tcsdup(s);
					}

					POSITION p2 = cmdInfo.consGroups.GetHeadPosition();
					cIdx = 0;
					while (p2 != NULL) {
						CString s = cmdInfo.consGroups.GetNext(p2);
						consGroups[cIdx++] = _tcsdup(s);
					}

					multiRun = true;
					isSilent = true;
				}
			}
		}//eo if (_tcslen(m_lpCmdLine))
	}//eo if (m_lpCmdLine)
	
	if (!command_arg_ok && !hasInputFile)
	{
		CFileDialog Open(	TRUE,									//construct a file open dialog
							_T("xml"),									//default file name extension
							NULL,									//default file name
							OFN_FILEMUSTEXIST |OFN_HIDEREADONLY ,	//default behaviour
							szFilterUDM,							//no filter
							NULL									//no parent windows
							);
		if (Open.DoModal() == IDOK)
		{
			_tcscpy(input_file, Open.GetPathName());
		} 
		else 
		{
			cancel_input = true;
			return TRUE;
		}
	}
	
	tstring infile= stripQuotes( input_file);
	infile.copy( input_file, infile.length(), 0);
	input_file[ infile.length()]= 0;

	// If output_file name is given, use it, else tack an _back at the end
	// (i.e., output has the same name, but sufxed by _back.[xml|mga|mem])
	if(hasOutputFile) {
		tstring outFile = stripQuotes( output_file );
		outFile.copy( output_file, outFile.length(), 0);
		output_file[ outFile.length() ] = 0;

		tstring strOutFName = output_file;
		std::size_t dotPos = strOutFName.find_last_of('.');
		if(dotPos != std::string::npos) {
			desert_config_info_file = strOutFName.substr(0, dotPos) + _T("_configs.xml");
		} else {
			desert_config_info_file = strOutFName + _T("_configs.xml");
		}
		fdDcif = _tfopen(desert_config_info_file.c_str(), _T("w+"));
	}
	else {
		_tcsncpy(output_file, input_file, _tcslen(input_file)-4);
		*(output_file+_tcslen(input_file)-4)='\0';

		desert_config_info_file = output_file;
		desert_config_info_file += _T("_configs.xml");
		fdDcif = _tfopen(desert_config_info_file.c_str(), _T("w+"));
	
		if (_tcsstr(input_file, _T(".xml")) || _tcsstr(input_file, _T(".XML"))) _tcscat(output_file, _T("_back.xml"));
		if (_tcsstr(input_file, _T(".mem")) || _tcsstr(input_file, _T(".MEM"))) _tcscat(output_file, _T("_back.mem"));
		if (_tcsstr(input_file, _T(".mga")) || _tcsstr(input_file, _T(".MGA"))) _tcscat(output_file, _T("_back.mga"));
	}

	if (!cancel_input)
	{
		CStatusDlg s_dlg( 0, isSilent);
		s_dlg.Create(IDD_DIALOG1);
		GetStatusDlg(&s_dlg);

		
		DesertSystem ds;
		Udm::SmartDataNetwork nw(diagram);
		try
		{

			s_dlg.SetStatus(SD_INIT);
			s_dlg.SetStatus(SD_PARSE);

			nw.OpenExisting(std::string(CStringA(input_file)), "", Udm::CHANGES_LOST_DEFAULT);
			ds = DesertSystem::Cast(nw.GetRootObject());
			DesertInit(CString(((std::string)ds.SystemName()).c_str()));
			
			s_dlg.SetStatus(SD_SPS);
			//spaces, elements
			set<Space> spaces = ds.Space_kind_children();
			set<Space>::iterator sp_iterator;

			ASSERT(spaces.begin() != spaces.end());	
			
			UdmDesertMap des_map;
			DesertUdmMap inv_des_map;


			UdmElementSet elements;
			UdmMemberSet custom_members;
						
			CStatusDlg * st_dlg = GetStatusDlg(NULL);
			std::function<void(short)> UpdateStatus = [&st_dlg](short status) { st_dlg->StepInState(status); };
	
			//Build spaces
			if (!spaces.empty())
			{
				Space sp;
				Element dummy;
				
				for (sp_iterator = spaces.begin(); sp_iterator != spaces.end(); sp_iterator++)
				{
					Space sp = *(sp_iterator);
					TRACE("Creating space: %s\n", ((string)sp.name()).c_str());
					CreateDesertSpace(sp, dummy, des_map, inv_des_map, elements, true, UpdateStatus);
				}//eo for (sp_iterator)
			}//if (!spaces.empty())
			
			//create relations
			s_dlg.SetStatus(SD_ERS);
			CreateElementRelations(ds, des_map, inv_des_map, UpdateStatus);

			//create constrains
			s_dlg.SetStatus(SD_CTS);
			CreateConstraints(ds, des_map, inv_des_map);

			//create foumulas
			CreateCustomFormulas(ds, des_map, inv_des_map);

			//create natural domains
			s_dlg.SetStatus(SD_NDS);
			CreateNaturalDomains(ds, des_map, inv_des_map, UpdateStatus);

			//create custom domains
			s_dlg.SetStatus(SD_CDS);
			CreateCustomDomains(ds, des_map, inv_des_map, custom_members, UpdateStatus);

			//create custom domain relations
			s_dlg.SetStatus(SD_MRS);
			CreateMemberRelations(ds, des_map, inv_des_map, UpdateStatus);

			//create variable properties
			s_dlg.SetStatus(SD_VPS);
			CreateVariableProperties(des_map, inv_des_map, elements, UpdateStatus);

			//create constant properties
			s_dlg.SetStatus(SD_CPS);
			CreateConstantProperties(des_map, inv_des_map, elements, custom_members, UpdateStatus);
	
			//create simpleformula for properties
			CreateSimpleFormulas(ds, des_map, inv_des_map);
			//create assignments for VariableProperties
			s_dlg.SetStatus(SD_ASS);
			CreateAssignments(des_map, inv_des_map, elements, custom_members, UpdateStatus);
	
			//invoking Desert UI
			s_dlg.SetStatus(SD_GUI);

			using namespace BackIfaceFunctions;
		
			fprintf(fdDcif, "<?xml version=\"1.1\"?>\n");
			fprintf(fdDcif, "<DesertConfigurations>\n");

			if (multiRun) {
				// Initialize
				std::cout << "Starting Multirun" << std::endl;
				DesertFinitWithMultirun_Pre(numConsGroups, consGroupNames, consGroups);

				// First run with no constraints applied
				int numCfgs = DesertFinitWithMultirun_Exec(true, CString(((std::string) ds.SystemName()).c_str()), _T("NONE"), _T(""));
				std::cout << "Group: NONE\tConfigs: " << numCfgs << std::endl;
				fprintf(fdDcif, "\t<None NumConfigs=\"%d\"/>\n", numCfgs);
				ReInitializeManager(&ds, &des_map, &inv_des_map);

				// Next run with all constraints applied
				numCfgs = DesertFinitWithMultirun_Exec(true, CString(((std::string) ds.SystemName()).c_str()), _T("ALL"), _T("applyAll"));
				std::cout << "Group: NONE\tConfigs: " << numCfgs << std::endl;
				fprintf(fdDcif, "\t<All NumConfigs=\"%d\"/>\n", numCfgs);
				ReInitializeManager(&ds, &des_map, &inv_des_map);

				// Next run for all groups
				fprintf(fdDcif, "\t<Groups>\n");
				for (int j = 0; j < numConsGroups; j++) {
					numCfgs = DesertFinitWithMultirun_Exec(true, CString(((std::string) ds.SystemName()).c_str()), consGroupNames[j], consGroups[j]);

					std::cout << "Group: NONE\tConfigs: " << numCfgs << std::endl;
					fprintf(fdDcif, "\t\t<Group Name=\"%S\" NumConfigs=\"%d\">\n", consGroupNames[j], numCfgs);
					std::vector<tstring> splittedCons = splitConstraints(consGroups[j]);
					for (std::vector<tstring>::iterator conIt = splittedCons.begin(); conIt != splittedCons.end(); ++conIt)
						fprintf(fdDcif, "\t\t\t<Constraint Name=\"%S\"/>\n", conIt->c_str());
					fprintf(fdDcif, "\t\t</Group>\n");

					if (j < numConsGroups) {
						ReInitializeManager(&ds, &des_map, &inv_des_map);
					}
				}
				fprintf(fdDcif, "\t</Groups>\n");

				// Finalize
				DesertFinitWithMultirun_Post();
				std::cout << "Finished Multirun" << std::endl;
				std::cout.flush();
			}
			else {

				// AfxMessageBox(CString("Calling DESERT Finit w/:") + consList );
				std::cout << "Running with constraint set: \t" << consList << std::endl;
				DBConfigurations * confs = (DBConfigurations *)DesertFinit(true, isSilent, consList == "" ? NULL : (LPCTSTR)consList);
				int numCfgs = (confs) ? confs->GetCount() : 0;
				
				tstring strConsList = trimSpaces(tstring(consList));
				if (strConsList.length() == 0 || strConsList.compare(_T("None")) == 0 || strConsList.compare(_T("none")) == 0) {
					fprintf(fdDcif, "\t<None NumConfigs=\"%d\"/>\n", numCfgs);
				} else if(strConsList.compare(_T("applyAll")) == 0) {
					fprintf(fdDcif, "\t<All NumConfigs=\"%d\"/>\n", numCfgs);
				} else {
					fprintf(fdDcif, "\t<ConstraintSet NumConfigs=\"%d\">\n", numCfgs);
					std::vector<tstring> allStrCons = splitConstraints(strConsList);
					for (std::vector<tstring>::iterator strCIt = allStrCons.begin(); strCIt != allStrCons.end(); ++strCIt)
						fprintf(fdDcif, "\t\t<Constraint Name=\"%S\"/>\n", strCIt->c_str());
					fprintf(fdDcif, "\t</ConstraintSet>\n");
				}
				std::cout << "Configs: " << numCfgs << std::endl;
				std::cout.flush();
			
				if (confs)
				{
					//open file dialog to write out configurations
					if (!command_arg_ok || !isSilent)
					{
						CFileDialog SaveAs(
								FALSE,									//construct a file open dialog
								_T("xml"),									//default file name extension
								output_file,							//default file name
								OFN_HIDEREADONLY ,						//default behaviour
								szFilterUDM,							//no filter
								NULL									//no parent windows
								);
						if (SaveAs.DoModal() == IDOK)
						{
							_tcscpy(output_file, SaveAs.GetPathName());
						}
							else cancel_output = true;

					}
					if (!cancel_output)
					{
				
						//create data network
						Udm::SmartDataNetwork bw(DesertIfaceBack::diagram);
						DesertIfaceBack::DesertBackSystem dbs;
						bw.CreateNew(
							//(LPCTSTR)SaveAs.GetFileName(), 
							std::string(CStringA(output_file)),
							"DesertIfaceBack",	
							DesertIfaceBack::DesertBackSystem::meta,
							Udm::CHANGES_PERSIST_ALWAYS);	

						//get&take care of the root object
						dbs = DesertIfaceBack::DesertBackSystem::Cast(bw.GetRootObject());
						dbs.SystemName() = ds.SystemName();

						//elements, custommembers and natural members will be created
						//on the fly, as it they are participating in an assignment

						int confn = confs->GetCount();
						POSITION pos = confs->GetHeadPosition();
						int count = 0;
						s_dlg.SetStatus(SD_PREP);
						while (pos)
						{
		
							DBConfiguration * config = confs->GetNext(pos);
							if (config)
							{
								DesertIfaceBack::Configuration dummy;
								//check for the existence of elements, properties,
								//and values which will be associated then
								POSITION pos1 = config->assignments.GetHeadPosition();
								while (pos1)
								{
									long valid_ass = config->assignments.GetNext(pos1);				
									BackIfaceFunctions::CreatePropertyAssignment(dbs, dummy, inv_des_map, des_map, valid_ass, false);
								}
								POSITION pos2 = config->alt_assignments.GetStartPosition();
								while (pos2)
								{
									long alt, alt_of;
									config->alt_assignments.GetNextAssoc(pos2, alt_of, alt);
									BackIfaceFunctions::CreateAlternativeAssignment(dbs, dummy, inv_des_map, alt_of, alt, false);

								};
							}//eo if (config)	
							s_dlg.StepInState((double)(((double)(++count)) / ((double)(confs->GetCount())))*100.0);	//progress bar

						}//eo while(pos)
						pos = confs->GetHeadPosition();
						s_dlg.SetStatus(SD_BACK);
						count = 0;
						while (pos)
						{
							DBConfiguration * config = confs->GetNext(pos);
							if (config)
							{
								//create configuration
								DesertIfaceBack::Configuration dib_conf = DesertIfaceBack::Configuration::Create(dbs);
								CString s;
								s.Format(_T("Conf. no: %d"), config->id);
								dib_conf.name() = static_cast<LPCSTR>(CStringA(s));
								dib_conf.id() = config->id;
							

								POSITION pos1 = config->assignments.GetHeadPosition();
								while (pos1)
								{
									long valid_ass = config->assignments.GetNext(pos1);				
									BackIfaceFunctions::CreatePropertyAssignment(dbs, dib_conf, inv_des_map, des_map, valid_ass, true);
								}
								POSITION pos2 = config->alt_assignments.GetStartPosition();
								while (pos2)
								{
									long alt, alt_of;
									config->alt_assignments.GetNextAssoc(pos2, alt_of, alt);
									BackIfaceFunctions::CreateAlternativeAssignment(dbs, dib_conf, inv_des_map, alt_of, alt, true);
								};
							
								TRACE("Got %d of configurations!\n", confs->GetCount());


								delete config;
							}//eo if (config)
							s_dlg.StepInState((double)(((double)(++count)) / ((double)(confs->GetCount())))*100.0);	//progress bar
						}//eo while(pos)
					
						delete confs;
			
						set<DesertIfaceBack::Configuration> cfgs = dbs.Configuration_kind_children();		
						for (set<DesertIfaceBack::Configuration>::iterator it = cfgs.begin(); it != cfgs.end(); ++it)
						{
							DesertIfaceBack::Configuration cfg = *it;
							std::string cfgid = cfg.cfgId();
							boost::crc_32_type id_hash;
							id_hash.process_bytes(cfgid.c_str(), cfgid.length());
							int uid = id_hash.checksum();
							std::stringstream sstream;
							sstream << std::hex << uid;
							cfg.cfgId() = sstream.str();
						}
					}//eo if DoModal() == IDOK
				}//eo if (configs)	
		
				//all done
				s_dlg.SetStatus(SD_FINIT);
			
				/*{
					//debug test
					set<ConstraintSet> ts_set = ds.ConstraintSet_kind_children();
				
					set<ConstraintSet>::iterator i = ts_set.begin();
					ConstraintSet cts = *i;
				
					Constraint ct = Constraint::Create(cts);
				
					ct.id() = 1234567890;
					ct.externalID() = -1234567890;
					ct.name() = "f**k name";
					ct.expression() = "f**k expression";
				

					set<Space> sp_set = ds.Space_kind_children();
					set<Space> :: iterator j = sp_set.begin();
					Space sp = *j;
				
					set<Element> e_set = sp.Element_kind_children();
					set<Element> :: iterator k = e_set.begin();
					Element e = *k;
				
					ct.context() = e;
				


				}*/

			} // eo multiRun

			fprintf(fdDcif, "</DesertConfigurations>\n");
			fflush(fdDcif);
			fclose(fdDcif);

		}//eo try
		catch (CDesertException *e)
		{
			fprintf(fdDcif, "</DesertConfigurations>\n");
			fflush(fdDcif);
			fclose(fdDcif);

			e->ReportError();
			//	throw e;
			return FALSE;
		}
		catch (udm_exception e)
		{
			fprintf(fdDcif, "</DesertConfigurations>\n");
			fflush(fdDcif);
			fclose(fdDcif);

			if (m_lpCmdLine && command_arg_ok)
				std::cerr << std::string("Udm exception: ") + e.what();
			else
				AfxMessageBox(CString("Udm exception: ") + CString(e.what()));
			//	throw e;
			return FALSE;
		}
	
	}//eo if (Open.DoModal())

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return TRUE;
}