代码拉取完成,页面将自动刷新
package ipmi
import (
"fmt"
"strings"
)
// 35.11 Get Sensor Event Enable Command
type GetSensorEventEnableRequest struct {
SensorNumber uint8
}
// For event , true means the event has enabled.
type GetSensorEventEnableResponse struct {
EventMessagesDisabled bool
SensorScanningDisabled bool
SensorEventFlag
}
func (req *GetSensorEventEnableRequest) Command() Command {
return CommandGetSensorEventEnable
}
func (req *GetSensorEventEnableRequest) Pack() []byte {
out := make([]byte, 1)
packUint8(req.SensorNumber, out, 0)
return out
}
func (res *GetSensorEventEnableResponse) Unpack(msg []byte) error {
if len(msg) < 1 {
return ErrUnpackedDataTooShortWith(len(msg), 1)
}
b1, _, _ := unpackUint8(msg, 0)
res.EventMessagesDisabled = !isBit7Set(b1)
res.SensorScanningDisabled = !isBit6Set(b1)
if len(msg) >= 2 {
b2, _, _ := unpackUint8(msg, 1)
res.SensorEvent_UNC_High_Assert = isBit7Set(b2)
res.SensorEvent_UNC_Low_Assert = isBit6Set(b2)
res.SensorEvent_LNR_High_Assert = isBit5Set(b2)
res.SensorEvent_LNR_Low_Assert = isBit4Set(b2)
res.SensorEvent_LCR_High_Assert = isBit3Set(b2)
res.SensorEvent_LCR_Low_Assert = isBit2Set(b2)
res.SensorEvent_LNC_High_Assert = isBit1Set(b2)
res.SensorEvent_LNC_Low_Assert = isBit0Set(b2)
res.SensorEvent_State_7_Assert = isBit7Set(b2)
res.SensorEvent_State_6_Assert = isBit6Set(b2)
res.SensorEvent_State_5_Assert = isBit5Set(b2)
res.SensorEvent_State_4_Assert = isBit4Set(b2)
res.SensorEvent_State_3_Assert = isBit3Set(b2)
res.SensorEvent_State_2_Assert = isBit2Set(b2)
res.SensorEvent_State_1_Assert = isBit1Set(b2)
res.SensorEvent_State_0_Assert = isBit0Set(b2)
}
if len(msg) >= 3 {
b3, _, _ := unpackUint8(msg, 2)
res.SensorEvent_UNR_High_Assert = isBit3Set(b3)
res.SensorEvent_UNR_Low_Assert = isBit2Set(b3)
res.SensorEvent_UCR_High_Assert = isBit1Set(b3)
res.SensorEvent_UCR_Low_Assert = isBit0Set(b3)
res.SensorEvent_State_14_Assert = isBit6Set(b3)
res.SensorEvent_State_13_Assert = isBit5Set(b3)
res.SensorEvent_State_12_Assert = isBit4Set(b3)
res.SensorEvent_State_11_Assert = isBit3Set(b3)
res.SensorEvent_State_10_Assert = isBit2Set(b3)
res.SensorEvent_State_9_Assert = isBit1Set(b3)
res.SensorEvent_State_8_Assert = isBit0Set(b3)
}
if len(msg) >= 4 {
b4, _, _ := unpackUint8(msg, 3)
res.SensorEvent_UNC_High_Deassert = isBit7Set(b4)
res.SensorEvent_UNC_Low_Deassert = isBit6Set(b4)
res.SensorEvent_LNR_High_Deassert = isBit5Set(b4)
res.SensorEvent_LNR_Low_Deassert = isBit4Set(b4)
res.SensorEvent_LCR_High_Deassert = isBit3Set(b4)
res.SensorEvent_LCR_Low_Deassert = isBit2Set(b4)
res.SensorEvent_LNC_High_Deassert = isBit1Set(b4)
res.SensorEvent_LNC_Low_Deassert = isBit0Set(b4)
res.SensorEvent_State_7_Deassert = isBit7Set(b4)
res.SensorEvent_State_6_Deassert = isBit6Set(b4)
res.SensorEvent_State_5_Deassert = isBit5Set(b4)
res.SensorEvent_State_4_Deassert = isBit4Set(b4)
res.SensorEvent_State_3_Deassert = isBit3Set(b4)
res.SensorEvent_State_2_Deassert = isBit2Set(b4)
res.SensorEvent_State_1_Deassert = isBit1Set(b4)
res.SensorEvent_State_0_Deassert = isBit0Set(b4)
}
if len(msg) >= 5 {
b5, _, _ := unpackUint8(msg, 4)
res.SensorEvent_UNR_High_Deassert = isBit3Set(b5)
res.SensorEvent_UNR_Low_Deassert = isBit2Set(b5)
res.SensorEvent_UCR_High_Deassert = isBit1Set(b5)
res.SensorEvent_UCR_Low_Deassert = isBit0Set(b5)
res.SensorEvent_State_14_Deassert = isBit6Set(b5)
res.SensorEvent_State_13_Deassert = isBit5Set(b5)
res.SensorEvent_State_12_Deassert = isBit4Set(b5)
res.SensorEvent_State_11_Deassert = isBit3Set(b5)
res.SensorEvent_State_10_Deassert = isBit2Set(b5)
res.SensorEvent_State_9_Deassert = isBit1Set(b5)
res.SensorEvent_State_8_Deassert = isBit0Set(b5)
}
return nil
}
func (r *GetSensorEventEnableResponse) CompletionCodes() map[uint8]string {
return map[uint8]string{}
}
func (res *GetSensorEventEnableResponse) Format() string {
all := res.SensorEventFlag.TrueEvents()
asserted := SensorEvents(all).FilterAssert()
deasserted := SensorEvents(all).FilterDeassert()
var assertedStr = []string{}
var deassertedStr = []string{}
for _, v := range asserted {
assertedStr = append(assertedStr, v.String())
}
for _, v := range deasserted {
deassertedStr = append(deassertedStr, v.String())
}
return fmt.Sprintf(`Event Messages Disabled : %v
Sensor Scanning Disabled : %v
Enabled Assert Event : %s
Enabled Deassert Event : %s`,
res.EventMessagesDisabled,
res.SensorScanningDisabled,
strings.Join(assertedStr, "\n - "),
strings.Join(deassertedStr, "\n - "),
)
}
func (c *Client) GetSensorEventEnable(sensorNumber uint8) (response *GetSensorEventEnableResponse, err error) {
request := &GetSensorEventEnableRequest{
SensorNumber: sensorNumber,
}
response = &GetSensorEventEnableResponse{}
err = c.Exchange(request, response)
return
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。