This template creates ST code that provides symbolic access to all technology objects of your TIA Portal project if you are using the Siemens.Simatic.S71500.MotionControl.Native library.
Expand to view the motioncontrol-native template and the resulting ST code
**Example:** Imagine your TIA Portal project contains three technology objects:  Then the import would result in code similar to ...NAMESPACE TiaProject.Motioncontrol_TIAX
CLASS PLC_1
VAR PUBLIC
SpeedAxis_1_Reference : REF_TO TO_SpeedAxis;
PositioningAxis_1_Reference : REF_TO TO_PositioningAxis;
SynchronousAxis_1_Reference : REF_TO TO_SynchronousAxis;
END_VAR
METHOD PUBLIC Initialize : Bool
...
END_METHOD
END_CLASS
END_NAMESPACE
USING Siemens.Simatic.S71500.MotionControl.Native;
USING TiaProject.Motioncontrol_TIAX.Native; // import generated namespace
CLASS MyMotionApplication
VAR
plc_1_tos : PLC_1; // instantiate generated class containing TO references
powerSpeedAxis : MC_Power;
powerPosAxis : MC_Power;
powerSyncAxis : MC_Power;
END_VAR
METHOD Setup : BOOL
Setup := plc_1_tos.Initialize(); // attach all TO references
END_METHOD
METHOD ActivateAxes
// use TOs references
powerSpeedAxis(Axis := plc_1_tos.SpeedAxis_1_Reference^, Enable := true);
powerPosAxis(Axis := plc_1_tos.PositioningAxis_1_Reference^, Enable := true);
powerSyncAxis(Axis := plc_1_tos.SynchronousAxis_1_Reference^, Enable := true);
END_METHOD
END_CLASS
{{#partials}}
TO_SpeedAxis+ref : SpeedAxis
TO_PositioningAxis+ref : PositioningAxis
TO_SynchronousAxis+ref : SynchronousAxis
TO_ExternalEncoder+ref : ExternalEncoder
TO_OutputCam+ref : OutputCam
TO_CamTrack+ref : CamTrack
TO_MeasuringInput+ref : MeasuringInput
TO_Cam+ref : Cam
TO_Cam_10k+ref : Cam_10k
TO_Kinematics+ref : Kinematics
TO_LeadingAxisProxy+ref : LeadingAxisProxy
TO_Interpreter+ref : Interpreter
// prepend underscore if the name do not already start with a underscore.
PrivateName: {{^Name.IsMatch(^_)}}_{{/Name.IsMatch(^_)}}{{Name}}
{{/partials}}
USING Siemens.Simatic.S71500.MotionControl.Native;
NAMESPACE TiaProject.{{Name}}
{{#PLCs}}
{{#Is1500}}
/// {{Name}}
/// {{TypeName}}
/// OrderNumber:{{OrderNumber}}
/// FwVersion:{{FirmwareVersion}}
/// Author: {{Author}}
/// InstallationDate: {{InstallationDate}}
CLASS {{Name}}
{{#Software.TechnologicalObjectGroup}}
VAR PRIVATE
// DB Numbers
{{#AllTechnologicalObjects}}
{{>PrivateName}}DbNumber : DB_ANY := UINT#{{Number}};
{{/AllTechnologicalObjects}}
END_VAR
VAR PUBLIC
// Initialize state
IsInitialized : BOOL;
// References
{{#AllTechnologicalObjects}}
{{Name}}Reference : REF_TO {{Type}};
{{/AllTechnologicalObjects}}
END_VAR
/// To initialize all technological objects it must be called once.
/// After initialization they can be used via reference.
/// Returns TRUE if initialization of all references is completed successfully. Otherwise FALSE.
/// The state of initialization can also be checked later by the tag "IsInitialized".
METHOD PUBLIC Initialize : BOOL
// Check state of initialization
IF NOT IsInitialized THEN
// Initialize references
{{#AllTechnologicalObjects.ExceptType(TO_InterpreterMapping|TO_InterpreterProgram)}}
{{Name}}Reference := As{{>*Type+ref}}Ref({{>PrivateName}}DbNumber);
{{/AllTechnologicalObjects.ExceptType(TO_InterpreterMapping|TO_InterpreterProgram)}}
IsInitialized := (TRUE {{#AllTechnologicalObjects.ExceptType(TO_InterpreterMapping|TO_InterpreterProgram)}}
AND NOT ({{Name}}Reference = NULL){{/AllTechnologicalObjects.ExceptType(TO_InterpreterMapping|TO_InterpreterProgram)}}
);
END_IF;
Initialize := IsInitialized;
END_METHOD
END_CLASS
{{/Software.TechnologicalObjectGroup}}
{{/Is1500}}
{{/PLCs}}
END_NAMESPACE