GVKun编程网logo

在Linux上使用可滚动的x(时间/水平)轴绘制数据(linux屏幕滚动)

21

本文的目的是介绍在Linux上使用可滚动的x的详细情况,特别关注时间/水平轴绘制数据的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解在Linux上使用可滚动的x的机会

本文的目的是介绍在Linux上使用可滚动的x的详细情况,特别关注时间/水平轴绘制数据的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解在Linux上使用可滚动的x的机会,同时也不会遗漏关于c – 在Linux上使用Epoll增强Asio、c – 在linux上使用SDL2和g?、c – 在Linux上使用默认查看器打开文件、IPC在linux上使用信号的知识。

本文目录一览:

在Linux上使用可滚动的x(时间/水平)轴绘制数据(linux屏幕滚动)

在Linux上使用可滚动的x(时间/水平)轴绘制数据(linux屏幕滚动)

我想在x轴较长的地方绘制数据。如果我绘制整个x轴,则图会缩小并且几乎无法读取。我在SO上找到了这个答案,它指向以下scipy
/ matplotlib代码。但是,当我尝试运行上述代码时,出现以下错误:

Traceback (most recent call last):  File "scrollingPlot.py", line 88, in <module>    app = MyApp()  File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 8628, in __init__    self._BootstrapApp()  File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 8196, in _BootstrapApp    return _core_.PyApp__BootstrapApp(*args, **kwargs)  File "scrollingPlot.py", line 82, in OnInit    self.frame = MyFrame(parent=None,id=-1)  File "scrollingPlot.py", line 21, in __init__    self.scroll_range)  File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 11226, in SetScrollbar    return _core_.Window_SetScrollbar(*args, **kwargs)wx._core.PyAssertionError: C++ assertion "sb" failed at ../src/gtk/window.cpp(4754) in SetScrollbar(): this window is not scrollable

PS:也欢迎其他解决方案(最好是python,R或一些简单的多平台解决方案)

PPS:我已经打开了提到的错误的问题

答案1

小编典典

您是否考虑过使用matplotlib滑块小部件?

这里有一些代码只是作为示例显示

import numpy as npimport matplotlib.pyplot as pltfrom matplotlib.widgets import Sliderfig, ax = plt.subplots()plt.subplots_adjust(bottom=0.25)t = np.arange(0.0, 100.0, 0.1)s = np.sin(2*np.pi*t)l, = plt.plot(t,s)plt.axis([0, 10, -1, 1])axcolor = ''lightgoldenrodyellow''axpos = plt.axes([0.2, 0.1, 0.65, 0.03], axisbg=axcolor)spos = Slider(axpos, ''Pos'', 0.1, 90.0)def update(val):    pos = spos.val    ax.axis([pos,pos+10,-1,1])    fig.canvas.draw_idle()spos.on_changed(update)plt.show()

c – 在Linux上使用Epoll增强Asio

c – 在Linux上使用Epoll增强Asio

我的印象是boost :: asio默认使用epoll设置而不是select实现,但是在运行一些测试之后看起来我的设置是使用select.

操作系统:RHEL 4
内核:2.6
GCC:3.4.6

我写了一个小测试程序,以验证正在使用哪个反应器头,看起来它使用选择反应器而不是epoll反应器.

#include 

我能做错什么?

最佳答案
你的程序也为我说“选择”,但asio正在使用epoll_wait(),如ps -Teo tid,wchan:25,comm报告.

怎么样

#include 

(从/usr/include/boost/asio/serial_port_service.hpp抓取ifdefs的梯子)

c – 在linux上使用SDL2和g?

c – 在linux上使用SDL2和g?

  1 #include "SDL2/SDL.h"

  3 
  4 int main(int argc,char* args[])
  5 {
  6     SDL_Init(SDL_INIT_EVERYTHING);

  8     SDL_QUIT();
  9     return 0;
 10 }

我已经通过debian存储库安装了SDL2,我正在运行

g++ -o test.cpp a.out -lSDL2 

我收到了很多错误:

a.out:(.rodata+0x0): multiple deFinition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here
a.out: In function `data_start':
(.data+0x8): multiple deFinition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o:(.data+0x0): first defined here
a.out: In function `_fini':
(.fini+0x0): multiple deFinition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here
a.out: In function `_start':
(.text+0x0): multiple deFinition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here
a.out: In function `_init':
(.init+0x0): multiple deFinition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
a.out: In function `data_start':
(.data+0x0): multiple deFinition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtend.o:(.tm_clone_table+0x0): multiple deFinition of `__TMC_END__'
a.out:(.data+0x10): first defined here
/usr/bin/ld: error in a.out(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status

我试过了

g++ test.cpp $(pkg-config --cflags --libs sdl2)

得到:

test.cpp: In function ‘int main(int,char**)’:
test.cpp:6:14: error: ‘(SDL_EventType)256u’ cannot be used as a function

我不知道造成这些错误的原因.
正确的头文件存在于

的/ usr /包括/ SDL2 /

目录.难道我做错了什么?

最佳答案
标题必须是:< SDL2 / SDL.h>
退出函数:SDL_Quit();
命令:g teste.cpp -o filename -lSDL2

c – 在Linux上使用默认查看器打开文件

c – 在Linux上使用默认查看器打开文件

我在一个独立于操作系统的文件管理器(主要是Windows和Linux)上工作,我想知道是否有一种Linux方法可以在其默认查看器中打开文件.例如,使用Firefox打开html文件,使用vlc打开.avi,依此类推.
在Windows上,有一个函数ShellExecute()可以做到这一点,但我的理解是,在Linux上并不是那么简单,每个桌面环境都有一个特定的方式.
我很感激任何帮助.

最佳答案
您可以使用xdg-open(1).它适用于所有符合freedesktop标准的桌面.

IPC在linux上使用信号

IPC在linux上使用信号

使用信号捕获和信号提升可以进行IPC(进程间通信)吗?

我制作了两个节目.在第一个程序中,我处理了信号,而在另一个程序中,我只是提出了我想在另一个程序中处理的信号.我工作正常,但我希望使用信号在这两个程序之间进行通信,并且还希望使用此提升信号发送一些字节数据.我怎样才能做到这一点?

我也希望用这个信号传递消息.我可以做吗?有可能的?

而且,IPC机制使用信号的缺点和优势是什么?

以下是我的两个程序的工作代码.就是这样,我只能提升信号并捕获信号,但我想将数据从一个程序传递到另一个程序.

在第二个程序中,我使用了第一个程序的进程ID.我怎样才能让它变得动态.

第一个程序:

/* Example of using sigaction() to setup a signal handler with 3 arguments
 * including siginfo_t.
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>

static void hdl (int sig,siginfo_t *siginfo,void *context)
{
    printf("sig no = %d \n",sig);
    if(sig == SIGINT)
        exit(0);
    printf ("Sending PID: %ld,UID: %ld\n",(long)siginfo->si_pid,(long)siginfo->si_uid);
}

int main (int argc,char *argv[])
{
    struct sigaction act;


    sigemptyset(&act.sa_mask);

    act.sa_sigaction = &hdl;
    act.sa_flags = SA_SIGINFO;

    if (sigaction(SIGUSR1,&act,NULL) < 0) {
        perror ("sigaction SIGUSR1");
        return 1;
    }
    if (sigaction(SIGINT,NULL) < 0) {
        perror ("sigaction SIGINT");
        return 1;
    }

    while (1)
    {
        sleep(1);
    }

    return 0;
}

第二个计划

#include  <stdio.h>
#include  <signal.h>

void  main(void)
{

   while (1)
    {
        sleep(1);
        kill(11558,SIGUSR1);
    }

}

解决方法

Signals旨在提供对过程的基本控制形式,而不是IPC机制.当用作其他任何东西时,信号有几个问题:

>许多系统调用将被信号中断,需要特殊处理.
>因此,野外的许多代码都不是信号安全的.
>信号没有任何类型的数据内容,除了他们自己.这使得它们作为消息传递方法大多无用.
>在信号处理程序中只能做很多事情.
>最重要的是,相同类型的后续信号不会排队 – 它们会合并为一个实例.
>更重要的是,无法保证信号的输送顺序与生成的顺序相同.从手册页:

By contrast,if multiple standard signals are pending for a process,the order in which
they are delivered is unspecified
.

理论上你可以使用几个来回的信号设置某种类型的通道,其中一些信号像某种确认,但没有理智的人会想要尝试类似的东西.您也可以使用烟雾信号代替……

今天关于在Linux上使用可滚动的x时间/水平轴绘制数据的讲解已经结束,谢谢您的阅读,如果想了解更多关于c – 在Linux上使用Epoll增强Asio、c – 在linux上使用SDL2和g?、c – 在Linux上使用默认查看器打开文件、IPC在linux上使用信号的相关知识,请在本站搜索。

本文标签: