-- Copyright (c) 2024 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--          http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.
local mdb = require 'mc.mdb'
local class = require 'mc.class_mgnt'
local privilege = require 'mc.privilege'

local chassis_fru_ctrl_class_types = require 'class.types.ChassisFruCtrl'
local fru_ctrl_class_types = require 'class.types.FruCtrl'
local record_fault_class_types = require 'class.types.RecordFault'
local pg_signal_class_types = require 'class.types.PGSignal'
local power_button_class_types = require 'class.types.PowerButton'
local ac_cycle_class_types = require 'class.types.ACCycle'
local nmi_class_types = require 'class.types.Nmi'
local force_reset_class_types = require 'class.types.ForceReset'
local button_evt_class_types = require 'class.types.ButtonEvt'
local sys_reset_class_types = require 'class.types.SysReset'
local therm_trip_class_types = require 'class.types.ThermTrip'
local system_lock_down_class_types = require 'class.types.SystemLockDown'
local power_action_class_types = require 'class.types.PowerAction'
local chassis_fru_ctrl_intf_types = require 'fructrl.json_types.ChassisFruCtrl'
local chassis_power_on_lock_intf_types = require 'fructrl.json_types.ChassisPowerOnLock'
local properties_intf_types = require 'fructrl.json_types.Properties'
local systems_power_on_lock_intf_types = require 'fructrl.json_types.SystemsPowerOnLock'
local delayed_power_on_policy_intf_types = require 'fructrl.json_types.DelayedPowerOnPolicy'
local systems_fru_ctrl_intf_types = require 'fructrl.json_types.SystemsFruCtrl'
local manufacture_intf_types = require 'fructrl.json_types.Manufacture'
local system_lock_down_intf_types = require 'fructrl.json_types.SystemLockDown'
local power_action_intf_types = require 'fructrl.json_types.PowerAction'
local multihost_intf_types = require 'fructrl.json_types.Multihost'
local fru_ctrl_capabilities_intf_types = require 'fructrl.json_types.FruCtrlCapabilities'

