예제 #1
0
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent=parent)

        self.plot = wxmplot.PlotPanel(self, dpi=100, size=(2400, 1600))
        self.plot.plot([0, 1, 2], [2, 3, 1])

        hsizer = wx.BoxSizer(wx.HORIZONTAL)
        hsizer.Add(self.plot, 1, wx.ALL | wx.EXPAND)

        vsizer = wx.BoxSizer(wx.VERTICAL)
        vsizer.Add(hsizer, 1, wx.ALL | wx.EXPAND)
        self.SetSizer(vsizer)
	def __init__(self, parent):
		pacemakerInterface.MainFrame.__init__(self, parent)
		
		self.plotLength = 2000
		self.plotPointsX = []
		self.plotPointsY = []
		self.relativeX = []
		self.pointsToAdd = []
		self.axisOverscale = 0.2 # 20%
		self.lastCurrentTime = 0
		
		sizer = self.GetSizer()
		self.canvas = wxmplot.PlotPanel(self)
		sizer.Replace(self.PlotFrame, self.canvas)
		self.Layout()
		self.canvas.plot(numpy.array([0]), numpy.array([0]), ymin=-5, ymax=10, axes_style='bottom')
		self.canvas.axesmargins = (10, 10, 10, 10)
		
		self.annotationMax = None
		self.annotationMin = None
		
		self.serialPortsAvailable = []
		self.SerialInterface = None
		self.streamingData = False
		self.runSerialThread = True
		self.serialThreadExit = False
		
		self.paramsFromDevice = []
		self.paramNames = ['Device ID', 'Device Implant Date', 'Lead Implant Date', 'Pacing State', 'Pacing Mode', 'Hysteresis', 'Hysteresis Interval', 'Pacing Amplitude', 'Pace Width', 'VRP', 'Base HR', 'Max HR']
		self.readParams = False
		
		self.simulating = False
		self.simulatedData = []
		self.simulatedDataPosition = 0
		with open('simulatedECG.csv', 'rb') as csvfile:
			csvReader = csv.reader(csvfile, delimiter=' ', quotechar='|')
			for row in csvReader:
				self.simulatedData.append(float(row[0]))
		
		self.StaticBitmapDisconnected = scale_bitmap(wx.Bitmap('img/disconnected.png', wx.BITMAP_TYPE_ANY), 50, 50)
		self.StaticBitmapConnected = scale_bitmap(wx.Bitmap('img/connected.png', wx.BITMAP_TYPE_ANY), 50, 50)
		self.Img_Connected.SetBitmap(self.StaticBitmapDisconnected)
		
		self.timer = wx.Timer()
		self.timer.Bind(wx.EVT_TIMER, self.OnGraphUpdateTimer)
		self.timer.Start(100)
		self.limitTimer = wx.Timer()
		self.limitTimer.Bind(wx.EVT_TIMER, self.OnLimitUpdateTimer)
		self.limitTimer.Start(500)
예제 #3
0
    def __init__(self, parent, name, address, plot_width=600, plot_height=150,
                 air_flow_len=1000, acc_magn_len=1000, ecg_v1_len=1000,
                 heart_rate_len=1000, o2_len=1000, temperature_len=1000,
                 capture_file_name='details_frame.png', sleep_time=5000,
                 *args, **kwds):
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, parent, *args, **kwds)

        self.parent = parent
        self.name = name
        self.address = address
        dir_name = os.path.dirname(capture_file_name)
        base_name = os.path.basename(capture_file_name).split('.')
        self.capture_file_name = '{}_{}.{}'.format(base_name[0], self.name,
                                                   base_name[1])
        self.capture_file_name = os.path.join(dir_name, self.capture_file_name)
        self.air_flow = deque([0] * air_flow_len, maxlen=air_flow_len)
        self.air_flow_plt = wxmplot.PlotPanel(
                                    self, output_title='Air Flow',
                                    size=(plot_width, plot_height),
                                    messenger=None)
        self.acc_magn = deque([0] * acc_magn_len, maxlen=acc_magn_len)
        self.acc_magn_plt = wxmplot.PlotPanel(
                                        self, output_title='Body Acceleration',
                                        size=(plot_width, plot_height),
                                        messenger=None)
        self.ecg_v1 = deque([0] * ecg_v1_len, maxlen=ecg_v1_len)
        self.ecg_v1_plt = wxmplot.PlotPanel(
                                        self, output_title='ECG',
                                        size=(plot_width, plot_height),
                                        messenger=None)
        self.heart_rate = deque([0] * heart_rate_len, maxlen=heart_rate_len)
        self.heart_rate_plt = wxmplot.PlotPanel(
                                        self, output_title='Heart Rate',
                                        size=(plot_width, plot_height),
                                        messenger=None)
        self.o2 = deque([0] * o2_len, maxlen=o2_len)
        self.o2_plt = wxmplot.PlotPanel(
                                    self, output_title='SPO2',
                                    size=(plot_width, plot_height),
                                    messenger=None)
        self.temperature = deque([0] * temperature_len, maxlen=temperature_len)
        self.temperature_plt = wxmplot.PlotPanel(
                                            self, output_title='Temperature',
                                            size=(plot_width, plot_height),
                                            messenger=None)
        # draw the plots once so they set up the labels
        kwargs = {'air_flow': self.air_flow, 'acc_magn': self.acc_magn,
                  'ecg_v1': self.ecg_v1, 'heart_rate': self.heart_rate,
                  'o2': self.o2, 'temperature': self.temperature}
        self.update_plots(**kwargs)

        self.sleep_time = sleep_time
        self.Bind(wx.EVT_CLOSE, self.on_close)
        self.__set_properties()
        self.setup_layout()
