示例#1
0
    def __init__(self, e, control):
        self.e = e
        self.name = control.get_name()
        e.controls[self.name] = self
        self.control_type_str = control.get_type_string()
        self.control_id = control.get_id()
        self.ui = e.ui;
        self.updater = ControlRefreshData(self)
        self.vals = [ ]
        self.ui.add_control(self.e, self)
        self.control_type = control.get_type()
        self.destroyed = False
        if (self.control_type == OpenIPMI.CONTROL_IDENTIFIER):
            self.num_vals = control.identifier_get_max_length();
        else:
            self.num_vals = control.get_num_vals();
            pass

        if ((self.control_type == OpenIPMI.CONTROL_LIGHT)
            and (control.light_set_with_setting())):
            self.setting_light = True
            self.lights = [ ]
            for  i in range (0, self.num_vals):
                lc = control.light_has_local_control(i)
                colors = [ ]
                for j in range (0, OpenIPMI.CONTROL_NUM_COLORS):
                    if control.light_is_color_supported(i, j):
                        colors.append(OpenIPMI.color_string(j))
                        pass
                    pass
                self.lights.append((lc, colors))
                pass
            pass
        else:
            self.setting_light = False
            pass

        self.is_settable = control.is_settable()
        self.is_readable = control.is_readable()
        if (self.is_settable):
            if (self.setting_light):
                self.setter = LightSet(self)
            else:
                self.setter = ControlSet(self)
                pass
            pass
        else:
            self.setter = None
            pass

        self.ui.prepend_item(self, "Control Type", self.control_type_str)
        cs = [ ]
        if (control.has_events()):
            cs.append("generates_events")
            pass
        if (self.is_settable):
            cs.append("settable")
            pass
        if (self.is_readable):
            cs.append("readable")
            pass
        self.ui.append_item(self, "Control Capabilities", ' '.join(cs))
        if (self.control_type == OpenIPMI.CONTROL_LIGHT):
            self.ui.append_item(self, "Num Lights", str(self.num_vals))
            if (self.setting_light):
                self.ui.append_item(self, "Light Type", "setting")
                for i in range(0, self.num_vals):
                    cap = [ ]
                    if control.light_has_local_control(i):
                        cap.append("local_control")
                        pass
                    for j in range (0, OpenIPMI.CONTROL_NUM_COLORS):
                        if control.light_is_color_supported(i, j):
                            cap.append(OpenIPMI.color_string(j))
                            pass
                        pass
                    self.ui.append_item(self, "Light" + str(i), ' '.join(cap))
                    pass
                pass
            else:
                self.ui.append_item(self, "Light Type", "transition")
                for i in range(0, self.num_vals):
                    cap = [ ]
                    for j in range (0, control.get_num_light_values(i)):
                        cap2 = [ ]
                        for k in range (0,control.get_num_light_transitions(i, j)):
                            cap3 = [ ]
                            val = control.get_light_color(i, j, k)
                            cap3.append(OpenIPMI.color_string(val))
                            val = control.get_light_color_time(i, j, k)
                            cap3.append(OpenIPMI.color_string(val))
                            cap2.append(cap3)
                            pass
                        cap.append(cap2)
                        pass
                    self.ui.append_item(self, "Light" + str(i), str(cap))
                    pass
                pass
            pass
        elif (self.control_type == OpenIPMI.CONTROL_IDENTIFIER):
            self.ui.append_item(self, "Max Length", str(self.num_vals))
        else:
            self.ui.append_item(self, "Num Vals", str(self.num_vals))
            pass
        return
