def __init__(self, **kwargs):
        super(case, self).__init__(**kwargs)
        box = FloatLayout()
        graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,
            x_ticks_major=25, y_ticks_major=1,
            y_grid_label=True, x_grid_label=True, padding=5,
            x_grid=True, y_grid=True, xmin=-0, xmax=20, ymin=0, ymax=10)
        plot = LinePlot()
        # plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]

        # data = np.array([[0,0], [1,1],[2,2]])

        data = collections.deque(maxlen = 20)
        time = collections.deque(maxlen = 20)

        d = (0,1,2,3,4,5,6,7,8,9)
        t = (0,1,2,3,4,5,6,7,8,9)

        data.append(d)
        time.append(t)

        toplot = np.vstack((time,data)).T

        print toplot

        plot.points = tuple(map(tuple, toplot))

        graph.add_plot(plot)
        box.add_widget(graph)

        self.add_widget(box)
Beispiel #2
0
class ChartThrottle(Graph):
    poin = ListProperty([])
    xlabel = StringProperty("")
    ylabel = StringProperty("")
    x_ticks_minor = NumericProperty(0)
    x_ticks_major = NumericProperty(10)
    y_ticks_major = NumericProperty(10)
    y_ticks_minor = NumericProperty(2)
    y_grid_label = BooleanProperty(True)
    x_grid_label = BooleanProperty(False)
    x_grid = BooleanProperty(False)
    y_grid = BooleanProperty(True)
    xmin = NumericProperty(0)
    xmax = NumericProperty(50)
    ymin = NumericProperty(0)
    ymax = NumericProperty(100)
    label_options = DictProperty({'color': [0, 1, 1, 1], 'bold': False})
    border_color = ListProperty([0, 1, 1, .1])
    tick_color = ListProperty([1, 1, 1, 1])
    plot_pressure = LinePlot(color=[1, 0, 0, 1], line_width=1.5)
    plot_batt = LinePlot(color=[1, 1, 0, 1], line_width=1.5)
    plot_pressure.points = [(0, 0)]
    plot_batt.points = [(0, 0)]

    def __init__(self, *args, **kwargs):
        super(ChartThrottle, self).__init__(*args, **kwargs)
        self.add_plot(self.plot_pressure)
        self.add_plot(self.plot_batt)
Beispiel #3
0
    def __init__(self):
        super(TestGUI, self).__init__()
        #Window.clearcolor = (1, 1, 1, 1)
        Window.clearcolor = (.14, .18, .2, 1)
        self.ser = serial.Serial()
        self.ser.port = '/dev/ttyUSB0'
        self.ser.baudrate = 115200

        self.setpoint_plot = LinePlot(line_width=2.5, color=[0, 1, 0.8, 1])
        self.act_pos_plot = LinePlot(line_width=2.5, color=[0, 1, 0.8, 1])

        self.ids.pos_graph.add_plot(self.setpoint_plot)
        self.ids.pos_graph.add_plot(self.act_pos_plot)

        self.setpoint_plot.color = [0, 1, 0.8, 1]
        self.act_pos_plot.color = [0.2196, 0.6431, 0.8, 1]

        self.graph_clock = Clock.schedule_interval(self.get_plot_points,
                                                   (1 / 100))
        self.graph_clock.cancel()
        self.slider_clock = Clock.schedule_interval(self.pid_listener,
                                                    (1 / 10))

        self.q = Queue()
        self.dt = 0
        self.ts = Queue()
        self.maxt = 1000
        self.tdata = [0]
        self.ydata = [0]
Beispiel #4
0
    def addGraph(self,datapoint,xData,yData,dt):
        points = [t for t in zip((xData).astype(int),yData)];
        ymin = int(min(yData))
        ymax = int(max(yData))
        xmin = int(min(xData))
        xmax = int(max(xData))

        if self.setMinMax :
            if self.ids.graph.ymin > ymin:
                self.ids.graph.ymin = ymin
            if self.ids.graph.ymax < ymax:
                self.ids.graph.ymax = ymax
            if self.ids.graph.xmin > xmin:
                self.ids.graph.xmin = xmin
            if self.ids.graph.xmax < xmax:
                self.ids.graph.xmax = xmax  
        else:
            self.ids.graph.ymin = ymin
            self.ids.graph.ymax = ymax
            self.ids.graph.xmin = xmin
            self.ids.graph.xmax = xmax  
            self.setMinMax = True

        plot = LinePlot(color=self.color)
        plot.points = points
        self.ids.graph.add_plot(plot)
        index = random.randint(0,3)
        btn1 = ToggleButton(text=datapoint,background_color=self.color)
        btn1.bind(state=partial(self.on_press,datapoint))
        cp = ColorPicker(color=self.color)
        cp.bind(color=partial(self.on_color,datapoint))
        self.plotdata[datapoint] = {'color':self.color,'button':btn1,'plot':plot,'colorpick':cp,'points':points}
        self.color[index]=self.color[index] - (random.random());
        self.ids.hBox.add_widget(btn1)
        self.ids.hBoxColor.add_widget(cp)
Beispiel #5
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.plot1 = LinePlot(color=[1., 0.65, 0., 1], line_width=1)
     self.plot2 = LinePlot(color=[1., 1., 0., 1], line_width=1)
     self.plot = LinePlot(color=[0., 0.29, 0.49, 1], line_width=3)
     self.__time = 0
     self.dt = 1 / 50000
     self.space = np.linspace(0, 1, 1000)
Beispiel #6
0
 def __init__(self, **kw):
     super(TEMPERATURE, self).__init__(**kw)
     self.graph_1 = LinePlot(line_width=1.2, color=[.62, .93, .25, 1])
     self.graph_2 = LinePlot(line_width=1.2, color=[.31, .42, .96, 1])
     self.graph_3 = LinePlot(line_width=1.2, color=[.96, .46, .21, 1])
     self.ids.graph.add_plot(self.graph_1)
     self.ids.graph.add_plot(self.graph_2)
     self.ids.graph.add_plot(self.graph_3)