local ChassisFruCtrl = {
    ['table_name'] = 't_chassis_fructrl_tb',
    ['prop_configs'] = {
        ['Id'] = {['primaryKey'] = true, ['baseType'] = 'U8', ['validator'] = chassis_fru_ctrl_class_types.Id},
        ['PowerGDState'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联整机PG寄存器，表征整机上下电状态',
            ['validator'] = chassis_fru_ctrl_class_types.PowerGDState
        },
        ['StaggeredPowerOnInterval'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 60,
            ['description'] = '错峰上电时间间隔，单位s',
            ['validator'] = chassis_fru_ctrl_class_types.StaggeredPowerOnInterval
        },
        ['PowerCycleInterval'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 10,
            ['description'] = '下电再上电时间间隔，单位s',
            ['validator'] = chassis_fru_ctrl_class_types.PowerCycleInterval
        },
        ['PowerCycleType'] = {
            ['usage'] = {'ResetPer'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['description'] = '0: 没有进行中的PowerCycle操作; 1: PowerCycle; 2: ForcePowerCycle;',
            ['validator'] = chassis_fru_ctrl_class_types.PowerCycleType
        },
        ['PowerCycleState'] = {
            ['usage'] = {'ResetPer'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['description'] = '0: 没有进行中的PowerCycle操作; 1: 下电中; 2: 上电中；',
            ['validator'] = chassis_fru_ctrl_class_types.PowerCycleState
        }
    },
    ['default_props'] = {
        ['Id'] = chassis_fru_ctrl_class_types.Id.default[1],
        ['PowerGDState'] = chassis_fru_ctrl_class_types.PowerGDState.default[1],
        ['StaggeredPowerOnInterval'] = 60,
        ['PowerCycleInterval'] = 10,
        ['PowerCycleType'] = 0,
        ['PowerCycleState'] = 0
    },
    ['mdb_prop_configs'] = {
        ['bmc.kepler.Chassis.FruCtrl'] = {
            ['PowerState'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['enum'] = {'ON', 'OFF'},
                ['description'] = '整刀片上下电状态',
                ['usage'] = {'CSR', 'ResetPer'},
                ['validator'] = chassis_fru_ctrl_intf_types.PowerState
            },
            ['PowerOnStrategy'] = {
                ['baseType'] = 'String',
                ['enum'] = {'AlwaysPowerOff', 'AlwaysPowerOn', 'LastState', 'AlwaysPowerOnUnmodifiable'},
                ['readOnly'] = false,
                ['description'] = '整刀片通电开机策略',
                ['usage'] = {'CSR', 'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'PowerMgmt'}},
                ['default'] = 'AlwaysPowerOn',
                ['validator'] = chassis_fru_ctrl_intf_types.PowerOnStrategy
            },
            ['PreviousPowerState'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['enum'] = {'ON', 'OFF'},
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '记录启动之前的整机上下电状态，用于通电开机策略为LastState时查询上下电操作',
                ['usage'] = {'PoweroffPer'},
                ['default'] = 'ON',
                ['validator'] = chassis_fru_ctrl_intf_types.PreviousPowerState
            }
        },
        ['bmc.kepler.Chassis.PowerOnLock'] = {},
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象类名',
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象名',
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['description'] = '对象标志符',
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_method_configs'] = {
        ['bmc.kepler.Chassis.FruCtrl'] = {
            ['PowerCtrl'] = {
                ['description'] = '上下电操作',
                ['req'] = {
                    {
                        ['baseType'] = 'String',
                        ['enum'] = {
                            'On', 'ForceOff', 'GracefulShutdown', 'ForceRestart', 'Nmi', 'PowerCycle',
                            'ForcePowerCycle', 'ACCycle'
                        },
                        ['description'] = '操作类型',
                        ['param'] = 'OperateType'
                    }, {
                        ['baseType'] = 'String',
                        ['enum'] = {
                            'Unknown', 'ChassisControlCommand', 'ResetViaPushButton', 'PowerUpViaPushButton',
                            'WatchdogExpiration', 'Oem', 'ACRestoreAlwaysPowerUp', 'ACRestoreKeepPreviousState',
                            'ResetViaPEF', 'PowerCycleViaPEF', 'SoftReset', 'PowerupViaRTC'
                        },
                        ['description'] = '重启原因',
                        ['param'] = 'RestartCause'
                    }
                },
                ['rsp'] = {{['baseType'] = 'S32', ['description'] = '命令执行结果', ['param'] = 'CmdResult'}},
                ['privilege'] = {'PowerMgmt'}
            },
            ['SetPowerOnStrategyExceptions'] = {
                ['description'] = '配置例外通电开机策略',
                ['req'] = {
                    {['baseType'] = 'String', ['description'] = '调用原因描述', ['param'] = 'Reason'}, {
                        ['baseType'] = 'String',
                        ['description'] = '例外通电开机策略 Yes: 下次重启执行通电开机 No:  下次重启不执行通电开机策略 None:下次重启清除额外的通电开机策略',
                        ['param'] = 'Execute'
                    }, {
                        ['baseType'] = 'String',
                        ['description'] = '生效周期 Once:单次  Continuous:永久',
                        ['param'] = 'EffectivePeriod'
                    }, {
                        ['baseType'] = 'U8',
                        ['description'] = '生效优先级 1-10  1:redfish(外部)  2:内部调用',
                        ['param'] = 'Priority'
                    }
                },
                ['rsp'] = {{['baseType'] = 'U32', ['description'] = '命令执行结果', ['param'] = 'CmdResult'}},
                ['privilege'] = {'PowerMgmt'}
            }
        },
        ['bmc.kepler.Chassis.PowerOnLock'] = {
            ['SetPowerOnLock'] = {
                ['description'] = '整机上电锁',
                ['req'] = {
                    {
                        ['baseType'] = 'Boolean',
                        ['description'] = '是否上电锁定:true:锁定 false:解锁',
                        ['param'] = 'PwrOnLocked'
                    },
                    {
                        ['baseType'] = 'U32',
                        ['description'] = '有效的超时时间(单位1s)范围10~3600s',
                        ['param'] = 'Timeout'
                    }, {['baseType'] = 'String', ['description'] = '模块App名', ['param'] = 'AppName'},
                    {['baseType'] = 'String', ['description'] = '增加上电锁的原因描述', ['param'] = 'Reason'}
                },
                ['rsp'] = {{['baseType'] = 'U8', ['description'] = '函数执行结果', ['param'] = 'CmdResult'}},
                ['privilege'] = {'PowerMgmt'}
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/kepler/Chassis/:ChassisId/FruCtrl'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.kepler.Chassis.FruCtrl'] = {
            ['property_defaults'] = {
                ['PowerState'] = chassis_fru_ctrl_intf_types.PowerState.default[1],
                ['PowerOnStrategy'] = 'AlwaysPowerOn',
                ['PreviousPowerState'] = 'ON'
            },
            ['privileges'] = {
                ['path'] = privilege.ReadOnly,
                ['props'] = {['PowerOnStrategy'] = {['read'] = privilege.ReadOnly, ['write'] = privilege.PowerMgmt}},
                ['methods'] = {
                    ['PowerCtrl'] = privilege.PowerMgmt,
                    ['SetPowerOnStrategyExceptions'] = privilege.PowerMgmt
                }
            },
            ['interface_types'] = chassis_fru_ctrl_intf_types
        },
        ['bmc.kepler.Chassis.PowerOnLock'] = {
            ['property_defaults'] = {},
            ['privileges'] = {['path'] = privilege.ReadOnly, ['methods'] = {['SetPowerOnLock'] = privilege.PowerMgmt}},
            ['interface_types'] = chassis_power_on_lock_intf_types
        },
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = properties_intf_types
        }
    })
}

local FruCtrl = {
    ['table_name'] = 't_fructrl_tb',
    ['prop_configs'] = {
        ['Id'] = {
            ['primaryKey'] = true,
            ['baseType'] = 'U8',
            ['usage'] = {'CSR'},
            ['validator'] = fru_ctrl_class_types.Id
        },
        ['FruID'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = fru_ctrl_class_types.FruID
        },
        ['PwrCycleDelaySeconds'] = {
            ['usage'] = {'PoweroffPer'},
            ['baseType'] = 'U32',
            ['default'] = 10,
            ['validator'] = fru_ctrl_class_types.PwrCycleDelaySeconds
        },
        ['PwrStateBeforeACLost'] = {
            ['usage'] = {'PoweroffPer'},
            ['baseType'] = 'Boolean',
            ['validator'] = fru_ctrl_class_types.PwrStateBeforeACLost
        },
        ['BmcResetFlag'] = {
            ['usage'] = {'ResetPer'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = fru_ctrl_class_types.BmcResetFlag
        },
        ['PwrRestoreRecord'] = {
            ['usage'] = {'PoweroffPer'},
            ['baseType'] = 'String[]',
            ['validator'] = fru_ctrl_class_types.PwrRestoreRecord
        },
        ['PwrOnLockedRecord'] = {
            ['usage'] = {'TemporaryPer'},
            ['baseType'] = 'Array',
            ['items'] = {
                ['usage'] = {'TemporaryPer'},
                ['baseType'] = 'Struct',
                ['$ref'] = 'types.json#/defs/PwrOnLockedRecord'
            },
            ['validator'] = fru_ctrl_class_types.PwrOnLockedRecord
        },
        ['PowerOnTimeoutSeconds'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U32',
            ['default'] = 10,
            ['validator'] = fru_ctrl_class_types.PowerOnTimeoutSeconds
        },
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = fru_ctrl_class_types.IsValid
        },
        ['ACPISystemPowerState'] = {
            ['usage'] = {'ResetPer'},
            ['baseType'] = 'String',
            ['default'] = '',
            ['validator'] = fru_ctrl_class_types.ACPISystemPowerState
        },
        ['ACPIDevicePowerState'] = {
            ['usage'] = {'ResetPer'},
            ['baseType'] = 'String',
            ['default'] = '',
            ['validator'] = fru_ctrl_class_types.ACPIDevicePowerState
        }
    },
    ['default_props'] = {
        ['Id'] = fru_ctrl_class_types.Id.default[1],
        ['FruID'] = 0,
        ['PwrCycleDelaySeconds'] = 10,
        ['PwrStateBeforeACLost'] = fru_ctrl_class_types.PwrStateBeforeACLost.default[1],
        ['BmcResetFlag'] = 0,
        ['PwrRestoreRecord'] = fru_ctrl_class_types.PwrRestoreRecord.default[1],
        ['PwrOnLockedRecord'] = fru_ctrl_class_types.PwrOnLockedRecord.default[1],
        ['PowerOnTimeoutSeconds'] = 10,
        ['IsValid'] = true,
        ['ACPISystemPowerState'] = '',
        ['ACPIDevicePowerState'] = ''
    },
    ['mdb_prop_configs'] = {
        ['bmc.kepler.Systems.PowerOnLock'] = {
            ['PwrOnLocked'] = {
                ['baseType'] = 'Boolean',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '是否满足上电条件',
                ['usage'] = {'CSR', 'TemporaryPer'},
                ['validator'] = systems_power_on_lock_intf_types.PwrOnLocked
            },
            ['Reasons'] = {
                ['baseType'] = 'String[]',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '不允许上电的原因，KVM呈现，记录所有原因',
                ['usage'] = {'CSR', 'TemporaryPer'},
                ['validator'] = systems_power_on_lock_intf_types.Reasons
            }
        },
        ['bmc.kepler.Systems.DelayedPowerOnPolicy'] = {
            ['Mode'] = {
                ['baseType'] = 'String',
                ['readOnly'] = false,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '延迟上电策略',
                ['usage'] = {'CSR', 'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'PowerMgmt'}},
                ['default'] = 'DefaultDelay',
                ['validator'] = delayed_power_on_policy_intf_types.Mode
            },
            ['Seconds'] = {
                ['baseType'] = 'Double',
                ['readOnly'] = false,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '延迟上电时间',
                ['usage'] = {'CSR', 'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'PowerMgmt'}},
                ['validator'] = delayed_power_on_policy_intf_types.Seconds
            }
        },
        ['bmc.kepler.Systems.FruCtrl'] = {
            ['PowerState'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '反映实时电源状态',
                ['usage'] = {'CSR', 'ResetPer'},
                ['validator'] = systems_fru_ctrl_intf_types.PowerState
            },
            ['SysResetDetected'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['description'] = '系统复位信号',
                ['usage'] = {'CSR'},
                ['validator'] = systems_fru_ctrl_intf_types.SysResetDetected
            },
            ['FruType'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '上下电的Fru类型信息：host、NP加速卡、交换mesh卡',
                ['usage'] = {'CSR'},
                ['validator'] = systems_fru_ctrl_intf_types.FruType
            },
            ['CurrentRestartCause'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '用于记录业务系统本次复位原因',
                ['usage'] = {'CSR', 'ResetPer'},
                ['validator'] = systems_fru_ctrl_intf_types.CurrentRestartCause
            },
            ['CurrentRestartCauseId'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '与CurrentRestartCause对应id',
                ['usage'] = {'CSR', 'ResetPer'},
                ['validator'] = systems_fru_ctrl_intf_types.CurrentRestartCauseId
            },
            ['CurrentRestartType'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['description'] = '当前系统复位类型，取值0:Initiated by power up,1:Initiated by hard reset,' ..
                    '2:Initiated by warm reset',
                ['default'] = 255,
                ['validator'] = systems_fru_ctrl_intf_types.CurrentRestartType
            },
            ['RestartCauseRecords'] = {
                ['baseType'] = 'String[]',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '用于记录业务系统历史复位原因，最多纪录10次',
                ['usage'] = {'CSR', 'ResetPer'},
                ['validator'] = systems_fru_ctrl_intf_types.RestartCauseRecords
            },
            ['RestartCount'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '用于纪记录业务系统复位次数',
                ['usage'] = {'CSR'},
                ['validator'] = systems_fru_ctrl_intf_types.RestartCount
            },
            ['PowerOnStrategy'] = {
                ['baseType'] = 'String',
                ['readOnly'] = false,
                ['description'] = '通电开机策略',
                ['usage'] = {'CSR', 'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'PowerMgmt'}},
                ['default'] = 'AlwaysPowerOn',
                ['validator'] = systems_fru_ctrl_intf_types.PowerOnStrategy
            },
            ['PowerOnStrategyExceptions'] = {
                ['baseType'] = 'U32',
                ['readOnly'] = false,
                ['description'] = '殊通电开机策略，1为不执行此次通电开机策略，0为清除策略',
                ['usage'] = {'CSR', 'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'PowerMgmt'}},
                ['validator'] = systems_fru_ctrl_intf_types.PowerOnStrategyExceptions
            },
            ['PanelPowerButtonEnabled'] = {
                ['baseType'] = 'Boolean',
                ['readOnly'] = false,
                ['description'] = '面板按钮使能true，不屏蔽为false',
                ['usage'] = {'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'PowerMgmt'}},
                ['default'] = true,
                ['validator'] = systems_fru_ctrl_intf_types.PanelPowerButtonEnabled
            },
            ['GracefulShutdownTimeoutEnabled'] = {
                ['baseType'] = 'U32',
                ['readOnly'] = false,
                ['description'] = '安全下电时限使能开关',
                ['usage'] = {'CSR', 'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'PowerMgmt'}},
                ['validator'] = systems_fru_ctrl_intf_types.GracefulShutdownTimeoutEnabled
            },
            ['GracefulShutdownTimeoutSeconds'] = {
                ['baseType'] = 'U32',
                ['readOnly'] = false,
                ['description'] = '安全下电超时时间，超时后执行强制下电',
                ['usage'] = {'CSR', 'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'PowerMgmt'}},
                ['default'] = 600,
                ['validator'] = systems_fru_ctrl_intf_types.GracefulShutdownTimeoutSeconds
            },
            ['GracefulShutdownDefaultTimeoutSeconds'] = {
                ['baseType'] = 'U32',
                ['readOnly'] = true,
                ['description'] = '安全下电默认超时时间，关联CSR',
                ['usage'] = {'CSR'},
                ['default'] = 600,
                ['validator'] = systems_fru_ctrl_intf_types.GracefulShutdownDefaultTimeoutSeconds
            },
            ['GracefulShutdownMaxTimeoutSeconds'] = {
                ['baseType'] = 'U32',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'const'},
                ['description'] = '安全下电超时时间上限，关联CSR',
                ['usage'] = {'CSR'},
                ['default'] = 6000,
                ['validator'] = systems_fru_ctrl_intf_types.GracefulShutdownMaxTimeoutSeconds
            },
            ['GracefulShutdownMinTimeoutSeconds'] = {
                ['baseType'] = 'U32',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'const'},
                ['description'] = '安全下电超时时间上限，关联CSR',
                ['usage'] = {'CSR'},
                ['default'] = 10,
                ['validator'] = systems_fru_ctrl_intf_types.GracefulShutdownMinTimeoutSeconds
            },
            ['HotswapState'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '上下电流程中内部状态机流转产生，需要通知到事件',
                ['usage'] = {'CSR'},
                ['validator'] = systems_fru_ctrl_intf_types.HotswapState
            },
            ['LastPowerEvent'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '仅对上电做事件记录复位持久化',
                ['usage'] = {'ResetPer'},
                ['validator'] = systems_fru_ctrl_intf_types.LastPowerEvent
            },
            ['PowerCtrlFault'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '判断上一次上电是否上电成功，或下电命令是否下电成功复位持久化',
                ['usage'] = {'ResetPer'},
                ['validator'] = systems_fru_ctrl_intf_types.PowerCtrlFault
            },
            ['PowerCycleType'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '0: 无power cycle任务;1: 有power cycle任务;2: 有force power cycle任务',
                ['usage'] = {'PoweroffPer'},
                ['validator'] = systems_fru_ctrl_intf_types.PowerCycleType
            },
            ['PreviousPowerState'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '表示上次通电状态 On: 上电状态;Off: 下电状态',
                ['usage'] = {'PoweroffPer'},
                ['validator'] = systems_fru_ctrl_intf_types.PreviousPowerState
            }
        },
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象类名',
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象名',
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['description'] = '对象标志符',
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_method_configs'] = {
        ['bmc.kepler.Systems.PowerOnLock'] = {
            ['SetPowerOnLock'] = {
                ['description'] = '系统上电锁',
                ['req'] = {
                    {
                        ['baseType'] = 'Boolean',
                        ['description'] = '是否上电锁定:true:锁定 false:解锁',
                        ['param'] = 'PwrOnLocked'
                    },
                    {
                        ['baseType'] = 'U32',
                        ['description'] = '有效的超时时间(单位1s)范围10~3600s',
                        ['param'] = 'Timeout'
                    }, {['baseType'] = 'String', ['description'] = '模块App名', ['param'] = 'AppName'},
                    {['baseType'] = 'String', ['description'] = '增加上电锁的原因描述', ['param'] = 'Reason'}
                },
                ['rsp'] = {{['baseType'] = 'U8', ['description'] = '函数执行结果', ['param'] = 'CmdResult'}},
                ['privilege'] = {'PowerMgmt'}
            }
        },
        ['bmc.kepler.Systems.FruCtrl'] = {
            ['PowerCtrl'] = {
                ['description'] = '上下电操作',
                ['req'] = {
                    {['baseType'] = 'String', ['description'] = '操作类型', ['param'] = 'PowerCtrlType'},
                    {['baseType'] = 'String', ['description'] = '重启原因', ['param'] = 'RestartCause'}
                },
                ['rsp'] = {{['baseType'] = 'S32', ['description'] = '命令执行结果', ['param'] = 'CmdResult'}},
                ['privilege'] = {'PowerMgmt'}
            },
            ['SetPowerOnStrategyExceptions'] = {
                ['description'] = '配置例外通电开机策略',
                ['req'] = {
                    {['baseType'] = 'String', ['description'] = '调用原因描述', ['param'] = 'Reason'}, {
                        ['baseType'] = 'String',
                        ['description'] = '例外通电开机策略 Yes: 下次重启执行通电开机 No:  下次重启不执行通电开机策略 None:下次重启清除额外的通电开机策略',
                        ['param'] = 'Execute'
                    }, {
                        ['baseType'] = 'String',
                        ['description'] = '生效周期 Once:单次  Continuous:永久',
                        ['param'] = 'EffectivePeriod'
                    }, {
                        ['baseType'] = 'U8',
                        ['description'] = '生效优先级 1-10  1:redfish(外部)  2:内部调用',
                        ['param'] = 'Priority'
                    }
                },
                ['rsp'] = {{['baseType'] = 'U32', ['description'] = '命令执行结果', ['param'] = 'CmdResult'}},
                ['privilege'] = {'PowerMgmt'}
            },
            ['SetACLost'] = {
                ['description'] = '通知fructrl组件发生整框掉电',
                ['req'] = {
                    {
                        ['baseType'] = 'U8',
                        ['enum'] = {1},
                        ['description'] = '整框掉电类型, 1:powerdrop引起的AClost',
                        ['param'] = 'Type'
                    }
                },
                ['rsp'] = {{['baseType'] = 'U32', ['description'] = '命令执行结果', ['param'] = 'CmdResult'}},
                ['privilege'] = {'PowerMgmt'}
            },
            ['FruPowerCtrl'] = {
                ['description'] = '根据FruID进行上下电操作',
                ['req'] = {
                    {['baseType'] = 'String', ['description'] = '操作类型', ['param'] = 'PowerCtrlType'},
                    {['baseType'] = 'String', ['description'] = '重启原因', ['param'] = 'RestartCause'},
                    {['baseType'] = 'U8', ['description'] = 'FruID类型', ['param'] = 'FruID'}
                },
                ['rsp'] = {{['baseType'] = 'S32', ['description'] = '命令执行结果', ['param'] = 'CmdResult'}},
                ['privilege'] = {'PowerMgmt'}
            }
        }
    },
    ['mdb_signal_configs'] = {
        ['bmc.kepler.Systems.FruCtrl'] = {
            ['BeforePowerOnSignal'] = {
                {
                    ['baseType'] = 'U8',
                    ['default'] = 3,
                    ['description'] = '上电前广播，通知其他App',
                    ['param'] = 'Timeout'
                }
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/kepler/Systems/:SystemId/FruCtrl/:Id'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.kepler.Systems.PowerOnLock'] = {
            ['property_defaults'] = {
                ['PwrOnLocked'] = systems_power_on_lock_intf_types.PwrOnLocked.default[1],
                ['Reasons'] = systems_power_on_lock_intf_types.Reasons.default[1]
            },
            ['privileges'] = {['path'] = privilege.ReadOnly, ['methods'] = {['SetPowerOnLock'] = privilege.PowerMgmt}},
            ['interface_types'] = systems_power_on_lock_intf_types
        },
        ['bmc.kepler.Systems.DelayedPowerOnPolicy'] = {
            ['property_defaults'] = {
                ['Mode'] = 'DefaultDelay',
                ['Seconds'] = delayed_power_on_policy_intf_types.Seconds.default[1]
            },
            ['privileges'] = {
                ['path'] = privilege.ReadOnly,
                ['props'] = {
                    ['Mode'] = {['read'] = privilege.ReadOnly, ['write'] = privilege.PowerMgmt},
                    ['Seconds'] = {['read'] = privilege.ReadOnly, ['write'] = privilege.PowerMgmt}
                }
            },
            ['interface_types'] = delayed_power_on_policy_intf_types
        },
        ['bmc.kepler.Systems.FruCtrl'] = {
            ['property_defaults'] = {
                ['PowerState'] = systems_fru_ctrl_intf_types.PowerState.default[1],
                ['SysResetDetected'] = systems_fru_ctrl_intf_types.SysResetDetected.default[1],
                ['FruType'] = systems_fru_ctrl_intf_types.FruType.default[1],
                ['CurrentRestartCause'] = systems_fru_ctrl_intf_types.CurrentRestartCause.default[1],
                ['CurrentRestartCauseId'] = systems_fru_ctrl_intf_types.CurrentRestartCauseId.default[1],
                ['CurrentRestartType'] = 255,
                ['RestartCauseRecords'] = systems_fru_ctrl_intf_types.RestartCauseRecords.default[1],
                ['RestartCount'] = systems_fru_ctrl_intf_types.RestartCount.default[1],
                ['PowerOnStrategy'] = 'AlwaysPowerOn',
                ['PowerOnStrategyExceptions'] = systems_fru_ctrl_intf_types.PowerOnStrategyExceptions.default[1],
                ['PanelPowerButtonEnabled'] = true,
                ['GracefulShutdownTimeoutEnabled'] = systems_fru_ctrl_intf_types.GracefulShutdownTimeoutEnabled.default[1],
                ['GracefulShutdownTimeoutSeconds'] = 600,
                ['GracefulShutdownDefaultTimeoutSeconds'] = 600,
                ['GracefulShutdownMaxTimeoutSeconds'] = 6000,
                ['GracefulShutdownMinTimeoutSeconds'] = 10,
                ['HotswapState'] = systems_fru_ctrl_intf_types.HotswapState.default[1],
                ['LastPowerEvent'] = systems_fru_ctrl_intf_types.LastPowerEvent.default[1],
                ['PowerCtrlFault'] = systems_fru_ctrl_intf_types.PowerCtrlFault.default[1],
                ['PowerCycleType'] = systems_fru_ctrl_intf_types.PowerCycleType.default[1],
                ['PreviousPowerState'] = systems_fru_ctrl_intf_types.PreviousPowerState.default[1]
            },
            ['privileges'] = {
                ['path'] = privilege.ReadOnly,
                ['props'] = {
                    ['PowerOnStrategy'] = {['read'] = privilege.ReadOnly, ['write'] = privilege.PowerMgmt},
                    ['PowerOnStrategyExceptions'] = {['read'] = privilege.ReadOnly, ['write'] = privilege.PowerMgmt},
                    ['PanelPowerButtonEnabled'] = {['read'] = privilege.ReadOnly, ['write'] = privilege.PowerMgmt},
                    ['GracefulShutdownTimeoutEnabled'] = {
                        ['read'] = privilege.ReadOnly,
                        ['write'] = privilege.PowerMgmt
                    },
                    ['GracefulShutdownTimeoutSeconds'] = {
                        ['read'] = privilege.ReadOnly,
                        ['write'] = privilege.PowerMgmt
                    }
                },
                ['methods'] = {
                    ['PowerCtrl'] = privilege.PowerMgmt,
                    ['SetPowerOnStrategyExceptions'] = privilege.PowerMgmt,
                    ['SetACLost'] = privilege.PowerMgmt,
                    ['FruPowerCtrl'] = privilege.PowerMgmt
                }
            },
            ['interface_types'] = systems_fru_ctrl_intf_types
        },
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = properties_intf_types
        }
    })
}

local RecordFault = {
    ['prop_configs'] = {
        ['FruID'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = record_fault_class_types.FruID
        },
        ['IssueRecoredAcc'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['validator'] = record_fault_class_types.IssueRecoredAcc
        },
        ['LatchRecoredAcc'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['validator'] = record_fault_class_types.LatchRecoredAcc
        },
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = record_fault_class_types.IsValid
        }
    },
    ['default_props'] = {
        ['FruID'] = 0,
        ['IssueRecoredAcc'] = record_fault_class_types.IssueRecoredAcc.default[1],
        ['LatchRecoredAcc'] = record_fault_class_types.LatchRecoredAcc.default[1],
        ['IsValid'] = true
    }
}

local PGSignal = {
    ['prop_configs'] = {
        ['FruID'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = pg_signal_class_types.FruID
        },
        ['PowerGDState'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['validator'] = pg_signal_class_types.PowerGDState
        },
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = pg_signal_class_types.IsValid
        }
    },
    ['default_props'] = {
        ['FruID'] = 0,
        ['PowerGDState'] = pg_signal_class_types.PowerGDState.default[1],
        ['IsValid'] = true
    }
}

local PowerButton = {
    ['prop_configs'] = {
        ['FruID'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = power_button_class_types.FruID
        },
        ['ShortPushButton'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['validator'] = power_button_class_types.ShortPushButton
        },
        ['LongPushButton'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['validator'] = power_button_class_types.LongPushButton
        },
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = power_button_class_types.IsValid
        }
    },
    ['default_props'] = {
        ['FruID'] = 0,
        ['ShortPushButton'] = power_button_class_types.ShortPushButton.default[1],
        ['LongPushButton'] = power_button_class_types.LongPushButton.default[1],
        ['IsValid'] = true
    }
}

local ACCycle = {
    ['prop_configs'] = {['AC'] = {['usage'] = {'CSR'}, ['baseType'] = 'U8', ['validator'] = ac_cycle_class_types.AC}},
    ['default_props'] = {['AC'] = ac_cycle_class_types.AC.default[1]}
}

local Nmi = {
    ['prop_configs'] = {
        ['FruID'] = {['usage'] = {'CSR'}, ['baseType'] = 'U8', ['default'] = 0, ['validator'] = nmi_class_types.FruID},
        ['NmiInt'] = {['usage'] = {'CSR'}, ['baseType'] = 'U8', ['validator'] = nmi_class_types.NmiInt},
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = nmi_class_types.IsValid
        }
    },
    ['default_props'] = {['FruID'] = 0, ['NmiInt'] = nmi_class_types.NmiInt.default[1], ['IsValid'] = true}
}

local ForceReset = {
    ['prop_configs'] = {
        ['FruID'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = force_reset_class_types.FruID
        },
        ['ForceRst'] = {['usage'] = {'CSR'}, ['baseType'] = 'U8', ['validator'] = force_reset_class_types.ForceRst},
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = force_reset_class_types.IsValid
        }
    },
    ['default_props'] = {['FruID'] = 0, ['ForceRst'] = force_reset_class_types.ForceRst.default[1], ['IsValid'] = true}
}

local ButtonEvt = {
    ['table_name'] = 't_powerbtn_tb',
    ['prop_configs'] = {
        ['Id'] = {
            ['primaryKey'] = true,
            ['baseType'] = 'U8',
            ['usage'] = {'CSR'},
            ['validator'] = button_evt_class_types.Id
        },
        ['PowerBtnLock'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['validator'] = button_evt_class_types.PowerBtnLock
        },
        ['GetPowerBtnEvt'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联Scanner, 用于读取电源按钮屏蔽',
            ['validator'] = button_evt_class_types.GetPowerBtnEvt
        },
        ['SetPowerBtnEvt'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联Accessor, 用于设置电源按钮屏蔽',
            ['validator'] = button_evt_class_types.SetPowerBtnEvt
        },
        ['PowerBtnShield'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联Accessor, 用于设置电源按钮防误触功能',
            ['validator'] = button_evt_class_types.PowerBtnShield
        },
        ['PowerButtonShieldEnabled'] = {
            ['usage'] = {'PoweroffPer'},
            ['baseType'] = 'Boolean',
            ['default'] = false,
            ['validator'] = button_evt_class_types.PowerButtonShieldEnabled
        }
    },
    ['default_props'] = {
        ['Id'] = button_evt_class_types.Id.default[1],
        ['PowerBtnLock'] = button_evt_class_types.PowerBtnLock.default[1],
        ['GetPowerBtnEvt'] = button_evt_class_types.GetPowerBtnEvt.default[1],
        ['SetPowerBtnEvt'] = button_evt_class_types.SetPowerBtnEvt.default[1],
        ['PowerBtnShield'] = button_evt_class_types.PowerBtnShield.default[1],
        ['PowerButtonShieldEnabled'] = false
    }
}

local SysReset = {
    ['prop_configs'] = {
        ['FruID'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = sys_reset_class_types.FruID
        },
        ['GetSysRstDetected'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联Scanner，用于读取',
            ['validator'] = sys_reset_class_types.GetSysRstDetected
        },
        ['SetSysRstDetected'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联Accessor，用于设置',
            ['validator'] = sys_reset_class_types.SetSysRstDetected
        },
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = sys_reset_class_types.IsValid
        }
    },
    ['default_props'] = {
        ['FruID'] = 0,
        ['GetSysRstDetected'] = sys_reset_class_types.GetSysRstDetected.default[1],
        ['SetSysRstDetected'] = sys_reset_class_types.SetSysRstDetected.default[1],
        ['IsValid'] = true
    }
}