示例#2
0
    def __init__(self, e, control):
        self.e = e
        self.name = control.get_name()
        e.controls[self.name] = self
        self.control_type_str = control.get_type_string()
        self.control_id = control.get_id()
        self.ui = e.ui;
        self.updater = ControlRefreshData(self)
        self.vals = [ ]
        self.ui.add_control(self.e, self)
        self.control_type = control.get_type()
        self.destroyed = False
        if (self.control_type == OpenIPMI.CONTROL_IDENTIFIER):
            self.num_vals = control.identifier_get_max_length();
        else:
            self.num_vals = control.get_num_vals();
            pass

        if ((self.control_type == OpenIPMI.CONTROL_LIGHT)
            and (control.light_set_with_setting())):
            self.setting_light = True
            self.lights = [ ]
            for  i in range (0, self.num_vals):
                lc = control.light_has_local_control(i)
                colors = [ ]
                for j in range (0, OpenIPMI.CONTROL_NUM_COLORS):
                    if control.light_is_color_supported(i, j):
                        colors.append(OpenIPMI.color_string(j))
                        pass
                    pass
                self.lights.append((lc, colors))
                pass
            pass
        else:
            self.setting_light = False
            pass

        self.is_settable = control.is_settable()
        self.is_readable = control.is_readable()
        if (self.is_settable):
            if (self.setting_light):
                self.setter = LightSet(self)
            else:
                self.setter = ControlSet(self)
                pass
            pass
        else:
            self.setter = None
            pass

        self.ui.prepend_item(self, "Control Type", self.control_type_str)
        cs = [ ]
        if (control.has_events()):
            cs.append("generates_events")
            pass
        if (self.is_settable):
            cs.append("settable")
            pass
        if (self.is_readable):
            cs.append("readable")
            pass
        self.ui.append_item(self, "Control Capabilities", ' '.join(cs))
        if (self.control_type == OpenIPMI.CONTROL_LIGHT):
            self.ui.append_item(self, "Num Lights", str(self.num_vals))
            if (self.setting_light):
                self.ui.append_item(self, "Light Type", "setting")
                for i in range(0, self.num_vals):
                    cap = [ ]
                    if control.light_has_local_control(i):
                        cap.append("local_control")
                        pass
                    for j in range (0, OpenIPMI.CONTROL_NUM_COLORS):
                        if control.light_is_color_supported(i, j):
                            cap.append(OpenIPMI.color_string(j))
                            pass
                        pass
                    self.ui.append_item(self, "Light" + str(i), ' '.join(cap))
                    pass
                pass
            else:
                self.ui.append_item(self, "Light Type", "transition")
                for i in range(0, self.num_vals):
                    cap = [ ]
                    for j in range (0, control.get_num_light_values(i)):
                        cap2 = [ ]
                        for k in range (0,control.get_num_light_transitions(i, j)):
                            cap3 = [ ]
                            val = control.get_light_color(i, j, k)
                            cap3.append(OpenIPMI.color_string(val))
                            val = control.get_light_color_time(i, j, k)
                            cap3.append(OpenIPMI.color_string(val))
                            cap2.append(cap3)
                            pass
                        cap.append(cap2)
                        pass
                    self.ui.append_item(self, "Light" + str(i), str(cap))
                    pass
                pass
            pass
        elif (self.control_type == OpenIPMI.CONTROL_IDENTIFIER):
            self.ui.append_item(self, "Max Length", str(self.num_vals))
        else:
            self.ui.append_item(self, "Num Vals", str(self.num_vals))
            pass
        return
