{
    "name"  : "查看端口硬件供电状态",
    "precondition" : ["name", "type"],
    "problems" : {
        "pd_overload" : {
            "desc"      : "【问题】PD过载",
            "advice"    : "【建议】确认PD的瞬时功率是否会超过对应标准等级，有条件的话，更换其他PD试试"
        },
        "pd_overflow" : {
            "desc"      : "【问题】PD过流",
            "advice"    : "【建议】确认PD的脉冲电流是否会超过对应标准等级，有条件的话，更换其他PD试试"
        },
        "other" :{
            "desc"      : "【问题】参考附录说明",
            "advice"    : "【建议】研发支持"
        }
    }
}
---------------------------code-------------------------------
type = precondition('type')
if type != 'copper':
    add_reason('非电口类型的端口不需要进行该项诊断')
    return 'skip'
end

cli('run-system-shell')

res =cli('at', '@')

model = get_device_model()
print model
load_cmd = 'load poepd_ssa'
res = cli(load_cmd, '@')
if res.search(/Server poepd_ssa not published/i) != -1 || model.search(/s2910-24gt4sfp-up-e/i) != -1:
    load_cmd = 'load ssa_poe'
    cli(load_cmd, '@')
end

cli('ut debug chip 1', '@')

#获取端口号
reg = /(?:\d+\/)+(\d+)/
intf_name = precondition('name')
tmp = intf_name.match(reg)
port_num = tmp[1]

cmd = 'ut get_port_status ' + port_num
res = cli(cmd, '@')
reg = /pdchip_get_port_status.*status\s*=\s(\d*)/i
tmp = res.match(reg)
is_success = true
if tmp != null :
    status = tmp[1]
    status = parse_int(status)
    if status == 31 :
        is_success = false
        add_problem('pd_overload')
    end
    if status == 52 :
        is_success = false
        add_problem('pd_overflow')
    end
    if status != 31 && status != 52 && status != 0 && status != 1:
        is_success = false
        add_problem('other')
    end
end

cli('quit')
cli('cat mp/proxy/defout/ssa_process')

cli('at', '@')
cli(load_cmd, '@')
cli('ut debug chip 0', '@')
cli('quit')
cli('exit')

if is_success == false :
    return 'warn'
end
return 'success'