local ThermTrip = {
    ['prop_configs'] = {
        ['FruID'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = therm_trip_class_types.FruID
        },
        ['GetThermTrip'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联Scanner，用于读取cpu1',
            ['validator'] = therm_trip_class_types.GetThermTrip
        },
        ['SetThermTrip'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联Accessor，用于设置cpu1',
            ['validator'] = therm_trip_class_types.SetThermTrip
        },
        ['GetThermTrip2'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联Scanner，用于读取cpu2',
            ['validator'] = therm_trip_class_types.GetThermTrip2
        },
        ['SetThermTrip2'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['description'] = '关联Accessor，用于设置cpu2',
            ['validator'] = therm_trip_class_types.SetThermTrip2
        },
        ['Actions'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 1,
            ['description'] = '0-NoAction, 1-PowerOn',
            ['validator'] = therm_trip_class_types.Actions
        },
        ['TimeDelaySeconds'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U32',
            ['default'] = 300,
            ['validator'] = therm_trip_class_types.TimeDelaySeconds
        },
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = therm_trip_class_types.IsValid
        }
    },
    ['default_props'] = {
        ['FruID'] = 0,
        ['GetThermTrip'] = therm_trip_class_types.GetThermTrip.default[1],
        ['SetThermTrip'] = therm_trip_class_types.SetThermTrip.default[1],
        ['GetThermTrip2'] = therm_trip_class_types.GetThermTrip2.default[1],
        ['SetThermTrip2'] = therm_trip_class_types.SetThermTrip2.default[1],
        ['Actions'] = 1,
        ['TimeDelaySeconds'] = 300,
        ['IsValid'] = true
    }
}

