<?xml version="1.0" encoding="utf-8"?>

<ExportedUserProgram
    Version="1.0.0">
   <VariableTable>
   <Variable
       Offset="0"
       TagName="LastPosition"
       Format="REAL"
       Retain="True"
       Units="pu"
       DefaultValue="0"/>
</VariableTable>
   <DiscreteIO/>
   <UserProgram
    Name="SavePosition"
    Type="STEP"
    Number="0"
    Desc="This program recovers the last measured position on power up"
    SingleInstance="True"
    TaskMask="32767">
   <ProgramBlock
       Type="STEP">
      <Comment
          Comment="This step runs only once when the controller starts up.&#13;&#10;&#13;&#10;Set the actual position to the last saved position"/>
      <Step>
         <Command
             Command="49"
             CmdAxes="1"
             CmdPrm1="LastPosition"/>
      </Step>
      <Transition>
         <Jump
             Type="NEXT"/>
      </Transition>
   </ProgramBlock>
   <ProgramBlock
       Type="STEP">
      <Comment
          Comment="This step runs every loop while the controller is powered up&#13;&#10;&#13;&#10;Save the last measured position to a retained variable"/>
      <Step>
         <Expression
             Src="LastPosition := _Axis[0].ActPos;"/>
      </Step>
      <Transition>
         <Jump
             Type="JUMP"
             Next="Repeat"/>
      </Transition>
   </ProgramBlock>
</UserProgram>
</ExportedUserProgram>