示例#3
0
    def entity_control_update_cb(self, op, entity, control):
	use_setting = 0

	print op + " control " + control.get_name()
        if ((op == "added") or (op == "changed")):
	    t = control.get_type()
	    print "  type = " + str(t)
	    print "  entity_id = " + str(control.get_entity_id())
	    print "  entity_instance = " + str(control.get_entity_instance())
	    print "  settable = " + str(control.is_settable())
	    print "  readable = " + str(control.is_readable())
	    print("  ignore_if_no_entity = " +
		  str(control.get_ignore_if_no_entity()))
	    print "  control_id = " + str(control.get_control_id())
	    print "  has_events = " + str(control.has_events())
	    num_vals = control.get_num_vals()
	    print "  num_vals = " + str(num_vals)

            if t == OpenIPMI.CONTROL_LIGHT:
		use_setting = control.light_set_with_setting()
                pass

	    if use_setting:
		print "  light controlled with setting"
		tstr = "  Colors: "
                for i in range(0, OpenIPMI.CONTROL_NUM_COLORS):
                    if (control.light_is_color_supported(i)):
			tstr += " " + OpenIPMI.color_string(i) + ("(%d)" % i)
                        pass
                    pass
		print tstr
		print("  light_has_local_control = " +
		      str(control.light_has_local_control()))
		rv = control.ipmi_control_get_light(self)
                if rv:
		    print "***Error getting light: " + str(rv)
                    pass
                pass
	    elif t == OpenIPMI.CONTROL_IDENTIFIER:
		print("  identifier_get_max_length = " +
		      str(control.identifier_get_max_length()))
		rv = control.identifier_get_val(self)
                if rv:
		    print "***Error getting control id: " + str(rv)
                    pass
                pas
            elif t == OpenIPMI.CONTROL_LIGHT:
                for i in range(0, num_vals) :
                    n = control.get_num_light_values(i)
                    print "  Light %d" % i
                    for j in range (0, n):
                        print "    Value %d" % j
                        o = control.get_num_light_transitions(i, j)
                        for k in range (0, o):
                            tstr = "    Transition %d:" & k
                            v = control.get_light_color(i, j, k)
                            tstr += " " + OpenIPMI.color_string(v)
                            v = control.get_light_color_time(i, j, k)
                            tstr += " time(" + str(v) + ")"
                            pass
                        pass
                    pass
                pass

            if op == "added":
		rv = control.add_event_handler(self)
                if rv:
		    print "***Error adding control event handler: " + str(rv)
                    pass
                pass
            pass
        elif op == "deleted":
	    rv = control.remove_event_handler(self)
            if rv:
		print "***Error removing control event handler: " + str(rv)
                pass
            pass
        return
示例#4
0
文件: sample.py 项目: xiar/openipmi
    def entity_control_update_cb(self, op, entity, control):
        use_setting = 0

        print op + " control " + control.get_name()
        if ((op == "added") or (op == "changed")):
            t = control.get_type()
            print "  type = " + str(t)
            print "  entity_id = " + str(control.get_entity_id())
            print "  entity_instance = " + str(control.get_entity_instance())
            print "  settable = " + str(control.is_settable())
            print "  readable = " + str(control.is_readable())
            print("  ignore_if_no_entity = " +
                  str(control.get_ignore_if_no_entity()))
            print "  control_id = " + str(control.get_control_id())
            print "  has_events = " + str(control.has_events())
            num_vals = control.get_num_vals()
            print "  num_vals = " + str(num_vals)

            if t == OpenIPMI.CONTROL_LIGHT:
                use_setting = control.light_set_with_setting()
                pass

            if use_setting:
                print "  light controlled with setting"
                tstr = "  Colors: "
                for i in range(0, OpenIPMI.CONTROL_NUM_COLORS):
                    if (control.light_is_color_supported(i)):
                        tstr += " " + OpenIPMI.color_string(i) + ("(%d)" % i)
                        pass
                    pass
                print tstr
                print("  light_has_local_control = " +
                      str(control.light_has_local_control()))
                rv = control.ipmi_control_get_light(self)
                if rv:
                    print "***Error getting light: " + str(rv)
                    pass
                pass
            elif t == OpenIPMI.CONTROL_IDENTIFIER:
                print("  identifier_get_max_length = " +
                      str(control.identifier_get_max_length()))
                rv = control.identifier_get_val(self)
                if rv:
                    print "***Error getting control id: " + str(rv)
                    pass
                pas
            elif t == OpenIPMI.CONTROL_LIGHT:
                for i in range(0, num_vals):
                    n = control.get_num_light_values(i)
                    print "  Light %d" % i
                    for j in range(0, n):
                        print "    Value %d" % j
                        o = control.get_num_light_transitions(i, j)
                        for k in range(0, o):
                            tstr = "    Transition %d:" & k
                            v = control.get_light_color(i, j, k)
                            tstr += " " + OpenIPMI.color_string(v)
                            v = control.get_light_color_time(i, j, k)
                            tstr += " time(" + str(v) + ")"
                            pass
                        pass
                    pass
                pass

            if op == "added":
                rv = control.add_event_handler(self)
                if rv:
                    print "***Error adding control event handler: " + str(rv)
                    pass
                pass
            pass
        elif op == "deleted":
            rv = control.remove_event_handler(self)
            if rv:
                print "***Error removing control event handler: " + str(rv)
                pass
            pass
        return