⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datamanager.cpp

📁 一个通过矩阵运算得到图形连接关系的动态连接库
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			(g_netModel.pComponentInfo+i)->pComponent = object;
			g_mapComponentID.SetAt(tagKey->nID,g_netModel.pComponentInfo+i);
			bFind = TRUE;
			break;
		}
	}
	if(!bFind)
	{
		CString str(_T(""));
		str.Format(_T("网络模型中没有找到元件%s!"),tagKey->chKey);
		if(bShowMsg) ::MessageBox(AfxGetMainWnd()->GetSafeHwnd(),str,"提示::AVInfoKernel_AVInitComponentID",MB_OK | MB_ICONEXCLAMATION | MB_ICONWARNING);
		return AVERR_NOT_FOUND;
	}
	return AV_NO_ERR;
}
/*****************************************************************************
【功能说明】:初始化元件端子联接元件键值信息(InitSecondA,Option)
【输入参数】:无
【输出参数】:无
【返回说明】:本图形系统定义的调用返回码
*****************************************************************************/
AV_EXPORT USHORT AVInitComponentInfo()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if(!g_netModel.pComponentInfo) return AVERR_NOT_FOUND;

	//检出图形上存在但数据库中不存在的、并且没有与任何存在元件存在连接关系的元件
	for(int i=0; i<g_netModel.nComponentSum; i++)
	{
		if((g_netModel.pComponentInfo+i)->keyInfo.nID == -1)
		{
			CString str(_T(""));
			str.Format(_T("图形模型中的元件%s在数据库中不存在!"),(g_netModel.pComponentInfo+i)->keyInfo.chKey);
			::MessageBox(AfxGetMainWnd()->GetSafeHwnd(),str,"提示::AVInfoKernel_AVInitComponentInfo",MB_OK | MB_ICONEXCLAMATION | MB_ICONWARNING);
			return AVERR_NOT_FOUND;
		}
	}

	int nID = -1;
	AV_COMPONENT_INFO* pComponent = NULL;
	POSITION pos = g_mapComponentID.GetStartPosition();
	while(pos)
	{
		g_mapComponentID.GetNextAssoc(pos,nID,pComponent);
		if(pComponent)
		{
			for(int i=0; i <pComponent->nPortSum; i++)
			{
				for(int j=0; j<(pComponent->pPortInfo+i)->nLinkSum; j++)
				{
					AV_COMPONENT_INFO* pComponentLinked = GetComponentInfoByKey((pComponent->pPortInfo+i)->pKeyInfo+j);
					if(pComponentLinked) ((pComponent->pPortInfo+i)->pKeyInfo+j)->nID = pComponentLinked->keyInfo.nID;
					else ((pComponent->pPortInfo+i)->pKeyInfo+j)->nID = -1;
				}
			}
		}
	}
	return AV_NO_ERR;
}
/*****************************************************************************
【功能说明】:初始化网络节点联接元件键值信息(InitSecondB,Option)
【输入参数】:无
【输出参数】:无
【返回说明】:本图形系统定义的调用返回码
*****************************************************************************/
AV_EXPORT USHORT AVInitNetNodeInfo()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if(!g_netModel.pNodeInfo) return AVERR_NOT_FOUND;

	for(int i=0; i<g_netModel.nNodeSum; i++)
	{
		for(int j=0; j<(g_netModel.pNodeInfo+i)->nComponentSum; j++)
		{
			AV_COMPONENT_INFO* pComponent = GetComponentInfoByKey((g_netModel.pNodeInfo+i)->pKeyInfo+j);
			if(pComponent) ((g_netModel.pNodeInfo+i)->pKeyInfo+j)->nID = pComponent->keyInfo.nID;
			else ((g_netModel.pNodeInfo+i)->pKeyInfo+i)->nID = -1;
		}
	}

	return AV_NO_ERR;
}
/*****************************************************************************
【功能说明】:初始化元件相关标记数据库(InitThirdA,Option)
【输入参数】:指定元件检索键tagKey,标记类型type,标记后缀suffix,标记描述desc
【输出参数】:无
【返回说明】:本图形系统定义的调用返回码
【附加说明】:之所以需要指定元件是方便二次开发者对特定元件进行特定处理
【严重声明】:由于在图形页面打开时必须由变量名定位变量ID以提高动态图形效率,因此
              在更新了图形页面后,即增加了新的元件后,必须先初始化变量库,然后切换
			  或更新图形界面显示,否则当有新的元件加入时状态将无效
*****************************************************************************/
AV_EXPORT USHORT AVMakeComponentTagBase(AV_KEY_INFO* tagKey,USHORT type,char* prefix,char* suffix,char* desc,ULONG* tagID)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
    if(!tagKey) return AVERR_BAD_PARAM;
	if(strlen(tagKey->chKey) <= 0) return AVERR_BAD_PARAM;
	if((!prefix && !suffix) || !desc) return AVERR_BAD_PARAM;
	if((strlen(prefix) <= 0 && strlen(suffix) <= 0) || strlen(desc) <= 0) return AVERR_BAD_PARAM;
	if(type < TAG_ANALOG || type > TAG_MDIGITAL) return AVERR_BAD_PARAM;

	CString str(tagKey->chKey);
	CString strMsg(_T(""));
	AV_TAG_DEF tagDef;
	tagDef.type = type;
	if(prefix && strlen(prefix) > 0) str = CString(prefix) + str;
	if(suffix && strlen(suffix) > 0) str = str + _T("_") + CString(suffix);
	if(str.GetLength() >= TAGNAME_LENGTH+8)//wxg+8 [_State]
	{
		int nCount = 0;
		if(prefix) nCount = strlen(prefix);
		if(str.Left(nCount+4).Right(4).CompareNoCase(_T("LINK")) == 0) return AVERR_BAD_PARAM;
		strMsg.Format(_T("元件的相关标记[%s]超过标记长度限制,不予支持!"),str);
		::MessageBox(AfxGetMainWnd()->GetSafeHwnd(),strMsg,"提示::AVInfoKernel_AVMakeComponentTagBase",MB_OK | MB_ICONEXCLAMATION | MB_ICONWARNING);
		return AVERR_BAD_PARAM;
	}
	strcpy((char*)tagDef.name,str.GetBuffer(str.GetLength()));
	str.ReleaseBuffer();
	str.Format(_T("元件%s%s"),tagKey->chKey,desc);
	if(str.GetLength() >= TAGDESC_LENGTH)
	{
		strMsg.Format(_T("元件的相关标记描述[%s]超过长度限制,不予支持!"),str);
		::MessageBox(AfxGetMainWnd()->GetSafeHwnd(),strMsg,"提示::AVInfoKernel_AVMakeComponentTagBase",MB_OK | MB_ICONEXCLAMATION | MB_ICONWARNING);
		return AVERR_BAD_PARAM;
	}
	strcpy((char*)tagDef.description,str.GetBuffer(str.GetLength()));
	str.ReleaseBuffer();
	switch(type)
	{
	case TAG_ANALOG:
		tagDef.value.fValue = -100.0;
		break;
	case TAG_DIGITAL:
	case TAG_MDIGITAL:
		tagDef.value.nValue = -100;
		break;
	case TAG_STRING:
		strcpy(tagDef.value.szValue,"\0");
		break;
	default:
		break;
	}
	if(::AVAddTagDef(&tagDef) == AV_NO_ERR)
		*tagID = tagDef.identity;
	else *tagID = -1;

	return AV_NO_ERR;
}
/*****************************************************************************
【功能说明】:初始化元件触发宏记录库(InitThirdB,Option)
【输入参数】:指定元件检索键tagKey,触发宏类型type,宏名称后缀suffix,宏描述后缀desc
【输出参数】:无
【返回说明】:本图形系统定义的调用返回码
【附加说明】:之所以需要指定元件是方便二次开发者对特定元件进行特定处理
*****************************************************************************/
AV_EXPORT USHORT AVMakeComponentMacroBase(AV_KEY_INFO* tagKey,USHORT type,char* prefix,char* suffix,char* desc)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
    if(!tagKey) return AVERR_BAD_PARAM;
	if(strlen(tagKey->chKey) <= 0) return AVERR_BAD_PARAM;
	if((!prefix && !suffix) || !desc) return AVERR_BAD_PARAM;
	if((strlen(prefix) <= 0 && strlen(suffix) <= 0) || strlen(desc) <= 0) return AVERR_BAD_PARAM;
	if(type < TOUCH_SETANALOG || type > TOUCH_EXEMACRO) return AVERR_BAD_PARAM;

	return AV_NO_ERR;
}
/*****************************************************************************
【功能说明】:关闭网络模型(Last call,Must)
【输入参数】:无
【输出参数】:无
【返回说明】:本图形系统定义的调用返回码
*****************************************************************************/
AV_EXPORT USHORT AVCloseNetModel()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	//删除节点矩阵(原始矩阵、前一矩阵、当前矩阵)
	if(g_pMatrixNodeOrigin)
	{
		for(int i=0; i<g_netModel.nNodeSum; i++)
		{
			delete *(g_pMatrixNodeOrigin+i);
		}
		delete g_pMatrixNodeOrigin;
		g_pMatrixNodeOrigin = NULL;
	}
	if(g_pMatrixNodePrev)
	{
		for(int i=0; i<g_netModel.nNodeSum; i++)
		{
			delete *(g_pMatrixNodePrev+i);
		}
		delete g_pMatrixNodePrev;
		g_pMatrixNodePrev = NULL;
	}
	if(g_pMatrixNodeCurrent)
	{
		for(int i=0; i<g_netModel.nNodeSum; i++)
		{
			delete *(g_pMatrixNodeCurrent+i);
		}
		delete g_pMatrixNodeCurrent;
		g_pMatrixNodeCurrent = NULL;
	}
	if(pMatrixLocal)
	{
		for(int i=0; i<g_netModel.nNodeSum; i++)
		{
			delete *(pMatrixLocal+i);
		}
		delete pMatrixLocal;
		pMatrixLocal = NULL;
	}


	//删除节点信息
	for(int i=0; i<g_netModel.nNodeSum; i++)
	{
		if((g_netModel.pNodeInfo+i)->pKeyInfo && (g_netModel.pNodeInfo+i)->nComponentSum > 0) 
			delete (g_netModel.pNodeInfo+i)->pKeyInfo;
	}
	delete g_netModel.pNodeInfo;

	//删除元件信息
	for(i=0; i<g_netModel.nComponentSum; i++)
	{
		for(int j=0; j<(g_netModel.pComponentInfo+i)->nPortSum; j++)
		{
			AV_PORT_INFO* pPortInfo = (g_netModel.pComponentInfo+i)->pPortInfo+j;
			if(pPortInfo->pKeyInfo && pPortInfo->nLinkSum > 0)
				delete pPortInfo->pKeyInfo;
		}
		if((g_netModel.pComponentInfo+i)->pPortInfo && (g_netModel.pComponentInfo+i)->nPortSum > 0)
			delete (g_netModel.pComponentInfo+i)->pPortInfo;
	}
	delete g_netModel.pComponentInfo;

	g_netModel.pNodeInfo = NULL;
	g_netModel.pComponentInfo = NULL;
	g_netModel.nNodeSum = 0;
	g_netModel.nComponentSum = 0;
	g_mapComponentID.RemoveAll();

	return AV_NO_ERR;
}

#ifdef __cplusplus
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -