Ejemplo n.º 1
0
/*
 * Search for address 'a'.  Use *vp for context, *r as the starting point
 * for searches.  May create a new window, but doesn't otherwise affect
 * the screen.  If it finds something, update *vp and *r and return
 * true, otherwise return false and leave vp and r alone.
 *
 * 's' may be of the form path:addr, or path, or :addr.
 */
static Bool
view_gotofile(View**vp, Range *r, char *a) {
	Path	s;
	View	*v = *vp;
	View	*v2;
	char *colon;	/* preserve the colon */
	Path	label;

	if (strlen(a) > sizeof(Path)-1) {
		errno=0;
		diag(0, "couldn't goto \"%s\": path too long", a);
		return false;
	}
	strcpy(s,a);
	colon = strchr(s, ':');
	if (colon) {
		*colon=0;
	}

	/* look for 's' as a file or directory */
	if(strlen(s)) {
		/* 'path' or 'path:addr' */
		data_addcontext(view_data(v), label, s);
		if( (v2=openlabel(label, false))){
			if(colon) {
				Range oldr = v2->sel;
				
				if(!text_search(v2->t, r, colon+1, v2->sel)) {
					*r = oldr;
				}
			} else {
				*r = v2->sel;
			}
			*vp = v2;
			return true;
		} else 
			return false;	/* bad path */
	}
	assert(!strlen(s));

	/* :addr by itself then */
	if(!ISBODY(v)){
		if( ! ((v = view_body(v)) || (v = view_body(last_selection))) )
			return false;
	}
	*r = v->sel;
	if (text_search(v->t, r, colon+1, v->sel)) {
		*vp = v;
 		return true;
	} 
	return false;
}
Ejemplo n.º 2
0
/* We've clicked the 'goto' button, selecting 'r' in 'v'
 * If this window is under external control, just send the event,
 * otherwise expand the selection, and 'goto' it, in the context of 'v'.
 */
void
b3(View *v, Range r) {
	char	*s;
	View *oldv;
	Range expanded;
	Data	*d;
	View*found;
	
	/* Try to send simply expanded version to remote process */
	expanded = view_expand(v, r, notaddress);
	if (!RLEN(expanded))
		return;	/* empty click nowhere -- ignore */
	s = text_duputf(v->t, expanded);
	d = view_data(v);
	oldv = v;
	
	/* Send to remote process? */
	if(data_sendgoto(d,expanded, s))
		goto cleanup;
	
	
	if (view_gotofile(&v, &expanded, s)) { /* Simple file? */
		r = expanded;
	} else if ( (found = openinclude(v,r)) ) {
		v = found;
		r = found->sel;
	} else if (view_literal(&v, &expanded, s)) { /* Literal? */
		r = expanded;
	} else {	/* found nothing */
		goto cleanup;
	}
	
	view_show(v,r);
	view_select(v,r);
	view_setlastselection(v);

	/* warp unless b3 in the tag jumps to the body. */
	if (oldv != tile_tag(view_win(v)))
		view_warp(v,r);
	
cleanup:
	free(s);
}
Ejemplo n.º 3
0
VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
    /// Do your job.
    static DWORD prevTime = 0;
    //printf("dwTime : %d\n",dwTime-prevTime);
    retrieve_VICON();

    if(isLiveChecked == true)
    {
        printf("[REC] errRoll=%2.2f,errPitch=%2.2f,Vx=%2.2f,Vy=%2.2f,Alt=%2.2f,dt=%f\n",state_error.rollErr,state_error.pitchErr,state_error.vxErr,state_error.vyErr,optical_flow.ground_distance,optical_flow.time/1000000.0);
        fprintf(fp,"%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n",state_error.rollErr,state_error.pitchErr,state_error.vxErr,state_error.vyErr,optical_flow.ground_distance,xA_dot,yA_dot,zA_dot,xA,yA,zA,optical_flow.quality,optical_flow.time/1000000.0);
    }
    else
    {
        //printf("errRoll=%2.2f,errPitch=%2.2f,Vx=%2.2f,Vy=%2.2f,Alt=%2.2f,dt=%f\n",state_error.rollErr,state_error.pitchErr,state_error.vxErr,state_error.vyErr,optical_flow.ground_distance,optical_flow.time/1000000.0);
        view_data();
    }

    prevTime = dwTime;
}
Ejemplo n.º 4
0
Archivo: exec.c Proyecto: knusbaum/Wily
/* Execute 'cmd', which was selected in 'v'.
 * PRE: the first character of cmd is not 0 or whitespace.
 * Return 0 for success.
 */
