VC做的OPC客户端怎样访问WINCC的变量数据
1个回答
展开全部
void SetActive (BOOL bActive, BOOL bApply = FALSE);//激活
BOOL IsActive ();//是否激活?
pUnkGroup->SetActive(TRUE,TURE);
另个需保证OPC地址验证要通过
启动流程
先启动OPC驱动
if(!pOpcServer->IsAlive())
pOpcServer->Start();
AddOpcItem(XXX,XXX,XXX);//往OPC的某个组增加Item
COPCItem* AddOpcItem(COPCServer *pOpcServer,COPCGroup *pOpcGroup,CVarObj *pVarObj)
{
if(pOpcServer && pOpcGroup && pVarObj)
{
COPCItem *pItem = new COPCItem (pOpcGroup);
// Set item properties:
pItem->SetAccessPath (pVarObj->m_strAccessPath);
pItem->SetActive (pVarObj->m_bEnable);
pItem->SetDataType (pVarObj->m_vtData);
pItem->SetItemID (pVarObj->m_strAddress);
// 验证地址
if(pOpcGroup->ValidateItem(pVarObj->m_strAddress,pVarObj->m_strAccessPath,pVarObj->m_vtData))
{
CObArray cList;
cList.Add(pItem);
int cnItems = cList.GetSize();
pOpcGroup->AddItems (cList, cnItems);
return pItem;
}
else
{
delete pItem;
}
}
return NULL;
}
BOOL IsActive ();//是否激活?
pUnkGroup->SetActive(TRUE,TURE);
另个需保证OPC地址验证要通过
启动流程
先启动OPC驱动
if(!pOpcServer->IsAlive())
pOpcServer->Start();
AddOpcItem(XXX,XXX,XXX);//往OPC的某个组增加Item
COPCItem* AddOpcItem(COPCServer *pOpcServer,COPCGroup *pOpcGroup,CVarObj *pVarObj)
{
if(pOpcServer && pOpcGroup && pVarObj)
{
COPCItem *pItem = new COPCItem (pOpcGroup);
// Set item properties:
pItem->SetAccessPath (pVarObj->m_strAccessPath);
pItem->SetActive (pVarObj->m_bEnable);
pItem->SetDataType (pVarObj->m_vtData);
pItem->SetItemID (pVarObj->m_strAddress);
// 验证地址
if(pOpcGroup->ValidateItem(pVarObj->m_strAddress,pVarObj->m_strAccessPath,pVarObj->m_vtData))
{
CObArray cList;
cList.Add(pItem);
int cnItems = cList.GetSize();
pOpcGroup->AddItems (cList, cnItems);
return pItem;
}
else
{
delete pItem;
}
}
return NULL;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询