Beispiel #7
0
    def __init__(self, **kwargs):
        super(PowerGraph, self).__init__(**kwargs)

        plot = LinePlot(color=BLUE)
        plot.points = state.power_history.points
        self.add_plot(plot)

        self.plot = plot
        Clock.schedule_interval(self.update, UPDATE_INTERVAL)
Beispiel #8
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.orientation = 'vertical'
     self.plot_pressure = LinePlot(color=[1, 0, 0, 1], line_width=2)
     self.plot_flow = LinePlot(color=[1, 0, 0, 1], line_width=2)
     self.plot_volume = LinePlot(color=[1, 0, 0, 1], line_width=2)
     self.data = {'time': [], 'pressure': [], 'flow': [], 'volume': []}
     threading.Thread(target=self.generate_data, daemon=True).start()
     self.start()
Beispiel #9
0
 def __init__(self, **kwargs):
     super(TidalVolume, self).__init__(**kwargs)
     self.tidalVolume = LinePlot(line_width=1.5, color=[0, 0, 1, 1])
     self.oldtidalVolume = LinePlot(line_width=1, color=[0, 0, 1, 0.2])
     self.add_plot(self.tidalVolume)
     self.add_plot(self.oldtidalVolume)
     self.ymax = 400
     self.ymin = 0
     self.xmax = graphTime
     Clock.schedule_interval(self.get_value, 0.001)
Beispiel #10
0
 def __init__(self, **kwargs):
     super(PeakPressure, self).__init__(**kwargs)
     self.peakPressure = LinePlot(line_width=1.5, color=[1, 0, 0, 1])
     self.oldpeakPressure = LinePlot(line_width=1, color=[1, 0, 0, 0.2])
     self.add_plot(self.peakPressure)
     self.add_plot(self.oldpeakPressure)
     self.ymax = 50
     self.ymin = 0
     self.xmax = graphTime
     Clock.schedule_interval(self.get_value, 0.001)
Beispiel #11
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.plot = LinePlot(color=[0., 0.29, 0.49, 1], line_width=2)
     self.sep = LinePlot(color=[1, 0, 0, 1], line_width=4)
     self.__time = 0
     self.dt = 1 / 50000
     self.omega = 2 * np.pi * self.frequency
     self.x1 = np.linspace(-2, 0, 1000)
     self.x2 = np.linspace(0, 2, 1000)
     self.xtot = np.concatenate([self.x1, self.x2])
Beispiel #12
0
	def update(self):
		global t, x

		ch, prob = onestep()
		for _y in range(lstm_size):
			widget = self.cells[_y].children[-1]
			self.cells[_y].remove_widget(widget)
			box = LstmCell(size_hint=(1.0/time_window, 1))
			box.paint_z(z[t][_y])
			box.paint_i(i[t][_y])
			box.paint_f(f[t][_y])
			box.paint_o(o[t][_y])
			box.paint_h(h[t][_y])
			box.paint_c(c[t][_y])
			#box.set_char(ch)
			self.cells[_y].add_widget(box)
		widget = self.characterArea.children[-1]
		self.characterArea.remove_widget(widget)
		ch = ' ' + ch + "\n" + str(round(prob, 2))
		self.characterArea.add_widget(MyLabel(text=ch, size_hint=(1.0/time_window, 1)))

		if dispEquations:
			myStr = ""
			for _y in range(lstm_size):
				myStr += 'z[t] = tanh([' + str(round(Wz[0][0], 2)) + ', ' + str(round(Wz[0][1], 2)) + '] · [' + str(int(x[0])) + ', ' + str(int(x[1])) + '].T + [' + str(round(Rz[0][0], 2)) + '] · [' + str(round(h[t-1], 2)) + '] + ' + str(round(bz, 2)) +') = tanh('+ str(round(z_, 2)) +') = ' + str(round(z[t], 2)) + "\n"
				myStr += 'i[t] = sig([' + str(round(Wi[0][0], 2)) + ', ' + str(round(Wi[0][1], 2)) + '] · [' + str(int(x[0])) + ', ' + str(int(x[1])) + '].T + [' + str(round(Ri[0][0], 2)) + '] · [' + str(round(h[t-1], 2)) + '] + '+ str(round(bi, 2)) +') = sig('+ str(round(i_, 2)) +') = ' + str(round(i[t], 2)) + "\n"
				myStr += 'f[t] = sig([' + str(round(Wf[0][0], 2)) + ', ' + str(round(Wf[0][1], 2)) + '] · [' + str(int(x[0])) + ', ' + str(int(x[1])) + '].T + [' + str(round(Rf[0][0], 2)) + '] · [' + str(round(h[t-1], 2)) + '] + '+ str(round(bf, 2)) +') = sig('+ str(round(f_, 2)) +') = ' + str(round(f[t], 2)) + "\n"
				myStr += 'c[t] = '+ str(round(i[t], 2)) +' * '+ str(round(z[t], 2)) +' + '+ str(round(f[t], 2)) +' * ' + str(round(c[t-1], 2)) + ' = ' + str(round(i[t] * z[t], 2)) + ' + ' + str(round(f[t] * c[t-1], 2)) + ' = ' + str(round(c[t], 2)) + "\n"
				myStr += 'o[t] = sig([' + str(round(Wo[0][0], 2)) + ', ' + str(round(Wo[0][1], 2)) + '] · [' + str(int(x[0])) + ', ' + str(int(x[1])) + '].T + [' + str(round(Ro[0][0], 2)) + '] · [' + str(round(h[t-1], 2)) + '] + '+ str(round(bo, 2)) +') = sig('+ str(round(o_, 2)) +') = ' + str(round(o[t], 2)) + "\n"
				myStr += 'h[t] = tanh(' + str(round(c[t], 2)) + ') * ' + str(round(o[t], 2)) + ' = ' + str(round(tanh(c[t]) , 2)) + ' * ' + str(round(o[t], 2)) + ' = ' + str(round(h[t], 2)) + "\n"
				myStr += 'y[t] = [' + str(round(Wy[0][0], 2)) + ', ' + str(round(Wy[1][0], 2)) + '] · ' + str(round(h[t], 2)) + ' + [' + str(round(by[0], 2)) + ', ' + str(round(by[1], 2)) + '].T = [' + str(round(y[t][0], 2)) + ', ' + str(round(y[t][1], 2)) + '].T' + "\n"
				myStr += 'Input: [' + str(int(x[0])) + ', ' + str(int(x[1])) + '] --> Output: [' + str(int(x_next[0])) + ', ' + str(int(x_next[1])) + ']'
			self.equationArea.text = myStr

		for _y in range(lstm_size):
			self.graphs[_y].xmin = t - time_window
			self.graphs[_y].xmax = t

			for plot in self.graphs[_y].plots:
				self.graphs[_y].remove_plot(plot)

			ix = 1
			for v in (z, i, f, o, c, h):
				colors = [int(u) for u in bin(ix)[2:]]
				while len(colors) < 3:
					colors.insert(0, 0)
				ix += 1
				plot = LinePlot(color = colors, line_width = 2)
				plot.points = [(u, v[u][_y]) for u in range(max(0, t-time_window), t+1)]
				self.graphs[_y].add_plot(plot)

		t += 1
		return
    def change_points_over_time(self, graph):
        if self.plot_sys is not None and self.plot_dia is not None:
            graph.remove_plot(self.plot_dia)
            graph.remove_plot(self.plot_sys)

        dia_points = []
        sys_points = []

        if self.patient == 'Patient 1':
            patient1 = self.call_api('1')
            for x in range(patient1.get_timeStampsLength()):
                dia_points.append((x, patient1.get_diastolic(x)))
                sys_points.append((x, patient1.get_systolic(x)))

        elif self.patient == 'Patient 2':
            patient2 = self.call_api('2')
            for x in range(patient2.get_timeStampsLength()):
                dia_points.append((x, patient2.get_diastolic(x)))
                sys_points.append((x, patient2.get_systolic(x)))

        elif self.patient == 'Patient 3':
            patient3 = self.call_api('3')
            for x in range(patient3.get_timeStampsLength()):
                dia_points.append((x, patient3.get_diastolic(x)))
                sys_points.append((x, patient3.get_systolic(x)))

        elif self.patient == 'Patient 4':
            patient4 = self.call_api('4')
            for x in range(patient4.get_timeStampsLength()):
                dia_points.append((x, patient4.get_diastolic(x)))
                sys_points.append((x, patient4.get_systolic(x)))

        elif self.patient == 'Bob E Smith':
            patient5 = self.call_api('5')
            for x in range(patient5.get_timeStampsLength()):
                dia_points.append((x, patient5.get_diastolic(x)))
                sys_points.append((x, patient5.get_systolic(x)))
        else:
            patient6 = self.call_api('6')
            for x in range(patient6.get_timeStampsLength()):
                dia_points.append((x, patient6.get_diastolic(x)))
                sys_points.append((x, patient6.get_systolic(x)))

        self.plot_dia = LinePlot(color=[1, 0, 0, 1])
        self.plot_sys = LinePlot(color=[1, 0, 0, 1])

        self.plot_dia.points = dia_points
        self.plot_sys.points = sys_points

        graph.add_plot(self.plot_dia)
        graph.add_plot(self.plot_sys)