static int
ex_run(View*v, char *cmd) {
	View		*vout, *vin;	/* Views for output/input */
	int		pout[2];		/* pipe for stdout */
	int		perr[2];		/* pipe for stderr */
	Path		label;
	int		pid;
	
	if(pipe_views(&cmd, &vout, &vin))
		return -1;
	
	if(openpipes(pout, perr, vout!=0))
		return -1;

	data_getlabel(view_data(v), label);
	
	switch(pid=fork()) {
	case -1:	/* fork failed */
		close(perr[0]); close(perr[1]);
		close(pout[0]); close(pout[1]);
		return -1;
	default:	/* parent */
		close(perr[1]);
		close(pout[1]);
		return ex_parent(perr[0], pout[0], label, cmd, vout, pid);
	case 0:	/* child */
		close(perr[0]);
		close(pout[0]);
		ex_child(perr[1], pout[1], label, cmd, vin);
		
		/* ex_child doesn't return */
		assert(false);
		exit(1);
		return -1;
	}
}
Ejemplo n.º 5
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
//    setCentralWidget(ui->tabWidget);
    //设置编码,可用于国际化
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf-8"));

    //此定时器为轮询串口缓存数据
    serial_read_fresh_t=new QTimer(this);
    //设置定时器刷新周期
    serial_read_fresh_t->setInterval(400);
    //对串口进行初始化
    if(ser_serial_port_init()==Utils::SUCCESS)
    {
        ui->infoPad->append("Ser : Found Serial Device");
        th.start();
    }
    else
    {
        ui->infoPad->append(("Ser : No Serial Device Found"));
    }
    //初始化tcp服务器端
    tcpServer =new QTcpServer(this);
    //初始化udp发送套接字对象
    udpSendSocket = new QUdpSocket(this);
    //初始化udp接收套接字对象
    udpReceiveSocket = new QUdpSocket(this);
    //绑定本地udp套接字监听//8904
    udpReceiveSocket->bind(Utils::SER_UDP_RCV_PORT, QUdpSocket::ShareAddress);
    //绑定本地udp套接字的readyRead信号到processPendingDatagrams槽函数
    connect(udpReceiveSocket, SIGNAL(readyRead()),this, SLOT(processPendingDatagrams()));
    //初始化客户端默认地址对象
    addr = new QHostAddress("192.168.1.1");

    //设置按钮的初始化状态
    ui->startBtn->setEnabled(true);
    ui->stopBtn->setEnabled(false);
    //绑定tcpServer的newConnection信号到newConnectionComing槽函数
    connect(tcpServer,SIGNAL(newConnection()),this,SLOT(newConnectionComing()));
    //绑定startBtn的clicked信号到listenBtnClicked槽函数
    connect(ui->startBtn,SIGNAL(clicked()),this,SLOT(listenBtnClicked()));
     //绑定stopBtn的clicked信号到listenBtnClicked槽函数
    connect(ui->stopBtn,SIGNAL(clicked()),this,SLOT(stopBtnClicked()));
    //子节点将会发送的命令
    //在下一个迭代版本中将分离出去
    //
    // 将公用数据移入Utils工具类
    //  2014,03,15 已完成

    //温度传感器子节点发送的命令头
    // TEMP ="temp_data_is:";
    //湿度传感器子节点发送的命令头
    // HUMI ="humi_data_is:";

    table_fresh_t=new QTimer(this);
    table_fresh_t->setInterval(1000);
    connect(table_fresh_t,SIGNAL(timeout()),this,SLOT(view_data()));
    table_fresh_t->start();
    //将信号send_cmd_to_node与槽函数sendSerCom绑定
    connect(this,SIGNAL(send_cmd_to_node(QString)),this,SLOT(sendSerCom(QString)));
    //将信号send_data_to_thread与槽函数setData绑定
    connect(this,SIGNAL(send_data_to_thread(QString)),&th,SLOT(setData(QString)));
}