コード例 #1
0
ファイル: xlib.c プロジェクト: jacereda/glcv
intptr_t osEvent(ev * e) {
        intptr_t ret = 1;
        static int fullscreen = 0;
        switch (evType(e)) {
        case CVE_QUIT: g_done = 1; break;               
        case CVE_SETCURSOR: 
                setcursor((uint8_t*)evArg0(e), 
                        evArg1(e) >> 16, evArg1(e) & 0xffff); 
                break;
        case CVE_DEFAULTCURSOR: defaultcursor(); break;
        case CVE_WINDOWED:
                if (fullscreen) {
                        closewin();
                        openwin(g_nx, g_ny, g_nw, g_nh, 1);
                        map();
                        fullscreen = 0;
                }
                break;
        case CVE_FULLSCREEN: 
                if (!fullscreen) {
                        savegeom();
                        closewin();
                        openwin(0, 0, 
                                DisplayWidth(g_dpy, scr()), 
                                DisplayHeight(g_dpy, scr()), 0);
                        map();
                        fullscreen = 1;
                }
                break;
        default: ret = 0;
        }
        return ret;
}
コード例 #2
0
ファイル: search_cmd.c プロジェクト: rhpatel/linux-progarm
main(int argc,char **argv)
{
	int c=0;
	if(argc==2)
		c=scr(".",argv[1]);
	else if(argc==3)
		c=scr(argv[1],argv[2]);
	else
	{
		printf("Usage: ./a.out path fname\n\t ./a.out fname\n");
		return;
	}
	printf("count=%d\n",c);
}
コード例 #3
0
ファイル: search_cmd.c プロジェクト: rhpatel/linux-progarm
int scr(char *path,char *f)
{
	char a[500]={'\0'},s[500]={'\0'};
	//	char *s,*a;
	DIR *dp;
	struct dirent *p;
	struct stat v;
	dp=opendir(path);
	if(dp==0)
	{
		perror("opendir");
		return;
	}             
	while(p=readdir(dp))
	{ strcpy(a,path);                //change the directories......
		strcat(a,"/");
		strcat(a,p->d_name); 
		printf("%s\n",a);
		if(p->d_name[0]!='.')
		{
			stat(a,&v);
			if(S_ISDIR(v.st_mode))
			{
				//               printf("%s is directory\n",p->d_name);
				scr(a,f);   
			}
			else if((strcmp(p->d_name,f))==0)
			{
				c++;
			}
		}
	}
	return c;
}
コード例 #4
0
const DisplayResVector& DisplayResX::GetVideoModes(void) const
{
    if (m_video_modes.size())
        return m_video_modes;

    Display *display = NULL;
    XRRScreenConfiguration *cfg = GetScreenConfig(display);
    if (!cfg)
        return m_video_modes;

    int num_sizes, num_rates;
    XRRScreenSize *sizes = NULL;
    X11S(sizes = XRRConfigSizes(cfg, &num_sizes));
    for (int i = 0; i < num_sizes; ++i)
    {
        short *rates = NULL;
        X11S(rates = XRRRates(display, DefaultScreen(display), i, &num_rates));
        DisplayResScreen scr(sizes[i].width, sizes[i].height,
                             sizes[i].mwidth, sizes[i].mheight,
                             rates, num_rates);
        m_video_modes.push_back(scr);
    }
    m_video_modes_unsorted = m_video_modes;
    sort(m_video_modes.begin(), m_video_modes.end());

    X11L;
    XRRFreeScreenConfigInfo(cfg);
    XCloseDisplay(display);
    X11U;

    return m_video_modes;
}
コード例 #5
0
Image<double> AffineTransform::computeTransform(const CalibrationTransform::Data& d)
{
//loop through calib pts work out the transform M = pInv(e) x S
//set itsTransform= new transform image

    const std::vector<CalPt>& itsCals = d.getItsCalPts();
    int numCalPts = (int)itsCals.size();
    Image<double> scr(3,numCalPts,ZEROS);
    Image<double> eye(3,numCalPts,ZEROS);
    Image<double> eyeInv;
    Image<double> M(3,3,ZEROS);

    Image<double>::iterator scrAptr = scr.beginw();
    Image<double>::iterator eyeAptr = eye.beginw();

    for(int i=0; i < numCalPts; i++)
    {
        *scrAptr++ = itsCals[i].scr_x;
        *scrAptr++ = itsCals[i].scr_y;
        *scrAptr++ = 1;

        *eyeAptr++ = itsCals[i].raw_x;
        *eyeAptr++ = itsCals[i].raw_y;
        *eyeAptr++ = 1;
    }

    int rank =0;
    eyeInv = svdPseudoInv(eye,SVD_LAPACK,&rank,0.0F);

    M = matrixMult(eyeInv,scr);
    itsTransform = M;

    return itsTransform;

}
コード例 #6
0
ファイル: fmtowns.c プロジェクト: dinkc64/mame
void towns_state::towns_crtc_refresh_mode()
{
	unsigned int width,height;

	rectangle scr(0, m_video.towns_crtc_reg[4], 0, m_video.towns_crtc_reg[8] / 2);

	// layer 0
	width = m_video.towns_crtc_reg[10] - m_video.towns_crtc_reg[9];
	height = (m_video.towns_crtc_reg[14] - m_video.towns_crtc_reg[13]) / 2;
	m_video.towns_crtc_layerscr[0].min_x = scr.xcenter() - (width / 2);
	m_video.towns_crtc_layerscr[0].min_y = scr.ycenter() - (height / 2);
	m_video.towns_crtc_layerscr[0].max_x = scr.xcenter() + (width / 2);
	m_video.towns_crtc_layerscr[0].max_y = scr.ycenter() + (height / 2);

	// layer 1
	width = m_video.towns_crtc_reg[12] - m_video.towns_crtc_reg[11];
	height = (m_video.towns_crtc_reg[16] - m_video.towns_crtc_reg[15]) / 2;
	m_video.towns_crtc_layerscr[1].min_x = scr.xcenter() - (width / 2);
	m_video.towns_crtc_layerscr[1].min_y = scr.ycenter() - (height / 2);
	m_video.towns_crtc_layerscr[1].max_x = scr.xcenter() + (width / 2);
	m_video.towns_crtc_layerscr[1].max_y = scr.ycenter() + (height / 2);

	// sanity checks
	if(scr.max_x == 0 || scr.max_y == 0)
		return;
	if(scr.max_x <= scr.min_x || scr.max_y <= scr.min_y)
		return;

	machine().first_screen()->configure(scr.max_x+1,scr.max_y+1,scr,HZ_TO_ATTOSECONDS(60));
}
コード例 #7
0
ファイル: xlib.c プロジェクト: jacereda/glcv
static void openwin(int x, int y, unsigned w, unsigned h, int b) {
        XSizeHints hints;
        XSetWindowAttributes swa; 
        unsigned long swamask;
        Atom datom;
        swa.event_mask = EVMASK;
        swamask = CWEventMask;
        hints.x = x;
        hints.y = y;
        hints.width = w;
        hints.height = h;
        assert(!g_win);
        g_win = XCreateWindow(g_dpy, XRootWindow(g_dpy, scr()),
                            hints.x, hints.y, hints.width, hints.height,
                            0, CopyFromParent,
                            InputOutput, 
                            CopyFromParent,
                            swamask, &swa);
        borders(b);
        hints.flags = USSize | USPosition;
        XSetWMNormalHints(g_dpy, g_win, &hints);
        datom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False);
        XSetWMProtocols(g_dpy, g_win, &datom, 1);
        XSelectInput(g_dpy, g_win, EVMASK);
        g_xic = XCreateIC(g_xim,
                        XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
                        XNClientWindow, g_win,
                        XNFocusWindow, g_win,
                        NULL);
        if (g_cursor)
                XDefineCursor(g_dpy, g_win, g_cursor);
        XStoreName(g_dpy, g_win, (const char*)cvInject(CVQ_NAME, 0, 0));
}
コード例 #8
0
void get_put_vars(int exo_file, ex_entity_type type, int num_blocks, int num_vars,
                  int num_time_steps, const std::vector<int> &num_per_block, const char* mname)

{
  /* truth table */
  if (debug) logger("\tTruth Table");
  std::vector<int> truth_table(num_vars*num_blocks);
  ex_get_truth_table(exo_file, type, num_blocks, num_vars,TOPTR(truth_table));

  size_t num_entity = std::accumulate(num_per_block.begin(), num_per_block.end(), 0);
  std::vector<double> scr(num_entity * num_time_steps);

  std::vector<int> ids(num_blocks);
  ex_get_ids(exo_file, type, TOPTR(ids));

  char str[32];
  for (int i=0; i < num_vars; i++) {
    if (debug) logger("\tReading");
    std::fill(scr.begin(), scr.end(), 0.0);
    size_t n=0;
    sprintf(str,mname,i+1);
    for (int j=0; j<num_time_steps; j++){
      for (int k=0; k<num_blocks; k++){
        if (truth_table[num_vars*k+i]==1) {
          ex_get_var(exo_file,j+1,type, i+1,ids[k],num_per_block[k],&scr[n]);
        }
        n=n+num_per_block[k];
      }
    }
    if (debug) logger("\tWriting");
    PutDbl(str,num_entity,num_time_steps,TOPTR(scr));
  }
}
コード例 #9
0
ファイル: QScope.cpp プロジェクト: HaikuArchives/QScope
void QScopeWindow::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case MSG_DAC_STREAM: the_subscriber->Enter(dac_stream); break;
		case MSG_ADC_STREAM: the_subscriber->Enter(adc_stream); break;

		case MSG_LEFT_CHANNEL:
			the_looper->RightChannel = false;
			the_looper->Stereo = false;
			break;
		case MSG_RIGHT_CHANNEL:
			the_looper->RightChannel = true;
			the_looper->Stereo = false;
			break;
		case MSG_STEREO_CHANNELS:
			the_looper->RightChannel = false;
			the_looper->Stereo = true;
			break;

		case MSG_TIME_DIV_100us: the_subscriber->SetTimePerDiv(0.1E-3); break;
		case MSG_TIME_DIV_200us: the_subscriber->SetTimePerDiv(0.2E-3); break;
		case MSG_TIME_DIV_500us: the_subscriber->SetTimePerDiv(0.5E-3); break;
		case MSG_TIME_DIV_1ms: the_subscriber->SetTimePerDiv(1E-3); break;
		case MSG_TIME_DIV_2ms: the_subscriber->SetTimePerDiv(2E-3); break;
		case MSG_TIME_DIV_5ms: the_subscriber->SetTimePerDiv(5E-3); break;
		case MSG_TIME_DIV_10ms: the_subscriber->SetTimePerDiv(10E-3); break;

		case MSG_TRIGGER_OFF: the_subscriber->SetTriggerMode(TRIGGER_OFF); break;
		case MSG_TRIGGER_LEVEL: the_subscriber->SetTriggerMode(TRIGGER_LEVEL); break;
		case MSG_TRIGGER_PEAK: the_subscriber->SetTriggerMode(TRIGGER_PEAK); break;

		case MSG_TRIGGER_LEFT: the_subscriber->TriggerRightChannel = false; break;
		case MSG_TRIGGER_RIGHT: the_subscriber->TriggerRightChannel = true; break;

		case MSG_SLOPE_POS: the_subscriber->TriggerSlopeNeg = false; break;
		case MSG_SLOPE_NEG: the_subscriber->TriggerSlopeNeg = true; break;

		case MSG_ILLUMINATION: {
			BScreen scr(this);
			illumination = !illumination;
			if (illumination) {
				c_black = scr.IndexForColor(128, 96, 0);
				c_dark_green = scr.IndexForColor(16, 32, 16);
			} else {
				c_black = scr.IndexForColor(0, 0, 0);
				c_dark_green = scr.IndexForColor(0, 32, 16);
			}
			break;
		}

		default:
			BWindow::MessageReceived(msg);
	}
}
コード例 #10
0
static cairo_surface_t *
_cairo_beos_surface_create_similar (void            *abstract_surface,
				    cairo_content_t  content,
				    int              width,
				    int              height)
{
    fprintf(stderr, "Creating similar\n");

    cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>(
							abstract_surface);

    if (width <= 0)
	width = 1;
    if (height <= 0)
	height = 1;

    BRect rect(0.0, 0.0, width - 1, height - 1);
    BBitmap* bmp;
    switch (content) {
	case CAIRO_CONTENT_ALPHA:
	    // Can't support this natively
	    return _cairo_image_surface_create_with_content(content, width,
							    height);
	case CAIRO_CONTENT_COLOR_ALPHA:
	    bmp = new BBitmap(rect, B_RGBA32, true);
	    break;
	case CAIRO_CONTENT_COLOR:
	    // Match the color depth
	    if (surface->bitmap) {
		color_space space = surface->bitmap->ColorSpace();
		// No alpha was requested -> make sure not to return
		// a surface with alpha
		if (space == B_RGBA32)
		    space = B_RGB32;
		if (space == B_RGBA15)
		    space = B_RGB15;
		bmp = new BBitmap(rect, space, true);
	    } else {
		BScreen scr(surface->view->Window());
		color_space space = B_RGB32;
		if (scr.IsValid())
		    space = scr.ColorSpace();
		bmp = new BBitmap(rect, space, true);
	    }
	    break;
	default:
	    assert(0);
	    return NULL;
	    
    };
    BView* view = new BView(rect, "Cairo bitmap view", B_FOLLOW_ALL_SIDES, 0);
    bmp->AddChild(view);
    return _cairo_beos_surface_create_internal(view, bmp, true);
}
コード例 #11
0
ファイル: script_test.cpp プロジェクト: OnceBe/qlcplus
void Script_Test::initial()
{
    Doc doc(this);
    UniverseArray ua(512 * 4);

    Script scr(&doc);
    scr.setData(script0);

    for (int i = 0; i < 9; i++)
        scr.executeCommand(i, doc.masterTimer(), &ua);
}
コード例 #12
0
ファイル: ctrl.cpp プロジェクト: heocon8319/Wordryo
static void
print_cookies( int socket, CookieID theID )
{
    CRefMgr* cmgr = CRefMgr::Get();
    CookieMapIterator iter = cmgr->GetCookieIterator();
    CookieID id;
    for ( id = iter.Next(); id != 0; id = iter.Next() ) {
        if ( theID == 0 || theID == id ) {
            SafeCref scr( id );
            string s;
            scr.PrintCookieInfo( s );

            print_to_sock( socket, true, s.c_str() );
        }
    }
}
コード例 #13
0
ファイル: ScopeView.cpp プロジェクト: tgkokk/WhisperBeNet
void
ScopeView::AttachedToWindow()
{
	// Look up colors for scope
	{
		BScreen scr(Window());
      //m_back_color = scr.IndexForColor(0, 32, 16);  OliverESP: for transparent efect
        m_back_color = scr.IndexForColor(192, 192, 192);
        
		m_mute_color = scr.IndexForColor(192, 192, 192);
	//	m_beam_color = scr.IndexForColor(255, 0, 0);  OliverESP: looks nicer with transparent
		m_beam_color = scr.IndexForColor(0, 0, 255);
		
		m_null_color = scr.IndexForColor(75, 75, 75);//OliverESP: 
	}
}
コード例 #14
0
ファイル: Thread.cpp プロジェクト: Chase-C/Mandelbrot
void *CreateDisplay(ALLEGRO_THREAD *thr, void *arg)
{
    DISPLAY_DATA *data = (DISPLAY_DATA*) arg;   
    ALLEGRO_DISPLAY *display;

    ALLEGRO_EVENT_QUEUE *queue = al_create_event_queue();
    if(!queue) {
        fprintf(stderr, "failed to create event queue");
        return NULL;
    }

    al_lock_mutex(data->mutex);

    display = AllegroNewDisplay(data->sizeX, data->sizeY, queue);
    al_broadcast_cond(data->cond);

    // Define the size of the image
    Window<int> scr(0, data->sizeX, 0, data->sizeY);
    // Define the domain in which we test for points
    Window<double> fract(data->zoomXmin, data->zoomXmax, data->zoomYmin, data->zoomYmax);
    
    al_unlock_mutex(data->mutex);

    // Generate the fractal
    Mandelbrot(scr, fract);

    while(!al_get_thread_should_stop(thr)) {
        ALLEGRO_EVENT ev;
        al_wait_for_event(queue, &ev);

        if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
            al_set_thread_should_stop(thr);
            al_lock_mutex(data->mutex);
            al_broadcast_cond(data->cond);
            al_unlock_mutex(data->mutex);
            break;
        }       
    }

    al_destroy_display(display);
    al_destroy_event_queue(queue);
}
コード例 #15
0
ファイル: xlib.c プロジェクト: jacereda/glcv
int cvrun(int argc, char ** argv) {
        int attr[] = {
                GLX_RGBA,
                GLX_DOUBLEBUFFER,
                GLX_RED_SIZE, 1,
                GLX_GREEN_SIZE, 1,
                GLX_BLUE_SIZE, 1,
                GLX_DEPTH_SIZE, 1,
                None};
        XVisualInfo * vi;
        g_dpy = XOpenDisplay(0);
        g_xim = XOpenIM(g_dpy, 0, 0, 0);
        cvInject(CVE_INIT, 0, 0);
        openwin(cvInject(CVQ_XPOS, 0, 0),
                cvInject(CVQ_YPOS, 0, 0),
                cvInject(CVQ_WIDTH, 0, 0),
                cvInject(CVQ_HEIGHT, 0, 0), 1);
        vi = glXChooseVisual(g_dpy, scr(), attr);
        g_ctx = glXCreateContext(g_dpy, vi, 0, True);
        XFree(vi);

        map();
        ((int(*)(int))glXGetProcAddress((GLubyte*)"glXSwapIntervalSGI"))(1);
        cvInject(CVE_GLINIT, 0, 0);
        while (!g_done) {
                XEvent e;
                if (XCheckWindowEvent(g_dpy, g_win, EVMASK, &e)
                    || XCheckTypedWindowEvent(g_dpy, g_win, ClientMessage, &e))
                        handle(g_dpy, g_win, g_xic, &e);
                glXSwapBuffers(g_dpy, g_win);
                cvInject(CVE_UPDATE, 0, 0);
        }
        cvInject(CVE_GLTERM, 0, 0);
                closewin();
                glXDestroyContext(g_dpy, g_ctx);
        XCloseIM(g_xim);
        XCloseDisplay(g_dpy);
        return cvInject(CVE_TERM, 0, 0);
}
コード例 #16
0
ファイル: main.cpp プロジェクト: QtDesktop/screengrab
int main(int argc, char *argv[])
{
    SingleApp scr(argc, argv, QStringLiteral(VERSION));
    scr.setApplicationVersion(QStringLiteral(VERSION));
    scr.setOrganizationName(QStringLiteral("lxqt"));
    scr.setOrganizationDomain(QStringLiteral("https://lxqt.org"));
    scr.setApplicationName(QStringLiteral("screengrab"));
    scr.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
    Core *ScreenGrab = Core::instance();
    ScreenGrab->modules()->initModules();
    ScreenGrab->processCmdLineOpts(scr.arguments());

    QObject::connect(&scr, &SingleApp::messageReceived, ScreenGrab, &Core::initWindow);

    if (!ScreenGrab->config()->getAllowMultipleInstance() && scr.isRunning())
    {
        QString type = QString::number(ScreenGrab->config()->getDefScreenshotType());
        scr.sendMessage(QStringLiteral("screengrab --type=") + type);
        return 0;
    }

    return scr.exec();
}
コード例 #17
0
ファイル: main.cpp プロジェクト: futuarmo/SVkPlayer
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    /*QLabel *id = new QLabel("Email or mobile phone");
    QLineEdit *idLine = new QLineEdit;
    QLabel *password = new QLabel("Password");
    QLineEdit *passwordLine = new QLineEdit;
    QPushButton *enter = new QPushButton("Enter");

    QHBoxLayout *enterBox = new QHBoxLayout;
    //LoginScreenForm *form = new LoginScreenForm(id, idLine, password, passwordLine, enter, box, enterBox);
    //LoginScreen mainWindow(form);*/
    QVBoxLayout *box = new QVBoxLayout;
    QWebView *view = new QWebView;
    QProgressBar *bar = new QProgressBar;
    WebLoginScreen scr(view, bar, box);
    scr.show();
    requester req("6585056", "effe73b8de201068cc9a8819dac22d518f4e6a06e304d542c71f7af93f88fad2b44db86ff2ccc28b831ed");
    req.getAudio("6585056");
    QEventLoop wait;
    QTimer::singleShot(5000, &wait, SLOT(quit()));
    wait.exec();
    qDebug() << "get Result " << req.getResult();
    QByteArray array = req.getResult();
    qDebug() << "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" << array;
    xmlParser prs;
    dataHolder* data = new dataHolder(prs.parseXML(array));
    qDebug() << data->getObject(102).value("title").toString();
    dataModel model(data);
    qDebug() << model.rowCount();
    QListView list;
    list.setModel(&model);
    songsListDelegate *del = new songsListDelegate;
    list.setItemDelegate(del);
    list.show();
    return app.exec();
}
コード例 #18
0
ファイル: main.cpp プロジェクト: qianlv/learning
int main()
{
    Scales_data item;
    std::string null_book = "9-999-99999-9";
    item.combine(null_book);
    print(std::cout, item) << std::endl;
    constexpr Debug io_sub(false, true, false);
    if (io_sub.any())
        std::cerr << "print appropriate error messages" << std::endl;
    constexpr Debug prob(false);
    if (prob.any())
        std::cerr << "print an error messages" << std::endl;

    // Scales_data total(std::cin);
    std::string null_book("abc");
    // Scales_data item = null_book;  // explicit Scales_data(std::string) cause error
    Scales_data item;
    item.combine(Scales_data(null_book));
    item.combine(static_cast<Scales_data>(std::cin));

    Screen myScreen(5, 3, '$');
    const Screen blank(5, 3, '0');
    myScreen.move(1, 3).set('#').display(std::cout);
    blank.display(std::cout);
    std::cout << std::endl;
    Window_mgr my_windows({myScreen, blank});
    my_windows.display();
    my_windows.clear(0);
    my_windows.display();

    Screen::pos ht(24), wd(80);
    Screen scr(ht, wd, ' ');
    Screen *p = &scr;
    char c = scr.get();
    c = p->get();
    std::cout << c << std::endl;
}
コード例 #19
0
ファイル: fmtowns.cpp プロジェクト: MASHinfo/mame
void towns_state::towns_crtc_refresh_mode()
{
	rectangle scr(0, m_video.towns_crtc_reg[4] - m_video.towns_crtc_reg[0], 0, m_video.towns_crtc_reg[8] / 2);

	// layer 0
	m_video.towns_crtc_layerscr[0].min_x = m_video.towns_crtc_reg[9] - m_video.towns_crtc_reg[0];
	m_video.towns_crtc_layerscr[0].min_y = (m_video.towns_crtc_reg[13] - m_video.towns_crtc_reg[6]) / 2;
	m_video.towns_crtc_layerscr[0].max_x = m_video.towns_crtc_reg[10] - m_video.towns_crtc_reg[0];
	m_video.towns_crtc_layerscr[0].max_y = ((m_video.towns_crtc_reg[14] - m_video.towns_crtc_reg[6]) / 2) - 1;

	// layer 1
	m_video.towns_crtc_layerscr[1].min_x = m_video.towns_crtc_reg[11] - m_video.towns_crtc_reg[0];
	m_video.towns_crtc_layerscr[1].min_y = (m_video.towns_crtc_reg[15] - m_video.towns_crtc_reg[6]) / 2;
	m_video.towns_crtc_layerscr[1].max_x = m_video.towns_crtc_reg[12] - m_video.towns_crtc_reg[0];
	m_video.towns_crtc_layerscr[1].max_y = ((m_video.towns_crtc_reg[16] - m_video.towns_crtc_reg[6]) / 2) - 1;

	// sanity checks
	if(scr.max_x == 0 || scr.max_y == 0)
		return;
	if(scr.max_x <= scr.min_x || scr.max_y <= scr.min_y)
		return;

	m_screen->configure(scr.max_x+1,scr.max_y+1,scr,HZ_TO_ATTOSECONDS(60));
}
コード例 #20
0
/* ****************************************************************************
*
* restErrorReplyGet - 
*
* This function renders an error reply depending on the 'request' type.
* Many responses have different syntax and especially the tag in the reply
* differs (registerContextResponse, discoverContextAvailabilityResponse etc).
*
* Also, the function is called from more than one place, especially from 
* restErrorReply, but also from where the payload type is matched against the request URL.
* Where the payload type is matched against the request URL, the incoming 'request' is a
* request and not a response.
*/
std::string restErrorReplyGet(ConnectionInfo* ciP, Format format, std::string indent, std::string request, HttpStatusCode code, std::string details)
{
   std::string   tag = tagGet(request);
   StatusCode    errorCode(code, details, "errorCode");
   std::string   reply;

   ciP->httpStatusCode = SccOk;

   if (tag == "registerContextResponse")
   {
      RegisterContextResponse rcr("000000000000000000000000", errorCode);
      reply =  rcr.render(RegisterContext, format, indent);
   }
   else if (tag == "discoverContextAvailabilityResponse")
   {
      DiscoverContextAvailabilityResponse dcar(errorCode);
      reply =  dcar.render(DiscoverContextAvailability, format, indent);
   }
   else if (tag == "subscribeContextAvailabilityResponse")
   {
      SubscribeContextAvailabilityResponse scar("000000000000000000000000", errorCode);
      reply =  scar.render(SubscribeContextAvailability, format, indent);
   }
   else if (tag == "updateContextAvailabilitySubscriptionResponse")
   {
      UpdateContextAvailabilitySubscriptionResponse ucas(errorCode);
      reply =  ucas.render(UpdateContextAvailabilitySubscription, format, indent, 0);
   }
   else if (tag == "unsubscribeContextAvailabilityResponse")
   {
      UnsubscribeContextAvailabilityResponse ucar(errorCode);
      reply =  ucar.render(UnsubscribeContextAvailability, format, indent);
   }
   else if (tag == "notifyContextAvailabilityResponse")
   {
      NotifyContextAvailabilityResponse ncar(errorCode);
      reply =  ncar.render(NotifyContextAvailability, format, indent);
   }

   else if (tag == "queryContextResponse")
   {
      QueryContextResponse qcr(errorCode);
      reply =  qcr.render(QueryContext, format, indent);
   }
   else if (tag == "subscribeContextResponse")
   {
      SubscribeContextResponse scr(errorCode);
      reply =  scr.render(SubscribeContext, format, indent);
   }
   else if (tag == "updateContextSubscriptionResponse")
   {
      UpdateContextSubscriptionResponse ucsr(errorCode);
      reply =  ucsr.render(UpdateContextSubscription, format, indent);
   }
   else if (tag == "unsubscribeContextResponse")
   {
      UnsubscribeContextResponse uncr(errorCode);
      reply =  uncr.render(UnsubscribeContext, format, indent);
   }
   else if (tag == "updateContextResponse")
   {
      UpdateContextResponse ucr(errorCode);
      reply = ucr.render(UpdateContext, format, indent);
   }
   else if (tag == "notifyContextResponse")
   {
      NotifyContextResponse ncr(errorCode);
      reply =  ncr.render(NotifyContext, format, indent);
   }
   else if (tag == "StatusCode")
   {
     StatusCode sc(code, details);
     reply = sc.render(format, indent);
   }
   else
   {
      OrionError orionError(errorCode);

      LM_E(("Unknown tag: '%s', request == '%s'", tag.c_str(), request.c_str()));
      
      reply = orionError.render(format, indent);
   }

   return reply;
}
コード例 #21
0
ファイル: DisplayResX.cpp プロジェクト: Olti/mythtv
const DisplayResVector& DisplayResX::GetVideoModes(void) const
{
    if (!m_videoModes.empty())
        return m_videoModes;

    MythXDisplay *display = NULL;

    XRRScreenConfiguration *cfg = GetScreenConfig(display);

    if (!cfg)
        return m_videoModes;

    int num_sizes, num_rates;

    XRRScreenSize *sizes = NULL;

    sizes = XRRConfigSizes(cfg, &num_sizes);

    for (int i = 0; i < num_sizes; ++i)
    {
        short *rates = NULL;
        rates = XRRRates(display->GetDisplay(), display->GetScreen(),
                         i, &num_rates);
        DisplayResScreen scr(sizes[i].width, sizes[i].height,
                             sizes[i].mwidth, sizes[i].mheight,
                             rates, num_rates);
        m_videoModes.push_back(scr);
    }

    t_screenrate screenmap;

    int nvidiarate = GetNvidiaRates(screenmap);

    if (nvidiarate > 0)
    {
        // Update existing DisplayResScreen vector, and update it with
        // new frequencies
        for (uint i = 0; i < m_videoModes.size(); i++)
        {
            DisplayResScreen scr = m_videoModes[i];
            int w = scr.Width();
            int h = scr.Height();
            int mw = scr.Width_mm();
            int mh = scr.Height_mm();
            std::vector<double> newrates;
            std::map<double, short> realRates;
            const std::vector<double>& rates = scr.RefreshRates();
            bool found = false;

            for (std::vector<double>::const_iterator it = rates.begin();
                    it !=  rates.end(); ++it)
            {
                uint64_t key = DisplayResScreen::CalcKey(w, h, *it);

                if (screenmap.find(key) != screenmap.end())
                {
                    // Rate is defined in NV-CONTROL extension, use it
                    newrates.push_back(screenmap[key]);
                    realRates[screenmap[key]] = (int) round(*it);
                    found = true;
#if 0
                    LOG(VB_PLAYBACK, LOG_INFO,
                        QString("CustomRate Found, set %1x%2@%3 as %4Hz")
                        .arg(w) .arg(h) .arg(*it) .arg(screenmap[key]));
#endif
                }
            }

            if (found)
            {
                m_videoModes.erase(m_videoModes.begin() + i);
                std::sort(newrates.begin(), newrates.end());
                m_videoModes.insert(m_videoModes.begin() + i,
                                    DisplayResScreen(w, h, mw, mh, newrates,
                                                     realRates));
            }
        }
    }

    m_videoModesUnsorted = m_videoModes;

    std::sort(m_videoModes.begin(), m_videoModes.end());
    XRRFreeScreenConfigInfo(cfg);
    delete display;

    return m_videoModes;
}
コード例 #22
0
ファイル: util.cpp プロジェクト: mapleyustat/papaya
void dump_contours (const std::string &filename, const Boundary &a, int flags) {
    std::ofstream os ((filename + ".out").c_str ());
    dump_contours (os, a);
    std::ofstream scr ((filename + ".gp").c_str ());
    scr << "plot \"" << filename << ".out\" w lp\n"; 
}
コード例 #23
0
ファイル: paired.cpp プロジェクト: acgtun/walt
int OutputBestPairedResults(const CandidatePosition& r1,
                            const CandidatePosition& r2, const int& frag_range,
                            const uint32_t& read_len1,
                            const uint32_t& read_len2, const Genome& genome,
                            const string& read_name, const string& read_seq1,
                            const string& read_score1, const string& read_seq2,
                            const string& read_score2, const bool& SAM,
                            FILE * fout) {
  string read_seq2_rev = ReverseComplimentString(read_seq2);
  string read_scr2_rev = ReverseString(read_score2);

  uint32_t chr_id1 = getChromID(genome.start_index, r1.genome_pos);
  uint32_t chr_id2 = getChromID(genome.start_index, r2.genome_pos);

  uint32_t s1 = 0, s2 = 0, e1 = 0, e2 = 0;
  ForwardChromPosition(r1.genome_pos, r1.strand, chr_id1, read_len1, genome, s1,
                       e1);
  ForwardChromPosition(r2.genome_pos, r2.strand, chr_id2, read_len2, genome, s2,
                       e2);

  uint32_t overlap_s = MAX(s1, s2);
  uint32_t overlap_e = MIN(e1, e2);

  uint32_t one_l = r1.strand == '+' ? s1 : MAX(overlap_e, s1);
  uint32_t one_r = r1.strand == '+' ? MIN(overlap_s, e1) : e1;

  uint32_t two_l = r1.strand == '+' ? MAX(overlap_e, s2) : s2;
  uint32_t two_r = r1.strand == '+' ? e2 : MIN(overlap_s, e2);

  int len = r1.strand == '+' ? (two_r - one_l) : (one_r - two_l);
  if (SAM) {
    return len;
  }

  string seq(len, 'N');
  string scr(len, 'B');
  if (len > 0 && len <= frag_range) {
    // lim_one: offset in merged sequence where overlap starts
    uint32_t lim_one = one_r - one_l;
    copy(read_seq1.begin(), read_seq1.begin() + lim_one, seq.begin());
    copy(read_score1.begin(), read_score1.begin() + lim_one, scr.begin());

    uint32_t lim_two = two_r - two_l;
    copy(read_seq2_rev.end() - lim_two, read_seq2_rev.end(),
         seq.end() - lim_two);
    copy(read_scr2_rev.end() - lim_two, read_scr2_rev.end(),
         scr.end() - lim_two);

    // deal with overlapping part
    if (overlap_s < overlap_e) {
      uint32_t one_bads = count(read_seq1.begin(), read_seq1.end(), 'N');
      int info_one = read_len1 - (one_bads + r1.mismatch);

      uint32_t two_bads = count(read_seq2_rev.begin(), read_seq2_rev.end(),
                                'N');
      int info_two = read_len2 - (two_bads + r2.mismatch);

      // use the mate with the most info to fill in the overlap
      if (info_one >= info_two) {
        uint32_t a = r1.strand == '+' ? (overlap_s - s1) : (e1 - overlap_e);
        uint32_t b = r1.strand == '+' ? (overlap_e - s1) : (e1 - overlap_s);
        copy(read_seq1.begin() + a, read_seq1.begin() + b,
             seq.begin() + lim_one);
        copy(read_score1.begin() + a, read_score1.begin() + b,
             scr.begin() + lim_one);
      } else {
        uint32_t a = r1.strand == '+' ? (overlap_s - s2) : (e2 - overlap_e);
        uint32_t b = r1.strand == '+' ? (overlap_e - s2) : (e2 - overlap_s);
        copy(read_seq2_rev.begin() + a, read_seq2_rev.begin() + b,
             seq.begin() + lim_one);
        copy(read_scr2_rev.begin() + a, read_scr2_rev.begin() + b,
             scr.begin() + lim_one);
      }
    }
  }

  uint32_t start_pos = r1.strand == '+' ? s1 : s2;
  fprintf(fout, "%s\t%u\t%u\tFRAG:%s\t%u\t%c\t%s\t%s\n",
          genome.name[chr_id1].c_str(), start_pos, start_pos + len,
          read_name.c_str(), r1.mismatch + r2.mismatch, r1.strand, seq.c_str(),
          scr.c_str());

  return 0;
}
コード例 #24
0
ファイル: x68k_crtc.cpp プロジェクト: fesh0r/mame-full
void x68k_crtc_device::refresh_mode()
{
	// Calculate data from register values
	m_vmultiple = 1;
	if ((m_reg[20] & 0x10) != 0 && (m_reg[20] & 0x0c) == 0)
		m_vmultiple = 2;  // 31.5kHz + 256 lines = doublescan
	if (m_interlace)
		m_vmultiple = 0.5f;  // 31.5kHz + 1024 lines or 15kHz + 512 lines = interlaced
	m_htotal = (m_reg[0] + 1) * 8;
	m_vtotal = (m_reg[4] + 1) / m_vmultiple; // default is 567 (568 scanlines)
	m_hbegin = (m_reg[2] * 8) + 1;
	m_hend = (m_reg[3] * 8);
	m_vbegin = (m_reg[6]) / m_vmultiple;
	m_vend = (m_reg[7] - 1) / m_vmultiple;
	if ((m_vmultiple == 2) && !(m_reg[7] & 1)) // otherwise if the raster irq line == vblank line, the raster irq fires too late
		m_vend++;
	m_hsync_end = (m_reg[1]) * 8;
	m_vsync_end = (m_reg[5]) / m_vmultiple;
	m_hsyncadjust = m_reg[8];

	rectangle scr(0, m_htotal - 8, 0, m_vtotal);
	if (scr.max_y <= m_vend)
		scr.max_y = m_vend + 2;
	if (scr.max_x <= m_hend)
		scr.max_x = m_hend + 2;
	rectangle visiblescr(m_hbegin, m_hend, m_vbegin, m_vend);

	// expand visible area to the size indicated by CRTC reg 20
	int length = m_hend - m_hbegin;
	if (length < m_width)
	{
		visiblescr.min_x = m_hbegin - ((m_width - length)/2);
		visiblescr.max_x = m_hend + ((m_width - length)/2);
	}
	length = m_vend - m_vbegin;
	if (length < m_height)
	{
		visiblescr.min_y = m_vbegin - ((m_height - length)/2);
		visiblescr.max_y = m_vend + ((m_height - length)/2);
	}
	// bounds check
	if (visiblescr.min_x < 0)
		visiblescr.min_x = 0;
	if (visiblescr.min_y < 0)
		visiblescr.min_y = 0;
	if (visiblescr.max_x >= scr.max_x)
		visiblescr.max_x = scr.max_x - 2;
	if (visiblescr.max_y >= scr.max_y - 1)
		visiblescr.max_y = scr.max_y - 2;

//  LOG("CRTC regs - %i %i %i %i  - %i %i %i %i - %i - %i\n", m_reg[0], m_reg[1], m_reg[2], m_reg[3],
//      m_reg[4], m_reg[5], m_reg[6], m_reg[7], m_reg[8], m_reg[9]);
	unsigned div = (m_reg[20] & 0x03) == 0 ? 4 : 2;
	if (BIT(m_reg[20], 4) && !BIT(m_reg[20], 1))
		div = BIT(m_reg[20], 0) ? 3 : 6;
	if ((m_reg[20] & 0x0c) == 0)
		div *= 2;
	attotime refresh = attotime::from_hz((BIT(m_reg[20], 4) ? clock_69m() : clock_39m()) / div) * (scr.max_x * scr.max_y);
	LOG("screen().configure(%i,%i,[%i,%i,%i,%i],%f)\n", scr.max_x, scr.max_y, visiblescr.min_x, visiblescr.min_y, visiblescr.max_x, visiblescr.max_y, refresh.as_hz());
	screen().configure(scr.max_x, scr.max_y, visiblescr, refresh.as_attoseconds());
}
コード例 #25
0
ファイル: Bras.cpp プロジェクト: clement91190/eurobot
void Bras::in_state_func()
{
    switch (state)
    {
        case RANGE_DEPART :
            scr(); 
            a0();
            spb();
            pf();
            break;
        case INT_RANGE :
            //va bumper
            scn(); 
            a0();
            spb();
            pf();
            break;
        case INT2_RANGE :
            set_time_out(400, trigger_to_be);
            scn(); 
            a0();
            spb();
            pf();
            break;
         case GO_ATTENTE :
            scn(); 
            a1();
            spb();
            pf();
            break;

        case ATTENTE_ACTIF :
            scn(); 
            a1();
            spb();
            pf();
            break;

        case DESCENTE_LAT :
            scn(); 
            a4();
            spb();
            pf();
            break;
        case DESCENTE_POMPE_LAT :
            scn(); 
            a4();
            spb();
            po();
            break;
        case PRISE_LAT :
            scn(); 
            a4();
            spb();
            po();
            break;
        case MONTE_VERT :
            set_time_out(500, TIME_OUT);
            scn(); 
            a0();
            spv();
            po();
            break;
        case MONTE :
            scn(); 
            a0();
            spb();
            po();
            break;
        case RANGE_PRISE :
            set_time_out(2000, TIME_OUT);
            scl(); 
            a0();
            spb();
            po();
            break;
        case LACHE :
            set_time_out(300, TIME_OUT);
            scl(); 
            a0();
            spb();
            pf();
            break;
        case MONTE_ECH :
            scn(); 
            a3();
            spb();
            po();
            break;

        case MONTE_ECH_VERT :
            sce(); 
            a3();
            spr();
            po();
            break;
       
        case RETOURNE_ECH :
            call_for_help();
            sce(); 
            a3();
            spr();
            po();
            break;
        case REPLACE_APRES_ECH :
            set_time_out(300, TIME_OUT);
            scn(); 
            a3();
            spb();
            pf();
            break;

        case SEND_MINE :
            scv(); 
            a4();
            spv();
            pf();
            break;
        case SENDMASTER_PRET :
            scv(); 
            a4();
            spv();
            po();
            break;
        case PRISE_VERT :
            scv(); 
            a4();
            spv();
            po();
            break;

        case PRISE_COPAIN :
            a2(); 
            sce();
            spb();
            po();
            break;
    }
}
コード例 #26
0
ファイル: main.cpp プロジェクト: JackShannon/nirvash
void start_video(void *data)
{
	Nepgear::State *ng = (Nepgear::State*)data;
	Nepgear::Window *w;
	Nepgear::Logger log(NULL);
	log.print_header();

	// wait for the window to be created.
	while(ng->windows.empty());

	w = ng->windows[0];

	// Bind the OpenGL context to this thread
	const Nepgear::WindowFlags f = w->GetFlags();
	w->MakeCurrent();
	w->VSync(true);
	if (!w->Prepare(f.gl_major, f.gl_minor))
	{
		/* We shouldn't ever get here if window creation succeeded, unless
		 * the driver lied to us when we created the window. */
		log.warn(
			"OpenGL %d.%d is not supported. Please check your drivers "
			"or hardware for support.", f.gl_major, f.gl_minor
		);
		w->ClearCurrent();
		return;
	}

	// HACK: NVIDIA 295.20 drivers specifically doesn't wait properly.
	if (strcmp((const char*)glGetString(GL_VERSION), "3.2.0 NVIDIA 295.20")==0)
		ng->configuration["enable_wait_hack"] = true;
	ng->start = true;

	std::vector<Nepgear::Screen> screen_stack;

	Nepgear::Screen scr("Base");
	scr.load(ng);

	screen_stack.push_back(scr);

	glm::vec4 clear = glm::vec4(0.1, 0.4, 0.8, 1.0);

	glClearColor(clear.r, clear.g, clear.b, clear.a);
	glEnable(GL_DEPTH_TEST);

	double now = glfwGetTime();
	double then = now;
	double delta = 0.0;

	while(ng->running)
	{
		now = glfwGetTime();
		delta = now - then;
		then = now;

		glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

		for (size_t i = 0; i < screen_stack.size(); i++)
			screen_stack[i].update(delta);

		for (size_t i = 0; i < screen_stack.size(); i++)
			screen_stack[i].draw();

		w->SwapBuffers();

		// This only needs to happen for the first update!
		if (ng->configuration["enable_wait_hack"])
		{
			glfwPollEvents();
			ng->configuration["enable_wait_hack"] = false;
		}
	}

	screen_stack.clear();

	w->ClearCurrent();
}
コード例 #27
0
ファイル: script_create_dialog.cpp プロジェクト: a12n/godot
void ScriptCreateDialog::ok_pressed() {

	if (class_name->is_editable() && !_validate(class_name->get_text())) {

		alert->set_text("Class Name is Invalid!");
		alert->popup_centered_minsize();
		return;
	}
	if (!_validate(parent_name->get_text())) {
		alert->set_text("Parent Class Name is Invalid!");
		alert->popup_centered_minsize();

		return;

	}


	String cname;
	if (class_name->is_editable())
		cname=class_name->get_text();



	String text = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text());
	Script *script = ScriptServer::get_language( language_menu->get_selected() )->create_script();
	script->set_source_code(text);
	if (cname!="")
		script->set_name(cname);


	Ref<Script> scr(script);

	if (!internal->is_pressed()) {


		String lpath = Globals::get_singleton()->localize_path(file_path->get_text());
		script->set_path(lpath);
		if (!path_valid) {

			alert->set_text("Path is Invalid!");
			alert->popup_centered_minsize();
			return;

		}
		Error err = ResourceSaver::save(lpath,scr,ResourceSaver::FLAG_CHANGE_PATH);		
		if (err!=OK) {

			alert->set_text("Could not create script in filesystem: "+String(""));
			alert->popup_centered_minsize();
			return;
		}
		scr->set_path(lpath);
	//EditorFileSystem::get_singleton()->update_file(lpath,scr->get_type());


	}

	hide();
	emit_signal("script_created",scr);

}
コード例 #28
0
ファイル: QScope.cpp プロジェクト: HaikuArchives/QScope
QScopeWindow::QScopeWindow() : BWindow(BRect(0, 0, SCOPE_WIDTH+200-1, SCOPE_HEIGHT-1), "QScope", B_TITLED_WINDOW, B_NOT_RESIZABLE)
{
	// Move window to right position
	Lock();
	MoveTo(80, 60);
	BRect b = Bounds();

	// Look up colors for scope
	{
		BScreen scr(this);
		illumination = false;
		c_black = scr.IndexForColor(0, 0, 0);
		c_dark_green = scr.IndexForColor(0, 32, 16);
		for (int i=0; i<16; i++)
			c_beam[i] = scr.IndexForColor(0, 255 - i * 8, 128 - i * 4);
	}

	// Light gray background
	BView *top = new BView(BRect(0, 0, b.right, b.bottom), "top", B_FOLLOW_NONE, B_WILL_DRAW);
	AddChild(top);
	top->SetViewColor(fill_color);

	// Allocate bitmap
	the_bitmap = new BBitmap(BRect(0, 0, SCOPE_WIDTH-1, SCOPE_HEIGHT-1), B_COLOR_8_BIT);

	// Create bitmap view
	main_view = new BitmapView(BRect(0, 0, SCOPE_WIDTH-1, SCOPE_HEIGHT-1), the_bitmap);
	top->AddChild(main_view);

	// Create interface elements
	{
		BBox *box = new BBox(BRect(SCOPE_WIDTH + 4, 4, SCOPE_WIDTH + 196, 62));
		top->AddChild(box);
		box->SetLabel("Input");

		BPopUpMenu *popup = new BPopUpMenu("stream popup", true, true);
		popup->AddItem(new BMenuItem("DAC", new BMessage(MSG_DAC_STREAM)));
		popup->AddItem(new BMenuItem("ADC", new BMessage(MSG_ADC_STREAM)));
		popup->SetTargetForItems(this);
		popup->ItemAt(0)->SetMarked(true);
		BMenuField *menu_field = new BMenuField(BRect(4, 14, 188, 34), "stream", "Stream", popup);
		box->AddChild(menu_field);

		popup = new BPopUpMenu("channel popup", true, true);
		popup->AddItem(new BMenuItem("Left", new BMessage(MSG_LEFT_CHANNEL)));
		popup->AddItem(new BMenuItem("Right", new BMessage(MSG_RIGHT_CHANNEL)));
		popup->AddItem(new BMenuItem("Stereo", new BMessage(MSG_STEREO_CHANNELS)));
		popup->SetTargetForItems(this);
		popup->ItemAt(0)->SetMarked(true);
		menu_field = new BMenuField(BRect(4, 34, 188, 54), "channel", "Channel", popup);
		box->AddChild(menu_field);
	}

	{
		BBox *box = new BBox(BRect(SCOPE_WIDTH + 4, 66, SCOPE_WIDTH + 196, 104));
		top->AddChild(box);
		box->SetLabel("Time");

		BPopUpMenu *popup = new BPopUpMenu("time/div popup", true, true);
		popup->AddItem(new BMenuItem("0.1ms", new BMessage(MSG_TIME_DIV_100us)));
		popup->AddItem(new BMenuItem("0.2ms", new BMessage(MSG_TIME_DIV_200us)));
		popup->AddItem(new BMenuItem("0.5ms", new BMessage(MSG_TIME_DIV_500us)));
		popup->AddItem(new BMenuItem("1ms", new BMessage(MSG_TIME_DIV_1ms)));
		popup->AddItem(new BMenuItem("2ms", new BMessage(MSG_TIME_DIV_2ms)));
		popup->AddItem(new BMenuItem("5ms", new BMessage(MSG_TIME_DIV_5ms)));
		popup->AddItem(new BMenuItem("10ms", new BMessage(MSG_TIME_DIV_10ms)));
		popup->SetTargetForItems(this);
		popup->ItemAt(4)->SetMarked(true);
		BMenuField *menu_field = new BMenuField(BRect(4, 14, 188, 34), "time/div", "Time/Div.", popup);
		box->AddChild(menu_field);
	}

	{
		BBox *box = new BBox(BRect(SCOPE_WIDTH + 4, 108, SCOPE_WIDTH + 196, 230));
		top->AddChild(box);
		box->SetLabel("Trigger");

		BPopUpMenu *popup = new BPopUpMenu("trigger channel popup", true, true);
		popup->AddItem(new BMenuItem("Left", new BMessage(MSG_TRIGGER_LEFT)));
		popup->AddItem(new BMenuItem("Right", new BMessage(MSG_TRIGGER_RIGHT)));
		popup->SetTargetForItems(this);
		popup->ItemAt(0)->SetMarked(true);
		BMenuField *menu_field = new BMenuField(BRect(4, 14, 188, 34), "trigger_channel", "Channel", popup);
		box->AddChild(menu_field);

		popup = new BPopUpMenu("trigger mode popup", true, true);
		popup->AddItem(new BMenuItem("Off", new BMessage(MSG_TRIGGER_OFF)));
		popup->AddItem(new BMenuItem("Level", new BMessage(MSG_TRIGGER_LEVEL)));
		popup->AddItem(new BMenuItem("Peak", new BMessage(MSG_TRIGGER_PEAK)));
		popup->SetTargetForItems(this);
		popup->ItemAt(1)->SetMarked(true);
		menu_field = new BMenuField(BRect(4, 34, 188, 54), "trigger_mode", "Trigger Mode", popup);
		box->AddChild(menu_field);

		BStringView *label = new BStringView(BRect(5, 54, 97, 73), "", "Level");
		box->AddChild(label);
		TSliderView *the_slider = new TSliderView(BRect(98, 58, 188, 76), "level", 0.5, trigger_level_callback, this);
		box->AddChild(the_slider);

		popup = new BPopUpMenu("slope popup", true, true);
		popup->AddItem(new BMenuItem("pos", new BMessage(MSG_SLOPE_POS)));
		popup->AddItem(new BMenuItem("neg", new BMessage(MSG_SLOPE_NEG)));
		popup->SetTargetForItems(this);
		popup->ItemAt(0)->SetMarked(true);
		menu_field = new BMenuField(BRect(4, 76, 188, 96), "slope", "Slope", popup);
		box->AddChild(menu_field);

		label = new BStringView(BRect(5, 96, 97, 115), "", "Hold off");
		box->AddChild(label);
		the_slider = new TSliderView(BRect(98, 100, 188, 118), "hold_off", 0.0, hold_off_callback, this);
		box->AddChild(the_slider);
	}

	BCheckBox *check_box = new BCheckBox(BRect(SCOPE_WIDTH + 10, 234, SCOPE_WIDTH + 190, 254), "illumination", "Illumination", new BMessage(MSG_ILLUMINATION));
	top->AddChild(check_box);
	Unlock();

	// Create drawing looper
	the_looper = new DrawLooper(main_view, the_bitmap);

	// Create stream objects
	dac_stream = new BDACStream();
	adc_stream = new BADCStream();

	// Create subscriber and attach it to the stream
	the_subscriber = new QScopeSubscriber(the_looper);
	the_subscriber->Enter(dac_stream);

	// Show the window
	Show();
}
コード例 #29
0
ファイル: IO.cpp プロジェクト: clement91190/eurobot
void Pince::in_state_func()
{
    switch (state)
    {
        case RANGE_DEPART :
            a1();
            scv();
            slr();
            break;
        case TAPE_VERTICAL :
            a1();
            scv();
            slt();
            break;
        case INTERMEDIAIRE_SORTIE :
            set_time_out(400, trigger_to_be);
            a1();
            slo();
            scv();
            break;
        case HORIZ_VERT :
            a1();
            slo();
            scn();
            break;
        case NOMINAL_VIDE : 
            set_time_out(500, trigger_to_be);
            a0();
            slo();
            scn();
            break;
        case ACTIF_TORCHE :
            a0();
            slo();
            scn();
            break;
        case PRISE_TORCHE : 
            Serial.println('# PRISE');
            a0();
            slf();
            scn();
            break;
        case ACTIF_FEU :
            a0();
            slo();
            scn();
            break;
        case PRISE_FEU :
            Serial.println('# PRISE');
            set_time_out(500, TIME_OUT);
            a0();
            slf();
            scn();
            break;
        case WAIT_COOL_OK :
            break;
        case MONTE_COOL :
            set_time_out(800, TIME_OUT);
            a1();
            slf();
            scn();
            break;
        case MONTE_COOL2 :
            a1();
            slf();
            scn();
            break;
        case RETOURNE_COOL_N :
            set_time_out(500, TIME_OUT);
            a1();
            slf();
            scr();
            break;
        case DESCEND_COOL_N :
            a0();
            slf();
            scr();
            break;
        case POSE_COOL_N :
            set_time_out(500, TIME_OUT);
            a0();
            slo();
            scr();
            break;
        case INT1_COOL_N : 
            set_time_out(500, TIME_OUT);
            a1();
            slo();
            scr();
            break;
        case INT2_COOL_N : 
            set_time_out(500, TIME_OUT);
            a1();
            slf();
            scr();
            break;
        case INT3_COOL_N :
            set_time_out(500, TIME_OUT);
            a1();
            slf();
            scn();
            break;
        case INT_RANGE :
            a1();
            slo();
            break;
        case INT2_RANGE :
            set_time_out(10, trigger_to_be);
            a1();
            slo();
            break;
    }
}
コード例 #30
0
int main (int argc, char *argv[])
{
  char *oname = nullptr, *dot = nullptr, *filename = nullptr;
  char str[32];

  const char* ext=EXT;

  int
    n, n1,n2,err,
    num_axes,num_blocks,
    num_side_sets,num_node_sets,num_time_steps,
    num_info_lines,num_global_vars,
    num_nodal_vars,num_element_vars,num_nodeset_vars, num_sideset_vars;

  size_t num_nodes = 0;
  size_t num_elements = 0;

  int mat_version = 73;

  /* process arguments */
  for (int j=1; j< argc; j++){
    if ( strcmp(argv[j],"-t")==0){    /* write text file (*.m) */
      del_arg(&argc,argv,j);
      textfile=1;
      j--;
      continue;
    }
    if ( strcmp(argv[j],"-h")==0){    /* write help info */
      del_arg(&argc,argv,j);
      usage();
      exit(1);
    }
    if ( strcmp(argv[j],"-d")==0){    /* write help info */
      del_arg(&argc,argv,j);
      j--;
      debug = 1;
      continue;
    }
    if ( strcmp(argv[j],"-v73")==0){    /* Version 7.3 */
      del_arg(&argc,argv,j);
      mat_version = 73;
      j--;
      continue;
    }
    // This matches the option used in matlab
    if ( (strcmp(argv[j],"-v7.3")==0) || (strcmp(argv[j],"-V7.3")==0)){    /* Version 7.3 */
      del_arg(&argc,argv,j);
      mat_version = 73;
      j--;
      continue;
    }
    if ( strcmp(argv[j],"-v5")==0){    /* Version 5 (default) */
      del_arg(&argc,argv,j);
      mat_version = 50;
      j--;
      continue;
    }
    if ( strcmp(argv[j],"-o")==0){    /* specify output file name */
      del_arg(&argc,argv,j);
      if ( argv[j] ){
        oname=(char*)calloc(strlen(argv[j])+10,sizeof(char));
        strcpy(oname,argv[j]);
        del_arg(&argc,argv,j);
        std::cout << "output file: " << oname << "\n";
      }
      else {
        std::cerr << "ERROR: Invalid output file specification.\n";
        return 2;
      }
      j--;

      continue;
    }
  }

  /* QA Info */
  printf("%s: %s, %s\n", qainfo[0], qainfo[2], qainfo[1]);

  /* usage message*/
  if (argc != 2){
    usage();
    exit(1);
  }

  /* open output file */
  if ( textfile )
    ext=".m";

  if ( !oname ){
    filename = (char*)malloc( strlen(argv[1])+10);
    strcpy(filename,argv[1]);
    dot=strrchr(filename,'.');
    if ( dot ) *dot='\0';
    strcat(filename,ext);
  }
  else {
    filename=oname;
  }

  if ( textfile ){
    m_file = fopen(filename,"w");
    if (!m_file ){
      std::cerr << "ERROR: Unable to open " << filename << "\n";
      exit(1);
    }
  }
  else {
    if (mat_version == 50) {
      mat_file = Mat_CreateVer(filename, nullptr, MAT_FT_MAT5);
    }
    else if (mat_version == 73) {
      mat_file = Mat_CreateVer(filename, nullptr, MAT_FT_MAT73);
    }

    if (mat_file == nullptr) {
      std::cerr << "ERROR: Unable to create matlab file " << filename << "\n";
      exit(1);
    }
  }

  /* word sizes */
  int cpu_word_size=sizeof(double);
  int io_word_size=0;

  /* open exodus file */
  float exo_version;
  int exo_file=ex_open(argv[1],EX_READ,&cpu_word_size,&io_word_size,&exo_version);
  if (exo_file < 0){
    std::cerr << "ERROR: Cannot open " << argv[1] << "\n";
    exit(1);
  }

  /* print */
  std::cout << "\ttranslating " << argv[1] << " to " << filename << "...\n";

  /* read database paramters */
  char *line=(char *) calloc ((MAX_LINE_LENGTH+1),sizeof(char));
  ex_get_init(exo_file,line,
              &num_axes,&num_nodes,&num_elements,&num_blocks,
              &num_node_sets,&num_side_sets);
  num_info_lines = ex_inquire_int(exo_file,EX_INQ_INFO);
  num_time_steps = ex_inquire_int(exo_file,EX_INQ_TIME);
  ex_get_variable_param(exo_file,EX_GLOBAL,&num_global_vars);
  ex_get_variable_param(exo_file,EX_NODAL,&num_nodal_vars);
  ex_get_variable_param(exo_file,EX_ELEM_BLOCK,&num_element_vars);
  ex_get_variable_param(exo_file,EX_NODE_SET,&num_nodeset_vars);
  ex_get_variable_param(exo_file,EX_SIDE_SET,&num_sideset_vars);


  /* export paramters */
  PutInt("naxes",  num_axes);
  PutInt("nnodes", num_nodes);
  PutInt("nelems", num_elements);
  PutInt("nblks",  num_blocks);
  PutInt("nnsets", num_node_sets);
  PutInt("nssets", num_side_sets);
  PutInt("nsteps", num_time_steps);
  PutInt("ngvars", num_global_vars);
  PutInt("nnvars", num_nodal_vars);
  PutInt("nevars", num_element_vars);
  PutInt("nnsvars",num_nodeset_vars);
  PutInt("nssvars",num_sideset_vars);

  /* allocate -char- scratch space*/
  int nstr2 = num_info_lines;
  nstr2 = std::max(nstr2, num_blocks);
  nstr2 = std::max(nstr2, num_node_sets);
  nstr2 = std::max(nstr2, num_side_sets);
  char **str2 = get_exodus_names(nstr2, 512);

  /* title */
  PutStr("Title",line);

  /* information records */
  if (num_info_lines > 0 ){
    ex_get_info(exo_file,str2);
    std::string ostr;
    for (int i=0;i<num_info_lines;i++) {
      if (strlen(str2[i]) > 0) {
        ostr += str2[i];
        ostr += "\n";
      }
    }
    PutStr("info",ostr.c_str());
    ostr = "";
    for (int i=0;i<num_info_lines;i++) {
      if (strlen(str2[i]) > 0 && strncmp(str2[i],"cavi",4)==0) {
        ostr += str2[i];
        ostr += "\n";
      }
    }
    PutStr("cvxp",ostr.c_str());
  }

  /* nodal coordinates */
  {
    if (debug) {logger("Coordinates");}
    std::vector<double> x, y, z;
    x.resize(num_nodes);
    if (num_axes >= 2) y.resize(num_nodes);
    if (num_axes == 3) z.resize(num_nodes);
    ex_get_coord(exo_file,TOPTR(x), TOPTR(y), TOPTR(z));
    PutDbl("x0", num_nodes, 1, TOPTR(x));
    if (num_axes >= 2) {
      PutDbl("y0", num_nodes, 1, TOPTR(y));
    }
    if (num_axes == 3){
      PutDbl("z0",num_nodes,1, TOPTR(z));
    }
  }

  /* side sets */
  std::vector<int> num_sideset_sides(num_side_sets);
  std::vector<int> ids;
  if (num_side_sets > 0) {
    if (debug) {logger("Side Sets");}
    ids.resize(num_side_sets);
    ex_get_ids(exo_file,EX_SIDE_SET,TOPTR(ids));
    PutInt( "ssids",num_side_sets, 1,TOPTR(ids));
    std::vector<int> nssdfac(num_side_sets);
    std::vector<int> iscr;
    std::vector<int> jscr;
    std::vector<double> scr;
    std::vector<int> elem_list;
    std::vector<int> side_list;
    std::vector<int> junk;
    for (int i=0;i<num_side_sets;i++) {
      ex_get_set_param(exo_file,EX_SIDE_SET, ids[i],&n1,&n2);
      num_sideset_sides[i]=n1;
      nssdfac[i]=n2;
      /*
       * the following provision is from Version 1.6 when there are no
       * distribution factors in exodus file
       */
      bool has_ss_dfac = (n2 != 0);
      if (n2==0 || n1==n2){

        std::cerr << "WARNING: Exodus II file does not contain distribution factors.\n";

        /* n1=number of faces, n2=number of df */
        /* using distribution factors to determine number of nodes in the sideset
           causes a lot grief since some codes do not output distribution factors
           if they are all equal to 1. mkbhard: I am using the function call below
           to figure out the total number of nodes in this sideset. Some redundancy
           exists, but it works for now */

        junk.resize(n1);
        ex_get_side_set_node_count(exo_file,ids[i],TOPTR(junk));
        n2=0; /* n2 will be equal to the total number of nodes in the sideset */
        for (int j=0; j<n1; j++)
          n2+=junk[j];
      }

      iscr.resize(n1);
      jscr.resize(n2);
      ex_get_side_set_node_list(exo_file,ids[i],TOPTR(iscr),TOPTR(jscr));
      /* number-of-nodes-per-side list */
      sprintf(str,"ssnum%02d",i+1);
      PutInt(str,n1,1,TOPTR(iscr));
      /* nodes list */
      sprintf(str,"ssnod%02d",i+1);
      PutInt(str,n2,1,TOPTR(jscr));

      /* distribution-factors list */
      scr.resize(n2);
      if (has_ss_dfac) {
        ex_get_side_set_dist_fact(exo_file,ids[i], TOPTR(scr));
      } else {
        for (int j=0; j<n2; j++) {
          scr[j] = 1.0;
        }
      }
      sprintf(str,"ssfac%02d",i+1);
      PutDbl(str,n2,1,TOPTR(scr));

      /* element and side list for side sets (dgriffi) */
      elem_list.resize(n1);
      side_list.resize(n1);
      ex_get_set(exo_file,EX_SIDE_SET,ids[i],TOPTR(elem_list),TOPTR(side_list));
      sprintf(str,"ssside%02d",i+1);
      PutInt(str,n1,1,TOPTR(side_list));
      sprintf(str,"sselem%02d",i+1);
      PutInt(str,n1,1,TOPTR(elem_list));
    }
    /* Store # sides and # dis. factors per side set (dgriffi) */
    PutInt("nsssides",num_side_sets,1,TOPTR(num_sideset_sides));
    PutInt("nssdfac",num_side_sets,1,TOPTR(nssdfac));
  }

  /* node sets (section by dgriffi) */
  std::vector<int> num_nodeset_nodes(num_node_sets);
  if (num_node_sets > 0){
    if (debug) {logger("Node Sets");}
    std::vector<int> iscr;
    std::vector<double> scr;
    ids.resize(num_node_sets);
    ex_get_ids(exo_file,EX_NODE_SET, TOPTR(ids));
    PutInt( "nsids",num_node_sets, 1,TOPTR(ids));

    std::vector<int> num_nodeset_df(num_node_sets);
    for (int i=0;i<num_node_sets;i++){
      ex_get_set_param(exo_file,EX_NODE_SET,ids[i],&n1,&n2);
      iscr.resize(n1);
      ex_get_node_set(exo_file,ids[i],TOPTR(iscr));
      /* nodes list */
      sprintf(str,"nsnod%02d",i+1);
      PutInt(str,n1,1,TOPTR(iscr));
      {
        /* distribution-factors list */
        scr.resize(n2);
        ex_get_node_set_dist_fact(exo_file,ids[i],TOPTR(scr));
        sprintf(str,"nsfac%02d",i+1);
        PutDbl(str,n2,1,TOPTR(scr));
      }
      num_nodeset_nodes[i]=n1;
      num_nodeset_df[i]=n2;
    }

    /* Store # nodes and # dis. factors per node set */
    PutInt("nnsnodes",num_node_sets,1,TOPTR(num_nodeset_nodes));
    PutInt("nnsdfac",num_node_sets,1,TOPTR(num_nodeset_df));
  }

  /* element blocks */
  if (debug) {logger("Element Blocks");}
  std::vector<int> num_elem_in_block(num_blocks);
  {
    ids.resize(num_blocks);
    std::vector<int> iscr;
    ex_get_ids(exo_file,EX_ELEM_BLOCK,TOPTR(ids));
    PutInt( "blkids",num_blocks, 1,TOPTR(ids));
    for (int i=0;i<num_blocks;i++) {
      ex_get_elem_block(exo_file,ids[i],str2[i],&n,&n1,&n2);
      num_elem_in_block[i]=n;
      iscr.resize(n*n1);
      ex_get_conn(exo_file,EX_ELEM_BLOCK,ids[i],TOPTR(iscr), nullptr, nullptr);
      sprintf(str,"blk%02d",i+1);
      PutInt(str,n1,n,TOPTR(iscr));
    }
    str[0]='\0';
    for (int i=0;i<num_blocks;i++) {
      strcat(str, str2[i]);
      strcat(str, "\n");
    }
    PutStr("blknames",str);
  }

  /* time values */
  if (num_time_steps > 0 ) {
    if (debug) {logger("Time Steps");}
    std::vector<double> scr(num_time_steps);
    ex_get_all_times (exo_file, TOPTR(scr));
    PutDbl( "time", num_time_steps, 1, TOPTR(scr));
  }

  /* global variables */
  if (num_global_vars > 0 ) {
    if (debug) {logger("Global Variables");}
    get_put_names(exo_file, EX_GLOBAL, num_global_vars, "gnames");

    std::vector<double> scr(num_time_steps);
    for (int i=0;i<num_global_vars;i++){
      sprintf(str,"gvar%02d",i+1);
      ex_get_glob_var_time(exo_file,i+1,1,num_time_steps,TOPTR(scr));
      PutDbl(str,num_time_steps,1,TOPTR(scr));
    }
  }

  /* nodal variables */
  if (num_nodal_vars > 0 ) {
    if (debug) {logger("Nodal Variables");}
    if (debug) {logger("\tNames");}
    get_put_names(exo_file, EX_NODAL, num_nodal_vars, "nnames");

    std::vector<double> scr(num_nodes*num_time_steps);
    for (int i=0; i<num_nodal_vars; i++){
      sprintf(str,"nvar%02d",i+1);
      if (debug) {logger("\tReading");}
      for (int j=0; j<num_time_steps; j++) {
        ex_get_nodal_var(exo_file,j+1,i+1,num_nodes,
                         &scr[num_nodes*j]);
      }
      if (debug) {logger("\tWriting");}
      PutDbl(str,num_nodes,num_time_steps,TOPTR(scr));
    }
  }

  /* element variables */
  if (num_element_vars > 0 ) {
    if (debug) {logger("Element Variables");}
    get_put_names(exo_file, EX_ELEM_BLOCK, num_element_vars, "enames");

    get_put_vars(exo_file, EX_ELEM_BLOCK,
                 num_blocks, num_element_vars, num_time_steps, num_elem_in_block, "evar%02d");
  }

  /* nodeset variables */
  if (num_nodeset_vars > 0 ) {
    if (debug) {logger("Nodeset Variables");}
    get_put_names(exo_file, EX_NODE_SET, num_nodeset_vars, "nsnames");

    get_put_vars(exo_file, EX_NODE_SET,
                 num_node_sets, num_nodeset_vars, num_time_steps, num_nodeset_nodes, "nsvar%02d");
  }

  /* sideset variables */
  if (num_sideset_vars > 0 ) {
    if (debug) {logger("Sideset Variables");}
    get_put_names(exo_file, EX_SIDE_SET, num_sideset_vars, "ssnames");

    get_put_vars(exo_file, EX_SIDE_SET,
                 num_side_sets, num_sideset_vars, num_time_steps, num_sideset_sides, "ssvar%02d");
  }

  /* node and element number maps */
  if (debug) {logger("Node and Element Number Maps");}
  ex_opts(0);  /* turn off error reporting. It is not an error to have no map*/
  ids.resize(num_nodes);
  err = ex_get_node_num_map(exo_file,TOPTR(ids));
  if ( err==0 ){
    PutInt("node_num_map",num_nodes,1,TOPTR(ids));
  }

  ids.resize(num_elements);
  err = ex_get_elem_num_map(exo_file,TOPTR(ids));
  if ( err==0 ){
    PutInt("elem_num_map",num_elements,1,TOPTR(ids));
  }

  if (debug) {logger("Closing file");}
  ex_close(exo_file);

  if ( textfile )
    fclose(m_file);
  else
    Mat_Close(mat_file);

  std::cout << "done...\n";

  free(filename);
  free(line);

  delete_exodus_names(str2, nstr2);

  /* exit status */
  add_to_log("exo2mat", 0);
  return(0);
}