/**
 * Apply the created mapping to the workspace
 */
void CreateSimulationWorkspace::applyDetectorMapping() {
  size_t wsIndex(0);
  for (auto iter = m_detGroups.begin(); iter != m_detGroups.end(); ++iter) {
    ISpectrum *spectrum = m_outputWS->getSpectrum(wsIndex);
    spectrum->setSpectrumNo(
        static_cast<specid_t>(wsIndex + 1)); // Ensure a contiguous mapping
    spectrum->clearDetectorIDs();
    spectrum->addDetectorIDs(iter->second);
    ++wsIndex;
  }
}
Example #2
0
ret_ CXMLLoaderActions::LoadNetworkVarialbe(const CData &Data,
											const DOMElement *pElement,
											CVariable *&pOV,
											const CPDUInfo *pPDU)
{
#ifdef _DEBUG_
	if (!pElement)
		return PARAMETER_NULL | PARAMETER_2;

	if (pOV)
		return PARAMETER_NOT_NULL | PARAMETER_3;
	
	if (!pPDU)
		return PARAMETER_NULL | PARAMETER_4;
#endif

	//
	auto_xerces_str wsGroupName	("group_name");
	auto_xerces_str wsFieldName	("field_name");
	auto_xerces_str wsIndex		("index");

	auto_xerces_str sGroupName	(pElement->getAttribute(wsGroupName));
	auto_xerces_str	sFieldName	(pElement->getAttribute(wsFieldName));
	auto_xerces_str sIndex		(pElement->getAttribute(wsIndex));

	ch_1 szName[VARIABLE_NAME_LENGTH * 2];

	memset(szName, 0, VARIABLE_NAME_LENGTH * 2);

	if (0 < strlen(sGroupName))
	{
		
		sprintf(szName, 
				"%s.%s", 
				(const ch_1 *)sGroupName, 
				(const ch_1 *)sFieldName);
	}
	else
	{
		sprintf(szName, "%s", (const ch_1 *)sFieldName);
	}

	CField *pField = null_v;

	if (SUCCESS != (((CPDUInfo *)pPDU)->GetField(szName, pField)))
		return XML_LOADER_ERROR;

	if (0 == strcmp(sIndex, SIGN_UNBOUNDED))
		pOV = new CVarNetwork(pField);
	else
		pOV = new CVarNetwork(pField, sIndex);

	return SUCCESS;
}
/**
 * Apply the created mapping to the workspace
 */
void CreateSimulationWorkspace::applyDetectorMapping() {
  size_t wsIndex(0);
  for (auto &detGroup : m_detGroups) {
    auto &spectrum = m_outputWS->getSpectrum(wsIndex);
    spectrum.setSpectrumNo(
        static_cast<specnum_t>(wsIndex + 1)); // Ensure a contiguous mapping
    spectrum.clearDetectorIDs();
    spectrum.addDetectorIDs(detGroup.second);
    ++wsIndex;
  }
}
Example #4
0
ret_ CXMLLoaderActions::LoadGroupVariable(const CData &Data,
										  const DOMElement *pElement,
										  CVariable *&pOV)
{
#ifdef _DEBUG_
	if (!pElement)
		return (PARAMETER_NULL | PARAMETER_2);

	if (pOV)
		return (PARAMETER_NOT_NULL | PARAMETER_3);
#endif
	auto_xerces_str wsGroupName	("group_name");
	auto_xerces_str wsFieldName	("field_name");
	auto_xerces_str wsIndex		("index");

	auto_xerces_str sGroupName	(pElement->getAttribute(wsGroupName));
	auto_xerces_str	sFieldName	(pElement->getAttribute(wsFieldName));
	auto_xerces_str sIndex		(pElement->getAttribute(wsIndex));

	ch_1 szName[VARIABLE_NAME_LENGTH * 2];
	const char *pszSubName = null_v;
	const char *pszIndexName = null_v;

	memset(szName, 0, VARIABLE_NAME_LENGTH * 2);

	if (0 < strlen(sFieldName))
	{
		sprintf(szName, 
				"%s.%s", 
				(const ch_1 *)sGroupName, 
				(const ch_1 *)sFieldName);
		pszSubName = sFieldName;
	}
	else
	{
		sprintf(szName, "%s", (const ch_1 *)sGroupName);
	}

	v_ *pV = Data.Value(szName);

	if (!pV)
		return XML_LOADER_ERROR; // There is no variable defined above

	if (0 != strcmp(sIndex, SIGN_UNBOUNDED))
		pszIndexName = sIndex;

	pOV = new CVarGroupDefined(sGroupName, pszSubName, pszIndexName);

	return SUCCESS;
}
Example #5
0
FX_BOOL CXFA_NodeHelper::CreateNode_ForCondition(CFX_WideString& wsCondition) {
  int32_t iLen = wsCondition.GetLength();
  CFX_WideString wsIndex(L"0");
  FX_BOOL bAll = FALSE;
  if (iLen == 0) {
    m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne;
    return FALSE;
  }
  if (wsCondition.GetAt(0) == '[') {
    int32_t i = 1;
    for (; i < iLen; ++i) {
      FX_WCHAR ch = wsCondition[i];
      if (ch == ' ') {
        continue;
      }
      if (ch == '+' || ch == '-') {
        break;
      } else if (ch == '*') {
        bAll = TRUE;
        break;
      } else {
        break;
      }
    }
    if (bAll) {
      wsIndex = FX_WSTRC(L"1");
      m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeAll;
    } else {
      m_iCreateFlag = XFA_RESOLVENODE_RSTYPE_CreateNodeOne;
      wsIndex = wsCondition.Mid(i, iLen - 1 - i);
    }
    int32_t iIndex = wsIndex.GetInteger();
    m_iCreateCount = iIndex;
    return TRUE;
  }
  return FALSE;
}