Beispiel #14
0
 def __init__(self, **kwargs):
     super(RespiratoryRate, self).__init__(**kwargs)
     self.respirationRate = LinePlot(line_width=1.5, color=[0, 0.5, 0, 1])
     self.oldrespirationRate = LinePlot(line_width=1,
                                        color=[0, 0.5, 0, 0.2])
     self.add_plot(self.respirationRate)
     self.add_plot(self.oldrespirationRate)
     self.ymax = 60
     self.ymin = -60
     self.xmax = graphTime
     Clock.schedule_interval(self.get_value, 0.001)
     get_level_thread = Thread(target=get_data)
     get_level_thread.daemon = True
     get_level_thread.start()
Beispiel #15
0
 def on_graph(self, instance, value):
     super(WaveDACPlot, self).on_graph(instance, value)
     self.graph.ylabel = 'Amplitude (V)'
     self.plot = LinePlot(color=(0.75, 0.4, 0.4, 1.0))
     self.plot.line_width = 2
     self.plot.points = zip(self.x_points, self.y_points)
     self.graph.add_plot(self.plot)
Beispiel #16
0
class PsiScreen(Screen):
    graph = Graph(xlabel=' ',
                  ylabel='',
                  x_ticks_minor=5,
                  x_ticks_major=0,
                  y_ticks_major=10,
                  y_ticks_minor=2,
                  y_grid_label=True,
                  x_grid_label=False,
                  padding=5,
                  x_grid=True,
                  y_grid=True,
                  xmin=-0,
                  xmax=50,
                  ymin=0,
                  ymax=100,
                  label_options={
                      'color': [0, 1, 1, 1],
                      'bold': False
                  },
                  border_color=[0, 1, 1, .1],
                  tick_color=[1, 1, 1, 1])
    plot = LinePlot(color=[1, 0, 0, 1], line_width=1.5)
    plot.points = [(0, 0)]
    graph.add_plot(plot)
    clock = Clock

    def __init__(self, *args, **kwargs):
        super(PsiScreen, self).__init__(*args, **kwargs)
        self.ids["flt"].add_widget(self.graph)
Beispiel #17
0
	def build(self):
		root = FloatLayout(orientation='horizontal')
		btnRight = Button(text='Scroll', size_hint=(.05,1),pos_hint={'right':1})#,'y':0})
		btnLeft = Button(text='Scroll', size_hint=(.05,1),pos_hint={'left':1})			
		root.add_widget(btnRight)
		root.add_widget(btnLeft)
