Ejemplo n.º 1
0
int print(int n){
	char* p;

	p = i2str(n);
	while(*p)
		mputc(*p++);
	return 0;
}
Ejemplo n.º 2
0
bool HM_follow::draw(Frame* pFrame, vInt4* pTextPos)
{
	NULL_F(pFrame);
	Mat* pMat = pFrame->getCMat();

	putText(*pMat,
			"HM: rpmL=" + i2str(m_pHM->m_motorPwmL) + ", rpmR="
					+ i2str(m_pHM->m_motorPwmR),
			cv::Point(pTextPos->m_x, pTextPos->m_y), FONT_HERSHEY_SIMPLEX, 0.5,
			Scalar(0, 255, 0), 1);
	pTextPos->m_y += pTextPos->m_w;

	CHECK_T(m_pTarget==NULL);
	circle(*pMat, Point(m_pTarget->m_bbox.midX(), m_pTarget->m_bbox.midY()), 10,
			Scalar(0, 0, 255), 2);

	return true;
}
Ejemplo n.º 3
0
/* ----------------- */
void test_int2str(void)
/* ----------------- */
{
    int x;
    char *str;
    
    x = 9;
    str = i2str(x); printf("%d = \"%s\"\n", x, str);
    free(str); str = NULL; 
    
    x = 10;
    str = i2str(x); printf("%d = \"%s\"\n", x, str);
    free(str); str = NULL; 
    
    x = 100;
    str = i2str(x); printf("%d = \"%s\"\n", x, str);
    free(str); str = NULL; 
    
    x = 1000;
    str = i2str(x); printf("%d = \"%s\"\n", x, str);
    free(str); str = NULL; 
}
Ejemplo n.º 4
0
    void XMLDocument::PutInteger(TiXmlElement& parent, const string& szName, _INT64 nValue)
    {
        TiXmlElement newelement(szName.c_str());
        string s = i2str(nValue);

        TiXmlText text(s.c_str());
        newelement.InsertEndChild(text);

        TiXmlElement* existing = parent.FirstChildElement(szName.c_str());
        if(existing)
            parent.ReplaceChild(existing, newelement);
        else
            parent.InsertEndChild(newelement);
    }