예제 #4
0
파일: Sensors.py 프로젝트: ATElve/FellesLab
    def __init__(self, parent=None, *args, **kwargs):
        """
        Constructor
        """
        super(FellesPlot, self).__init__(parent)

        self.parentFrame = parent  # Parent SensorFrame (from SensorGUI.py)
        self.candidates = self.parentFrame.sensors
        self.first_time = True

        # setting up plot
        self.plot_panel = wxmplot.PlotPanel(parent=self,
                                            size=(500, 500),
                                            dpi=100)

        self.plot_panel.set_xlabel('time')
        self.plot_panel.set_ylabel(self.parentFrame.GetLabel())
        #        self.plot_panel.set_y2label(label)
        self.plot_panel.set_title(self.parentFrame.GetLabel())

        #         plotpanel.unzoom()
        #         plotpanel.unzoom_all()
        #         plotpanel.set_title(title)
        #         plotpanel.set_bgcol(color)
        #         plotpanel.write_message(message)

        # adding sizer
        self.panel_sizer = wx.BoxSizer()
        self.panel_sizer.Add(self.plot_panel)

        # assigning the sizer to the panel
        self.SetSizer(self.panel_sizer)

        # plotIDs keeps track over which sensor to plot.
        #      ID            bool  ,       ID          bool
        # {'0x7f921e6977a0': False , '0x7f921e696530': True }
        # (The ID is the address in memory of the sensor object)
        self.plotIDs = {c.GetID(): c['plot'] for c in self.candidates}

        # fit the sizer to the panel
        self.Fit()

        wx.EVT_CLOSE(self, self.OnClose)
        pub.subscribe(self.OnClose, 'Close.%s' % self.parentFrame.GetLabel())
        pub.subscribe(self.UpdatePlot, 'Plot.%s' % self.parentFrame.GetLabel())