local DftPowerButton = {
    ['mdb_prop_configs'] = {
        ['bmc.kepler.Manufacture'] = {
            ['Type'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '装备测试项类型，1人工自检，2需要人工准备前置条件，3拷机测试，4人工检查结果，5人工操作测试，6与装备交互测试',
                ['usage'] = {'CSR'},
                ['validator'] = manufacture_intf_types.Type
            },
            ['Id'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '装备测试项id',
                ['usage'] = {'CSR'},
                ['validator'] = manufacture_intf_types.Id
            },
            ['Slot'] = {
                ['baseType'] = 'U32',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '槽位号',
                ['usage'] = {'CSR'},
                ['validator'] = manufacture_intf_types.Slot
            },
            ['Param'] = {
                ['baseType'] = 'U8[]',
                ['readOnly'] = false,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '测试项传入的参数',
                ['validator'] = manufacture_intf_types.Param
            },
            ['DeviceNum'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '设备id',
                ['usage'] = {'CSR'},
                ['validator'] = manufacture_intf_types.DeviceNum
            },
            ['ItemName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '设备名称',
                ['usage'] = {'CSR'},
                ['validator'] = manufacture_intf_types.ItemName
            },
            ['PrompteReady'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '测试前交互提示',
                ['usage'] = {'CSR'},
                ['validator'] = manufacture_intf_types.PrompteReady
            },
            ['PrompteFinish'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '测试完成交互提示',
                ['usage'] = {'CSR'},
                ['validator'] = manufacture_intf_types.PrompteFinish
            },
            ['ProcessPeriod'] = {
                ['baseType'] = 'U16',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '测试所需时间',
                ['usage'] = {'CSR'},
                ['validator'] = manufacture_intf_types.ProcessPeriod
            },
            ['Status'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '当前测试状态',
                ['enum'] = {'Complete', 'Testing', 'Unstart'},
                ['default'] = 'Unstart',
                ['validator'] = manufacture_intf_types.Status
            }
        },
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象类名',
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象名',
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['description'] = '对象标志符',
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_method_configs'] = {
        ['bmc.kepler.Manufacture'] = {
            ['Start'] = {
                ['req'] = {},
                ['rsp'] = {},
                ['description'] = '开始装备测试项',
                ['privilege'] = {'ConfigureSelf'}
            },
            ['Stop'] = {
                ['req'] = {},
                ['rsp'] = {},
                ['description'] = '停止装备测试项',
                ['privilege'] = {'ConfigureSelf'}
            },
            ['GetResult'] = {
                ['req'] = {},
                ['rsp'] = {
                    {
                        ['baseType'] = 'String',
                        ['enum'] = {'Succeed', 'Failed', 'Non'},
                        ['description'] = '装备测试项状态',
                        ['param'] = 'Status'
                    }, {['baseType'] = 'String', ['description'] = '装备测试项描述', ['param'] = 'Description'}
                },
                ['description'] = '获取装备测试项结果',
                ['privilege'] = {'ConfigureSelf'}
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/kepler/Manufacture/OperateTest/DftPowerButton/:Id'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.kepler.Manufacture'] = {
            ['property_defaults'] = {
                ['Type'] = manufacture_intf_types.Type.default[1],
                ['Id'] = manufacture_intf_types.Id.default[1],
                ['Slot'] = manufacture_intf_types.Slot.default[1],
                ['Param'] = manufacture_intf_types.Param.default[1],
                ['DeviceNum'] = manufacture_intf_types.DeviceNum.default[1],
                ['ItemName'] = manufacture_intf_types.ItemName.default[1],
                ['PrompteReady'] = manufacture_intf_types.PrompteReady.default[1],
                ['PrompteFinish'] = manufacture_intf_types.PrompteFinish.default[1],
                ['ProcessPeriod'] = manufacture_intf_types.ProcessPeriod.default[1],
                ['Status'] = 'Unstart'
            },
            ['privileges'] = {
                ['path'] = privilege.ReadOnly,
                ['methods'] = {
                    ['Start'] = privilege.ConfigureSelf,
                    ['Stop'] = privilege.ConfigureSelf,
                    ['GetResult'] = privilege.ConfigureSelf
                }
            },
            ['interface_types'] = manufacture_intf_types
        },
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = properties_intf_types
        }
    })
}

