当前位置: 首页>>代码示例>>Python>>正文


Python Device.add_state方法代码示例

本文整理汇总了Python中Device.Device.add_state方法的典型用法代码示例。如果您正苦于以下问题:Python Device.add_state方法的具体用法?Python Device.add_state怎么用?Python Device.add_state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device.Device的用法示例。


在下文中一共展示了Device.add_state方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Me

# 需要导入模块: from Device import Device [as 别名]
# 或者: from Device.Device import add_state [as 别名]
class Me(wx.Frame):
    def __init__(self, _stop_event):
        super(Me, self).__init__(None)
        self.pause = 0
        self.stop_event = _stop_event
        self.SetSize = (1000, 1000)
        self.col = wx.Colour(0,190,255)
        self.SetBackgroundColour(self.col)
        self.cpu0 = Device("CORE0")
        self.cpu1 = Device("CORE1")
        self.dev1 = Device("dev1")
        self.dev2 = Device("dev2")
        self.dev3 = Device("dev3")
        self.dev4 = Device("dev4")
        self.dev5 = Device("dev5")
        self.dev6 = Device("dev6")
        self.cpuC0 = DeviceState(0, "green", "C0")
        self.cpuC1 = DeviceState(1, "yellow", "C1")
        self.cpuC2 = DeviceState(2, "red", "C2")

        self.create_menu()
        self.SetMinSize((1100, 800))
        self.SetPosition((100,100))
        self.set_title("PM analyzer")

        self.gpf = GraphicModeFrame(self, -1, "Sizer Test")
        self.mode1_constructor()



        '''for i in range(0, 100, 2):
            cpu1.add_state(i, cpuC1)
            cpu1.add_state(i+1, cpuC2)
        cpu1.add_state(100, cpuC0)'''
        self.gpf.AddDevice(self.cpu1)
        self.gpf.AddDevice(self.cpu0)
        self.gpf.AddDevice(self.dev1)
        self.gpf.AddDevice(self.dev2)
        self.gpf.AddDevice(self.dev3)
        self.gpf.AddDevice(self.dev4)
        self.gpf.AddDevice(self.dev5)
        self.gpf.AddDevice(self.dev6)

    def GetPMValues(self, tick):
        if self.pause is 0:
            if tick % 2 == 0:
                self.cpu0.add_state(tick, self.cpuC0)
                self.cpu1.add_state(tick, self.cpuC1)
                self.dev1.add_state(tick, self.cpuC0)
                self.dev2.add_state(tick, self.cpuC1)
                self.dev3.add_state(tick, self.cpuC2)
                self.dev4.add_state(tick, self.cpuC0)
                self.dev5.add_state(tick, self.cpuC1)
                self.dev6.add_state(tick, self.cpuC2)
            else:
                self.cpu0.add_state(tick, self.cpuC1)
                self.cpu1.add_state(tick, self.cpuC2)
                self.dev1.add_state(tick, self.cpuC1)
                self.dev2.add_state(tick, self.cpuC2)
                self.dev3.add_state(tick, self.cpuC0)
                self.dev4.add_state(tick, self.cpuC1)
                self.dev5.add_state(tick, self.cpuC2)
                self.dev6.add_state(tick, self.cpuC0)
            self.gpf.Refresh()
            self.panel.Refresh()
        #self.Refresh()

    def mode1_constructor(self):
        self.vbox1 = wx.BoxSizer(wx.VERTICAL)
        self.panel = FlasherChart(self, -1)
        self.panel.SetBackgroundColour(wx.Colour(245,222,179)) 
        self.panel.Bind(wx.EVT_PAINT, self.OnPaint)
        self.vbox1.Add(self.panel, proportion=1, flag=wx.EXPAND)

        #Addind device
        self.panel.AddDevice(self.cpu0, 10, 15, 60, 40)

    def OnPaint(self, event):
        self.panel.OnPaint(None)
        #Experiment
        dc = wx.PaintDC(self.panel)

        #Define pens and brushes
        pen_basic = wx.Pen(wx.Colour(23,128,109), 2, wx.SOLID)
        brush_basic = wx.Brush(wx.Colour(48,186,143))
        pen_service = wx.Pen(wx.Colour(78,87,84), 2, wx.SOLID)
        brush_service = wx.Brush('#C8A696')
        pen_bus = wx.Pen('#FF2B2B', 6, wx.SOLID)
        brush_bus = wx.Brush('#FD5E53')
        pen_csme = wx.Pen('#FF9218', 2, wx.SOLID)
        brush_csme = wx.Brush('#F8D568')
        pen_hw = wx.Pen('#131313', 2, wx.SOLID)
        brush_hw = wx.Brush('#F8F8FF')

        #Contur
        dc.SetPen(wx.Pen('#4c4c4c', 1, wx.SHORT_DASH))
        dc.SetBrush(wx.Brush('#C9C0BB'))
        dc.DrawRectangle(550, 305, 500, 220)
        dc.SetBrush(wx.Brush('#D7D7D7'))
        dc.DrawRectangle(565, 395, 330, 110)
#.........这里部分代码省略.........
开发者ID:ShimchenkoMarina,项目名称:TrialPMApplicaion,代码行数:103,代码来源:main.py


注:本文中的Device.Device.add_state方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。