예제 #5
0
    def __init__(self, parent, title):
        """
        The application will be made in this function. The style will be adjusted to make it user friendly. Only the
        necessary parameters will be shown in the application. The data, which is used as input data, is obtained by
        tests.
        """

        # Create the main frame
        wx.Frame.__init__(self,
                          parent,
                          title=title,
                          style=wx.DEFAULT_FRAME_STYLE
                          & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX),
                          size=(900, 450))
        self.top_panel = wx.Panel(self)
        self.SetBackgroundColour("white")

        # Create the file menu
        file_menu = wx.Menu()
        menu_about = file_menu.Append(wx.ID_ABOUT, "&About",
                                      "Information about this program")
        file_menu.AppendSeparator()
        menu_exit = file_menu.Append(wx.ID_EXIT, "E&xit",
                                     "Terminate the program")

        # Create the menu bar
        menu_bar = wx.MenuBar()
        menu_bar.Append(file_menu, "&File")
        self.SetMenuBar(menu_bar)

        # Creating buttons to reset or Exit the application
        self.exit_button = wx.Button(self.top_panel,
                                     -1,
                                     label='Exit',
                                     pos=(350, 320),
                                     size=(100, 30))
        self.reset_button = wx.Button(self.top_panel,
                                      -1,
                                      label='Reset',
                                      pos=(350, 288),
                                      size=(100, 30))

        # Loading image for the Tacx logo, placement of this photo will also be done right here.
        try:
            base_path = sys._MEIPASS
        except Exception:
            base_path = path.abspath('.')
        image_path = path.join(base_path, 'tacx-logo.png')

        image_file_png = wx.Image(image_path, wx.BITMAP_TYPE_PNG)
        image_file_png.Rescale(image_file_png.GetWidth() * 0.15,
                               image_file_png.GetHeight() * 0.15)
        image_file_png = wx.Bitmap(image_file_png)
        self.image = wx.StaticBitmap(self.top_panel,
                                     -1,
                                     image_file_png,
                                     pos=(340, 210),
                                     size=(image_file_png.GetWidth(),
                                           image_file_png.GetHeight()))

        # Creating panels: Every panel and text, which is shown in the application, is created in this piece of code.
        # Firstly, some font are specified to make the text more dynamic and clean.
        self.font_header = wx.Font(12,
                                   family=wx.FONTFAMILY_DECORATIVE,
                                   style=wx.FONTSTYLE_NORMAL,
                                   weight=wx.FONTWEIGHT_BOLD)
        self.font_header_1 = wx.Font(10,
                                     family=wx.FONTFAMILY_DECORATIVE,
                                     style=wx.FONTSTYLE_NORMAL,
                                     weight=wx.FONTWEIGHT_BOLD)
        self.font_normal = wx.Font(10,
                                   family=wx.FONTFAMILY_DECORATIVE,
                                   style=wx.FONTSTYLE_NORMAL,
                                   weight=wx.FONTWEIGHT_NORMAL)
        self.font_big = wx.Font(12,
                                family=wx.FONTFAMILY_DECORATIVE,
                                style=wx.FONTSTYLE_NORMAL,
                                weight=wx.FONTWEIGHT_NORMAL)
        self.statistics_titles = ["Diameter Roller", "Sink Depth Roller"]

        for i in range(len(self.statistics_titles)):
            self.data_panel = wx.Panel(self.top_panel,
                                       -1,
                                       size=(465, 100),
                                       pos=(10, 10 + (1.2 * i) * 60))
            self.data_panel_header = wx.StaticText(
                self.data_panel, label=self.statistics_titles[i], pos=(4, 2))
            if i == 0:
                self.slider_1 = wx.Slider(self.data_panel,
                                          -1,
                                          30,
                                          30,
                                          60,
                                          pos=(0, 25),
                                          size=(300, -1),
                                          style=wx.SL_HORIZONTAL
                                          | wx.SL_AUTOTICKS)
                self.slider_1.SetTickFreq(10)
                self.panel_output_1 = wx.Panel(self.data_panel,
                                               -1,
                                               style=wx.BORDER_SUNKEN,
                                               size=(40, 27),
                                               pos=(350, 20))
                self.text_1 = wx.StaticText(self.data_panel,
                                            label='mm',
                                            pos=(395, 23))
                self.text_1.SetFont(self.font_big)
                self.data_panel_slider_1 = wx.StaticText(self.panel_output_1,
                                                         label='30',
                                                         pos=(4, 2))
                self.data_panel_slider_1.SetFont(self.font_big)
            if i == 1:
                # TODO: AANPASSEN ALS WE DE ECHTE INDRUKKING WETEN
                self.slider_2 = wx.Slider(self.data_panel,
                                          -1,
                                          30,
                                          10,
                                          70,
                                          pos=(0, 25),
                                          size=(300, -1),
                                          style=wx.SL_HORIZONTAL
                                          | wx.SL_AUTOTICKS)
                self.slider_2.SetTickFreq(10)
                self.panel_output_2 = wx.Panel(self.data_panel,
                                               -1,
                                               style=wx.BORDER_SUNKEN,
                                               size=(40, 27),
                                               pos=(350, 20))
                self.text_1 = wx.StaticText(self.data_panel,
                                            label='mm',
                                            pos=(395, 23))
                self.text_1.SetFont(self.font_big)
                self.data_panel_slider_2 = wx.StaticText(self.panel_output_2,
                                                         label='3',
                                                         pos=(4, 2))
                self.data_panel_slider_2.SetFont(self.font_big)
            self.data_panel_header.SetFont(self.font_header)

        self.output_panel = wx.Panel(self.top_panel,
                                     -1,
                                     style=wx.BORDER_RAISED,
                                     size=(305, 160),
                                     pos=(10, 190))
        self.text = wx.StaticText(self.output_panel,
                                  label='Static Friction Force:',
                                  pos=(14, 21))
        self.text.SetFont(self.font_header_1)
        self.text = wx.StaticText(self.output_panel,
                                  label='Max. Rolling Resistance:',
                                  pos=(14, 118))
        self.text.SetFont(self.font_header_1)
        self.text = wx.StaticText(self.output_panel,
                                  label='Normal Force (Static): \n',
                                  pos=(14, 70))
        self.text.SetFont(self.font_header_1)
        self.panel_output_3 = wx.Panel(self.output_panel,
                                       -1,
                                       style=wx.BORDER_SUNKEN,
                                       size=(55, 27),
                                       pos=(220, 17))
        self.data_output_text = wx.StaticText(self.output_panel,
                                              label='N',
                                              pos=(280, 21))
        self.data_output_text.SetFont(self.font_big)
        self.data_panel_friction = wx.StaticText(self.panel_output_3,
                                                 label='30',
                                                 pos=(4, 2))
        self.data_panel_friction.SetFont(self.font_big)

        self.panel_output_4 = wx.Panel(self.output_panel,
                                       -1,
                                       style=wx.BORDER_SUNKEN,
                                       size=(55, 27),
                                       pos=(220, 65))
        self.data_output_text = wx.StaticText(self.output_panel,
                                              label='N',
                                              pos=(280, 69))
        self.data_output_text.SetFont(self.font_big)
        self.data_panel_normal_force = wx.StaticText(self.panel_output_4,
                                                     label='300',
                                                     pos=(4, 2))
        self.data_panel_normal_force.SetFont(self.font_big)

        self.panel_output_5 = wx.Panel(self.output_panel,
                                       -1,
                                       style=wx.BORDER_SUNKEN,
                                       size=(55, 27),
                                       pos=(220, 113))
        self.data_output_text = wx.StaticText(self.output_panel,
                                              label='N',
                                              pos=(280, 117))
        self.data_output_text.SetFont(self.font_big)
        self.data_panel_resistance = wx.StaticText(self.panel_output_5,
                                                   label='30',
                                                   pos=(4, 2))
        self.data_panel_resistance.SetFont(self.font_big)

        # Set start-up message
        welcome_dialog = wx.MessageDialog(
            self.top_panel,
            message=
            "Welcome to the Tacx design tool. \nIf you have read the README.pdf, you're good to go. \nIf you haven't yet, please do.",
            caption="Welcome!")
        welcome_dialog.CenterOnParent()
        if welcome_dialog.ShowModal() == wx.OK:
            welcome_dialog.Destroy()
            return

        # Create status bar
        self.statusbar = self.CreateStatusBar()
        self.statusbar.SetStatusText(
            'Right-click on graph for zooming / graph options')
        self.top_panel.Bind(wx.EVT_ENTER_WINDOW, self.on_graph_hover)

        # Create parameter which contains all the tested data. These are the parameters which are fixed and will be
        # used to test the traction and resistance.
        # TODO: ALLES AANPASSEN NAAR RESULTATEN EN DE GEBRUIKTE PARAMETERS ALS DEZE BESCHIKBAAR ZIJN
        self.speed = [5, 10, 15, 20, 25, 30, 35, 40, 45]
        self.diameter = [30, 40, 50, 60]
        self.depth = [1, 2, 3, 4, 5, 6, 7]

        # Traction for each depth at each diameter
        # self.traction_dia_20mm = [4, 6, 8, 10, 12, 14, 16]
        self.traction_dia_30mm = [
            11.266, 43.93333333, 84.46666667, 119.2666667, 163.3333333, 216.96,
            275.3
        ]
        self.traction_dia_40mm = [
            21.93333333, 57.466666678, 91.8666666710, 143.733333312,
            192.133333314, 248, 293.3333333
        ]
        self.traction_dia_50mm = [
            22.533333337, 68.733333339, 111.266666711, 152.333333313,
            212.466666715, 274.266666717, 312.066666719
        ]
        self.traction_dia_60mm = [
            26.666666678, 56, 112.6, 164.133333314, 226.4, 273.466666718, 332.6
        ]
        # self.traction_dia_70mm = [9, 11, 13, 15, 17, 19, 21]
        self.traction = [
            self.traction_dia_30mm, self.traction_dia_40mm,
            self.traction_dia_50mm, self.traction_dia_60mm
        ]

        # Normal force for each depth at each diameter
        # self.force_dia_20mm = [4, 6, 8, 10, 12, 14, 16]
        self.force_dia_30mm = [
            11.26666667, 43.93333333, 84.46666667, 119.2666667, 163.3333333,
            174.89, 220.39
        ]
        self.force_dia_40mm = [
            11.37307032, 32.06725336, 53.20532321, 87.74184581, 120.0873348,
            156.2715823, 182.7387804
        ]
        self.force_dia_50mm = [
            11.52867162, 31.99875246, 52.65015343, 76.64450822, 104.592265,
            133.0657971, 165.8865233
        ]
        self.force_dia_60mm = [
            8.952508764, 18.97873809, 41.28210562, 61.14278179, 83.96557661,
            104.6252831, 130.4116396
        ]
        # self.force_dia_70mm = [9, 11, 13, 15, 17, 19, 21]
        self.force = [
            self.force_dia_30mm, self.force_dia_40mm, self.force_dia_50mm,
            self.force_dia_60mm
        ]

        # Resistance for each speed at a certain depth and diameter
        # self.resistance_dia_20mm_dept_1 = [0, 1, 1, 2, 3, 4]
        # self.resistance_dia_20mm_dept_2 = [0, 1, 2, 3, 4, 5]
        # self.resistance_dia_20mm_dept_3 = [0, 2, 3, 4, 5, 6]
        # self.resistance_dia_20mm_dept_4 = [0, 3, 4, 5, 6, 7]
        # self.resistance_dia_20mm_dept_5 = [0, 4, 5, 6, 7, 8]
        # self.resistance_dia_20mm_dept_6 = [0, 5, 6, 7, 8, 9]
        # self.resistance_dia_20mm_dept_7 = [0, 6, 7, 8, 9, 10]
        # self.resistance_dia_20mm = [self.resistance_dia_20mm_dept_1, self.resistance_dia_20mm_dept_2,
        #                             self.resistance_dia_20mm_dept_3, self.resistance_dia_20mm_dept_4,
        #                             self.resistance_dia_20mm_dept_5, self.resistance_dia_20mm_dept_6,
        #                             self.resistance_dia_20mm_dept_7]

        self.resistance_dia_30mm_dept_1 = self.resistance_at_diameter(
            0.86, 0.276)
        self.resistance_dia_30mm_dept_2 = self.resistance_at_diameter(
            1.29, 0.328)
        self.resistance_dia_30mm_dept_3 = self.resistance_at_diameter(
            2.47, 0.224)
        self.resistance_dia_30mm_dept_4 = self.resistance_at_diameter(
            3.39, 0.238)
        self.resistance_dia_30mm_dept_5 = self.resistance_at_diameter(
            5.09, 0.191)
        self.resistance_dia_30mm_dept_6 = self.resistance_at_diameter(
            5.46, 0.196)
        self.resistance_dia_30mm_dept_7 = self.resistance_at_diameter(
            8.1, 0.145)
        self.resistance_dia_30mm = [
            self.resistance_dia_30mm_dept_1, self.resistance_dia_30mm_dept_2,
            self.resistance_dia_30mm_dept_3, self.resistance_dia_30mm_dept_4,
            self.resistance_dia_30mm_dept_5, self.resistance_dia_30mm_dept_6,
            self.resistance_dia_30mm_dept_7
        ]

        self.resistance_dia_40mm_dept_1 = self.resistance_at_diameter(
            0.374, 0.425)
        self.resistance_dia_40mm_dept_2 = self.resistance_at_diameter(
            1.31, 0.247)
        self.resistance_dia_40mm_dept_3 = self.resistance_at_diameter(
            2.29, 0.238)
        self.resistance_dia_40mm_dept_4 = self.resistance_at_diameter(
            3.05, 0.238)
        self.resistance_dia_40mm_dept_5 = self.resistance_at_diameter(
            6.08, 0.13)
        self.resistance_dia_40mm_dept_6 = self.resistance_at_diameter(
            5.46, 0.196)
        self.resistance_dia_40mm_dept_7 = self.resistance_at_diameter(
            8.1, 0.145)
        self.resistance_dia_40mm = [
            self.resistance_dia_40mm_dept_1, self.resistance_dia_40mm_dept_2,
            self.resistance_dia_40mm_dept_3, self.resistance_dia_40mm_dept_4,
            self.resistance_dia_40mm_dept_5, self.resistance_dia_40mm_dept_6,
            self.resistance_dia_40mm_dept_7
        ]

        self.resistance_dia_50mmm_dept_1 = self.resistance_at_diameter(
            0.894 / 2, 0.246)
        self.resistance_dia_50mmm_dept_2 = self.resistance_at_diameter(
            0.894, 0.246)
        self.resistance_dia_50mmm_dept_3 = self.resistance_at_diameter(
            1.36, 0.278)
        self.resistance_dia_50mmm_dept_4 = self.resistance_at_diameter(
            2.27, 0.232)
        self.resistance_dia_50mmm_dept_5 = self.resistance_at_diameter(
            3.47, 0.203)
        self.resistance_dia_50mmm_dept_6 = self.resistance_at_diameter(
            4.7, 0.184)
        self.resistance_dia_50mmm_dept_7 = self.resistance_at_diameter(
            5.99, 0.172)
        self.resistance_dia_50mm = [
            self.resistance_dia_50mmm_dept_1, self.resistance_dia_50mmm_dept_2,
            self.resistance_dia_50mmm_dept_3, self.resistance_dia_50mmm_dept_4,
            self.resistance_dia_50mmm_dept_5, self.resistance_dia_50mmm_dept_6,
            self.resistance_dia_50mmm_dept_7
        ]

        self.resistance_dia_60mmm_dept_1 = self.resistance_at_diameter(
            0.129, 0.538)
        self.resistance_dia_60mmm_dept_2 = self.resistance_at_diameter(
            0.364, 0.446)
        self.resistance_dia_60mmm_dept_3 = self.resistance_at_diameter(
            1.35, 0.222)
        self.resistance_dia_60mmm_dept_4 = self.resistance_at_diameter(
            1.92, 0.26)
        self.resistance_dia_60mmm_dept_5 = self.resistance_at_diameter(
            3.03, 0.211)
        self.resistance_dia_60mmm_dept_6 = self.resistance_at_diameter(
            4.4, 0.171)
        self.resistance_dia_60mmm_dept_7 = self.resistance_at_diameter(
            5.57, 0.168)
        self.resistance_dia_60mm = [
            self.resistance_dia_60mmm_dept_1, self.resistance_dia_60mmm_dept_2,
            self.resistance_dia_60mmm_dept_3, self.resistance_dia_60mmm_dept_4,
            self.resistance_dia_60mmm_dept_5, self.resistance_dia_60mmm_dept_6,
            self.resistance_dia_60mmm_dept_7
        ]

        # self.resistance_dia_70mmm_dept_1 = [0, 5, 6, 7, 8, 9]
        # self.resistance_dia_70mmm_dept_2 = [0, 6, 7, 8, 9, 10]
        # self.resistance_dia_70mmm_dept_3 = [0, 7, 8, 9, 10, 11]
        # self.resistance_dia_70mmm_dept_4 = [0, 8, 9, 10, 11, 12]
        # self.resistance_dia_70mmm_dept_5 = [0, 9, 10, 11, 12, 13]
        # self.resistance_dia_70mmm_dept_6 = [0, 10, 11, 12, 13, 14]
        # self.resistance_dia_70mmm_dept_7 = [0, 11, 12, 13, 14, 15]
        # self.resistance_dia_70mm = [self.resistance_dia_70mmm_dept_1, self.resistance_dia_70mmm_dept_2,
        #                             self.resistance_dia_70mmm_dept_3, self.resistance_dia_70mmm_dept_4,
        #                             self.resistance_dia_70mmm_dept_5, self.resistance_dia_70mmm_dept_6,
        #                             self.resistance_dia_70mmm_dept_7]

        self.resistance = [
            self.resistance_dia_30mm, self.resistance_dia_40mm,
            self.resistance_dia_50mm, self.resistance_dia_60mm
        ]

        # Set events
        self.Bind(wx.EVT_MENU, self.on_about, menu_about)
        self.Bind(wx.EVT_MENU, self.on_exit, menu_exit)
        self.Bind(wx.EVT_SLIDER, self.on_slider_1, self.slider_1)
        self.Bind(wx.EVT_SLIDER, self.on_slider_2, self.slider_2)
        self.exit_button.Bind(wx.EVT_BUTTON, self.on_exit_button)
        self.exit_button.Bind(wx.EVT_ENTER_WINDOW, self.on_exit_widget_enter)
        self.reset_button.Bind(wx.EVT_BUTTON, self.on_reset)
        self.reset_button.Bind(wx.EVT_ENTER_WINDOW, self.on_reset_widget_enter)

        # Some variables needed
        self.value_slider_1 = self.slider_1.GetValue()
        self.value_slider_2 = self.slider_2.GetValue() / 10
        self.begin = True
        self.interpolation()

        # Create initial plot
        self.figure_panel = wx.Panel(self.top_panel,
                                     -1,
                                     size=(400, 400),
                                     pos=(480, -20))
        self.figure_panel.SetBackgroundColour((255, 255, 255))
        self.figure = wxmplot.PlotPanel(self.figure_panel,
                                        size=(400, 400),
                                        dpi=100,
                                        fontsize=2,
                                        axisbg='#FFFFFF')
        self.figure.oplot(numpy.array(self.speed),
                          numpy.array(self.rolling_resistance),
                          framecolor='white',
                          xmin=0,
                          xmax=50,
                          ymin=0,
                          ymax=16)

        # Figure cosmetics
        self.figure.set_xlabel("Velocity [km/h]")
        self.figure.set_ylabel("Rolling resistance [N]")