#		scrollV = ScrollView(size_hint=(None,None),size=(800,400))
#		scrollV.do_scroll_y=False
		graph = Graph()
		plot = LinePlot(mode='line_strip', color=[1,0,0,1])
		plot.points = [(x[i],y[i]) for i in xrange(len(x))]
		graph.add_plot(plot)
		graph.x_ticks_major=1
		graph.xmin=xmin
		graph.xmax=xmax
		graph.ymin=ymin
		graph.ymax=ymax
		graph.y_ticks_major=25
		graph.y_grid_label=True
		graph.x_grid_label=True
		graph.xlabel='X axis'
		graph.ylabel='Y axis'
		graph.y_grid = True
		graph.x_grid = True
		def moveRight(obj):
			global xmin
			global xmax
			xmin=xmin+.5
			xmax=xmax+.5
			graph.xmin=xmin
			graph.xmax=xmax
			#graph.remove_plot(plot)
			#graph.add_plot(plot)
			#graph._redraw_size(xmin,ymin,xmax,ymax)
		btnRight.bind(on_release=moveRight)
		def moveLeft(obj):
			global xmin
			global xmax
			xmin=xmin-.5
			xmax=xmax-.5
			graph.xmin=xmin
			graph.xmax=xmax
		btnLeft.bind(on_release=moveLeft)
		root.add_widget(graph)
#		graph.bind(minimum_height=graph.setter('height'))
#		scrollV.add_widget(graph)
		return root
Beispiel #18
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.plot = LinePlot(color=[0., 0.29, 0.49, 1], line_width=3)
     self.t = np.linspace(0, 2, 1000)
     self.range = []
     self.__even = range(3, self.N, 2)
     self.__odd = range(2, self.N, 2)
     self.__all = range(2, self.N)
    def change_points(self, graph):
        if self.plot_hor is not None and self.plot_vert is not None:
            graph.remove_plot(self.plot_hor)
            graph.remove_plot(self.plot_vert)

        x = 0
        y = 0

        if self.patient == 'Patient 1':
            patient1 = self.call_api('1')
            x = patient1.get_diastolic(patient1.get_timeStampsLength() - 1)
            y = patient1.get_systolic(patient1.get_timeStampsLength() - 1)
        elif self.patient == 'Patient 2':
            patient2 = self.call_api('2')
            x = patient2.get_diastolic(patient2.get_timeStampsLength() - 1)
            y = patient2.get_systolic(patient2.get_timeStampsLength() - 1)
        elif self.patient == 'Patient 3':
            patient3 = self.call_api('3')
            x = patient3.get_diastolic(patient3.get_timeStampsLength() - 1)
            y = patient3.get_systolic(patient3.get_timeStampsLength() - 1)
        elif self.patient == 'Patient 4':
            patient4 = self.call_api('4')
            x = patient4.get_diastolic(patient4.get_timeStampsLength() - 1)
            y = patient4.get_systolic(patient4.get_timeStampsLength() - 1)
        elif self.patient == 'Bob E Smith':
            patient5 = self.call_api('5')
            x = patient5.get_diastolic(patient5.get_timeStampsLength() - 1)
            y = patient5.get_systolic(patient5.get_timeStampsLength() - 1)
        else:
            patient6 = self.call_api('6')
            x = patient6.get_diastolic(patient6.get_timeStampsLength() - 1)
            y = patient6.get_systolic(patient6.get_timeStampsLength() - 1)

        p1 = (x, 0)
        p2 = (x, y)
        p3 = (0, y)

        self.plot_hor = LinePlot(color=[0, 0, 0, 1])
        self.plot_vert = LinePlot(color=[0, 0, 0, 1])
        self.plot_hor.points = [p1, p2]
        self.plot_vert.points = [p2, p3]

        graph.add_plot(self.plot_hor)
        graph.add_plot(self.plot_vert)

        print(self.patient, x, y)
Beispiel #20
0
    def __init__(self):
        super(AccelerometerDemo, self).__init__()

        self.sensorEnabled = False
        self.graph = self.ids.graph_plot

        # For all X, Y and Z axes
        self.plot = []
        self.plot.append(LinePlot(color=[1, 0, 0, 1], line_width=3))  # X - Red
        self.plot.append(LinePlot(color=[0, 1, 0, 1],
                                  line_width=3))  # Y - Green
        self.plot.append(LinePlot(color=[0, 0, 1, 1],
                                  line_width=3))  # Z - Blue

        self.reset_plots()

        for plot in self.plot:
            self.graph.add_plot(plot)
Beispiel #21
0
    def __init__(self, **kwargs):
        super(case, self).__init__(**kwargs)
        box = FloatLayout()
        graph = Graph(xlabel='X',
                      ylabel='Y',
                      x_ticks_minor=5,
                      x_ticks_major=25,
                      y_ticks_major=1,
                      y_grid_label=True,
                      x_grid_label=True,
                      padding=5,
                      x_grid=True,
                      y_grid=True,
                      xmin=-0,
                      xmax=20,
                      ymin=0,
                      ymax=10)
        plot = LinePlot()
        # plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]

        # data = np.array([[0,0], [1,1],[2,2]])

        data = collections.deque(maxlen=20)
        time = collections.deque(maxlen=20)

        d = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
        t = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

        data.append(d)
        time.append(t)

        toplot = np.vstack((time, data)).T

        print toplot

        plot.points = tuple(map(tuple, toplot))

        graph.add_plot(plot)
        box.add_widget(graph)

        self.add_widget(box)
Beispiel #22
0
 def on_color(self,datapoint,instance, value):
     self.plotdata[datapoint]['color'] = value
     # print(datapoint+":RGBA = "+ str(value))
     self.plotdata[datapoint]['plot'].color = value
     # self.plotdata[datapoint]['plot'].draw()
     self.ids.graph.remove_plot(self.plotdata[datapoint]['plot'])
     points = self.plotdata[datapoint]['points']
     self.plotdata[datapoint]['plot'] = LinePlot(color=value)
     self.plotdata[datapoint]['plot'].points = points
     self.plotdata[datapoint]['points'] = points
     self.plotdata[datapoint]['button'].background_color = value
     self.ids.graph.add_plot(self.plotdata[datapoint]['plot'])
