-- Copyright (c) 2026 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 validate = require 'mc.validate'
local utils = require 'mc.utils'

local MPOH = {}

---@class MPOH.Counter
---@field Counter integer
local TCounter = {}
TCounter.__index = TCounter
TCounter.group = {}

local function TCounter_from_obj(obj)
    return setmetatable(obj, TCounter)
end

function TCounter.new(Counter)
    return TCounter_from_obj({Counter = Counter})
end
---@param obj MPOH.Counter
function TCounter:init_from_obj(obj)
    self.Counter = obj.Counter
end

function TCounter:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TCounter.group)
end

TCounter.from_obj = TCounter_from_obj

TCounter.proto_property = {'Counter'}

TCounter.default = {0}

TCounter.struct = {{name = 'Counter', is_array = false, struct = nil}}

function TCounter:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Counter', self.Counter, 'uint32', false, errs, need_convert)

    TCounter:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TCounter.proto_property, errs, need_convert)
    return self
end

function TCounter:unpack(_)
    return self.Counter
end

MPOH.Counter = TCounter

---@class MPOH.MinutesPerCount
---@field MinutesPerCount integer
local TMinutesPerCount = {}
TMinutesPerCount.__index = TMinutesPerCount
TMinutesPerCount.group = {}

local function TMinutesPerCount_from_obj(obj)
    return setmetatable(obj, TMinutesPerCount)
end

function TMinutesPerCount.new(MinutesPerCount)
    return TMinutesPerCount_from_obj({MinutesPerCount = MinutesPerCount})
end
---@param obj MPOH.MinutesPerCount
function TMinutesPerCount:init_from_obj(obj)
    self.MinutesPerCount = obj.MinutesPerCount
end

function TMinutesPerCount:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TMinutesPerCount.group)
end

TMinutesPerCount.from_obj = TMinutesPerCount_from_obj

TMinutesPerCount.proto_property = {'MinutesPerCount'}

TMinutesPerCount.default = {0}

TMinutesPerCount.struct = {{name = 'MinutesPerCount', is_array = false, struct = nil}}

function TMinutesPerCount:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'MinutesPerCount', self.MinutesPerCount, 'uint8', false, errs, need_convert)

    TMinutesPerCount:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TMinutesPerCount.proto_property, errs, need_convert)
    return self
end

function TMinutesPerCount:unpack(_)
    return self.MinutesPerCount
end

MPOH.MinutesPerCount = TMinutesPerCount

---@class MPOH.POHEnable
---@field POHEnable boolean
local TPOHEnable = {}
TPOHEnable.__index = TPOHEnable
TPOHEnable.group = {}

local function TPOHEnable_from_obj(obj)
    return setmetatable(obj, TPOHEnable)
end

function TPOHEnable.new(POHEnable)
    return TPOHEnable_from_obj({POHEnable = POHEnable})
end
---@param obj MPOH.POHEnable
function TPOHEnable:init_from_obj(obj)
    self.POHEnable = obj.POHEnable
end

function TPOHEnable:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TPOHEnable.group)
end

TPOHEnable.from_obj = TPOHEnable_from_obj

TPOHEnable.proto_property = {'POHEnable'}

TPOHEnable.default = {false}

TPOHEnable.struct = {{name = 'POHEnable', is_array = false, struct = nil}}

function TPOHEnable:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'POHEnable', self.POHEnable, 'bool', false, errs, need_convert)

    TPOHEnable:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TPOHEnable.proto_property, errs, need_convert)
    return self
end

function TPOHEnable:unpack(_)
    return self.POHEnable
end

MPOH.POHEnable = TPOHEnable

---@class MPOH.SystemId
---@field SystemId integer
local TSystemId = {}
TSystemId.__index = TSystemId
TSystemId.group = {}

local function TSystemId_from_obj(obj)
    return setmetatable(obj, TSystemId)
end

function TSystemId.new(SystemId)
    return TSystemId_from_obj({SystemId = SystemId})
end
---@param obj MPOH.SystemId
function TSystemId:init_from_obj(obj)
    self.SystemId = obj.SystemId
end

function TSystemId:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSystemId.group)
end

TSystemId.from_obj = TSystemId_from_obj

TSystemId.proto_property = {'SystemId'}

TSystemId.default = {0}

TSystemId.struct = {{name = 'SystemId', is_array = false, struct = nil}}

function TSystemId:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Required(prefix .. 'SystemId', self.SystemId, 'uint8', false, errs, need_convert)

    TSystemId:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSystemId.proto_property, errs, need_convert)
    return self
end

function TSystemId:unpack(_)
    return self.SystemId
end

MPOH.SystemId = TSystemId

return MPOH
