C++ Project -> Revision control
These instructions describe how to add subsequently a revision control to a TwinCAT C++ project.
The code to be changed is stored in bold in the source code.
- C++ project. For the sample "Untitled1" is used as C++ project name.
In addition, an empty, new project with a versioned C++ project is to be created. This serves as a copy template.
- 1. Open the file Untitled1.vcxproj in an editor.
- 2. Make the following addition:
<PropertyGroup Label="Globals">
<ProjectGuid>{….}</ProjectGuid>
<RootNamespace>Untitled1</RootNamespace>
<Keyword>Win32Proj</Keyword>
<AutomaticRetargetPlatformVersion>true</AutomaticRetargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Label="TcGeneral">
<TcGeneralUseTmx>true</TcGeneralUseTmx>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- 3. Transfer the Untitled1.rc and Untitled1W32.rc files from the new project to the project to be migrated, overwriting the Untitled1.rc file.
- 4. Open the project.
- 5. Under TwinCAT UM Files -> Context menu / Add Existing Items select the file Unititled1W32.rc and add it to the project.
- 6. This file only needs to be built for TwinCAT UM platforms, so it should otherwise be excluded for the build process. This is done via right-click and properties:
- 7. Open the TMC Editor.
- 8. Set the name of the class factory and the version to "0.0.0.1".
- 9. Under Deployment, delete all entries.
- 10. Change in header Modul1.h DECLARE_IPERSIST_LIB():
public:
DECLARE_IUNKNOWN()
DECLARE_IPERSIST_LIB()
DECLARE_ITCOMOBJECT_LOCKOP()
- 11. Add Modul1.cpp to the source code:
#pragma hdrstop
#include "Module1.h"
#include "Untitled1Version.h"
#ifdef _DEBUG
- 12. Add Modul1.cpp to the source code:
END_INTERFACE_MAP()
IMPLEMENT_IPERSIST_LIB(CModule1, VID_Untitled1,
CID_Untitled1CModule1)
IMPLEMENT_ITCOMOBJECT(CModule1)
IMPLEMENT_ITCOMOBJECT_SETSTATE_LOCKOP2(CModule1)
- 13. Call the code generator.
- 14. Change in the file Untitled1Classfactory.cpp:
CUntitled1ClassFactory::CUntitled1ClassFactory() : CObjClassFactory()
{
TcDbgUnitSetImageName(TCDBG_UNIT_IMAGE_NAME_TMX(SRVNAME_UNTITLED1));
#if defined(TCDBG_UNIT_VERSION)
TcDbgUnitSetVersion(TCDBG_UNIT_VERSION(Untitled1));
#endif //defined(TCDBG_UNIT_VERSION)
}
- 15. Change the signing in the project properties in the tab Tc Sign. To do this, switch SHA1 signing off and TwinCAT signing on; provide TwinCAT user certificate and password at the same time.
- 16. Trigger the Rebuild of the project.
- The result is a C++ project that supports revision control.
If a module is to be made Online Change capable, this can be achieved by the following instructions.