Beispiel #23
0
class ChartPressure(Graph):
    poin = ListProperty([])
    xlabel = StringProperty("")
    ylabel = StringProperty("")
    x_ticks_minor = NumericProperty(0)
    x_ticks_major = NumericProperty(10)
    y_ticks_major = NumericProperty(10)
    y_ticks_minor = NumericProperty(2)
    y_grid_label = BooleanProperty(True)
    x_grid_label = BooleanProperty(False)
    x_grid = BooleanProperty(False)
    y_grid = BooleanProperty(True)
    xmin = NumericProperty(0)
    xmax = NumericProperty(50)
    ymin = NumericProperty(0)
    ymax = NumericProperty(100)
    label_options = DictProperty({'color': [0, 1, 1, 1], 'bold': False})
    border_color = ListProperty([0, 1, 1, .1])
    tick_color = ListProperty([1, 1, 1, 1])
    plot_pressure = LinePlot(color=[1, 0, 0, 1], line_width=1.5)
    plot_batt = LinePlot(color=[1, 1, 0, 1], line_width=1.5)
    plot_pressure.points = [(0, 0)]
    plot_batt.points = [(0, 0)]

    def __init__(self, *args, **kwargs):
        super(ChartPressure, self).__init__(*args, **kwargs)
        self.add_plot(self.plot_pressure)
        self.add_plot(self.plot_batt)

    def show_chart_pressure(self, x_value, y_value):
        self.plot_pressure.points.append((x_value, y_value))
        if x_value > 50:
            self.xmax += 1
            self.xmin += 1
            # self.plot_pressure.points.remove(self.plot_pressure.points[0])
        if x_value > 55:
            self.plot_pressure.points.remove(self.plot_pressure.points[0])

    def show_chart_batt(self, x_value, y_value):
        self.plot_batt.points.append((x_value, y_value))
    def on_graph_hr(self, instance, value):

        self.graph_hr.label_options['color'] = 0, 0, 0, 1
        self.graph_hr.label_options['bold'] = True
        self.graph_hr.xlabel = "Time [s]"
        self.graph_hr.ylabel = "Heart Rate [bpm]"
        self.graph_hr.x_ticks_major = 5  # x ticks major value
        self.graph_hr.x_ticks_minor = 1  # x ticks minor value
        self.graph_hr.x_grid_label = True  # grid on x axis
        self.graph_hr.y_ticks_major = 10  # x ticks major value
        self.graph_hr.y_ticks_minor = 5  # x ticks minor value
        self.graph_hr.y_grid_label = True  # grid on y axis
        self.plot_hr = LinePlot(color=[0, 0, 0, 1.0])
        self.plot_hr.line_width = 1
Beispiel #25
0
	def __init__(self, **kwargs):
		# 8
		self.startTime = self.getCurrentTime()
		
		# 7
		kwargs = dict(
				label_options=dict(color=(1,1,1,1), bold=False),
				background_color=(0,0,0,1),
				tick_color=(1,1,1,1),
				border_color=(1,1,1,1),
				padding=2,
				xlabel='On Time (Seconds):',
				ylabel='Temperature',
				x_ticks_minor=2,
				x_ticks_major=10,
				y_ticks_minor=2,
				y_ticks_major=10,
				y_grid_label=False,
				x_grid_label=False,
				xlog=False,
				ylog=False,
				x_grid=False,
				y_grid=False,
				ymin=0,
				ymax=170,
				# 8
				xmin= int(self.getCurrentTime()*TIME_DECIMALS)/TIME_DECIMALS,
				xmax= int((self.getCurrentTime() + START_SIZE_WINDOW)*TIME_DECIMALS)/TIME_DECIMALS
				)
		# 7
		super(PlotterWidget, self).__init__(**kwargs)
		
		# 8
		self.SPplot = LinePlot(color=(1,0,0,1))
		self.add_plot(self.SPplot)
		self.PVplot = LinePlot(color=(0,1,0,1))
		self.add_plot(self.PVplot)
    def on_graph_signal(self, instance, value):

        self.graph_signal.label_options['color'] = 0, 0, 0, 1
        self.graph_signal.label_options['bold'] = True
        self.graph_signal.xlabel = "Time [s]"
        self.graph_signal.ylabel = "Amplitude [V]"
        self.graph_signal.x_ticks_major = 5  # x ticks major value
        self.graph_signal.x_ticks_minor = 1  # x ticks minor value
        self.graph_signal.x_grid_label = True  # grid on x axis
        self.graph_signal.y_ticks_major = 0.5  # y ticks major value
        self.graph_signal.y_ticks_minor = 0.5  # y ticks minor value
        self.graph_signal.y_grid_label = True  # grid on x axis
        self.sample_rate = 995  # 1000 samples per second
        self.plot = LinePlot(color=[0, 0, 0, 1.0])
        self.plot.line_width = 1
        self.plot2 = MeshStemPlot(color=[1, 0, 0, 1.0])
Beispiel #27
0
 def __init__(self,**kwargs):
     self.color=kwargs.pop('color',[1,1,1,1])
     self.line_width=kwargs.pop('line_width',1)
     self.draw_border=True
     self.y_grid_label=True
     self.x_grid_label=False
     self.padding=5
     self.x_grid=True
     self.y_grid=True
     self.xmin=0
     if (not self.y_ticks_major):
         if (self.ymax-self.ymin > 50 ):
             self.y_ticks_major=10
         else:
             self.y_ticks_major=5
     super(ScrollGraph,self).__init__(**kwargs)
     self.plot=LinePlot(color=self.color,line_width=self.line_width)
     self.add_plot(self.plot)