Ejemplo n.º 5
0
int update_tx_poweroff_info_of_otherform(void)
{
	char str[16];
	rt_uint32_t ntime, n_1_time, n_2_time;

	if (SUC_FIBER_CHANNEL_2 == get_sys_use_channel()) {
		i2str(str, poweroff_info_data.poi_tx2_poweroff_cnt);
		get_tx2_last3poweroff_time(&ntime, &n_1_time, &n_2_time);
	} else {
		i2str(str, poweroff_info_data.poi_tx1_poweroff_cnt);
		get_tx_last3poweroff_time(&ntime, &n_1_time, &n_2_time);
	}

	rtgui_form_set_item(other_form, str, OT_SE_POWEROFF_CNT_ROW, OT_SE_POWEROFF_CNT_COL, 0);

	get_timestr(ntime, str, sizeof(str));
	rtgui_form_set_item(other_form, str, OT_SE_N_ROW, OT_SE_N_COL, 0);
	get_timestr(n_1_time, str, sizeof(str));
	rtgui_form_set_item(other_form, str, OT_SE_N_1_ROW, OT_SE_N_1_COL, 0);
	get_timestr(n_2_time, str, sizeof(str));
	rtgui_form_set_item(other_form, str, OT_SE_N_2_ROW, OT_SE_N_2_COL, 0);

	return SUCC;
}
Ejemplo n.º 6
0
int update_rx_poweroff_info_of_otherform(void)
{
	char str[16];
	rt_uint32_t ntime, n_1_time, n_2_time;

	i2str(str, poweroff_info_data.poi_rx_poweroff_cnt);
	rtgui_form_set_item(other_form, str, OT_RE_POWEROFF_CNT_ROW, OT_RE_POWEROFF_CNT_COL, 0);

	get_rx_last3poweroff_time(&ntime, &n_1_time, &n_2_time);

	get_timestr(ntime, str, sizeof(str));
	rtgui_form_set_item(other_form, str, OT_RE_N_ROW, OT_RE_N_COL, 0);
	get_timestr(n_1_time, str, sizeof(str));
	rtgui_form_set_item(other_form, str, OT_RE_N_1_ROW, OT_RE_N_1_COL, 0);
	get_timestr(n_2_time, str, sizeof(str));
	rtgui_form_set_item(other_form, str, OT_RE_N_2_ROW, OT_RE_N_2_COL, 0);

	return SUCC;
}
Ejemplo n.º 7
0
bool _Universe::draw(Frame* pFrame, vInt4* pTextPos)
{
	NULL_F(pFrame);

	Mat* pMat = pFrame->getCMat();
	putText(*pMat, "Universe FPS: " + i2str(getFrameRate()),
			cv::Point(pTextPos->m_x, pTextPos->m_y), FONT_HERSHEY_SIMPLEX, 0.5,
			Scalar(0, 255, 0), 1);
	pTextPos->m_y += pTextPos->m_w;

	OBJECT* pObj;
	Scalar color;
	double thickness;

	for (int i = 0; i < m_nObj; i++)
	{
		pObj = &m_pObj[i];
		if (pObj->m_frameID <= 0)continue;

		color = Scalar(0, 255, 0);
		thickness = 1;
		Rect bbox;
		bbox.x = pObj->m_bbox.m_x;
		bbox.y = pObj->m_bbox.m_y;
		bbox.width = pObj->m_bbox.m_z - pObj->m_bbox.m_x;
		bbox.height = pObj->m_bbox.m_w - pObj->m_bbox.m_y;

		rectangle(*pMat, bbox, color, thickness);

		if(pObj->m_iClass >= m_nObjClass)continue;
		putText(*pMat, m_pObjClass[pObj->m_iClass].m_name,
				Point(bbox.x + bbox.width / 2, bbox.y + bbox.height / 2),
				FONT_HERSHEY_SIMPLEX, 0.8, color, thickness);
	}

	return true;

}
Ejemplo n.º 8
0
void MusicManager::loadSounds(std::string path, std::string root)
{
    if( !file_existsX(path) ) return;

    INIReader SoundsIni( path );
    if (SoundsIni.ParseError() < 0)
    {
        MessageBoxA(0, std::string(path+"\n\nError of read INI file").c_str(), "Error", 0);
        return;
    }

    curRoot=root;
    for(int i=0; i<91; i++)
    {
        std::string head = "sound-"+i2str(i+1);
        std::string fileName;
        std::string reserveChannel;

        fileName = SoundsIni.Get(head, "file", "");
        if(fileName.size()==0) continue;

        reserveChannel = SoundsIni.Get(head, "single-channel", "0");

        replaceSubStr(fileName, "\"", "");
        replaceSubStr(fileName, "\\\\",  "\\");
        replaceSubStr(fileName, "/",  "\\");

        if( file_existsX(root+fileName) )
        {
            sounds[i].setPath(root+fileName.c_str());
            if(reserveChannel=="1")
                sounds[i].channel = 0;
            else
                sounds[i].channel = -1;
        }
    }
}
Ejemplo n.º 9
0
/*
 * 构建应用视图
 */
int app_view_structure(struct rtgui_workbench *workbench, struct rtgui_view *view)
{
	int ret = SUCC;
	rtgui_rect_t rect, body_rect;
	rtgui_label_t* label;
	char str[48];
	//rtgui_radiobox_t *radiobox;
	//rtgui_button_t* button;
	struct tm *ptime;
#if 1==DISPLAY_OVERLOAD_INFO
	rtgui_label_t *rx_overload_label;
#endif

	app_view_get_can_use_rect(view, &rect);
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   rect.x1, rect.y1, rect.x2, rect.y2));

	body_rect.x1 = 0;
	body_rect.y1 = 0;
	body_rect.x2 = rect.x2;
	body_rect.y2 = TITLE_PANEL_HEIGHT;
	label = rtgui_label_create(DEVICE_NAME);
	if (NULL != label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
		RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = blue;
		rtgui_widget_set_rect(RTGUI_WIDGET(label), &body_rect);
		/* view是一个container控件,调用add_child方法添加这个label控件 */
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
	} else {
		printf_syn("creat title label fail\n");
	}

	body_rect.x1 = 0;
	body_rect.y1 = TITLE_PANEL_HEIGHT;
	body_rect.x2 = rect.x2;
	body_rect.y2 = rect.y2;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	zvd_notebook = rtgui_notebook_create(&body_rect, RTGUI_NOTEBOOK_TOP);
	rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(zvd_notebook));

	re_form = rtgui_form_create(re_form_head, RE_FORM_ROWS, RE_FORM_COLS, &body_rect);
	rtgui_notebook_add(zvd_notebook, "接收端", RTGUI_WIDGET(re_form));
