Configuration | Basics CComPtr pProject; hr = pSolution- >AddFromTemplate(strTemplatePath,strProjectPath,strProjectName,VARIANT_FALSE,&pProject); // Wenn z.B.
Projekt bereits besteht >> error if (FAILED(hr)) { cout cout // define project automation class (here the Coclass TcSysManager) CComPtr pDispatch; hr = pProject->get_Object(&pDispatch); // retrieve ITcSysManager interface CComPtr pSystemManager; hr = pDispatch.QueryInterface(&pSystemManager); // operate with SystemManager interface CComBSTR netId; netId = (pSystemManager->GetTargetNetId()).GetBSTR(); cout hr = pSystemManager->ActivateConfiguration(); hr = pSystemManager->StartRestartTwinCAT(); // save project and solution hr = pProject->Save(CComBSTR()); hr = pSolution->SaveAs(strSolutionPath); cout return 0; } import Known Issue:
CComPtr m_pDTE; CLSID clsid; CLSIDFromProgID(L"VisualStudio.DTE.10.0",&clsid); CComPtr punk; HRESULT hr = GetActiveObject(clsid,NULL,&punk); // retrieve actual instance of Visual Studio .NET m_pDTE = punk; Please note: ITcSysManager::NewConfiguration, ITcSysManager::OpenConfiguraiton and ITcSysManager::SaveConfiguration will create error messages in this case, because the project handling is delegated to the Visual Studio IDE (the Solution and Project instances realized by the DTE object). 4.2.2 Browsing TwinCAT configuration | Browsing TwinCAT configuration In a separate article, we have already shown you how to access TwinCAT [ } 22] via the Visual Studio Automation Model.
This reference to TwinCAT is being represented by an object of type ITcSysManager. From this point on we would like to discuss now how you can navigate through the TwinCAT configuration. General Information It is important to understand that all information in TwinCAT is organized in a tree-like structure. In the Automation Interface, each structure node and therefore each element of a TwinCAT configuration is represented by the ITcSmTreeItem interface. You can navigate through the TwinCAT data model in different ways, depending on the type of information you want to query. Lookup methods search for specific Tree Items using specified search criteria, e.g.
the path to a Tree Item Iterators or search functions iterate over a set of queried Tree Items Both methods are now discussed in the following article. TE1000 25 Version: 1.7.0