Beispiel #28
0
    def __init__(self, **kwargs):
        super(TemperatureGraph, self).__init__(**kwargs)

        plot = LinePlot(color=ORANGE)
        plot.points = state.temp_history.points
        self.add_plot(plot)
        self.temp_plot = plot

        plot = LinePlot(color=GREEN)
        plot.points = state.temp_history.points
        self.add_plot(plot)

        self.target_temp_plot = plot
        Clock.schedule_interval(self.update, UPDATE_INTERVAL)
    def on_graph(self, instance, value):
        '''
        @brief Callback called when graph object is ready on the UI
        '''

        self.graph.label_options['color'] = 0, 0, 0, 1
        self.graph.label_options['bold'] = True
        self.graph.xlabel = "Time [s]"
        self.graph.ylabel = "Amplitude [V]"
        self.graph.x_ticks_major = 5  # x ticks major value
        self.graph.x_ticks_minor = 1  # x ticks minor value
        self.graph.x_grid_label = True  # grid on x axis

        self.n_seconds = 3
        self.graph.y_ticks_major = 1  # x ticks major value
        self.graph.y_ticks_minor = 1  # x ticks minor value
        self.graph.y_grid_label = True  # grid on x axis
        self.graph.xmin = -self.n_seconds
        self.graph.xmax = 0
        self.graph.ymin = 0
        self.graph.ymax = 5

        self.sample_rate = 1000  # 10 samples per second
        self.n_points = self.n_seconds * self.sample_rate
        #self.n_seconds * self.sample_rate  # Number of points to plot
        #  Distance between points
        self.time_between_points = (self.n_seconds) / float(self.n_points)

        self.plot = LinePlot(color=[0, 0, 0, 1.0])
        self.plot.line_width = 1
        # Populate lists of points
        self.x_points = [x for x in range(-self.n_points, 0)]
        self.y_points = [0 for y in range(-self.n_points, 0)]
        for j in range(self.n_points):
            self.x_points[j] = -self.n_seconds + j * self.time_between_points
        # Zip them and add them to the plot points
        self.plot.points = zip(self.x_points, self.y_points)

        self.graph.add_plot(self.plot)
Beispiel #30
0
    def _onReceive(self, data):
        genericIndex = 0
        data = data.decode('utf-8').rstrip()
        if self.first:
            self.first = False
            self.plotsList = []
            self.nPlots = len(data.split(','))
            for genericIndex in range(0, self.nPlots):
                newPlot = LinePlot(line_width=2,
                                   color=[random(),
                                          random(),
                                          random(), 1])
                self.widget.graph.add_plot(newPlot)
                self.plotsList.append(newPlot)
            self.file.write("Time,")
            for genericIndex in range(0, self.nPlots):
                if (genericIndex == self.nPlots - 1):
                    self.file.write("Plot {}\n".format(genericIndex + 1))
                else:
                    self.file.write("Plot {},".format(genericIndex + 1))

        self.addData(data)
        self.file.write("{}, {}\n".format(self.widget.elapsedSec, data))
Beispiel #31
0
    def __init__(self, **kwargs):
        super(FourthScreen, self).__init__(**kwargs)

	# create buttons
        btnRight = Button(text='Scroll', size_hint=(.05,1),pos_hint={'x':0.45})#,'y':0})
        btnLeft = Button(text='Scroll', size_hint=(.05,1),pos_hint={'left':1})			
        self.add_widget(btnRight)
        self.add_widget(btnLeft)
        
	# create graph
        graph = Graph()
        plot = LinePlot(mode='line_strip',color=[1,0,0,1])
        plot.points = [(x[i],y[i]) for i in xrange(len(x))]
        graph.add_plot(plot)
        graph.x_ticks_major=.5
        graph.xmin=xmin
        graph.xmax=xmax
        graph.ymin=ymin
        graph.ymax=ymax
        graph.y_ticks_major=10
        graph.xlabel='Time (min)'
        graph.ylabel='Brain Wave Amplitude (mV)'
        graph.y_grid = True
        graph.x_grid = True
        graph.size_hint=(0.4,0.9)
        graph.x_grid_label=True
        graph.y_grid_label=True

        # create video player
        video = VideoPlayer(source='Momona.mp4')
        video.play=False
        video.size_hint=(0.5,0.9)
        video.pos_hint={'right':1,'top':1}       

        graph.pos_hint={'x':0.05,'top':1}
        def moveRight(obj):
	    global xmin
            global xmax
            global xGlobalmax
            xmin=xmin+.5
            xmax=xmax+.5
            graph.xmin=xmin
            graph.xmax=xmax
            
            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)

        btnRight.bind(on_release=moveRight)
        def moveLeft(obj):
            global xmin
            global xmax
            global xGlobalmax
            xmin=xmin-.5
            xmax=xmax-.5
            graph.xmin=xmin
            graph.xmax=xmax

            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)
        btnLeft.bind(on_release=moveLeft)
        self.add_widget(graph)
        self.add_widget(video)