#if 1
	set_form_px_col(re_form);
	i2str(str, avg_val[AVI_RE_PA]);
	rtgui_form_set_item(re_form, str, RE_PA_AVG_VALUE_ROW, RE_PA_AVG_VALUE_COL, 0);
	rtgui_form_set_item(re_form, print_info_str[PIS_ID_ZHENGCHANG], RE_PA_OVER_RANGE_ROW, RE_PA_OVER_RANGE_COL, 0);

	i2str(str, avg_val[AVI_RE_PB]);
	rtgui_form_set_item(re_form, str, RE_PB_AVG_VALUE_ROW, RE_PB_AVG_VALUE_COL, 0);
	rtgui_form_set_item(re_form, print_info_str[PIS_ID_ZHENGCHANG], RE_PB_OVER_RANGE_ROW, RE_PB_OVER_RANGE_COL, 0);

	i2str(str, avg_val[AVI_RE_PC]);
	rtgui_form_set_item(re_form, str, RE_PC_AVG_VALUE_ROW, RE_PC_AVG_VALUE_COL, 0);
	rtgui_form_set_item(re_form, print_info_str[PIS_ID_ZHENGCHANG], RE_PC_OVER_RANGE_ROW, RE_PC_OVER_RANGE_COL, 0);
#endif

	se_form = rtgui_form_create(se_form_head, SE_FORM_ROWS, SE_FORM_COLS, &body_rect);
	rtgui_notebook_add(zvd_notebook, "发射端", RTGUI_WIDGET(se_form));
#if 1
	set_form_px_col(se_form);
	rtgui_form_set_item(se_form, print_info_str[PIS_ID_ZHENGCHANG], SE_PA_OVER_RANGE_ROW, SE_PA_OVER_RANGE_COL, 0);
	rtgui_form_set_item(se_form, print_info_str[PIS_ID_FOU], SE_PA_POWER_DOWN_ROW, SE_PA_POWER_DOWN_COL, 0);

	rtgui_form_set_item(se_form, print_info_str[PIS_ID_ZHENGCHANG], SE_PB_OVER_RANGE_ROW, SE_PB_OVER_RANGE_COL, 0);
	rtgui_form_set_item(se_form, print_info_str[PIS_ID_FOU], SE_PB_POWER_DOWN_ROW, SE_PB_POWER_DOWN_COL, 0);

	rtgui_form_set_item(se_form, print_info_str[PIS_ID_ZHENGCHANG], SE_PC_OVER_RANGE_ROW, SE_PC_OVER_RANGE_COL, 0);
	rtgui_form_set_item(se_form, print_info_str[PIS_ID_FOU], SE_PC_POWER_DOWN_ROW, SE_PC_POWER_DOWN_COL, 0);
#endif

	sys_form = rtgui_form_create(sys_form_head, SYS_FORM_ROWS, SYS_FORM_COLS, &body_rect);
	rtgui_notebook_add(zvd_notebook, "系统", RTGUI_WIDGET(sys_form));
#if 1
	rtgui_form_set_item(sys_form, "接收端", 1, 0, 0);
	i2str(str, sys_temper[STI_RE_CPU_T]);
	rtgui_form_set_item(sys_form, str, 		RE_RE_CPU_TEMP_ROW, RE_RE_CPU_TEMP_COL, 0);
	i2str(str, sys_temper[STI_RE_CTB_T]);
	rtgui_form_set_item(sys_form, str, 		RE_RE_BOX_TEMP_ROW, RE_RE_BOX_TEMP_COL, 0);
	convert_ver2str(re_version, str);
	rtgui_form_set_item(sys_form, str, 	RE_RE_SOFT_VER_ROW, RE_RE_SOFT_VER_COL, 0);

	rtgui_form_set_item(sys_form, "发射端", 2, 0, 0);
	i2str(str, sys_temper[STI_SE_CPU_T]);
	rtgui_form_set_item(sys_form, str, 		RE_SE_CPU_TEMP_ROW, RE_SE_CPU_TEMP_COL, 0);
	i2str(str, sys_temper[STI_SE_CTB_T]);
	rtgui_form_set_item(sys_form, str, 		RE_SE_BOX_TEMP_ROW, RE_SE_BOX_TEMP_COL, 0);
	convert_ver2str(se_version, str);
	rtgui_form_set_item(sys_form, str, 	RE_SE_SOFT_VER_ROW, RE_SE_SOFT_VER_COL, 0);

	creat_devsn(str, sizeof(str), 0);
	rtgui_form_set_row(sys_form, str, TE_SN_ROW);

	creat_devsn(str, sizeof(str), 1);
	rtgui_form_set_row(sys_form, str, RE_SN_ROW);
#endif


	other_form = rtgui_form_create(other_form_head, OTHER_FORM_ROWS, OTHER_FORM_COLS, &body_rect);
	rtgui_notebook_add(zvd_notebook, "掉电", RTGUI_WIDGET(other_form));
#if 1
	rtgui_form_set_item(other_form, "次数", 1, 0, 0);
	rtgui_form_set_item(other_form, "n", 2, 0, 0);
	rtgui_form_set_item(other_form, "n-1", 3, 0, 0);
	rtgui_form_set_item(other_form, "n-2", 4, 0, 0);
	update_tx_poweroff_info_of_otherform();
	update_rx_poweroff_info_of_otherform();
#endif

	body_rect.x1 = FRAME_GAP;
	body_rect.y1 = body_rect.y2 + WIDGET_ROW_GAP;
	body_rect.x2 = FRAME_GAP + 8 * rt_strlen(RE_IF_SWITCH2CABLE_STR);
	body_rect.y2 = body_rect.y1 + 16;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	switch_cable_label = rtgui_label_create(RE_IF_SWITCH2CABLE_STR);
	if (NULL != switch_cable_label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(switch_cable_label)) =  RTGUI_ALIGN_CENTER_VERTICAL;
		//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(switch_cable_label)) = blue;
		rtgui_widget_set_rect(RTGUI_WIDGET(switch_cable_label), &body_rect);
		/* view是一个container控件,调用add_child方法添加这个label控件 */
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(switch_cable_label));
	} else {
		printf_syn("creat cable label fail\n");
	}

#if 1
	body_rect.x1 = body_rect.x2 + 2;
	body_rect.x2 = body_rect.x1 + 16 + 8;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	switch_cable_yn_textview = rtgui_textview_create(print_info_str[PIS_ID_FOU], &body_rect);
	if (NULL != switch_cable_yn_textview) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(switch_cable_yn_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(switch_cable_yn_textview)) = red;
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(switch_cable_yn_textview));
	} else {
		printf_syn("creat cable yn textview fail\n");
	}
#endif

#if 1
	body_rect.x1 = body_rect.x2 + 2 + 2*8;
	body_rect.x2 = body_rect.x1 + 8*rt_strlen(TE_HAD_POWEROFF_STR);
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	tx_poweroff_label = rtgui_label_create(TE_HAD_POWEROFF_STR);
	if (NULL != tx_poweroff_label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(tx_poweroff_label)) =  RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(tx_poweroff_label), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(tx_poweroff_label));
	} else {
		printf_syn("tx poweroff label fail\n");
	}

	body_rect.x1 = body_rect.x2 + 2;
	body_rect.x2 = body_rect.x1 + 16 + 8;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	tx_poweroff_yn_textview = rtgui_textview_create(print_info_str[PIS_ID_FOU], &body_rect);
	if (NULL != tx_poweroff_yn_textview) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(tx_poweroff_yn_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(tx_poweroff_yn_textview));
	} else {
		printf_syn("creat cable yn textview fail\n");
	}
#endif


#if 1
	body_rect.x1 = FRAME_GAP;
	body_rect.y1 = body_rect.y2 + WIDGET_ROW_GAP;
	body_rect.x2 = FRAME_GAP + (8+1) * rt_strlen(RE_BUZZER_DISABLE_STR);
	body_rect.y2 = body_rect.y1 + 16 + 2*WIDGET_ROW_GAP;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	buzzer_button = rtgui_pushbutton_create(RE_BUZZER_DISABLE_STR);
	if (NULL != buzzer_button) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(buzzer_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(buzzer_button)) = blue;
		rtgui_widget_set_rect(RTGUI_WIDGET(buzzer_button), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(buzzer_button));

		rtgui_button_set_onbutton(buzzer_button, buzzer_btn_onbutton);
	} else {
		printf_syn("creat buzzer pushbutton fail\n");
	}

	body_rect.x1 = body_rect.x2 + FRAME_GAP;
	/* body_rect.y1 = body_rect.y1; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */
	body_rect.x2 = body_rect.x1 + (8+1) * rt_strlen(SWITCH_TO_PT_STR);;
	/* body_rect.y2 = body_rect.y2; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */
	
	switch2pt_button = rtgui_pushbutton_create(SWITCH_TO_PT_STR);
	if (NULL != switch2pt_button) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(switch2pt_button)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(switch2pt_button)) = blue;
		rtgui_widget_set_rect(RTGUI_WIDGET(switch2pt_button), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(switch2pt_button));
		rtgui_button_set_onbutton(switch2pt_button, switch2pt_btn_onbutton);
	} else {
		printf_syn("creat switch button fail\n");
	}

#if USE_OPTICX_200S_VERSION
	body_rect.x1 = body_rect.x2 + FRAME_GAP;
	/* body_rect.y1 = body_rect.y1; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */
	body_rect.x2 = body_rect.x1 + (8) * rt_strlen(RE_CUR_CHANNEL_NO_STR) + 2;
	/* body_rect.y2 = body_rect.y2; */ /* 与前一个按钮在同一行, 所以, y1, y2保持不变 */
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));
	rxe_cur_channel_label = rtgui_label_create(RE_CUR_CHANNEL_NO_STR);
	if (NULL != rxe_cur_channel_label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rxe_cur_channel_label)) =  RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(rxe_cur_channel_label), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rxe_cur_channel_label));
	} else {
		printf_syn("rxe cru channel label fail\n");
	}

	body_rect.x1 = body_rect.x2 + 2;
	body_rect.x2 = body_rect.x1 + 8 + 8;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));
	str[0] = convert_cur_channel_to_char();
	str[1] = '\0';
	rxe_cur_channel_no_textview = rtgui_textview_create(str, &body_rect);
	if (NULL != rxe_cur_channel_no_textview) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rxe_cur_channel_no_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL
				| RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rxe_cur_channel_no_textview));
	} else {
		printf_syn("creat cable yn textview fail\n");
	}
#endif
#endif

#if 1==DISPLAY_OVERLOAD_INFO
	body_rect.x1 = body_rect.x2 + 2 + 7*8;
	body_rect.x2 = body_rect.x1 + 8*rt_strlen(RE_OVERLOAD_CNT_STR);
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	rx_overload_label = rtgui_label_create(RE_OVERLOAD_CNT_STR);
	if (NULL != rx_overload_label) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rx_overload_label)) =  RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_widget_set_rect(RTGUI_WIDGET(rx_overload_label), &body_rect);
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rx_overload_label));
	} else {
		printf_syn("tx poweroff label fail\n");
	}

	body_rect.x1 = body_rect.x2 + 2;
	body_rect.x2 = body_rect.x1 + 16 + 8;
	zvd_gui_debug(("fun:%s(), line:%d, (%d,%d) (%d,%d)!\n", __FUNCTION__, __LINE__,
				   body_rect.x1, body_rect.y1, body_rect.x2, body_rect.y2));

	rx_overload_cnt_textview = rtgui_textview_create("0", &body_rect);
	if (NULL != rx_overload_cnt_textview) {
		RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(rx_overload_cnt_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
		rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(rx_overload_cnt_textview));
	} else {
		printf_syn("creat cable yn textview fail\n");
	}
#endif



