--- Auto generated by 'aubo_scope' v0.32.0-alpha.98 2025-04-01 15:29:02
--- DO NOT MODIFY IT!
local app = {}
local aubo = require('aubo')
local sched = sched or aubo.sched
local math = aubo.math or math
local realtime = aubo.realtime or realtime

local sleep = sched.sleep
local thread = sched.thread
local sync = sched.sync
local run = sched.run
local kill = sched.kill
local halt = sched.halt

app.PRIORITY = 1000 -- set the app priority, which determines app execution order
app.VERSION = "0.1"
app.VENDOR = "Aubo Robotics"

function p_Untitled_9()
    local _ENV = sched.select_robot(1)
    setCollisionStopType(1)
    setCollisionLevel(6)
    setFreedriveDamp({0.5,0.5,0.5,0.5,0.5,0.5})
    setHomePosition({0,-0.2617993877991494,1.74532925199433,0.4363323129985824,1.570796326794897,0}    )
    modbusDeleteAllSignals()
    setDigitalInputActionDefault()
    setDigitalOutputRunstateDefault()
    setPayload(0, {0,0,0}, {0,0,0}, {0,0,0,0,0,0,0,0,0})
    setTcpOffset({0,0,0,0,0,0})
    setToolVoltageOutputDomain(0)
    setToolIoInput(0, true)
    setToolIoInput(1, true)
    setToolIoInput(2, true)
    setToolIoInput(3, true)
    u5faau73af_0 = nil
    now_count = nil
    delta_count = nil
    uwind_count = nil
    start_count = nil
    enc_type = nil
    Base= {0,0,0,0,0,0}
    Tool= {0,0,0,0,0,0}
    setLabel(1, "初始变量")
    
    setLabel(2, "机器人编程")
    sched.sync_program_point()
    if (hasEncoderSensor()) then
        setLabel(3, "如果 hasEncoderSensor()")
        
        
        
        
        setLabel(8, "enc_type:=getEncDecoderType()")
        enc_type = getEncDecoderType()
        
        setLabel(9, "start_count:=getEncTickCount()")
        start_count = getEncTickCount()
        
        setLabel(10, "循环_0 ")
        u5faau73af_0 = 1
        while true do
            setLabel(11, "now_count:=getEncTickCount()")
            now_count = getEncTickCount()
            
            setLabel(12, "delta_count:=start_count - now_count")
            delta_count = start_count - now_count
            
            setLabel(13, "uwind_count:=unwindEncDeltaTickCount(delta_count)")
            uwind_count = unwindEncDeltaTickCount(delta_count)
            :: end_of_u5faau73af_0:: 
            u5faau73af_0 = u5faau73af_0 + 1
            sched.cancel_point()
        end
        
    else
        setLabel(14, "否则")
        setLabel(15, "弹窗 警告：没有配置编码器")
        sched.sync_program_point()
        clearNamedVariable("_popup_continue_or_stop")
        do
            local _popup_t = getControlSystemTime()
            popup(TraceLevel.WARNING, "Warning", "没有配置编码器", 1)
            while not variableUpdated("_popup_continue_or_stop", _popup_t) do sync() end
            if not getBool("_popup_continue_or_stop", true) then halt() end
        end
        
        setLabel(16, "终止")
        halt()
    end
end

function app:start(api)
  --
  self.api = api
  print("start---")
  p_Untitled_9()
end

function app:robot_error_handler(name, err)
  --
  print("An error hanppen to robot "..name)
end

-- return our app object
return app