Beispiel #32
0
class PlotterWidget(Graph): # 7
	# 7
	SPplot = ObjectProperty(None) # Set Point, will either be 105 or 140
	PVplot = ObjectProperty(None) # Process Value, will be temperature
	
	# 8
	index =	ObjectProperty(0) # Time
	startTime = ObjectProperty(0)
	currentTemp =  ObjectProperty(23)
	currentSignal = ObjectProperty(105)
	
	def __init__(self, **kwargs):
		# 8
		self.startTime = self.getCurrentTime()
		
		# 7
		kwargs = dict(
				label_options=dict(color=(1,1,1,1), bold=False),
				background_color=(0,0,0,1),
				tick_color=(1,1,1,1),
				border_color=(1,1,1,1),
				padding=2,
				xlabel='On Time (Seconds):',
				ylabel='Temperature',
				x_ticks_minor=2,
				x_ticks_major=10,
				y_ticks_minor=2,
				y_ticks_major=10,
				y_grid_label=False,
				x_grid_label=False,
				xlog=False,
				ylog=False,
				x_grid=False,
				y_grid=False,
				ymin=0,
				ymax=170,
				# 8
				xmin= int(self.getCurrentTime()*TIME_DECIMALS)/TIME_DECIMALS,
				xmax= int((self.getCurrentTime() + START_SIZE_WINDOW)*TIME_DECIMALS)/TIME_DECIMALS
				)
		# 7
		super(PlotterWidget, self).__init__(**kwargs)
		
		# 8
		self.SPplot = LinePlot(color=(1,0,0,1))
		self.add_plot(self.SPplot)
		self.PVplot = LinePlot(color=(0,1,0,1))
		self.add_plot(self.PVplot)
		
	# 8; At dt update the plot
	def update(self, dt):
		self.addPlott()
		if self.startScrolling() == True:
			self.scrollXaxis()		  	# Commence scrolling axis.
			self.cutLinesNotInWindow()  # Remove data not seen from array. Smoothes the graphics
	
	# 8; Get current run time by subtracting start time
	def getCurrentTime(self):
		# Obtains time stamp as an float from epoch (1/1/1970)
		ts = time.time()
		# Take start time away from the epoch time to min the label size. 
		ts = ts - self.startTime 
		return ts

	# 8; Add plots to the graph at current run time
	def addPlott(self):
		self.index = self.getCurrentTime()
		self.SPplot.points.append([self.index, self.currentSignal])
		self.SPplot.draw()
		self.PVplot.points.append([self.index, self.currentTemp])
		self.PVplot.draw()
		
	# 8; Returns a true value if the plot has reached the START_SCROLLING point on the window.
	def startScrolling(self):
		if self.index >= self.xmax - START_SCROLLING:
			return True
		else: return False
		
	# 8; Commences Scroll of xAxis
	def scrollXaxis(self):
		# Round time stamp to 2DP
		self.xmax=float((self.index+START_SCROLLING)*TIME_DECIMALS)/TIME_DECIMALS
		self.xmin=float((self.xmax-START_SIZE_WINDOW)*TIME_DECIMALS)/TIME_DECIMALS
	
	# 8; Remove lines that are no longer on the graph
	def cutLinesNotInWindow(self):
		del self.SPplot.points[0]
		del self.PVplot.points[0]
    def __init__(self, **kwargs):
        super(Screen, self).__init__(**kwargs)

        self.allowed_receive_database = True

        self.error = Image(
            source='Img/error.png',
            allow_stretch=False,
            keep_ratio=True,
            pos_hint={"center_x": 0.095, "center_y": 0.64},
            size_hint=(0.11, 0.11))

        self.wait = Image(
            source='Img/wait.png',
            allow_stretch=False,
            keep_ratio=True,
            pos_hint={"center_x": 0.095, "center_y": 0.64},
            size_hint=(0.11, 0.11))

        graph_theme = {
            'label_options': {
                'color': rgb('444444'),  # color of tick labels and titles
                'bold': True},
            'background_color': rgb('f8f8f2'),  # back ground color of canvas
            'tick_color': rgb('808080'),  # ticks and grid
            'border_color': rgb('808080')}  # border drawn around each graph

        self.graph1 = Graph(
            xlabel='Time [s]',
            ylabel='Value',
            x_ticks_minor=5,
            x_ticks_major=5,
            y_ticks_minor=1,
            y_ticks_major=10,
            y_grid_label=True,
            x_grid_label=True,
            padding=5,
            xlog=False,
            ylog=False,
            x_grid=False,
            y_grid=False,
            xmin=0,
            xmax=30,
            ymin=0,
            ymax=100,
            pos_hint={'center_x': 0.5, 'center_y': 0.5},
            _with_stencilbuffer=False,
            **graph_theme)

        self.graph2 = Graph(
            xlabel='Time [s]',
            ylabel='Value',
            x_ticks_minor=5,
            x_ticks_major=5,
            y_ticks_minor=1,
            y_ticks_major=1,
            y_grid_label=True,
            x_grid_label=True,
            padding=5,
            xlog=False,
            ylog=False,
            x_grid=False,
            y_grid=False,
            xmin=0,
            xmax=30,
            ymin=-5,
            ymax=5,
            pos_hint={'center_x': 0.5, 'center_y': 0.5},
            _with_stencilbuffer=False,
            **graph_theme)

        self.plot1 = LinePlot(line_width=2, color=[1, 0, 0, 1])
        self.plot1.points = [(i, j*10/3) for i, j in enumerate(range(31))]
        self.graph1.add_plot(self.plot1)
        self.ids.panel1.add_widget(self.graph1)

        self.plot2 = LinePlot(line_width=2, color=[1, 0, 0, 1])
        self.plot2.points = [(i, j/3 - 5) for i, j in enumerate(range(31))]
        self.graph2.add_plot(self.plot2)
        self.ids.panel2.add_widget(self.graph2)