#if 1
	/* 创建时间标签, 2013-03-18 09:20 */
	rtc_dev = rt_device_find("rtc");
	if (NULL != rtc_dev) {
		time_t time;
		rt_device_control(rtc_dev, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
		ptime = localtime(&time);
		rt_sprintf(sys_time_str, "%4d-%02d-%02d %02d:%02d:%02d", (ptime->tm_year+1900), (ptime->tm_mon+1),
				   ptime->tm_mday,	ptime->tm_hour, ptime->tm_min, ptime->tm_sec);

		body_rect.x2 = rtgui_graphic_driver_get_default()->width;
		body_rect.y2 = rtgui_graphic_driver_get_default()->height;
		body_rect.x1 = body_rect.x2 - (8+1) * 19;
		body_rect.y1 = body_rect.y2 - 20;
#if SYS_TIME_USE_TEXTBOX
		sys_time_textbox = rtgui_textbox_create(sys_time_str, RTGUI_TEXTBOX_SINGLE | RTGUI_TEXTBOX_CARET_HIDE);
		if (NULL != sys_time_textbox) {
			RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(sys_time_textbox)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
			//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(sys_time_textbox)) = blue;
			RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(sys_time_textbox)) = blue; //default_background;
			//RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view));
			rtgui_widget_set_rect(RTGUI_WIDGET(sys_time_textbox), &body_rect);
			rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(sys_time_textbox));

		} else {
			printf_syn("creat sys time textbox fail\n");
		}
#else
		sys_time_textview = rtgui_textview_create(sys_time_str, &body_rect);
		if (NULL != sys_time_textview) {
			RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(sys_time_textview)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
			//RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(sys_time_textbox)) = blue;
			rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(sys_time_textview));
		} else {
			printf_syn("creat sys time textview fail\n");
		}
#endif

	} else {
		printf_syn("find rtc device fail\n");
	}