local SystemLockDown = {
    ['table_name'] = 't_system_lockdown',
    ['prop_configs'] = {
        ['FruID'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = system_lock_down_class_types.FruID
        },
        ['SystemId'] = {
            ['primaryKey'] = true,
            ['baseType'] = 'U8',
            ['usage'] = {'CSR'},
            ['validator'] = system_lock_down_class_types.SystemId
        },
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = system_lock_down_class_types.IsValid
        }
    },
    ['default_props'] = {
        ['FruID'] = 0,
        ['SystemId'] = system_lock_down_class_types.SystemId.default[1],
        ['IsValid'] = true
    },
    ['mdb_prop_configs'] = {
        ['bmc.kepler.Systems.SystemLockDown'] = {
            ['SystemLockDownSupport'] = {
                ['baseType'] = 'String',
                ['readOnly'] = false,
                ['options'] = {['emitsChangedSignal'] = 'true'},
                ['enum'] = {'Supported', 'Unsupported'},
                ['default'] = 'Unsupported',
                ['description'] = '产品是否支持系统锁定功能，通过license控制其状态',
                ['usage'] = {'CSR', 'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'UserMgmt'}},
                ['validator'] = system_lock_down_intf_types.SystemLockDownSupport
            },
            ['SystemLockDownStatus'] = {
                ['baseType'] = 'String',
                ['readOnly'] = false,
                ['options'] = {['emitsChangedSignal'] = 'true'},
                ['enum'] = {'Locked', 'Unlocked'},
                ['default'] = 'Unlocked',
                ['description'] = '系统锁定开关状态',
                ['usage'] = {'CSR', 'PoweroffPer'},
                ['privilege'] = {['read'] = {'ReadOnly'}, ['write'] = {'UserMgmt'}},
                ['validator'] = system_lock_down_intf_types.SystemLockDownStatus
            }
        },
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象类名',
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象名',
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['description'] = '对象标志符',
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/kepler/Systems/:SystemId'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.kepler.Systems.SystemLockDown'] = {
            ['property_defaults'] = {['SystemLockDownSupport'] = 'Unsupported', ['SystemLockDownStatus'] = 'Unlocked'},
            ['privileges'] = {
                ['path'] = privilege.ReadOnly,
                ['props'] = {
                    ['SystemLockDownSupport'] = {['read'] = privilege.ReadOnly, ['write'] = privilege.UserMgmt},
                    ['SystemLockDownStatus'] = {['read'] = privilege.ReadOnly, ['write'] = privilege.UserMgmt}
                }
            },
            ['interface_types'] = system_lock_down_intf_types
        },
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = properties_intf_types
        }
    })
}