Beispiel #34
0
    def build(self): 
        availablePorts = listSerialPorts()
        self.connection = serial.Serial(availablePorts[0], 115200)
        self.counter = 1
        self.runState = False
        self.enableCO2 = False
        layoutMain = BoxLayout(orientation='horizontal',spacing=0, padding=0)
        
        layoutLeft = BoxLayout(orientation='vertical', spacing=0, padding=0)
        # Graphing area
        layoutGraph = BoxLayout(orientation='vertical', spacing=0, padding=(5,0))
        graphPaw = ScrollGraph(ylabel='Paw cmH2O', draw_border=True, y_ticks_major=5, y_grid_label=True, x_grid_label=False,  padding=5, x_grid=True, y_grid=True, xmin=0, xmax=600, ymin=0, ymax=20)
        graphFlow = ScrollGraph(ylabel='Flow L/min', draw_border=True, y_ticks_major=20, y_grid_label=True, x_grid_label=False, padding=5, x_grid=True, y_grid=True, xmin=0, xmax=600, ymin=-60, ymax=60)
        graphVt = ScrollGraph(ylabel='Vt mL', draw_border=True, y_ticks_major=10, y_grid_label=True, x_grid_label=False, padding=5, x_grid=True, y_grid=True, xmin=0, xmax=600, ymin=0, ymax=40)
        if (self.enableCO2):
            graphCO2 = ScrollGraph(ylabel='CO2 mmHg', draw_border=True, y_ticks_major=10, y_grid_label=True, x_grid_label=False, padding=5, x_grid=True, y_grid=True, xmin=0, xmax=600, ymin=0, ymax=40,size_hint_y=0,)
        self.plot = []
        self.plot.append(LinePlot(color=[1, 0, 1, 1],line_width=1))
        self.plot.append(LinePlot(color=[0, 1, 1, 1],line_width=1))
        self.plot.append(LinePlot(color=[1, 1, 0, 1],line_width=1))
        if (self.enableCO2): 
            self.plot.append(LinePlot(color=[0.5, 0.5, 1, 1],line_width=1))
  
        self.reset_plots()
  
        graphPaw.add_plot(self.plot[0])
        graphFlow.add_plot(self.plot[1])
        graphVt.add_plot(self.plot[2])
        if (self.enableCO2):
            graphCO2.add_plot(self.plot[3])

        layoutGraph.add_widget(graphPaw)
        layoutGraph.add_widget(graphFlow)
        layoutGraph.add_widget(graphVt)
        if (self.enableCO2):
            layoutGraph.add_widget(graphCO2)
        #self.graphCO2.height='0dp'
        #self.graphCO2.size_hint_y=0
        layoutLeft.add_widget(layoutGraph)
        
        # Bottom Controls
        layoutControlBottom = BoxLayout(orientation='horizontal', spacing=10, padding=(5,10),size_hint=(1,0.2))
        buttonMode = SelectButton(name='mode',text_top="Mode",value="PCV-VG",values=('PCV-VG','PCV'),text_bottom=" ")
        layoutControlBottom.add_widget(buttonMode);
        
        buttonTidalVolume = SliderButton(name='tidalv',text_top="TidalV",min=200,max=800,value=500,text_bottom="ml");
        layoutControlBottom.add_widget(buttonTidalVolume);
        
        buttonRespRate = SliderButton(name='rate',text_top="Rate",min=8,max=40,value=18,text_bottom="/min");
        layoutControlBottom.add_widget(buttonRespRate);
        
        buttonInhaleExhale = SelectButton(name='ie',text_top="I:E",value="1:2",values=('1:1','1:2','1:3','1:4'),text_bottom=" ");
        layoutControlBottom.add_widget(buttonInhaleExhale);
        
        buttonPEEP = SliderButton(name='peep',text_top="PEEP",min=0,value="5",max=25,text_bottom="cmH2O");
        layoutControlBottom.add_widget(buttonPEEP);
        
        buttonPressureMax = SliderButton(name='pmax',text_top="Pmax",min=10,value="20",max=60,text_bottom="cmH2O");
        layoutControlBottom.add_widget(buttonPressureMax);
        
        layoutLeft.add_widget(layoutControlBottom)
        layoutMain.add_widget(layoutLeft)
        
        # Right Controls
        layoutControlRight = BoxLayout(orientation='vertical', spacing=10, padding=(10,5),size_hint=(0.2,1))
        buttonAlarmPause = RotaryButton(name='alarm',text_top='Alarm Status',value="Silenced",values={'Normal','Alarm','Silenced'},value_colors={'Normal':(0.3,1,0.3,1),'Silenced':(1,1,0.3,1),'Alarm':(1,0.3,0.3,1)});
        layoutControlRight.add_widget(buttonAlarmPause);
        buttonAlarmSetup = DisplayButton(value="Alarm\nSetup");
        layoutControlRight.add_widget(buttonAlarmSetup);
        buttonSystemSetup = DisplayButton(value="System\nSetup");
        layoutControlRight.add_widget(buttonSystemSetup);
        self.buttonRun = RotaryButton(name='status',text_top="Status",on_press=self.runButton,value="Stopped",values=('Stopped','Running'),value_colors={'Stopped':(1,0.3,0.3,1),'Running':(0.3,1,0.3,1)})
        layoutControlRight.add_widget(self.buttonRun)

        layoutMain.add_widget(layoutControlRight)
       
        return layoutMain
Beispiel #35
0
 def __init__(self, **kw):
     super(SCREEN, self).__init__(**kw)
     self.graph = LinePlot(line_width=1.2, color=[.62, .93, .25, 1])
     self.ids.graph.add_plot(self.graph)
Beispiel #36
0
    def playVideo(self,FourthScreen):
	#get data for patient
	with open('choosePatient.txt','r') as f:
      	    patientName=f.read()
#      	data = data.split(',')
      	fileName ='videos/' + patientName + ".mp4"
	
	dataMatrix1 = genfromtxt('DemoEEGFile.txt')
	x = dataMatrix1[:,0]
	x = x - 5.539
	y = dataMatrix1[:,1]
	
	xmin = math.trunc(x[0])
	ymin = math.trunc(min(y))#math.trunc(y[0])
	xmax = xmin+1
	xGlobalmax = math.trunc(x[len(x)-1])
	ymax = math.trunc(max(y))#math.trunc(y[len(y)-1])
	# create buttons
        btnRight = Button(text='Scroll', size_hint=(.05,1),pos_hint={'x':0.45})#,'y':0})
        btnLeft = Button(text='Scroll', size_hint=(.05,1),pos_hint={'left':1})			
        FourthScreen.add_widget(btnRight)
        FourthScreen.add_widget(btnLeft)
        
	# create graph
        graph = Graph()
        plot = LinePlot(mode='line_strip',color=[1,0,0,1])
        plot.points = [(x[i],y[i]) for i in xrange(len(x))]
        graph.add_plot(plot)
        graph.x_ticks_major=.5
        graph.xmin=xmin
        graph.xmax=xmax
        graph.ymin=ymin
        graph.ymax=ymax
        graph.y_ticks_major=10
        graph.xlabel='Time (min)'
        graph.ylabel='Brain Wave Amplitude (mV)'
        graph.y_grid = True
        graph.x_grid = True
        graph.size_hint=(0.4,0.9)
        graph.x_grid_label=True
        graph.y_grid_label=True

        # create video player
        video = VideoPlayer(source=fileName)
        video.play=False
        video.size_hint=(0.5,0.9)
        video.pos_hint={'right':1,'top':1}       

        graph.pos_hint={'x':0.05,'top':1}
        def moveRight(obj):
	    global xmin
            global xmax
            global xGlobalmax
            xmin=xmin+.5
            xmax=xmax+.5
            graph.xmin=xmin
            graph.xmax=xmax
            
            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)

        btnRight.bind(on_release=moveRight)
        def moveLeft(obj):
            global xmin
            global xmax
            global xGlobalmax
            xmin=xmin-.5
            xmax=xmax-.5
            graph.xmin=xmin
            graph.xmax=xmax

            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)
        btnLeft.bind(on_release=moveLeft)
        FourthScreen.add_widget(graph)
        FourthScreen.add_widget(video)
Beispiel #37
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.plot1 = LinePlot(color=[1., 0.65, 0., 1], line_width=1)
     self.plot2 = LinePlot(color=[1., 1., 0., 1], line_width=1)
     self.plot = LinePlot(color=[0., 0.29, 0.49, 1], line_width=3)