#endif
	rtgui_view_show(view, RT_FALSE); /* 显示视图 */

	return ret;
}
Ejemplo n.º 10
0
int Client::sendData(int data)
{
	return sendData(i2str(data));
}
Ejemplo n.º 11
0
void mainLoop(int sock)
{
	uint16_t width, height;
	uint8_t devcount = POINTER_COUNT;
	UInputAbsPointer *uinputs[POINTER_COUNT];
	Display *display = 0;
	UInputAbsPointer *pointer = 0;
	
	unsigned char buffer[7];
	int bytes;
	
	// Warte auf HELO
	bytes = myrecv(sock, buffer, sizeof(buffer) - 1, 0);
	if (bytes == -1)
	{
		perror("recv() fehlgeschlagen");
 		return;
	}
	else if (bytes == 0)
		return;
	else if ((bytes >= 6) and (buffer[0] == '#') and (buffer[1] == '#'))
	{
		// Got HELO
		width = ntohs(*(reinterpret_cast<uint16_t*>(&buffer[2])));
		height = ntohs(*(reinterpret_cast<uint16_t*>(&buffer[4])));
	}
	else
	{
		std::cerr << "Received invalid HELO" << std::endl;
		return;
	}
	
	uint i;
	for (i=0;i<POINTER_COUNT;i++)
	{
		std::string name = "MTC Touchpoint ";
		name += i2str(i);
		// Erzeuge UInput-Gerät
		uinputs[i] = new UInputAbsPointer(name, width, height);
	}
	
	// Verbinde zu X-Display
	#ifdef MPX
	if (Mpx)
	{
		display = XOpenDisplay(NULL);
		if (display == NULL) {
			std::cout << "Could not connect to X-Server!" << std::endl;
			exit(1);
		}
		XSync(display, False);
	}
	if (Mpx) for (i=0;i<POINTER_COUNT;i++)
	{
		std::string mname;
		std::string name = "MTC Touchpoint ";
		name += i2str(i);
		if (i>0)
		{
			mname = "MTC Touchpoint Master ";
			mname += i2str(i);
			// Erzeuge einen neuen XInput2-Master
			if (xi2_create_master(display, mname, 0, 1) != 0) {
				std::cout << "Could not create XInput2 master device " << i2str(i) << "!" << std::endl;
				exit(1);
			}
		}
		else
			mname = "Virtual core pointer";
		// Warte bis das vorhin erzeugte UInput-Gerät vom X-Server eingebunden wurde
		// aber maximal 1s.
		xi2_wait_for_device(display, name, 1000);
		// Wechsle die UInput-Geräte in die neuen Master.
		xi2_change_attachment(display, name, mname);
	}
	#endif
	
	// Befehlsschleife
	while (!killed)
	{
		bytes = myrecv(sock, buffer, sizeof(buffer) - 1, 0);
		buffer[bytes] = 0;
		if (bytes == -1)
		{
			perror("recv() fehlgeschlagen");
			break;
		}
		if (bytes == 0)
			break;

		/*while (bytes < 6)
		{
			int i = recv(sock, buffer+bytes, sizeof(buffer-bytes) - 1, 0);
			if (i <= 0) break;
			bytes += i;
			buffer[bytes] = 0;
		}*/
		
		if (bytes >= 6)
		{
			unsigned char opcode = buffer[0], pointernum = buffer[1];
			uint16_t xcoord = ntohs(*(reinterpret_cast<uint16_t*>(&buffer[2]))),
						ycoord = ntohs(*(reinterpret_cast<uint16_t*>(&buffer[4])));
			if (Debug) printf("ACTION %c POINTER %hhu [ %hu, %hu ]\n", opcode, pointernum, xcoord, ycoord);
			if (pointernum < POINTER_COUNT)
			{
				pointer = uinputs[pointernum];
			}
			else continue;
			
			if (opcode == '.')
				pointer->moveTo(xcoord, ycoord);
			else if (opcode == '!')
			{
				pointer->moveTo(xcoord, ycoord);
				usleep(20000);
				pointer->click();
			}
			else if (opcode == 'd')
			{
				pointer->press();
				usleep(20000);
			}
			else if (opcode == 'D')
			{
				pointer->moveTo(xcoord, ycoord);
				pointer->press();
				usleep(20000);
			}
			else if (opcode == 'u')
			{
				pointer->release();
				usleep(20000);
			}
			else if (opcode == 'U')
			{
				pointer->moveTo(xcoord, ycoord);
				pointer->release();
				usleep(20000);
			}
			else { printf("Unknown opcode '%c' received.\n", opcode); }
		}
		else
			std::cerr << "Received invalid data: " << buffer << std::endl;
	}
	
	
	for (i=POINTER_COUNT-1;i>0;i--)
	{
		std::string name = "MTC Touchpoint ";
		name += i2str(i);
		// Lösche das UInput-Gerät
		if (uinputs[i])
		{
			if (Debug) std::cerr << "deleting " << name << std::endl;
			delete uinputs[i];
			uinputs[i] = NULL;
		}
	}
	#ifdef MPX
	if (Mpx) for (i=POINTER_COUNT-1;i>0;i--)
	{
		usleep(50000);
		std::string name = "MTC Touchpoint ";
		name += i2str(i);
		std::string mname = "MTC Touchpoint Master ";
		mname += i2str(i);
		// Lösche den Master
		if (display)
		{
			if (Debug) std::cerr << "deleting master " << mname << std::endl;
			xi2_remove_master(display, mname);
		}
	}
	#endif
	std::cerr << "done" << std::endl;
}
Ejemplo n.º 12
0
Archivo: s2.cpp Proyecto: dCache/s2
/********************************************************************
 * Parse command-line arguments (non -+ options)
 *
 * Returns:
 *   ERR_OK: if success
 *   >= ERR_OK: otherwise
 ********************************************************************/