local PowerAction = {
    ['prop_configs'] = {
        ['FruID'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'U8',
            ['default'] = 0,
            ['validator'] = power_action_class_types.FruID
        },
        ['IsValid'] = {
            ['usage'] = {'CSR'},
            ['baseType'] = 'Boolean',
            ['default'] = true,
            ['validator'] = power_action_class_types.IsValid
        }
    },
    ['default_props'] = {['FruID'] = 0, ['IsValid'] = true},
    ['mdb_prop_configs'] = {
        ['bmc.kepler.Systems.PowerAction'] = {
            ['PowerOnTimeoutFlag'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = false,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '上电超时状态',
                ['usage'] = {'CSR'},
                ['validator'] = power_action_intf_types.PowerOnTimeoutFlag
            }
        },
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象类名',
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象名',
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['description'] = '对象标志符',
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/kepler/Systems/:SystemId/PowerAction'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.kepler.Systems.PowerAction'] = {
            ['property_defaults'] = {['PowerOnTimeoutFlag'] = power_action_intf_types.PowerOnTimeoutFlag.default[1]},
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = power_action_intf_types
        },
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = properties_intf_types
        }
    })
}

local Multihost = {
    ['mdb_prop_configs'] = {
        ['bmc.kepler.Managers.Multihost'] = {
            ['HostType'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['default'] = 'Singlehost',
                ['enum'] = {'Singlehost', 'Multihost'},
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '表征当前机型的Host类型，默认是Singlehost',
                ['usage'] = {'CSR'},
                ['validator'] = multihost_intf_types.HostType
            },
            ['HostCount'] = {
                ['baseType'] = 'U8',
                ['readOnly'] = true,
                ['default'] = 1,
                ['minimum'] = 1,
                ['maximum'] = 63,
                ['options'] = {['emitsChangedSignal'] = 'false'},
                ['description'] = '表征当前机型的Host个数，默认是1，取值范围：[1 - 63]',
                ['usage'] = {'CSR'},
                ['validator'] = multihost_intf_types.HostCount
            }
        },
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象类名',
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象名',
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['description'] = '对象标志符',
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/kepler/Managers/:ManagerId/Multihost'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.kepler.Managers.Multihost'] = {
            ['property_defaults'] = {['HostType'] = 'Singlehost', ['HostCount'] = 1},
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = multihost_intf_types
        },
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = properties_intf_types
        }
    })
}