예제 #6
0
    def __init__(self, parent, title):
        """
        The application will be made in this function. The style will be adjusted to make it user friendly. Only the
        necessary parameters will be shown in the application. The data, which is used as input data, is obtained by
        tests.
        """

        # Create the main frame
        wx.Frame.__init__(self, parent, title=title,
                          style=wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX), size=(900, 450))
        self.top_panel = wx.Panel(self)
        self.SetBackgroundColour("white")

        # Create the file menu
        file_menu = wx.Menu()
        menu_about = file_menu.Append(wx.ID_ABOUT, "&About", "Information about this program")
        file_menu.AppendSeparator()
        menu_exit = file_menu.Append(wx.ID_EXIT, "E&xit", "Terminate the program")

        # Create the menu bar
        menu_bar = wx.MenuBar()
        menu_bar.Append(file_menu, "&File")
        self.SetMenuBar(menu_bar)

        # Creating buttons to reset or Exit the application
        self.exit_button = wx.Button(self.top_panel, -1, label='Exit', pos=(350, 320), size=(100, 30))
        self.reset_button = wx.Button(self.top_panel, -1, label='Reset', pos=(350, 288), size=(100, 30))

        # Loading image for the Tacx logo, placement of this photo will also be done right here.
        try:
            base_path = sys._MEIPASS
        except Exception:
            base_path = path.abspath('.')
        image_path = path.join(base_path, 'tacx-logo.png')

        image_file_png = wx.Image(image_path, wx.BITMAP_TYPE_PNG)
        image_file_png.Rescale(image_file_png.GetWidth() * 0.15, image_file_png.GetHeight() * 0.15)
        image_file_png = wx.Bitmap(image_file_png)
        self.image = wx.StaticBitmap(self.top_panel, -1, image_file_png, pos=(340, 210),
                                     size=(image_file_png.GetWidth(), image_file_png.GetHeight()))

        # Creating panels: Every panel and text, which is shown in the application, is created in this piece of code.
        # Firstly, some font are specified to make the text more dynamic and clean.
        self.font_header = wx.Font(12, family=wx.FONTFAMILY_DECORATIVE, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD)
        self.font_header_1 = wx.Font(10, family=wx.FONTFAMILY_DECORATIVE, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD)
        self.font_normal = wx.Font(10, family=wx.FONTFAMILY_DECORATIVE, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL)
        self.font_big = wx.Font(12, family=wx.FONTFAMILY_DECORATIVE, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL)
        self.statistics_titles = ["Roller diameter", "Sinking depth roller"]

        for i in range(len(self.statistics_titles)):
            self.data_panel = wx.Panel(self.top_panel, -1, size=(465, 100), pos=(10, 10 + (1.2*i) * 60))
            self.data_panel_header = wx.StaticText(self.data_panel, label=self.statistics_titles[i], pos=(4, 2))
            if i == 0:
                self.slider_1 = wx.Slider(self.data_panel, -1, 30, 20, 70, pos=(0, 25), size=(300, -1), style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS)
                self.slider_1.SetTickFreq(10)
                self.panel_output_1 = wx.Panel(self.data_panel, -1, style=wx.BORDER_SUNKEN, size=(40, 27), pos=(350, 20))
                self.text_1 = wx.StaticText(self.data_panel, label='mm', pos=(395, 23))
                self.text_1.SetFont(self.font_big)
                self.data_panel_slider_1 = wx.StaticText(self.panel_output_1, label='30', pos=(14, 2))
                self.data_panel_slider_1.SetFont(self.font_big)
            if i == 1:
                self.slider_2 = wx.Slider(self.data_panel, -1, 400, 200, 800, pos=(0, 25), size=(300, -1), style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS)
                self.panel_output_2 = wx.Panel(self.data_panel, -1, style=wx.BORDER_SUNKEN, size=(40, 27), pos=(350, 20))
                self.text_1 = wx.StaticText(self.data_panel, label='N', pos=(395, 23))

                # TODO: AANPASSEN ALS WE DE ECHTE INDRUKKING WETEN
                self.slider_2 = wx.Slider(self.data_panel, -1, 3, 1, 7, pos=(0, 25), size=(300, -1), style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS)
                self.slider_2.SetTickFreq(1)
                self.panel_output_2 = wx.Panel(self.data_panel, -1, style=wx.BORDER_SUNKEN, size=(40, 27), pos=(350, 20))
                self.text_1 = wx.StaticText(self.data_panel, label='mm', pos=(395, 23))
                self.text_1.SetFont(self.font_big)
                self.data_panel_slider_2 = wx.StaticText(self.panel_output_2, label='3', pos=(22, 2))
                self.data_panel_slider_2.SetFont(self.font_big)
            self.data_panel_header.SetFont(self.font_header)

        self.output_panel = wx.Panel(self.top_panel, -1, style=wx.BORDER_RAISED, size=(305, 160), pos=(10, 190))
        self.text = wx.StaticText(self.output_panel, label='friction force: \n(bigger = better)', pos=(14, 12))
        self.text.SetFont(self.font_header_1)
        self.text = wx.StaticText(self.output_panel, label='Max rolling resistance: \n(smaller = better)', pos=(14, 108))
        self.text.SetFont(self.font_header_1)
        self.text = wx.StaticText(self.output_panel, label='Normal force: \n(bigger = better)', pos=(14, 60))
        self.text.SetFont(self.font_header_1)
        self.panel_output_3 = wx.Panel(self.output_panel, -1, style=wx.BORDER_SUNKEN, size=(45, 27), pos=(230, 17))
        self.data_output_text = wx.StaticText(self.output_panel, label='N', pos=(280, 21))
        self.data_output_text.SetFont(self.font_big)
        self.data_panel_friction= wx.StaticText(self.panel_output_3, label='30', pos=(4, 2))
        self.data_panel_friction.SetFont(self.font_big)

        self.panel_output_4 = wx.Panel(self.output_panel, -1, style=wx.BORDER_SUNKEN, size=(45, 27), pos=(230, 65))
        self.data_output_text = wx.StaticText(self.output_panel, label='N', pos=(280, 69))
        self.data_output_text.SetFont(self.font_big)
        self.data_panel_normal_force = wx.StaticText(self.panel_output_4, label='300', pos=(4, 2))
        self.data_panel_normal_force.SetFont(self.font_big)

        self.panel_output_5 = wx.Panel(self.output_panel, -1, style=wx.BORDER_SUNKEN, size=(45, 27), pos=(230, 113))
        self.data_output_text = wx.StaticText(self.output_panel, label='N', pos=(280, 117))
        self.data_output_text.SetFont(self.font_big)
        self.data_panel_resistance = wx.StaticText(self.panel_output_5, label='30', pos=(4, 2))
        self.data_panel_resistance.SetFont(self.font_big)

        # Set start-up message
        welcome_dialog = wx.MessageDialog(self.top_panel,
                                          message="Welcome to the Tacx design tool. \nIf you have read the README.pdf, you're good to go. \nIf you haven't yet, please do.",
                                          caption="Welcome!")
        welcome_dialog.CenterOnParent()
        if welcome_dialog.ShowModal() == wx.OK:
            welcome_dialog.Destroy()
            return

        # Create status bar
        self.statusbar = self.CreateStatusBar()

        # Create parameter which contains all the tested data. These are the parameters which are fixed and will be
        # used to test the traction and resistance.
        # TODO: ALLES AANPASSEN NAAR RESULTATEN EN DE GEBRUIKTE PARAMETERS ALS DEZE BESCHIKBAAR ZIJN
        self.speed = [5, 10, 20, 30, 40, 50]
        self.diameter = [20, 30, 40, 50, 60, 70]
        self.depth = [1, 2, 3, 4, 5, 6, 7]

        # Traction for each depth at each diameter
        self.traction_dia_20mm = [4, 6, 8, 10, 12, 14, 16]
        self.traction_dia_30mm = [5, 7, 9, 11, 13, 15, 17]
        self.traction_dia_40mm = [6, 8, 10, 12, 14, 16, 18]
        self.traction_dia_50mm = [7, 9, 11, 13, 15, 17, 19]
        self.traction_dia_60mm = [8, 10, 12, 14, 16, 18, 20]
        self.traction_dia_70mm = [9, 11, 13, 15, 17, 19, 21]
        self.traction = [self.traction_dia_20mm, self.traction_dia_30mm, self.traction_dia_40mm, self.traction_dia_50mm,
                         self.traction_dia_60mm, self.traction_dia_70mm]

        # Resistance for each speed at a certain depth and diameter
        self.resistance_dia_20mm_dept_1 = [0, 1, 1, 2, 3, 4]
        self.resistance_dia_20mm_dept_2 = [0, 1, 2, 3, 4, 5]
        self.resistance_dia_20mm_dept_3 = [0, 2, 3, 4, 5, 6]
        self.resistance_dia_20mm_dept_4 = [0, 3, 4, 5, 6, 7]
        self.resistance_dia_20mm_dept_5 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_20mm_dept_6 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_20mm_dept_7 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_20mm = [self.resistance_dia_20mm_dept_1, self.resistance_dia_20mm_dept_2,
                                    self.resistance_dia_20mm_dept_3, self.resistance_dia_20mm_dept_4,
                                    self.resistance_dia_20mm_dept_5, self.resistance_dia_20mm_dept_6,
                                    self.resistance_dia_20mm_dept_7]

        self.resistance_dia_30mm_dept_1 = [0, 1, 2, 3, 4, 5]
        self.resistance_dia_30mm_dept_2 = [0, 2, 3, 4, 5, 6]
        self.resistance_dia_30mm_dept_3 = [0, 3, 4, 5, 6, 7]
        self.resistance_dia_30mm_dept_4 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_30mm_dept_5 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_30mm_dept_6 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_30mm_dept_7 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_30mm = [self.resistance_dia_30mm_dept_1, self.resistance_dia_30mm_dept_2,
                                    self.resistance_dia_30mm_dept_3, self.resistance_dia_30mm_dept_4,
                                    self.resistance_dia_30mm_dept_5, self.resistance_dia_30mm_dept_6,
                                    self.resistance_dia_30mm_dept_7]

        self.resistance_dia_40mm_dept_1 = [0, 2, 3, 4, 5, 6]
        self.resistance_dia_40mm_dept_2 = [0, 3, 4, 5, 6, 7]
        self.resistance_dia_40mm_dept_3 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_40mm_dept_4 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_40mm_dept_5 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_40mm_dept_6 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_40mm_dept_7 = [0, 8, 9, 10, 11, 12]
        self.resistance_dia_40mm = [self.resistance_dia_40mm_dept_1, self.resistance_dia_40mm_dept_2,
                                    self.resistance_dia_40mm_dept_3, self.resistance_dia_40mm_dept_4,
                                    self.resistance_dia_40mm_dept_5, self.resistance_dia_40mm_dept_6,
                                    self.resistance_dia_40mm_dept_7]

        self.resistance_dia_50mmm_dept_1 = [0, 3, 4, 5, 6, 7]
        self.resistance_dia_50mmm_dept_2 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_50mmm_dept_3 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_50mmm_dept_4 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_50mmm_dept_5 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_50mmm_dept_6 = [0, 8, 9, 10, 11, 12]
        self.resistance_dia_50mmm_dept_7 = [0, 9, 10, 11, 12, 13]
        self.resistance_dia_50mm = [self.resistance_dia_50mmm_dept_1, self.resistance_dia_50mmm_dept_2,
                                    self.resistance_dia_50mmm_dept_3, self.resistance_dia_50mmm_dept_4,
                                    self.resistance_dia_50mmm_dept_5, self.resistance_dia_50mmm_dept_6,
                                    self.resistance_dia_50mmm_dept_7]

        self.resistance_dia_60mmm_dept_1 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_60mmm_dept_2 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_60mmm_dept_3 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_60mmm_dept_4 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_60mmm_dept_5 = [0, 8, 9, 10, 11, 12]
        self.resistance_dia_60mmm_dept_6 = [0, 9, 10, 11, 12, 13]
        self.resistance_dia_60mmm_dept_7 = [0, 10, 11, 12, 13, 14]
        self.resistance_dia_60mm = [self.resistance_dia_60mmm_dept_1, self.resistance_dia_60mmm_dept_2,
                                    self.resistance_dia_60mmm_dept_3, self.resistance_dia_60mmm_dept_4,
                                    self.resistance_dia_60mmm_dept_5, self.resistance_dia_60mmm_dept_6,
                                    self.resistance_dia_60mmm_dept_7]

        self.resistance_dia_70mmm_dept_1 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_70mmm_dept_2 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_70mmm_dept_3 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_70mmm_dept_4 = [0, 8, 9, 10, 11, 12]
        self.resistance_dia_70mmm_dept_5 = [0, 9, 10, 11, 12, 13]
        self.resistance_dia_70mmm_dept_6 = [0, 10, 11, 12, 13, 14]
        self.resistance_dia_70mmm_dept_7 = [0, 11, 12, 13, 14, 15]
        self.resistance_dia_70mm = [self.resistance_dia_70mmm_dept_1, self.resistance_dia_70mmm_dept_2,
                                    self.resistance_dia_70mmm_dept_3, self.resistance_dia_70mmm_dept_4,
                                    self.resistance_dia_70mmm_dept_5, self.resistance_dia_70mmm_dept_6,
                                    self.resistance_dia_70mmm_dept_7]

        self.resistance = [self.resistance_dia_20mm, self.resistance_dia_30mm, self.resistance_dia_40mm,
                           self.resistance_dia_50mm, self.resistance_dia_60mm, self.resistance_dia_70mm]

        self.force = [200, 300, 400, 500, 600, 700, 800]

        # Set events
        self.Bind(wx.EVT_MENU, self.on_about, menu_about)
        self.Bind(wx.EVT_MENU, self.on_exit, menu_exit)
        self.Bind(wx.EVT_SLIDER, self.on_slider_1, self.slider_1)
        self.Bind(wx.EVT_SLIDER, self.on_slider_2, self.slider_2)
        self.exit_button.Bind(wx.EVT_BUTTON, self.on_exit_button)
        self.exit_button.Bind(wx.EVT_ENTER_WINDOW, self.on_exit_widget_enter)
        self.reset_button.Bind(wx.EVT_BUTTON, self.on_reset)
        self.reset_button.Bind(wx.EVT_ENTER_WINDOW, self.on_reset_widget_enter)

        # Some variables needed
        self.value_slider_1 = self.slider_1.GetValue()
        self.value_slider_2 = self.slider_2.GetValue()
        self.begin = True
        self.interpolation()

        # Create initial plot
        self.figure_panel = wx.Panel(self.top_panel, -1, size=(400, 400), pos=(480, -20))
        self.figure_panel.SetBackgroundColour((255, 255, 255))
        self.figure = wxmplot.PlotPanel(self.figure_panel, size=(400, 400), dpi=100, fontsize=2, axisbg='#FFFFFF')
        self.figure.oplot(array(self.speed), array(self.rolling_resistance), framecolor='white')

        # Figure cosmetics
        self.figure.set_xlabel("Velocity [km/h]")
        self.figure.set_ylabel("Rolling resistance [N]")