static int
s2_run(int argc, char **argv, int i)
{
  int rval = ERR_OK, lval;
  int i_1 = i;
  Node *root = NULL;
  Process *proc = NULL;
  BOOL tp_created = FALSE;

  /* init progress bar */
  Process::progress(-1,proc);

#if defined(HAVE_SRM21) || defined(HAVE_SRM22)
  srm_init();
#endif

  lval = parse(opts.scr_fname, &root);
  DM_DBG(DM_N(1), "parser return value=%d\n", lval);
  UPDATE_MAX(rval, lval);
  if(rval > opts.s2_eval) {
    /* stop evaluation */
    UPDATE_MAX(rval, ERR_NEXEC);
    goto cleanup;
  }

  /* create thread pool */
  if(!tp_created) tp_init(opts.tp_size);
  tp_created = TRUE;

  /* pretty-print S2 tree ($ENV{VAR} are evaluated) */
  if(opts.pp_fname) lval = pp_print(root);
  DM_DBG(DM_N(1), "pretty-printer return value=%d\n", lval);
  UPDATE_MAX(rval, lval);

  if(root) {
    Process::threads_init();
    proc = new Process(root, NULL, NULL);

    if(!proc) {
      DM_ERR(ERR_SYSTEM, _("failed to create a Process: %s\n"), _(strerror(errno)));
      UPDATE_MAX(rval, ERR_SYSTEM);
      goto cleanup;
    }

    /* write ${0}..${n} variables */
    const char *name = cmd_label();
    proc->WriteVariable("0", name, TRUE);
    for(; i < argc; i++) {
      proc->WriteVariable(i2str(i - i_1 + 1).c_str(), argv[i], TRUE);
    }

    setenv("CLIENT_INFO", build_client_info(name), 1);

    lval = proc->eval();
    Process::threads_destroy();
    DM_DBG(DM_N(1), "evaluation return value=%d\n", lval);
    UPDATE_MAX(rval, lval);
  }

  /* after-evaluation print of the tree */
  if(opts.e2_fname) lval = e2_print(root);
  DM_DBG(DM_N(2), "after-evaluation print return value=%d\n", lval);
  UPDATE_MAX(rval, lval);

cleanup:
  /* cleanup */
  DELETE(proc);	/* free proc *first*, then root */
  DELETE(root);

  /* destroy thread pool */
  if(tp_created) tp_cleanup();

  /* hide progress bar */
  Process::progress(0,proc);

  DM_DBG(DM_N(1), "s2_run return value=%d\n", rval);
  return rval;
}
char *i2str_zeropad(int i, char *buf) {
  if (i < 10) *buf++ = '0';
  return i2str(i, buf);
}
Ejemplo n.º 14
0
void MusicManager::loadMusics(std::string path, std::string root)
{
    if( !file_existsX(path) ) return;

    INIReader MusicIni( path );
    if (MusicIni.ParseError() < 0)
    {
        MessageBoxA(0, std::string(path+"\n\nError of read INI file").c_str(), "Error", 0);
        return;
    }

    curRoot=root;
    int i=0;

    //World music
    for(int j=1; (j<=16) && (i<74); i++, j++)
    {
        std::string head = "world-music-"+i2str(j);
        std::string fileName;

        fileName = MusicIni.Get(head, "file", "");
        if(fileName.size()==0) continue;
        replaceSubStr(fileName, "\"", "");
        replaceSubStr(fileName, "\\\\",  "\\");
        replaceSubStr(fileName, "/",  "\\");
        if (file_existsX(root + clearTrackNumber(fileName) ))
        {
            music_wld[j-1].setPath(root+fileName.c_str());
        }
    }

    //Special music
    for(int j=1; (j<=3) && (i<74); i++, j++)
    {
        std::string head = "special-music-"+i2str(j);
        std::string fileName;

        fileName = MusicIni.Get(head, "file", "");
        if(fileName.size()==0) continue;
        replaceSubStr(fileName, "\"", "");
        replaceSubStr(fileName, "\\\\",  "\\");
        replaceSubStr(fileName, "/",  "\\");
        if (file_existsX(root + clearTrackNumber(fileName)))
        {
            music_spc[j-1].setPath(root+fileName.c_str());
        }
    }

    //Level music
    for(int j=1; (j<=56) && (i<74); i++, j++)
    {
        if(j==24) j++;
        std::string head = "level-music-"+i2str(j);
        std::string fileName;

        fileName = MusicIni.Get(head, "file", "");
        if(fileName.size()==0) continue;
        replaceSubStr(fileName, "\"", "");
        replaceSubStr(fileName, "\\\\",  "\\");
        replaceSubStr(fileName, "/",  "\\");
        if (file_existsX(root + clearTrackNumber(fileName)))
        {
            music_lvl[j-1].setPath(root+fileName.c_str());
        }
    }
}