local FruCtrlCapabilities = {
    ['mdb_prop_configs'] = {
        ['bmc.kepler.ProductInfo.FruCtrlCapabilities'] = {
            ['GlobalDomainSupported'] = {
                ['baseType'] = 'Boolean',
                ['readOnly'] = true,
                ['description'] = '是否支持对全域进行上下电操作，支持true，不支持false',
                ['usage'] = {'CSR'},
                ['validator'] = fru_ctrl_capabilities_intf_types.GlobalDomainSupported
            },
            ['MultihostSupported'] = {
                ['baseType'] = 'Boolean',
                ['readOnly'] = true,
                ['description'] = '是否支持multihost，支持true，不支持false',
                ['usage'] = {'CSR'},
                ['validator'] = fru_ctrl_capabilities_intf_types.MultihostSupported
            }
        },
        ['bmc.kepler.Object.Properties'] = {
            ['ClassName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象类名',
                ['validator'] = properties_intf_types.ClassName
            },
            ['ObjectName'] = {
                ['baseType'] = 'String',
                ['readOnly'] = true,
                ['description'] = '对象名',
                ['validator'] = properties_intf_types.ObjectName
            },
            ['ObjectIdentifier'] = {
                ['baseType'] = 'Struct',
                ['$ref'] = '#/defs/StructIdentifier',
                ['readOnly'] = true,
                ['description'] = '对象标志符',
                ['validator'] = properties_intf_types.ObjectIdentifier
            }
        }
    },
    ['mdb_classes'] = mdb.get_class_obj('/bmc/kepler/ProductInfo/FruCtrlCapabilities'),
    ['new_mdb_objects'] = mdb.new_objects_builder({
        ['bmc.kepler.ProductInfo.FruCtrlCapabilities'] = {
            ['property_defaults'] = {
                ['GlobalDomainSupported'] = fru_ctrl_capabilities_intf_types.GlobalDomainSupported.default[1],
                ['MultihostSupported'] = fru_ctrl_capabilities_intf_types.MultihostSupported.default[1]
            },
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = fru_ctrl_capabilities_intf_types
        },
        ['bmc.kepler.Object.Properties'] = {
            ['property_defaults'] = {
                ['ClassName'] = properties_intf_types.ClassName.default[1],
                ['ObjectName'] = properties_intf_types.ObjectName.default[1],
                ['ObjectIdentifier'] = properties_intf_types.ObjectIdentifier.default[1]
            },
            ['privileges'] = {['path'] = privilege.ReadOnly},
            ['interface_types'] = properties_intf_types
        }
    })
}

local M = {}

function M.init(bus)
    class('ChassisFruCtrl', ChassisFruCtrl):set_bus(bus)
    class('FruCtrl', FruCtrl):set_bus(bus)
    class('RecordFault', RecordFault):set_bus(bus)
    class('PGSignal', PGSignal):set_bus(bus)
    class('PowerButton', PowerButton):set_bus(bus)
    class('ACCycle', ACCycle):set_bus(bus)
    class('Nmi', Nmi):set_bus(bus)
    class('ForceReset', ForceReset):set_bus(bus)
    class('ButtonEvt', ButtonEvt):set_bus(bus)
    class('SysReset', SysReset):set_bus(bus)
    class('ThermTrip', ThermTrip):set_bus(bus)
    class('DftPowerButton', DftPowerButton):set_bus(bus)
    class('SystemLockDown', SystemLockDown):set_bus(bus)
    class('PowerAction', PowerAction):set_bus(bus)
    class('Multihost', Multihost):set_bus(bus)
    class('FruCtrlCapabilities', FruCtrlCapabilities):set_bus(bus)
end

-- The callback needs to be registered during app initialization
function M.ImplChassisFruCtrlChassisFruCtrlPowerCtrl(cb)
    class('ChassisFruCtrl')['bmc.kepler.Chassis.FruCtrl'].PowerCtrl = function(obj, ctx, ...)
        local req = chassis_fru_ctrl_intf_types.PowerCtrlReq.new(...):validate(nil, nil, true)
        local rsp = chassis_fru_ctrl_intf_types.PowerCtrlRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplChassisFruCtrlChassisFruCtrlSetPowerOnStrategyExceptions(cb)
    class('ChassisFruCtrl')['bmc.kepler.Chassis.FruCtrl'].SetPowerOnStrategyExceptions = function(obj, ctx, ...)
        local req = chassis_fru_ctrl_intf_types.SetPowerOnStrategyExceptionsReq.new(...):validate(nil, nil, true)
        local rsp =
            chassis_fru_ctrl_intf_types.SetPowerOnStrategyExceptionsRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplChassisFruCtrlChassisPowerOnLockSetPowerOnLock(cb)
    class('ChassisFruCtrl')['bmc.kepler.Chassis.PowerOnLock'].SetPowerOnLock = function(obj, ctx, ...)
        local req = chassis_power_on_lock_intf_types.SetPowerOnLockReq.new(...):validate(nil, nil, true)
        local rsp = chassis_power_on_lock_intf_types.SetPowerOnLockRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplFruCtrlSystemsPowerOnLockSetPowerOnLock(cb)
    class('FruCtrl')['bmc.kepler.Systems.PowerOnLock'].SetPowerOnLock = function(obj, ctx, ...)
        local req = systems_power_on_lock_intf_types.SetPowerOnLockReq.new(...):validate(nil, nil, true)
        local rsp = systems_power_on_lock_intf_types.SetPowerOnLockRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplFruCtrlSystemsFruCtrlPowerCtrl(cb)
    class('FruCtrl')['bmc.kepler.Systems.FruCtrl'].PowerCtrl = function(obj, ctx, ...)
        local req = systems_fru_ctrl_intf_types.PowerCtrlReq.new(...):validate(nil, nil, true)
        local rsp = systems_fru_ctrl_intf_types.PowerCtrlRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplFruCtrlSystemsFruCtrlSetPowerOnStrategyExceptions(cb)
    class('FruCtrl')['bmc.kepler.Systems.FruCtrl'].SetPowerOnStrategyExceptions = function(obj, ctx, ...)
        local req = systems_fru_ctrl_intf_types.SetPowerOnStrategyExceptionsReq.new(...):validate(nil, nil, true)
        local rsp =
            systems_fru_ctrl_intf_types.SetPowerOnStrategyExceptionsRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplFruCtrlSystemsFruCtrlSetACLost(cb)
    class('FruCtrl')['bmc.kepler.Systems.FruCtrl'].SetACLost = function(obj, ctx, ...)
        local req = systems_fru_ctrl_intf_types.SetACLostReq.new(...):validate(nil, nil, true)
        local rsp = systems_fru_ctrl_intf_types.SetACLostRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplFruCtrlSystemsFruCtrlFruPowerCtrl(cb)
    class('FruCtrl')['bmc.kepler.Systems.FruCtrl'].FruPowerCtrl = function(obj, ctx, ...)
        local req = systems_fru_ctrl_intf_types.FruPowerCtrlReq.new(...):validate(nil, nil, true)
        local rsp = systems_fru_ctrl_intf_types.FruPowerCtrlRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplDftPowerButtonManufactureStart(cb)
    class('DftPowerButton')['bmc.kepler.Manufacture'].Start = function(obj, ctx, ...)
        local req = manufacture_intf_types.StartReq.new(...):validate(nil, nil, true)
        local rsp = manufacture_intf_types.StartRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplDftPowerButtonManufactureStop(cb)
    class('DftPowerButton')['bmc.kepler.Manufacture'].Stop = function(obj, ctx, ...)
        local req = manufacture_intf_types.StopReq.new(...):validate(nil, nil, true)
        local rsp = manufacture_intf_types.StopRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

-- The callback needs to be registered during app initialization
function M.ImplDftPowerButtonManufactureGetResult(cb)
    class('DftPowerButton')['bmc.kepler.Manufacture'].GetResult = function(obj, ctx, ...)
        local req = manufacture_intf_types.GetResultReq.new(...):validate(nil, nil, true)
        local rsp = manufacture_intf_types.GetResultRsp.new(cb(obj, ctx, req:unpack())):validate()
        return rsp:unpack(true)
    end
end

return M
