Example #1
0
void card_detect_demo(void)
{
	INT8U  err;
	INT32U msg_id;
	INT32S nRet;
	
	card_detect_q = OSQCreate(card_detect_area, 1);
	if (card_detect_q == NULL)
		while(1);
	
	card_detect_set_cf_callback(cf_card_plug_in_out);
	card_detect_set_sdms_callback(sdms_card_plug_in_out);
	card_detect_set_usb_h_callback(usb_h_plug_in_out);
	card_detect_set_usb_d_callback(usb_d_plug_in_out);
	card_detect_init(TYPE_CF|TYPE_SD|TYPE_MS|TYPE_USBH|TYPE_USBD|TYPE_NAND);
	
	if(card_detection(C_CFC))
	{  
		nRet = _devicemount(FS_CF);
		if(!nRet)
			DBG_PRINT("CF MOUNT Success\r\n");
		else 
			DBG_PRINT("CF MOUNT Fail!!!\r\n");
	}
	if(card_detection(C_SDC))
	{  
		nRet = _devicemount(FS_SD);
		if(!nRet)
			DBG_PRINT("SD MOUNT Success\r\n");
		else 
			DBG_PRINT("SD MOUNT Fail!!!\r\n");
	}
	if(card_detection(C_MSC))
	{  
		nRet = _devicemount(FS_MS);
		if(!nRet)
			DBG_PRINT("MS MOUNT Success\r\n");
		else 
			DBG_PRINT("MS MOUNT Fail!!!\r\n");
	}
	if(card_detection(C_USBH))
	{  
		nRet = _devicemount(FS_USBH);
		if(!nRet)
			DBG_PRINT("USB Host MOUNT Success\r\n");
		else 
			DBG_PRINT("USB Host MOUNT Fail!!!\r\n");
	}
	if(card_detection(C_USBD))
	{
		DBG_PRINT("USBD plug in\r\n");
	}  
	if(card_detection(C_NAND))
	{
		nRet = _devicemount(FS_NAND1);
		if(!nRet)
			DBG_PRINT("NAND1 MOUNT Success\r\n");
		else 
			DBG_PRINT("NAND1 MOUNT Fail!!!\r\n");
	}  
	if(card_detection(C_XDC))
	{
		nRet = _devicemount(FS_XD);
		if(!nRet)
			DBG_PRINT("XD MOUNT Success\r\n");
		else 
			DBG_PRINT("XD MOUNT Fail!!!\r\n");
	}  
	
	while(1)
	{
		msg_id = (INT32U) OSQPend(card_detect_q, 0, &err);
		switch(msg_id)
		{
		case CF_PLUG_IN:
	 		cfc_detection();
			if(card_detection(C_CFC))
			{
				nRet = _devicemount(FS_CF);
				if(!nRet)
					DBG_PRINT("CF PLUG-IN & MOUNT-SUCCESS\r\n");
				else
					DBG_PRINT("CF PLUG-IN & MOUNT-FAIL!!!\r\n");
		 	}
			break;
		case CF_PLUG_OUT:
			disk_safe_exit(FS_CF);
            nRet = _deviceunmount(FS_CF);
			if(!nRet)
				DBG_PRINT("CF PLUG-OUT & UN-MOUNT-SUCCESS\r\n");
			else
				DBG_PRINT("CF PLUG-OUT & UN-MOUNT-FAIL!!!\r\n");
	 		break;
	 
		case SDMSXD_PLUG_IN:
	 		sdms_detection();
			if(card_detection(C_SDC))
			{
				nRet = _devicemount(FS_SD);
				if(!nRet)
					DBG_PRINT("SD PLUG-IN & MOUNT-SUCCESS\r\n");
				else
					DBG_PRINT("SD PLUG-IN & MOUNT-FAIL!!!\r\n");
			}
			else if(card_detection(C_MSC))
			{
				nRet = _devicemount(FS_MS);
				if(!nRet)
					DBG_PRINT("MS PLUG-IN & MOUNT-SUCCESS\r\n");
				else
					DBG_PRINT("MS PLUG-IN & MOUNT-FAIL!!!\r\n");		
			}
			else if(card_detection(C_XDC))
			{
				nRet = _devicemount(FS_XD);
				if(!nRet)
					DBG_PRINT("XD PLUG-IN & MOUNT-SUCCESS\r\n");
				else
					DBG_PRINT("XD PLUG-IN & MOUNT-FAIL!!!\r\n");			
			}		
	 		break;
	 	case SDMSXD_PLUG_OUT:
	 		if(card_detection(C_SDC))
	 		{
				disk_safe_exit(FS_SD);
	            nRet = _deviceunmount(FS_SD);
				if(!nRet)
					DBG_PRINT("SD PLUG-OUT & UN-MOUNT-SUCCESS\r\n");
				else
					DBG_PRINT("SD PLUG-OUT & UN-MOUNT-FAIL!!!\r\n");
            }
            else if(card_detection(C_MSC))
			{
				disk_safe_exit(FS_MS);
	            nRet = _deviceunmount(FS_MS);
				if(!nRet)
					DBG_PRINT("MS PLUG-OUT & UN-MOUNT-SUCCESS\r\n");
				else
					DBG_PRINT("MS PLUG-OUT & UN-MOUNT-FAIL!!!\r\n");
			}
			else if(card_detection(C_XDC))
			{
				disk_safe_exit(FS_XD);
	            nRet = _deviceunmount(FS_XD);
				if(!nRet)
					DBG_PRINT("XD PLUG-OUT & UN-MOUNT-SUCCESS\r\n");
				else
					DBG_PRINT("XD PLUG-OUT & UN-MOUNT-FAIL!!!\r\n");
			}
	 		break;
	 		
	 	case USB_H_PLUG_IN:
	 		if(card_detection(C_USBH))
	 		{
	 			nRet = _devicemount(FS_USBH);
				if(!nRet)
					DBG_PRINT("USB Host PLUG-IN & MOUNT-SUCCESS\r\n");
				else
					DBG_PRINT("USB Host PLUG-IN & MOUNT-FAIL!!!\r\n");
	 		}
	 		break;
	 		
	 	case USB_H_PLUG_OUT:
	 		if(!card_detection(C_USBH))
	 		{
				disk_safe_exit(FS_USBH);
	            nRet = _deviceunmount(FS_USBH);
				if(!nRet)
					DBG_PRINT("USB Host PLUG-OUT & UN-MOUNT-SUCCESS\r\n");
				else
					DBG_PRINT("USB Host PLUG-OUT & UN-MOUNT-FAIL!!!\r\n");
	 		}
	 		break;
	 	
	 	case USB_D_PLUG_IN:
	 		if(card_detection(C_USBD))
	 		{
	 			DBG_PRINT("USB Device PLUG-IN\r\n");
	 		}
	 		break;
	 		
	 	case USB_D_PLUG_OUT:
	 		if(!card_detection(C_USBD))
	 		{
	 			DBG_PRINT("USB Device PLUG-OUT\r\n");
	 		}
	 		break;
	 	}	
	}
}
UINT8 CClearDepotFunc::ClearDepot(string &strErr)
{
	UINT8 ret = SUCCESS;
	INT32 tmp, errorcode;
	CSysArg cSysArg, *sysArg;
	sysArg = &cSysArg;
	INT8 sqlbuf[256];
	string sqlstr = "";

// 	memset((void *)sqlbuf,0x00,sizeof(sqlbuf));
// 	sprintf(sqlbuf,  "where SA_ID = %d", SYS_SERIAL_BAUDRATE);
// 	sysArg->m_filter.append(sqlbuf);
// 	sysArg->Requery();
// 	errorcode = sysArg->LoadOneRecord();
// 	DBG_PRINT(("errorcode= %d",errorcode));
// 	if (errorcode == SQLITE_OK)
// 	{
// 		memset((void *)sqlbuf,0x00,sizeof(sqlbuf));
// 		sprintf(sqlbuf, "update SYSARG set V_INT = %d where SA_ID = %d;\n", 
// 			sysArg->m_vInt, SYS_SERIAL_BAUDRATE);
// 		sqlstr += sqlbuf;
// 		DBG_PRINT(("sqlstr = %s", sqlstr.c_str()));
// 	}

	memset((void *)sqlbuf,0x00,sizeof(sqlbuf));
	sprintf(sqlbuf,  "where SA_ID = %d", SYS_ZS_PWD);
	sysArg->m_filter.append(sqlbuf);
	sysArg->Requery();
	errorcode = sysArg->LoadOneRecord();
	DBG_PRINT(("errorcode= %d",errorcode));
	if (errorcode == SQLITE_OK)
	{
		memset((void *)sqlbuf,0x00,sizeof(sqlbuf));
		sprintf(sqlbuf, "update SYSARG set V_TEXT = '%s' where SA_ID = %d;\n", 
			sysArg->m_vText.c_str(), SYS_ZS_PWD);
		sqlstr += sqlbuf;
		DBG_PRINT(("sqlstr = %s", sqlstr.c_str()));
	}

	memset((void *)sqlbuf,0x00,sizeof(sqlbuf));
	sprintf(sqlbuf,  "where SA_ID = %d", SYS_SKSB_PWD);
	sysArg->m_filter.append(sqlbuf);
	sysArg->Requery();
	errorcode = sysArg->LoadOneRecord();
	DBG_PRINT(("errorcode= %d",errorcode));
	if (errorcode == SQLITE_OK)
	{
		memset((void *)sqlbuf,0x00,sizeof(sqlbuf));
		sprintf(sqlbuf, "update SYSARG set V_TEXT = '%s' where SA_ID = %d;\n", 
			sysArg->m_vText.c_str(), SYS_SKSB_PWD);
		sqlstr += sqlbuf;
		DBG_PRINT(("sqlstr = %s", sqlstr.c_str()));
	}

	FILE *fp1; 
	if( (fp1=fopen(SAVEINFO_DIR,"w"))==NULL ) 
	{ 
		fclose(fp1); 
		strErr = "打开saveinfo.sql文件错误!";
		DBG_PRINT((" 打开saveinfo.sql文件错误"));
		return FAILURE;
	} 

	INT32 nRealLen = sqlstr.length();
	INT32 nLen = 0;
	nLen = fwrite(sqlstr.c_str(),1, nRealLen,fp1); 
	if (nLen!=nRealLen) 
	{
		fclose(fp1); 
		strErr = "写saveinfo.sql文件错误!";
		DBG_PRINT((" 写saveinfo.sql文件错误"));
		return FAILURE;
	}
	
	fclose(fp1);

	//删除数据库文件
	system(RM_CMD);
	DBG_PRINT((" 删除数据库文件"));
	
	//重建数据库
	DBG_PRINT((" 重建数据库"));
	string strCmd = SQL_CMD;
	string strCmd2 = SAVEINFO_CMD;
	DBG_PRINT((" strCmd = %s", strCmd.c_str()));
	DBG_PRINT((" strCmd2 = %s", strCmd2.c_str()));
	if ( system(strCmd.c_str()) != 0 )
	{
		strErr = "清库错误!";	
        return FAILURE;
	}

	if ( system(strCmd2.c_str()) != 0 )
	{
		strErr = "写保留信息错误";	
        return FAILURE;
	}
	
	DBG_PRINT((" 清库完成!请重新启动机器"));
	return SUCCESS;
}
Example #3
0
/*
 * java: read java file and pickup tag entries.
 */
void
java(const struct parser_param *param)
{
	int c;
	int level;					/* brace level */
	int startclass, startthrows, startequal;
	char classname[MAXTOKEN];
	char completename[MAXCOMPLETENAME];
	int classlevel;
	struct {
		char *classname;
		char *terminate;
		int level;
	} stack[MAXCLASSSTACK];
	const char *interested = "{}=;";

	*classname = *completename = 0;
	stack[0].classname = completename;
	stack[0].terminate = completename;
	stack[0].level = 0;
	level = classlevel = 0;
	startclass = startthrows = startequal = 0;

	if (!opentoken(param->file))
		die("'%s' cannot open.", param->file);
	while ((c = nexttoken(interested, java_reserved_word)) != EOF) {
		switch (c) {
		case SYMBOL:					/* symbol */
			for (; c == SYMBOL && peekc(1) == '.'; c = nexttoken(interested, java_reserved_word)) {
				PUT(PARSER_REF_SYM, token, lineno, sp);
			}
			if (c != SYMBOL)
				break;
			if (startclass || startthrows) {
				PUT(PARSER_REF_SYM, token, lineno, sp);
			} else if (peekc(0) == '('/* ) */) {
				if (level == stack[classlevel].level && !startequal)
					/* ignore constructor */
					if (strcmp(stack[classlevel].classname, token))
						PUT(PARSER_DEF, token, lineno, sp);
				if (level > stack[classlevel].level || startequal)
					PUT(PARSER_REF_SYM, token, lineno, sp);
			} else {
				PUT(PARSER_REF_SYM, token, lineno, sp);
			}
			break;
		case '{': /* } */
			DBG_PRINT(level, "{");	/* } */

			++level;
			if (startclass) {
				char *p = stack[classlevel].terminate;
				char *q = classname;

				if (++classlevel >= MAXCLASSSTACK)
					die("class stack over flow.[%s]", curfile);
				if (classlevel > 1)
					*p++ = '.';
				stack[classlevel].classname = p;
				while (*q)
					*p++ = *q++;
				stack[classlevel].terminate = p;
				stack[classlevel].level = level;
				*p++ = 0;
			}
			startclass = startthrows = 0;
			break;
			/* { */
		case '}':
			if (--level < 0) {
				if (param->flags & PARSER_WARNING)
					warning("missing left '{' (at %d).", lineno); /* } */
				level = 0;
			}
			if (level < stack[classlevel].level)
				*(stack[--classlevel].terminate) = 0;
			/* { */
			DBG_PRINT(level, "}");
			break;
		case '=':
			startequal = 1;
			break;
		case ';':
			startclass = startthrows = startequal = 0;
			break;
		case JAVA_CLASS:
		case JAVA_INTERFACE:
		case JAVA_ENUM:
			if ((c = nexttoken(interested, java_reserved_word)) == SYMBOL) {
				strlimcpy(classname, token, sizeof(classname));
				startclass = 1;
				PUT(PARSER_DEF, token, lineno, sp);
			}
			break;
		case JAVA_NEW:
		case JAVA_INSTANCEOF:
			while ((c = nexttoken(interested, java_reserved_word)) == SYMBOL && peekc(1) == '.')
				PUT(PARSER_REF_SYM, token, lineno, sp);
			if (c == SYMBOL)
				PUT(PARSER_REF_SYM, token, lineno, sp);
			break;
		case JAVA_THROWS:
			startthrows = 1;
			break;
		case JAVA_BOOLEAN:
		case JAVA_BYTE:
		case JAVA_CHAR:
		case JAVA_DOUBLE:
		case JAVA_FLOAT:
		case JAVA_INT:
		case JAVA_LONG:
		case JAVA_SHORT:
		case JAVA_VOID:
			if (peekc(1) == '.' && (c = nexttoken(interested, java_reserved_word)) != JAVA_CLASS)
				pushbacktoken();
			break;
		default:
			break;
		}
	}
	closetoken();
}
Example #4
0
void state_handling_init(void)
{
	INT32S config_load_flag;

	StateHandlingQ = OSQCreate(state_handling_q_stack, STATE_HANDLING_QUEUE_MAX);
	ApQ = msgQCreate(AP_QUEUE_MAX, AP_QUEUE_MAX, AP_QUEUE_MSG_MAX_LEN);
	
	nvmemory_init();
	config_load_flag = ap_state_config_load();
	ap_state_resource_init();
	ap_state_config_initial(config_load_flag);
#if ENABLE_CHECK_RTC == 1
	if (config_load_flag != STATUS_FAIL)
	{
		ap_state_config_data_time_check();
	}
#endif
	ap_state_handling_calendar_init();

	ap_state_handling_storage_id_set(NO_STORAGE);
	
	{
		DISPLAY_ICONSHOW icon = {216, 144, TRANSPARENT_COLOR, 0, 0};
		INT32U i, *buff_ptr, color_data, cnt;
		INT32U display_frame0;

		display_battery_low_frame0 = (INT32U) gp_malloc_align(icon.icon_w * icon.icon_h * 2, 64);
		DBG_PRINT("batteryLow_display_buf_addr = 0x%x \r\n",display_frame0);
		buff_ptr = (INT32U *) display_battery_low_frame0;
		color_data = 0x8C71ul|(0x8C71ul<<16);
		cnt = (icon.icon_w * icon.icon_h * 2) >> 2;
		for (i=0 ; i<cnt ; i++) {
			*buff_ptr++ = color_data;
		}
		DBG_PRINT("batteryLowshow! \r\n");

		{
			INT32U size, read_buf;
			INT16U logo_fd;
			INT8U *zip_buf;
			INT32U icon_buffer;

			logo_fd = nv_open((INT8U*)"INSERTSDC.GPZP");
			if (logo_fd != 0xFFFF) {
				size = nv_rs_size_get(logo_fd);
				read_buf = (INT32S) gp_malloc(size);
				if (!read_buf) {
					DBG_PRINT("allocate BACKGROUND.GPZP read buffer fail.[%d]\r\n", size);
				}

				if (nv_read(logo_fd, (INT32U) read_buf, size)) {
					DBG_PRINT("Failed to read icon_buffer resource\r\n");
					gp_free((void *) read_buf);
				}

				zip_buf = (INT8U *)read_buf;
				if (gpzp_decode((INT8U *) &zip_buf[4], (INT8U *) display_battery_low_frame0) == STATUS_FAIL) {
					DBG_PRINT("Failed to unzip GPZP file\r\n");
					gp_free((void *) read_buf);
					gp_free((void *) icon_buffer);
					read_buf = 0;
					icon_buffer = 0;
				}

				gp_free((void *) read_buf);
			}
		}
	}
	
	DBG_PRINT("state_handling_init OK!\r\n"); 
}
Example #5
0
void mac_cmd_handler(mac_cmd_t *cmd, mac_hdr_t *hdr)
{
    buffer_t *buf_out;
    mac_hdr_t hdr_out;
    nwk_nib_t *nib = nwk_nib_get();

    DBG_PRINT_SIMONLY("\n<INCOMING>");
    debug_dump_mac_cmd(cmd);
    switch (cmd->cmd_id)
    {
    case MAC_ASSOC_REQ:
        if (nib->joined)
        {
            DBG_PRINT_SIMONLY("MAC: MAC Association Request Command Received.\n");
            // check to make sure that association is permitted and the src address is the correct mode
            if ((pib.assoc_permit) && (hdr->src_addr.mode == LONG_ADDR))
            {
                mac_assoc_ind_t assoc_args;
                assoc_args.capability = cmd->assoc_req.cap_info;
                memcpy(&assoc_args.dev_addr, &hdr->src_addr, sizeof(address_t));
                mac_assoc_ind(&assoc_args);
            }
            else
            {
                mac_assoc_resp_t resp_args;
                memcpy(&resp_args.dev_addr, &hdr->src_addr, sizeof(address_t));
                resp_args.assoc_short_addr = 0xFFFF;
                resp_args.status = MAC_INVALID_PARAMETER;
                mac_assoc_resp(&resp_args);
            }
        }
        break;

    case MAC_ASSOC_RESP:
        if ((pcb.mac_state == MLME_DATA_REQ) || (pcb.mac_state == MLME_ASSOC_REQ))
        {
            pcb.mac_state = MLME_IDLE;
        }
        mac_assoc_conf(cmd->assoc_resp.short_addr, cmd->assoc_resp.assoc_status);
        break;

    case MAC_DATA_REQ:
        if (nib->joined)
        {
            DBG_PRINT("MAC: MAC Data Request Command Received.\n");
            mac_indir_data_req_handler(&hdr->src_addr);
        }
        break;

    case MAC_BEACON_REQ:
        if (nib->joined)
        {
            DBG_PRINT("MAC: MAC Beacon Request Command Received.\n");
            BUF_ALLOC(buf_out, TX);
            mac_gen_beacon_frm(buf_out, &hdr_out);
            mac_tx_handler(buf_out, &hdr_out.dest_addr, false, false, hdr_out.dsn, 0);
        }
        break;

    case MAC_ORPHAN_NOT:
        if (hdr->src_addr.mode == LONG_ADDR)
        {
            mac_orphan_ind(hdr->src_addr.long_addr);
        }
        break;

    case MAC_COORD_REALIGN:
        // check over the coord realign frame to make sure that the data is what we had previously
        if  ((cmd->coord_realign.pan_id == pib.pan_id) && (cmd->coord_realign.short_addr == pib.short_addr))
        {
            if ((pib.coord_addr.mode == SHORT_ADDR) && (cmd->coord_realign.coord_short_addr == pib.coord_addr.short_addr))
            {
                pcb.coor_realign_rcvd = true;
            }
            else if ((pib.coord_addr.mode == LONG_ADDR) && (hdr->src_addr.mode == LONG_ADDR) &&
                     (hdr->src_addr.long_addr == pib.coord_addr.long_addr))
            {
                pcb.coor_realign_rcvd = true;
            }
            else
            {
                return;
            }
        }
        else
        {
            return;
        }

        // stop the scan once we get a valid coord realignment command frame
        // the scan will end once the channel is beyond the channel range
        pcb.curr_scan_channel = MAC_PHY_CHANNEL_OFFSET + MAC_MAX_CHANNELS;
        ctimer_stop(&pcb.mlme_tmr);
        mac_scan(NULL);
        break;
    default:
        break;
    }
}
Example #6
0
JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_KDDisplay_DispatchMessages
  (JNIEnv *env, jobject obj)
{
    const KDEvent * evt;
    int numEvents = 0;

    // Periodically take a break
    while( numEvents<100 && NULL!=(evt=kdWaitEvent(0)) ) {
        KDWindow *kdWindow;
        jobject javaWindow;
        JOGLKDUserdata * userData = (JOGLKDUserdata *)(intptr_t)evt->userptr;
        if(NULL == userData || userData->magic!=JOGL_KD_USERDATA_MAGIC) {
            DBG_PRINT( "event unrelated: evt type: 0x%X\n", evt->type);
            continue;
        }
        kdWindow = userData->kdWindow;
        javaWindow = userData->javaWindow;
        DBG_PRINT( "[DispatchMessages]: userData %p, evt type: 0x%X\n", userData, evt->type);

        numEvents++;

        // FIXME: support resize and window re-positioning events

        switch(evt->type) {
            case KD_EVENT_WINDOW_FOCUS:
                {
                    KDboolean hasFocus;
                    kdGetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_FOCUS, &hasFocus);
                    DBG_PRINT( "event window focus : src: %p\n", userData);
                }
                break;
            case KD_EVENT_WINDOW_CLOSE:
                {
                    DBG_PRINT( "event window close : src: %p\n", userData);
                    (*env)->CallVoidMethod(env, javaWindow, windowDestroyNotifyID);
                }
                break;
            case KD_EVENT_WINDOWPROPERTY_CHANGE:
                {
                    const KDEventWindowProperty* prop = &evt->data.windowproperty;
                    switch (prop->pname) {
                        case KD_WINDOWPROPERTY_SIZE:
                            {
                                KDint32 v[2];
                                if(!kdGetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, v)) {
                                    DBG_PRINT( "event window size change : src: %p %dx%d\n", userData, v[0], v[1]);
                                    (*env)->CallVoidMethod(env, javaWindow, sizeChangedID, JNI_FALSE, (jint) v[0], (jint) v[1], JNI_FALSE);
                                } else {
                                    DBG_PRINT( "event window size change error: src: %p %dx%d\n", userData, v[0], v[1]);
                                }
                            }
                            break;
                        case KD_WINDOWPROPERTY_FOCUS:
                            DBG_PRINT( "event window focus: src: %p\n", userData);
                            break;
                        case KD_WINDOWPROPERTY_VISIBILITY:
                            {
                                KDboolean visible;
                                kdGetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visible);
                                DBG_PRINT( "event window visibility: src: %p, v:%d\n", userData, visible);
                                (*env)->CallVoidMethod(env, javaWindow, visibleChangedID, JNI_FALSE, visible?JNI_TRUE:JNI_FALSE);
                            }
                            break;
                        default:
                            break;
                    }
                }
                break;
            case KD_EVENT_INPUT_POINTER:
                {
                    const KDEventInputPointer* ptr = &(evt->data.inputpointer);
                    // button idx: evt->data.input.index
                    // pressed = ev->data.input.value.i
                    // time = ev->timestamp
                    if(KD_INPUT_POINTER_SELECT==ptr->index) {
                        DBG_PRINT( "event mouse click: src: %p, s:%d, (%d,%d)\n", userData, ptr->select, ptr->x, ptr->y);
                        (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, 
                                              (ptr->select==0) ? (jint) EVENT_MOUSE_RELEASED : (jint) EVENT_MOUSE_PRESSED, 
                                              (jint) 0,
                                              (jint) ptr->x, (jint) ptr->y, 1, 0);
                    } else {
                        DBG_PRINT( "event mouse: src: %d, s:%p, i:0x%X (%d,%d)\n", userData, ptr->select, ptr->index, ptr->x, ptr->y);
                        (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, 
                                              0,
                                              (jint) ptr->x, (jint) ptr->y, 0, 0);
                    }
                }
                break;
        }
    } 
}
Example #7
0
void rf_process()
{
    struct rf_cmd cmd;
    UINT32 val32;
    UINT8 devId, hostId;
    INT8 ret;
    if(32 != rcvCmd(&cmd)){
        return;
    }
    switch(cmd.cmd){
      case KFISH_CMD_DISCOVER:
	if(rf_mode_get() != SLAVE_MODE_WAIT_DISCOVER)
	  break;
	memcpy(&val32, cmd.data, sizeof(UINT32));
        if(val32 == 0xffffffff){
            DBG_PRINT("devId full\n");
	    rf_mode_set(SLAVE_MODE_WAIT_DISCOVER);
            return;
        }
        for(devId = 0; devId < 0x20; devId++){
            if(((val32 >> devId) & 1) == 0)
              break;
        }
        /* printk("rcv discover from 0x%x->%x \n", cmd.srcId, cmd.destId); */
	/* printk("try devid 0x%x plane %d mode %d\n", devId, cmd.rfPlane, rf_mode_get()); */
        /* printk("list 0x%lx\n", val32); */
        rf_config(cmd.srcId, devId);
        cmd.cmd = KFISH_CMD_DISCOVER_ACK;
	val32 = val32 | (1 << devId);
	memcpy(cmd.data, &val32, sizeof(UINT32));
        sndCmd(&cmd);
	rf_mode_set(SLAVE_MODE_DISCOVER_GET);
        break;
      
      case KFISH_CMD_DEVCONFIRM: /* 4Byte dev status, 1B controlNum */
	if(rf_mode_get() != SLAVE_MODE_DISCOVER_GET)
	  break;
        hostId = cmd.srcId;
        devId = cmd.destId;
	memcpy(&val32, cmd.data, sizeof(UINT32));
	val32 |= (1 << devId);
	memcpy(cmd.data, &val32, sizeof(UINT32));
        cmd.data[4] = __local_ctrl_num; /* control number */
        cmd.cmd = KFISH_CMD_DEVCONFIRM_ACK;
        rf_mode_set(SLAVE_MODE_NORMAL);
        sndCmd(&cmd);
	printk("confirmed, use devId 0x%x\n", devId);
        if(hostId != EEPROM_get(EEPROM_OFS_HOSTID)){
            EEPROM_put(EEPROM_OFS_HOSTID, hostId);
        }
        if(devId != EEPROM_get(EEPROM_OFS_DEVID)){
            EEPROM_put(EEPROM_OFS_RFPLANE, devId);
        }
        if(0xa9 != EEPROM_get(EEPROM_OFS_RFAVAIL)){
            EEPROM_put(EEPROM_OFS_RFAVAIL, 0xa9);
        }
        break;
      default:
	ret = uartCmdLocalProcess(&cmd);
	if(CMD_PROCESS_ACK == ret){
	    DBG_PRINT("<cmd 0x%x ctrl:%d data:%x %x %x\n", 
		   cmd.cmd, cmd.ctrlId, cmd.data[0], cmd.data[1], cmd.data[2]
		  );
	    sndCmd(&cmd);	/* 合法命令,发送应答 */
	    DBG_PRINT(">cmd 0x%x ctrl %d %x %x %x\n", 
		      cmd.cmd, cmd.ctrlId, cmd.data[0], cmd.data[1], cmd.data[2]
		     );
	}else if(CMD_PROCESS_NO_ACK == ret){	/* 合法命令,但是不用应答 */
	    
	}else{			/* 不合法的命令 */
	    DBG_PRINT("illegal command\n");
	    DBG_PRINT("\tcmd 0x%x ctrlId %d", cmd.cmd, cmd.ctrlId);
	}
        break;
    }
}
Example #8
0
void RenderThread::run (void)
{
	// Init state
	m_windowState	= WINDOWSTATE_NOT_CREATED;
	m_paused		= true;
	m_finish		= false;

	try
	{
		while (!m_finish)
		{
			if (m_paused || m_windowState != WINDOWSTATE_READY)
			{
				// Block until we are not paused and window is ready.
				Message msg = m_msgQueue.popBack();
				processMessage(msg);
				continue;
			}

			// Process available commands
			{
				Message msg;
				if (m_msgQueue.tryPopBack(msg))
				{
					processMessage(msg);
					continue;
				}
			}

			DE_ASSERT(m_windowState == WINDOWSTATE_READY);

			// Process input events.
			// \todo [2013-05-08 pyry] What if system fills up the input queue before we have window ready?
			while (m_inputQueue &&
				   AInputQueue_hasEvents(m_inputQueue) > 0)
			{
				AInputEvent* event;
				TCU_CHECK(AInputQueue_getEvent(m_inputQueue, &event) >= 0);
				onInputEvent(event);
				AInputQueue_finishEvent(m_inputQueue, event, 1);
			}

			// Everything set up - safe to render.
			if (!render())
			{
				DBG_PRINT(("RenderThread::run(): render\n"));
				break;
			}
		}
	}
	catch (const std::exception& e)
	{
		print("RenderThread: %s\n", e.what());
	}

	// Tell activity to finish.
	DBG_PRINT(("RenderThread::run(): done, waiting for FINISH\n"));
	m_activity.finish();

	// Thread must keep draining message queue until FINISH message is encountered.
	try
	{
		while (!m_finish)
		{
			Message msg = m_msgQueue.popBack();

			// Ignore all but SYNC and FINISH messages.
			if (msg.type == MESSAGE_SYNC || msg.type == MESSAGE_FINISH)
				processMessage(msg);
		}
	}
	catch (const std::exception& e)
	{
		die("RenderThread: %s\n", e.what());
	}

	DBG_PRINT(("RenderThread::run(): exiting...\n"));
}
Example #9
0
RenderActivity::RenderActivity (ANativeActivity* activity)
	: NativeActivity(activity)
	, m_thread		(DE_NULL)
{
	DBG_PRINT(("RenderActivity::RenderActivity()"));
}
Example #10
0
  bool PDFullSpaceSolver::Solve(Number alpha,
                                Number beta,
                                const IteratesVector& rhs,
                                IteratesVector& res,
                                bool allow_inexact,
                                bool improve_solution /* = false */)
  {
    DBG_START_METH("PDFullSpaceSolver::Solve",dbg_verbosity);
    DBG_ASSERT(!allow_inexact || !improve_solution);
    DBG_ASSERT(!improve_solution || beta==0.);

    // Timing of PDSystem solver starts here
    IpData().TimingStats().PDSystemSolverTotal().Start();

    DBG_PRINT_VECTOR(2, "rhs_x", *rhs.x());
    DBG_PRINT_VECTOR(2, "rhs_s", *rhs.s());
    DBG_PRINT_VECTOR(2, "rhs_c", *rhs.y_c());
    DBG_PRINT_VECTOR(2, "rhs_d", *rhs.y_d());
    DBG_PRINT_VECTOR(2, "rhs_zL", *rhs.z_L());
    DBG_PRINT_VECTOR(2, "rhs_zU", *rhs.z_U());
    DBG_PRINT_VECTOR(2, "rhs_vL", *rhs.v_L());
    DBG_PRINT_VECTOR(2, "rhs_vU", *rhs.v_U());
    DBG_PRINT_VECTOR(2, "res_x in", *res.x());
    DBG_PRINT_VECTOR(2, "res_s in", *res.s());
    DBG_PRINT_VECTOR(2, "res_c in", *res.y_c());
    DBG_PRINT_VECTOR(2, "res_d in", *res.y_d());
    DBG_PRINT_VECTOR(2, "res_zL in", *res.z_L());
    DBG_PRINT_VECTOR(2, "res_zU in", *res.z_U());
    DBG_PRINT_VECTOR(2, "res_vL in", *res.v_L());
    DBG_PRINT_VECTOR(2, "res_vU in", *res.v_U());

    // if beta is nonzero, keep a copy of the incoming values in res_ */
    SmartPtr<IteratesVector> copy_res;
    if (beta != 0.) {
      copy_res = res.MakeNewIteratesVectorCopy();
    }

    // Receive data about matrix
    SmartPtr<const Vector> x = IpData().curr()->x();
    SmartPtr<const Vector> s = IpData().curr()->s();
    SmartPtr<const SymMatrix> W = IpData().W();
    SmartPtr<const Matrix> J_c = IpCq().curr_jac_c();
    SmartPtr<const Matrix> J_d = IpCq().curr_jac_d();
    SmartPtr<const Matrix> Px_L = IpNLP().Px_L();
    SmartPtr<const Matrix> Px_U = IpNLP().Px_U();
    SmartPtr<const Matrix> Pd_L = IpNLP().Pd_L();
    SmartPtr<const Matrix> Pd_U = IpNLP().Pd_U();
    SmartPtr<const Vector> z_L = IpData().curr()->z_L();
    SmartPtr<const Vector> z_U = IpData().curr()->z_U();
    SmartPtr<const Vector> v_L = IpData().curr()->v_L();
    SmartPtr<const Vector> v_U = IpData().curr()->v_U();
    SmartPtr<const Vector> slack_x_L = IpCq().curr_slack_x_L();
    SmartPtr<const Vector> slack_x_U = IpCq().curr_slack_x_U();
    SmartPtr<const Vector> slack_s_L = IpCq().curr_slack_s_L();
    SmartPtr<const Vector> slack_s_U = IpCq().curr_slack_s_U();
    SmartPtr<const Vector> sigma_x = IpCq().curr_sigma_x();
    SmartPtr<const Vector> sigma_s = IpCq().curr_sigma_s();
    DBG_PRINT_VECTOR(2, "Sigma_x", *sigma_x);
    DBG_PRINT_VECTOR(2, "Sigma_s", *sigma_s);

    bool done = false;
    // The following flag is set to true, if we asked the linear
    // solver to improve the quality of the solution in
    // the next solve
    bool resolve_with_better_quality = false;
    // the following flag is set to true, if iterative refinement
    // failed and we want to try if a modified system is able to
    // remedy that problem by pretending the matrix is singular
    bool pretend_singular = false;
    bool pretend_singular_last_time = false;

    // Beginning of loop for solving the system (including all
    // modifications for the linear system to ensure good solution
    // quality)
    while (!done) {

      // if improve_solution is true, we are given already a solution
      // from the calling function, so we can skip the first solve
      bool solve_retval = true;
      if (!improve_solution) {
        solve_retval =
          SolveOnce(resolve_with_better_quality, pretend_singular,
                    *W, *J_c, *J_d, *Px_L, *Px_U, *Pd_L, *Pd_U, *z_L, *z_U,
                    *v_L, *v_U, *slack_x_L, *slack_x_U, *slack_s_L, *slack_s_U,
                    *sigma_x, *sigma_s, 1., 0., rhs, res);
        resolve_with_better_quality = false;
        pretend_singular = false;
      }
      improve_solution = false;

      if (!solve_retval) {
        // If system seems not to be solvable, we return with false
        // and let the calling routine deal with it.
        IpData().TimingStats().PDSystemSolverTotal().End();
        return false;
      }

      if (allow_inexact) {
        // no safety checks required
        if (Jnlst().ProduceOutput(J_MOREDETAILED, J_LINEAR_ALGEBRA)) {
          SmartPtr<IteratesVector> resid = res.MakeNewIteratesVector(true);
          ComputeResiduals(*W, *J_c, *J_d, *Px_L, *Px_U, *Pd_L, *Pd_U,
                           *z_L, *z_U, *v_L, *v_U, *slack_x_L, *slack_x_U,
                           *slack_s_L, *slack_s_U, *sigma_x, *sigma_s,
                           alpha, beta, rhs, res, *resid);
        }
        break;
      }

      // Get space for the residual
      SmartPtr<IteratesVector> resid = res.MakeNewIteratesVector(true);

      // ToDo don't to that after max refinement?
      ComputeResiduals(*W, *J_c, *J_d, *Px_L, *Px_U, *Pd_L, *Pd_U,
                       *z_L, *z_U, *v_L, *v_U, *slack_x_L, *slack_x_U,
                       *slack_s_L, *slack_s_U, *sigma_x, *sigma_s,
                       alpha, beta, rhs, res, *resid);

      Number residual_ratio =
        ComputeResidualRatio(rhs, res, *resid);
      Jnlst().Printf(J_DETAILED, J_LINEAR_ALGEBRA,
                     "residual_ratio = %e\n", residual_ratio);
      Number residual_ratio_old = residual_ratio;

      // Beginning of loop for iterative refinement
      Index num_iter_ref = 0;
      bool quit_refinement = false;
      while (!allow_inexact && !quit_refinement &&
             (num_iter_ref < min_refinement_steps_ ||
              residual_ratio > residual_ratio_max_) ) {

        // To the next back solve
        solve_retval =
          SolveOnce(resolve_with_better_quality, false,
                    *W, *J_c, *J_d, *Px_L, *Px_U, *Pd_L, *Pd_U, *z_L, *z_U,
                    *v_L, *v_U, *slack_x_L, *slack_x_U, *slack_s_L, *slack_s_U,
                    *sigma_x, *sigma_s, -1., 1., *resid, res);
        ASSERT_EXCEPTION(solve_retval, INTERNAL_ABORT,
                         "SolveOnce returns false during iterative refinement.");

        ComputeResiduals(*W, *J_c, *J_d, *Px_L, *Px_U, *Pd_L, *Pd_U,
                         *z_L, *z_U, *v_L, *v_U, *slack_x_L, *slack_x_U,
                         *slack_s_L, *slack_s_U, *sigma_x, *sigma_s,
                         alpha, beta, rhs, res, *resid);

        residual_ratio =
          ComputeResidualRatio(rhs, res, *resid);
        Jnlst().Printf(J_DETAILED, J_LINEAR_ALGEBRA,
                       "residual_ratio = %e\n", residual_ratio);

        num_iter_ref++;
        // Check if we have to give up on iterative refinement
        if (residual_ratio > residual_ratio_max_ &&
            num_iter_ref>min_refinement_steps_ &&
            (num_iter_ref>max_refinement_steps_ ||
             residual_ratio>residual_improvement_factor_*residual_ratio_old)) {

          Jnlst().Printf(J_DETAILED, J_LINEAR_ALGEBRA,
                         "Iterative refinement failed with residual_ratio = %e\n", residual_ratio);
          quit_refinement = true;

          // Pretend singularity only once - if it didn't help, we
          // have to live with what we got so far
          resolve_with_better_quality = false;
          DBG_PRINT((1, "pretend_singular = %d\n", pretend_singular));
          if (!pretend_singular_last_time) {
            // First try if we can ask the augmented system solver to
            // improve the quality of the solution (only if that hasn't
            // been done before for this linear system)
            if (!augsys_improved_) {
              Jnlst().Printf(J_DETAILED, J_LINEAR_ALGEBRA,
                             "Asking augmented system solver to improve quality of its solutions.\n");
              augsys_improved_ = augSysSolver_->IncreaseQuality();
              if (augsys_improved_) {
                IpData().Append_info_string("q");
                resolve_with_better_quality = true;
              }
              else {
                // solver said it cannot improve quality, so let
                // possibly conclude that the current modification is
                // singular
                pretend_singular = true;
              }
            }
            else {
              // we had already asked the solver before to improve the
              // quality of the solution, so let's now pretend that the
              // modification is possibly singular
              pretend_singular = true;
            }
            pretend_singular_last_time = pretend_singular;
            if (pretend_singular) {
              // let's only conclude that the current linear system
              // including modifications is singular, if the residual is
              // quite bad
              if (residual_ratio < residual_ratio_singular_) {
                pretend_singular = false;
                IpData().Append_info_string("S");
                Jnlst().Printf(J_DETAILED, J_LINEAR_ALGEBRA,
                               "Just accept current solution.\n");
              }
              else {
                IpData().Append_info_string("s");
                Jnlst().Printf(J_DETAILED, J_LINEAR_ALGEBRA,
                               "Pretend that the current system (including modifications) is singular.\n");
              }
            }
          }
          else {
            pretend_singular = false;
            DBG_PRINT((1,"Resetting pretend_singular to false.\n"));
          }
        }

        residual_ratio_old = residual_ratio;
      } // End of loop for iterative refinement

      done = !(resolve_with_better_quality) && !(pretend_singular);

    } // End of loop for solving the linear system (incl. modifications)

    // Finally let's assemble the res result vectors
    if (alpha != 0.) {
      res.Scal(alpha);
    }

    if (beta != 0.) {
      res.Axpy(beta, *copy_res);
    }

    DBG_PRINT_VECTOR(2, "res_x", *res.x());
    DBG_PRINT_VECTOR(2, "res_s", *res.s());
    DBG_PRINT_VECTOR(2, "res_c", *res.y_c());
    DBG_PRINT_VECTOR(2, "res_d", *res.y_d());
    DBG_PRINT_VECTOR(2, "res_zL", *res.z_L());
    DBG_PRINT_VECTOR(2, "res_zU", *res.z_U());
    DBG_PRINT_VECTOR(2, "res_vL", *res.v_L());
    DBG_PRINT_VECTOR(2, "res_vU", *res.v_U());

    IpData().TimingStats().PDSystemSolverTotal().End();

    return true;
  }
Example #11
0
void RenderThread::processMessage (const Message& message)
{
	DBG_PRINT(("RenderThread::processMessage(): message = { %s, %p }\n", getMessageTypeName(message.type), message.payload.window));

	switch (message.type)
	{
		case MESSAGE_RESUME:	m_paused = false;	break;
		case MESSAGE_PAUSE:		m_paused = true;	break;
		case MESSAGE_FINISH:	m_finish = true;	break;

		// \note While Platform / WindowRegistry are currently multi-window -capable,
		//		 the fact that platform gives us windows too late / at unexpected times
		//		 forces us to do some sanity checking and limit system to one window here.
		case MESSAGE_WINDOW_CREATED:
			if (m_windowState != WINDOWSTATE_NOT_CREATED && m_windowState != WINDOWSTATE_DESTROYED)
				throw InternalError("Got unexpected onNativeWindowCreated() event from system");

			m_windowState	= WINDOWSTATE_NOT_INITIALIZED;
			m_window		= message.payload.window;
			break;

		case MESSAGE_WINDOW_RESIZED:
			if (m_window != message.payload.window)
				throw InternalError("Got onNativeWindowResized() event targeting different window");

			if (m_windowState == WINDOWSTATE_NOT_INITIALIZED)
			{
				// Got first resize event, window is ready for use.
				m_windowState = WINDOWSTATE_READY;
				onWindowCreated(message.payload.window);
			}
			else if (m_windowState == WINDOWSTATE_READY)
				onWindowResized(message.payload.window);
			else
				throw InternalError("Got unexpected onNativeWindowResized() event from system");

			break;

		case MESSAGE_WINDOW_DESTROYED:
			if (m_window != message.payload.window)
				throw InternalError("Got onNativeWindowDestroyed() event targeting different window");

			if (m_windowState != WINDOWSTATE_NOT_INITIALIZED && m_windowState != WINDOWSTATE_READY)
				throw InternalError("Got unexpected onNativeWindowDestroyed() event from system");

			if (m_windowState == WINDOWSTATE_READY)
				onWindowDestroyed(message.payload.window);

			m_windowState	= WINDOWSTATE_DESTROYED;
			m_window		= DE_NULL;
			break;

		case MESSAGE_INPUT_QUEUE_CREATED:
			m_inputQueue = message.payload.inputQueue;
			break;

		case MESSAGE_INPUT_QUEUE_DESTROYED:
			m_inputQueue = message.payload.inputQueue;
			break;

		case MESSAGE_SYNC:
			message.payload.semaphore->increment();
			break;

		default:
			throw std::runtime_error("Unknown message type");
			break;
	}
}
Example #12
0
INT32 CFpkj::XmlParse(XMLParse *parse, CInvHead *pInvInfo)
{

	UINT8 i = 0;

	parse->LocateNodeByName(parse->m_RootElement, "body");
	parse->m_parentElement[1] = parse->m_Child;

	parse->LocateNodeByName(parse->m_parentElement[1], "input");
	parse->m_parentElement[2] = parse->m_Child;

	parse->LocateNodeByName(parse->m_parentElement[2], "jqbh");
	m_ywxml_gy.m_jqbh = parse->GetText();		//税控收款机编号
	DBG_PRINT(("m_ywxml_gy.m_jqbh == %s", m_ywxml_gy.m_jqbh.c_str()));	

	pInvInfo->m_jqbh = m_ywxml_gy.m_jqbh;
	DBG_PRINT(("pInvInfo->m_jqbh == %s", pInvInfo->m_jqbh.c_str()));

	parse->LocateNodeByName(parse->m_parentElement[2], "zskl");
	pInvInfo->m_zskl = parse->GetText();		//证书口令
	DBG_PRINT(("pInvInfo->m_zskl == %s", pInvInfo->m_zskl.c_str()));
	
	parse->LocateNodeByName(parse->m_parentElement[2], "xhdwdm");
	m_ywxml_gy.m_nsrsbh = parse->GetText();	
	DBG_PRINT(("m_ywxml_gy.nsrsbh == %s", m_ywxml_gy.m_nsrsbh.c_str()));
	pInvInfo->m_xfsh = parse->GetText();
	DBG_PRINT(("pInvInfo->m_xfsh == %s", pInvInfo->m_xfsh.c_str()));
	
	parse->LocateNodeByName(parse->m_parentElement[2], "xhdwmc");
	pInvInfo->m_xfmc = parse->GetText();
	DBG_PRINT(("pInvInfo->m_xfmc == %s", pInvInfo->m_xfmc.c_str()));
	
	parse->LocateNodeByName(parse->m_parentElement[2], "sksbbh");
	m_ywxml_gy.m_sksbbh = parse->GetText();	
	DBG_PRINT(("m_ywxml_gy.sksbbh == %s", m_ywxml_gy.m_sksbbh.c_str()));	
	pInvInfo->m_sksbbh = m_ywxml_gy.m_sksbbh;
	DBG_PRINT(("pInvInfo->m_sksbbh == %s", pInvInfo->m_sksbbh.c_str()));
	
	parse->LocateNodeByName(parse->m_parentElement[2], "sksbkl");
	m_ywxml_gy.m_sksbkl = parse->GetText();	
	DBG_PRINT(("m_ywxml_gy.sksbkl == %s", m_ywxml_gy.m_sksbkl.c_str()));	
	
	parse->LocateNodeByName(parse->m_parentElement[2], "fplxdm");
	m_ywxml_gy.m_fplxdm = parse->GetText();	
	pInvInfo->m_fplxdm = m_ywxml_gy.m_fplxdm;
	DBG_PRINT(("m_ywxml_gy.fplxdm == %s", m_ywxml_gy.m_fplxdm.c_str()));

	parse->LocateNodeByName(parse->m_parentElement[2], "kplx");
	pInvInfo->m_kplx = (UINT8)atoi(parse->GetText().c_str());	
	DBG_PRINT(("pInvInfo->m_kplx == %u", pInvInfo->m_kplx));

// 	parse->LocateNodeByName(parse->m_parentElement[2], "hyfl");
// 	pInvInfo->m_hyfl = parse->GetText();	
// 	DBG_PRINT(("hyfl== %s", pInvInfo->m_hyfl.c_str()));

	parse->LocateNodeByName(parse->m_parentElement[2], "ghdwdm");
	pInvInfo->m_payerCode = parse->GetText();
	CJSKMakeInvoice::FilterSpace(pInvInfo->m_payerCode);
	if(pInvInfo->m_payerCode == "")
		pInvInfo->m_payerCode = "000000000000000";
	DBG_PRINT(("pInvInfo->m_payerCode == %s", pInvInfo->m_payerCode.c_str()));

	parse->LocateNodeByName(parse->m_parentElement[2], "ghdwmc");
	pInvInfo->m_fkdw = parse->GetText();
	CJSKMakeInvoice::FilterSpace(pInvInfo->m_fkdw);
	DBG_PRINT(("pInvInfo->m_fkdw == %s", pInvInfo->m_fkdw.c_str()));
	
	parse->LocateNodeByName(parse->m_parentElement[2], "sfxm");
	parse->m_parentElement[3] = parse->m_Child;
	pInvInfo->m_sphsl = atoi(parse->GetAttr("count").c_str());	//解析XML后得到商品明细行数
	DBG_PRINT(("pInvInfo->m_sphsl == %u", pInvInfo->m_sphsl));
	
	CInvDet* pInvDet = NULL;

	for (i=0; i<pInvInfo->m_sphsl; i++)
	{
		pInvDet = pInvDet->GetNewInvDet();	//从静态数组获取一个可用的CInvDet对象
		DBG_ASSERT_EXIT((pInvDet != NULL), (" pInvDet == NULL!"));

		pInvDet->m_sphxh = i+1;

		//得到group节点
		parse->LocateNodeByName(parse->m_parentElement[3], "group", i);
		parse->m_parentElement[4] = parse->m_Child;

		parse->LocateNodeByName(parse->m_parentElement[4], "xm");
		pInvDet->m_spmc = parse->GetText();	
		CJSKMakeInvoice::FilterSpace(pInvDet->m_spmc);
		DBG_PRINT(("pInvDet->m_spmc == %s", pInvDet->m_spmc.c_str()));

		parse->LocateNodeByName(parse->m_parentElement[4], "dj");
		pInvDet->m_dj = atof(parse->GetText().c_str());
		DBG_PRINT(("pInvDet->m_dj == %lf", pInvDet->m_dj));

		parse->LocateNodeByName(parse->m_parentElement[4], "sl");
		pInvDet->m_spsl = atof(parse->GetText().c_str());	
		DBG_PRINT(("pInvDet->m_spsl == %lf", pInvDet->m_spsl));

		parse->LocateNodeByName(parse->m_parentElement[4], "je");
		pInvDet->m_je =double2int(atof(parse->GetText().c_str())*SUM_EXTENSION);	
		DBG_PRINT(("pInvDet->m_je == %lld", pInvDet->m_je));

		parse->LocateNodeByName(parse->m_parentElement[4], "zsl");
		pInvDet->m_sl = (float)atof(parse->GetText().c_str());	
		DBG_PRINT(("pInvDet->m_sl == %f", pInvDet->m_sl));

		parse->LocateNodeByName(parse->m_parentElement[4], "se");
		DBG_PRINT(("pInvDet->m_spse == %s", parse->GetText().c_str()));
		pInvDet->m_spse = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION);	
		DBG_PRINT(("pInvDet->m_spse == %lld", pInvDet->m_spse));

		parse->LocateNodeByName(parse->m_parentElement[4], "hsdj");
		pInvDet->m_spdj = atof(parse->GetText().c_str());
		DBG_PRINT(("pInvDet->m_spdj == %lf", pInvDet->m_spdj));
		
		parse->LocateNodeByName(parse->m_parentElement[4], "hsje");
		pInvDet->m_spje = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION);	
		DBG_PRINT(("pInvDet->m_spje == %lld", pInvDet->m_spje));

		pInvInfo->InsertNode(pInvDet);

		pInvDet = NULL;
	}

	parse->LocateNodeByName(parse->m_parentElement[2], "hjje");
	pInvInfo->m_kpje = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION);	
	DBG_PRINT(("pInvInfo->m_kpje == %lld", pInvInfo->m_kpje));

	parse->LocateNodeByName(parse->m_parentElement[2], "hjse");
	DBG_PRINT(("pInvDet->m_spse == %s", parse->GetText().c_str()));
	pInvInfo->m_kpse = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION);	
	DBG_PRINT(("pInvInfo->m_kpse == %lld", pInvInfo->m_kpse));

	parse->LocateNodeByName(parse->m_parentElement[2], "jshj");
	pInvInfo->m_kphjje = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION);	
	DBG_PRINT(("pInvInfo->m_kphjje == %lld", pInvInfo->m_kphjje));

	parse->LocateNodeByName(parse->m_parentElement[2], "bz");
	pInvInfo->m_backup1 = parse->GetText();	
	CJSKMakeInvoice::FilterSpace(pInvInfo->m_backup1);
	DBG_PRINT(("pInvInfo->m_backup1 == %s", pInvInfo->m_backup1.c_str()));

	parse->LocateNodeByName(parse->m_parentElement[2], "skr");
	pInvInfo->m_sky = parse->GetText();	
	CJSKMakeInvoice::FilterSpace(pInvInfo->m_sky);
	DBG_PRINT(("pInvInfo->m_sky == %s", pInvInfo->m_sky.c_str()));

//	parse->LocateNodeByName(parse->m_parentElement[2], "kpr");
//	pInvInfo->m_sky = parse->GetText();	
//	DBG_PRINT(("pInvInfo->m_sky == %s", pInvInfo->m_sky.c_str()));

	parse->LocateNodeByName(parse->m_parentElement[2], "yfpdm");
	pInvInfo->m_yfpdm = parse->GetText();	
	DBG_PRINT(("pInvInfo->m_yfpdm == %s", pInvInfo->m_yfpdm.c_str()));

	parse->LocateNodeByName(parse->m_parentElement[2], "yfphm");
	pInvInfo->m_yfphm = atoi(parse->GetText().c_str());	
	DBG_PRINT(("pInvInfo->m_yfphm == %u", pInvInfo->m_yfphm));

	return SUCCESS;
}
Example #13
0
/*
 * Class:     jogamp_nativewindow_x11_X11Lib
 * Method:    CreateWindow
 * Signature: (JJIIIIZZ)J
 */
JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateWindow
  (JNIEnv *env, jclass unused, jlong parent, jlong display, jint screen_index, jint visualID, jint width, jint height, jboolean input, jboolean visible)
{
    Display * dpy  = (Display *)(intptr_t)display;
    int       scrn_idx = (int)screen_index;
    Window root = RootWindow(dpy, scrn_idx);
    Window  windowParent = (Window) parent;
    Window  window = 0;

    XVisualInfo visualTemplate;
    XVisualInfo *pVisualQuery = NULL;
    Visual *visual = NULL;
    int depth;

    XSetWindowAttributes xswa;
    unsigned long attrMask;
    int n;

    Screen* scrn;

    if(NULL==dpy) {
        NativewindowCommon_FatalError(env, "invalid display connection..");
        return 0;
    }

    if(visualID<0) {
        NativewindowCommon_throwNewRuntimeException(env, "invalid VisualID ..");
        return 0;
    }

    NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 1, errorHandlerQuiet, 0);

    scrn = ScreenOfDisplay(dpy, scrn_idx);
    if(0==windowParent) {
        windowParent = root;
    }

    // try given VisualID on screen
    memset(&visualTemplate, 0, sizeof(XVisualInfo));
    visualTemplate.screen = scrn_idx;
    visualTemplate.visualid = (VisualID)visualID;
    pVisualQuery = XGetVisualInfo(dpy, VisualIDMask|VisualScreenMask, &visualTemplate,&n);
    if(pVisualQuery!=NULL) {
        visual   = pVisualQuery->visual;
        depth    = pVisualQuery->depth;
        visualID = (jint)pVisualQuery->visualid;
        XFree(pVisualQuery);
        pVisualQuery=NULL;
    }
    DBG_PRINT( "X11: [CreateWindow] trying given (dpy %p, screen %d, visualID: %d, parent %p) found: %p\n", dpy, scrn_idx, (int)visualID, windowParent, visual);

    if (visual==NULL)
    { 
        // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, errorHandlerQuiet, 1);
        NativewindowCommon_throwNewRuntimeException(env, "could not query Visual by given VisualID, bail out!");
        return 0;
    } 

    if(pVisualQuery!=NULL) {
        XFree(pVisualQuery);
        pVisualQuery=NULL;
    }


    attrMask  = ( CWBackingStore | CWBackingPlanes | CWBackingPixel | CWBackPixmap | 
                  CWBorderPixel | CWColormap | CWOverrideRedirect ) ;

    memset(&xswa, 0, sizeof(xswa));
    xswa.override_redirect = False; // use the window manager, always
    xswa.border_pixel = 0;
    xswa.background_pixmap = None;
    xswa.backing_store=NotUseful; /* NotUseful, WhenMapped, Always */
    xswa.backing_planes=0;        /* planes to be preserved if possible */
    xswa.backing_pixel=0;         /* value to use in restoring planes */
    if( input ) {
        xswa.event_mask  = X11_MOUSE_EVENT_MASK;
        xswa.event_mask |= KeyPressMask | KeyReleaseMask ;
    }
    if( visible ) {
        xswa.event_mask |= FocusChangeMask | SubstructureNotifyMask | StructureNotifyMask | ExposureMask ;
    }

    xswa.colormap = XCreateColormap(dpy,
                                    windowParent,
                                    visual,
                                    AllocNone);

    window = XCreateWindow(dpy,
                           windowParent,
                           0, 0, // only a hint, WM most likely will override
                           width, height,
                           0, // border width
                           depth,
                           InputOutput,
                           visual,
                           attrMask,
                           &xswa);
    if(0==window) {
        NativewindowCommon_throwNewRuntimeException(env, "could not create Window, bail out!");
        return 0;
    }

    NativewindowX11_setNormalWindowEWMH(dpy, window);
    NativewindowX11_setDecorations(dpy, window, False);

    if( visible ) {
        XEvent event;

        XMapWindow(dpy, window);
    }

    XSync(dpy, False);

    if( !input ) {
        XSelectInput(dpy, window, 0); // no events
    }

    // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, errorHandlerQuiet, 1);

    DBG_PRINT( "X11: [CreateWindow] created window %p on display %p\n", window, dpy);

    return (jlong) window;
}
Example #14
0
  bool StdStepCalculator::Step(DenseVector& delta_u,
			       IteratesVector& sol)
  {
    DBG_START_METH("StdStepCalculator::Step", dbg_verbosity);

    bool retval = false;

    SmartPtr<IteratesVector> delta_u_long = IpData().trial()->MakeNewIteratesVector();
    ift_data_->TransMultiply(delta_u, *delta_u_long);

    SmartPtr<IteratesVector> r_s = IpData().trial()->MakeNewIteratesVector();
    if (kkt_residuals_) {
      /* This should be almost zero... */
      r_s->Set_x_NonConst(*IpCq().curr_grad_lag_x()->MakeNewCopy());
      r_s->Set_s_NonConst(*IpCq().curr_grad_lag_s()->MakeNewCopy());
      r_s->Set_y_c_NonConst(*IpCq().curr_c()->MakeNewCopy());
      r_s->Set_y_d_NonConst(*IpCq().curr_d_minus_s()->MakeNewCopy());
      r_s->Set_z_L_NonConst(*IpCq().curr_compl_x_L()->MakeNewCopy());
      r_s->Set_z_U_NonConst(*IpCq().curr_compl_x_U()->MakeNewCopy());
      r_s->Set_v_L_NonConst(*IpCq().curr_compl_s_L()->MakeNewCopy());
      r_s->Set_v_U_NonConst(*IpCq().curr_compl_s_U()->MakeNewCopy());

      r_s->Print(Jnlst(),J_VECTOR,J_USER1,"r_s init");
      delta_u.Print(Jnlst(),J_VECTOR,J_USER1,"delta_u init");
      DBG_PRINT((dbg_verbosity,"r_s init Nrm2=%23.16e\n", r_s->Asum()));

      delta_u_long->Axpy(-1.0, *r_s);
    }

    backsolver_->Solve(&sol, ConstPtr(delta_u_long));

    SmartPtr<IteratesVector> Kr_s;
    if (Do_Boundcheck()) {
      Kr_s = sol.MakeNewIteratesVectorCopy();
    }

    sol.Axpy(1.0, *IpData().trial());

    if (Do_Boundcheck()) {
      DBG_PRINT((dbg_verbosity, "Entering boundcheck"));
      // initialize
      Index new_du_size =0;
      Number* new_du_values;
      std::vector<Index> x_bound_violations_idx;
      std::vector<Number> x_bound_violations_du;
      std::vector<Index> delta_u_sort;
      bool bounds_violated;
      SmartPtr<DenseVectorSpace> delta_u_space = new DenseVectorSpace(0);
      SmartPtr<DenseVector> old_delta_u = new DenseVector(GetRawPtr(delta_u_space));
      SmartPtr<DenseVector> new_delta_u;

      bounds_violated = BoundCheck(sol, x_bound_violations_idx, x_bound_violations_du);
      while (bounds_violated) {
	Driver()->data_A()->Print(Jnlst(),J_VECTOR,J_USER1,"data_A_init");
	Driver()->data_B()->Print(Jnlst(),J_VECTOR,J_USER1,"data_B_init");
	// write new schurdata A
	dynamic_cast<IndexSchurData*>(GetRawPtr(Driver()->data_A_nonconst()))->AddData_List(x_bound_violations_idx, delta_u_sort, new_du_size, 1);
	// write new schurdata B
	dynamic_cast<IndexSchurData*>(GetRawPtr(Driver()->data_B_nonconst()))->AddData_List(x_bound_violations_idx, delta_u_sort, new_du_size, 1);
	Driver()->data_A()->Print(Jnlst(),J_VECTOR,J_USER1,"data_A");
	Driver()->data_B()->Print(Jnlst(),J_VECTOR,J_USER1,"data_B");
	Driver()->SchurBuild();
	Driver()->SchurFactorize();

	old_delta_u->Print(Jnlst(),J_VECTOR,J_USER1,"old_delta_u");
	delta_u_space = NULL; // delete old delta_u space
	delta_u_space = new DenseVectorSpace(new_du_size); // create new delta_u space
	new_delta_u = new DenseVector(GetRawPtr(ConstPtr(delta_u_space)));
	new_du_values = new_delta_u->Values();
	IpBlasDcopy(old_delta_u->Dim(), old_delta_u->Values(), 1, new_du_values, 1);
	for (UINT i=0; i<x_bound_violations_idx.size(); ++i) {
	  //	  printf("i=%d, delta_u_sort[i]=%d, x_bound_viol_du[i]=%f\n", i, delta_u_sort[i], x_bound_violations_du[i]);
	  new_du_values[delta_u_sort[i]] = x_bound_violations_du[i];
	}
	SmartPtr<IteratesVector> new_sol = sol.MakeNewIteratesVector();
	new_delta_u->Print(Jnlst(),J_VECTOR,J_USER1,"new_delta_u");

	// solve with new data_B and delta_u
	retval = Driver()->SchurSolve(&sol, ConstPtr(delta_u_long), dynamic_cast<Vector*>(GetRawPtr(new_delta_u)), Kr_s);

	sol.Axpy(1.0, *IpData().trial());

	x_bound_violations_idx.clear();
	x_bound_violations_du.clear();
	delta_u_sort.clear();
	bounds_violated = BoundCheck(sol, x_bound_violations_idx, x_bound_violations_du);
	// copy new vector in old vector ->has to be done becpause otherwise only pointers will be copied and then it makes no sense
	old_delta_u = new_delta_u->MakeNewDenseVector();
	old_delta_u->Copy(*new_delta_u);
      }
    }

    return retval;
  }
Example #15
0
void RenderActivity::onInputQueueDestroyed (AInputQueue* queue)
{
	DBG_PRINT(("RenderActivity::onInputQueueDestroyed()"));
	m_thread->enqueue(Message(MESSAGE_INPUT_QUEUE_DESTROYED, queue));
	m_thread->sync();
}
Example #16
0
RenderActivity::~RenderActivity (void)
{
	DBG_PRINT(("RenderActivity::~RenderActivity()"));
}
Example #17
0
File: C.c Project: qbai/.emacs.d
/**
 *	@param[in]	param	source file
 *	@param[in]	type	#TYPE_C, #TYPE_YACC, #TYPE_LEX
 */
static void
C_family(const struct parser_param *param, int type)
{
	int c, cc;
	int savelevel;
	int startmacro, startsharp;
	const char *interested = "{}=;";
	STRBUF *sb = strbuf_open(0);
	/*
	 * yacc file format is like the following.
	 *
	 * declarations
	 * %%
	 * rules
	 * %%
	 * programs
	 *
	 */
	int yaccstatus = (type == TYPE_YACC) ? DECLARATIONS : PROGRAMS;
	int inC = (type == TYPE_YACC) ? 0 : 1;	/* 1 while C source */

	level = piflevel = externclevel = 0;
	savelevel = -1;
	startmacro = startsharp = 0;

	if (!opentoken(param->file))
		die("'%s' cannot open.", param->file);
	cmode = 1;			/* allow token like '#xxx' */
	crflag = 1;			/* require '\n' as a token */
	if (type == TYPE_YACC)
		ymode = 1;		/* allow token like '%xxx' */

	while ((cc = nexttoken(interested, c_reserved_word)) != EOF) {
		switch (cc) {
		case SYMBOL:		/* symbol	*/
			if (inC && peekc(0) == '('/* ) */) {
				if (param->isnotfunction(token)) {
					PUT(PARSER_REF_SYM, token, lineno, sp);
				} else if (level > 0 || startmacro) {
					PUT(PARSER_REF_SYM, token, lineno, sp);
				} else if (level == 0 && !startmacro && !startsharp) {
					char arg1[MAXTOKEN], savetok[MAXTOKEN], *saveline;
					int savelineno = lineno;

					strlimcpy(savetok, token, sizeof(savetok));
					strbuf_reset(sb);
					strbuf_puts(sb, sp);
					saveline = strbuf_value(sb);
					arg1[0] = '\0';
					/*
					 * Guile function entry using guile-snarf is like follows:
					 *
					 * SCM_DEFINE (scm_list, "list", 0, 0, 1, 
					 *           (SCM objs),
					 *            "Return a list containing OBJS, the arguments to `list'.")
					 * #define FUNC_NAME s_scm_list
					 * {
					 *   return objs;
					 * }
					 * #undef FUNC_NAME
					 *
					 * We should assume the first argument as a function name instead of 'SCM_DEFINE'.
					 */
					if (function_definition(param, arg1)) {
						if (!strcmp(savetok, "SCM_DEFINE") && *arg1)
							strlimcpy(savetok, arg1, sizeof(savetok));
						PUT(PARSER_DEF, savetok, savelineno, saveline);
					} else {
						PUT(PARSER_REF_SYM, savetok, savelineno, saveline);
					}
				}
			} else {
				PUT(PARSER_REF_SYM, token, lineno, sp);
			}
			break;
		case '{':  /* } */
			DBG_PRINT(level, "{"); /* } */
			if (yaccstatus == RULES && level == 0)
				inC = 1;
			++level;
			if ((param->flags & PARSER_BEGIN_BLOCK) && atfirst) {
				if ((param->flags & PARSER_WARNING) && level != 1)
					warning("forced level 1 block start by '{' at column 0 [+%d %s].", lineno, curfile); /* } */
				level = 1;
			}
			break;
			/* { */
		case '}':
			if (--level < 0) {
				if (externclevel > 0)
					externclevel--;
				else if (param->flags & PARSER_WARNING)
					warning("missing left '{' [+%d %s].", lineno, curfile); /* } */
				level = 0;
			}
			if ((param->flags & PARSER_END_BLOCK) && atfirst) {
				if ((param->flags & PARSER_WARNING) && level != 0) /* { */
					warning("forced level 0 block end by '}' at column 0 [+%d %s].", lineno, curfile);
				level = 0;
			}
			if (yaccstatus == RULES && level == 0)
				inC = 0;
			/* { */
			DBG_PRINT(level, "}");
			break;
		case '\n':
			if (startmacro && level != savelevel) {
				if (param->flags & PARSER_WARNING)
					warning("different level before and after #define macro. reseted. [+%d %s].", lineno, curfile);
				level = savelevel;
			}
			startmacro = startsharp = 0;
			break;
		case YACC_SEP:		/* %% */
			if (level != 0) {
				if (param->flags & PARSER_WARNING)
					warning("forced level 0 block end by '%%' [+%d %s].", lineno, curfile);
				level = 0;
			}
			if (yaccstatus == DECLARATIONS) {
				PUT(PARSER_DEF, "yyparse", lineno, sp);
				yaccstatus = RULES;
			} else if (yaccstatus == RULES)
				yaccstatus = PROGRAMS;
			inC = (yaccstatus == PROGRAMS) ? 1 : 0;
			break;
		case YACC_BEGIN:	/* %{ */
			if (level != 0) {
				if (param->flags & PARSER_WARNING)
					warning("forced level 0 block end by '%%{' [+%d %s].", lineno, curfile);
				level = 0;
			}
			if (inC == 1 && (param->flags & PARSER_WARNING))
				warning("'%%{' appeared in C mode. [+%d %s].", lineno, curfile);
			inC = 1;
			break;
		case YACC_END:		/* %} */
			if (level != 0) {
				if (param->flags & PARSER_WARNING)
					warning("forced level 0 block end by '%%}' [+%d %s].", lineno, curfile);
				level = 0;
			}
			if (inC == 0 && (param->flags & PARSER_WARNING))
				warning("'%%}' appeared in Yacc mode. [+%d %s].", lineno, curfile);
			inC = 0;
			break;
		case YACC_UNION:	/* %union {...} */
			if (yaccstatus == DECLARATIONS)
				PUT(PARSER_DEF, "YYSTYPE", lineno, sp);
			break;
		/*
		 * #xxx
		 */
		case SHARP_DEFINE:
		case SHARP_UNDEF:
			startmacro = 1;
			savelevel = level;
			if ((c = nexttoken(interested, c_reserved_word)) != SYMBOL) {
				pushbacktoken();
				break;
			}
			if (peekc(1) == '('/* ) */) {
				PUT(PARSER_DEF, token, lineno, sp);
				while ((c = nexttoken("()", c_reserved_word)) != EOF && c != '\n' && c != /* ( */ ')')
					if (c == SYMBOL)
						PUT(PARSER_REF_SYM, token, lineno, sp);
				if (c == '\n')
					pushbacktoken();
			} else {
				PUT(PARSER_DEF, token, lineno, sp);
			}
			break;
		case SHARP_IMPORT:
		case SHARP_INCLUDE:
		case SHARP_INCLUDE_NEXT:
		case SHARP_ERROR:
		case SHARP_LINE:
		case SHARP_PRAGMA:
		case SHARP_WARNING:
		case SHARP_IDENT:
		case SHARP_SCCS:
			while ((c = nexttoken(interested, c_reserved_word)) != EOF && c != '\n')
				;
			break;
		case SHARP_IFDEF:
		case SHARP_IFNDEF:
		case SHARP_IF:
		case SHARP_ELIF:
		case SHARP_ELSE:
		case SHARP_ENDIF:
			condition_macro(param, cc);
			break;
		case SHARP_SHARP:		/* ## */
			(void)nexttoken(interested, c_reserved_word);
			break;
		case C_EXTERN: /* for 'extern "C"/"C++"' */
			if (peekc(0) != '"') /* " */
				continue; /* If does not start with '"', continue. */
			while ((c = nexttoken(interested, c_reserved_word)) == '\n')
				;
			/*
			 * 'extern "C"/"C++"' block is a kind of namespace block.
			 * (It doesn't have any influence on level.)
			 */
			if (c == '{') /* } */
				externclevel++;
			else
				pushbacktoken();
			break;
		case C_STRUCT:
		case C_ENUM:
		case C_UNION:
			while ((c = nexttoken(interested, c_reserved_word)) == C___ATTRIBUTE__)
				process_attribute(param);
			if (c == SYMBOL) {
				if (peekc(0) == '{') /* } */ {
					PUT(PARSER_DEF, token, lineno, sp);
					do {
						c = nexttoken(interested, c_reserved_word);
					} while (c == '\n');
				} else {
					PUT(PARSER_REF_SYM, token, lineno, sp);
					c = nexttoken(interested, c_reserved_word);
				}
			}
			if (c == '{' /* } */ && cc == C_ENUM) {
				enumerator_list(param);
			} else {
				pushbacktoken();
			}
			break;
		/* control statement check */
		case C_BREAK:
		case C_CASE:
		case C_CONTINUE:
		case C_DEFAULT:
		case C_DO:
		case C_ELSE:
		case C_FOR:
		case C_GOTO:
		case C_IF:
		case C_RETURN:
		case C_SWITCH:
		case C_WHILE:
			if ((param->flags & PARSER_WARNING) && !startmacro && level == 0)
				warning("Out of function. %8s [+%d %s]", token, lineno, curfile);
			break;
		case C_TYPEDEF:
			{
				/*
				 * This parser is too complex to maintain.
				 * We should rewrite the whole.
				 */
				char savetok[MAXTOKEN];
				int savelineno = 0;
				int typedef_savelevel = level;

				savetok[0] = 0;

				/* skip type qualifiers */
				do {
					c = nexttoken("{}(),;", c_reserved_word);
				} while (IS_TYPE_QUALIFIER(c) || c == '\n');

				if ((param->flags & PARSER_WARNING) && c == EOF) {
					warning("unexpected eof. [+%d %s]", lineno, curfile);
					break;
				} else if (c == C_ENUM || c == C_STRUCT || c == C_UNION) {
					char *interest_enum = "{},;";
					int c_ = c;

					while ((c = nexttoken(interest_enum, c_reserved_word)) == C___ATTRIBUTE__)
						process_attribute(param);
					/* read tag name if exist */
					if (c == SYMBOL) {
						if (peekc(0) == '{') /* } */ {
							PUT(PARSER_DEF, token, lineno, sp);
							do {
								c = nexttoken(interest_enum, c_reserved_word);
							} while (c == '\n');
						} else {
							PUT(PARSER_REF_SYM, token, lineno, sp);
							c = nexttoken(interest_enum, c_reserved_word);
						}
					}
					if (c_ == C_ENUM) {
						if (c == '{') /* } */
							c = enumerator_list(param);
						else
							pushbacktoken();
					} else {
						for (; c != EOF; c = nexttoken(interest_enum, c_reserved_word)) {
							switch (c) {
							case SHARP_IFDEF:
							case SHARP_IFNDEF:
							case SHARP_IF:
							case SHARP_ELIF:
							case SHARP_ELSE:
							case SHARP_ENDIF:
								condition_macro(param, c);
								continue;
							default:
								break;
							}
							if (c == ';' && level == typedef_savelevel) {
								if (savetok[0])
									PUT(PARSER_DEF, savetok, savelineno, sp);
								break;
							} else if (c == '{')
								level++;
							else if (c == '}') {
								if (--level == typedef_savelevel)
									break;
							} else if (c == SYMBOL) {
								PUT(PARSER_REF_SYM, token, lineno, sp);
								/* save lastest token */
								strlimcpy(savetok, token, sizeof(savetok));
								savelineno = lineno;
							}
						}
						if (c == ';')
							break;
					}
					if ((param->flags & PARSER_WARNING) && c == EOF) {
						warning("unexpected eof. [+%d %s]", lineno, curfile);
						break;
					}
				} else if (c == SYMBOL) {
					PUT(PARSER_REF_SYM, token, lineno, sp);
				}
				savetok[0] = 0;
				while ((c = nexttoken("(),;", c_reserved_word)) != EOF) {
					switch (c) {
					case SHARP_IFDEF:
					case SHARP_IFNDEF:
					case SHARP_IF:
					case SHARP_ELIF:
					case SHARP_ELSE:
					case SHARP_ENDIF:
						condition_macro(param, c);
						continue;
					default:
						break;
					}
					if (c == '(')
						level++;
					else if (c == ')')
						level--;
					else if (c == SYMBOL) {
						if (level > typedef_savelevel) {
							PUT(PARSER_REF_SYM, token, lineno, sp);
						} else {
							/* put latest token if any */
							if (savetok[0]) {
								PUT(PARSER_REF_SYM, savetok, savelineno, sp);
							}
							/* save lastest token */
							strlimcpy(savetok, token, sizeof(savetok));
							savelineno = lineno;
						}
					} else if (c == ',' || c == ';') {
						if (savetok[0]) {
							PUT(PARSER_DEF, savetok, lineno, sp);
							savetok[0] = 0;
						}
					}
					if (level == typedef_savelevel && c == ';')
						break;
				}
				if (param->flags & PARSER_WARNING) {
					if (c == EOF)
						warning("unexpected eof. [+%d %s]", lineno, curfile);
					else if (level != typedef_savelevel)
						warning("unmatched () block. (last at level %d.)[+%d %s]", level, lineno, curfile);
				}
			}
			break;
		case C___ATTRIBUTE__:
			process_attribute(param);
			break;
		default:
			break;
		}
	}
	strbuf_close(sb);
	if (param->flags & PARSER_WARNING) {
		if (level != 0)
			warning("unmatched {} block. (last at level %d.)[+%d %s]", level, lineno, curfile);
		if (piflevel != 0)
			warning("unmatched #if block. (last at level %d.)[+%d %s]", piflevel, lineno, curfile);
	}
	closetoken();
}
Example #18
0
void RenderActivity::onStop (void)
{
	DBG_PRINT(("RenderActivity::onStop()"));
}
  Index TripletToCSRConverter::InitializeConverter(Index dim, Index nonzeros,
      const Index* airn,
      const Index* ajcn)
  {
    DBG_START_METH("TSymLinearSolver::InitializeStructure",
                   dbg_verbosity);

    DBG_ASSERT(dim>0);
    DBG_ASSERT(nonzeros>0);

    delete[] ia_;
    delete[] ja_;
    delete[] ipos_first_;
    delete[] ipos_double_triplet_;
    delete[] ipos_double_compressed_;

    dim_ = dim;
    nonzeros_triplet_ = nonzeros;

    // Create a list with all triplet entries
    std::list<TripletEntry> entry_list(nonzeros);
    std::list<TripletEntry>::iterator list_iterator = entry_list.begin();
    for (Index i=0; i<nonzeros; i++) {
      list_iterator->Set(airn[i], ajcn[i], i);
      list_iterator++;
    }
    DBG_ASSERT(list_iterator == entry_list.end());

    if (DBG_VERBOSITY()>=2) {
      for (Index i=0; i<nonzeros; i++) {
        DBG_PRINT((2, "airn[%5d] = %5d acjn[%5d] = %5d\n", i, airn[i], i, ajcn[i]));
      }
    }

    // sort the list
    entry_list.sort();

    // Now got through the list and compute ipos_ arrays and the
    // number of elements in the compressed format
    Index* ja_tmp = new Index[nonzeros];    // overestimate memory requirement
    Index* rc_tmp = NULL;
    if (hf_ == Full_Format) {
      rc_tmp = new Index[dim_+1];
    }
    ia_ = new Index[dim_+1];
    Index* ipos_first_tmp = new Index[nonzeros];  // overestimate memory requirement
    Index* ipos_double_triplet_tmp = new Index[nonzeros];  // overestimate memory requirement
    Index* ipos_double_compressed_tmp = new Index[nonzeros];  // overestimate memory requirement

    Index nonzeros_compressed_full = 0;
    nonzeros_compressed_ = 0;
    Index cur_row = 1;

    if (hf_ == Full_Format) {
      // Zero row counts
      for (Index i=0; i<dim_+1; i++) {
        rc_tmp[i] = 0;
      }
    }

    // Take care of possible emply rows
    list_iterator = entry_list.begin();
    while (cur_row < list_iterator->IRow()) {
      ia_[cur_row-1] = 0;
      cur_row++;
    }
    ia_[cur_row-1] = 0;
    ja_tmp[0] = list_iterator->JCol();
    ipos_first_tmp[0] = list_iterator->PosTriplet();
    if (hf_ == Full_Format) {
      // Count in both lower and upper triangles. Count diagonal only once.
      nonzeros_compressed_full++;
      rc_tmp[cur_row-1]++;
      if (cur_row!=list_iterator->JCol()) {
        nonzeros_compressed_full++;
        rc_tmp[list_iterator->JCol()-1]++;
      }
    }

    list_iterator++;
    Index idouble = 0;
    Index idouble_full = 0;
    while (list_iterator != entry_list.end()) {
      Index irow = list_iterator->IRow();
      Index jcol = list_iterator->JCol();
      if (cur_row == irow && ja_tmp[nonzeros_compressed_] == jcol) {
        // This element appears repeatedly, add to the double list
        ipos_double_triplet_tmp[idouble] = list_iterator->PosTriplet();
        ipos_double_compressed_tmp[idouble] = nonzeros_compressed_;
        idouble++;
        idouble_full++;
        if (hf_==Full_Format && irow!=jcol) {
          idouble_full++;
        }
      }
      else {
        // This is a new element
        if (hf_==Full_Format) {
          // Count in both lower and upper triangles. Count diagonal only once.
          nonzeros_compressed_full++;
          rc_tmp[jcol-1]++;
          if (irow!=jcol) {
            nonzeros_compressed_full++;
            rc_tmp[irow-1]++;
          }
        }
        nonzeros_compressed_++;
        ja_tmp[nonzeros_compressed_] = jcol;
        ipos_first_tmp[nonzeros_compressed_] = list_iterator->PosTriplet();
        if (cur_row != irow) {
          // this is in a new row

          ia_[cur_row] = nonzeros_compressed_;
          cur_row++;
        }
      }

      list_iterator++;
    }
    nonzeros_compressed_++;
    for (Index i=cur_row; i<=dim_; i++) {
      ia_[i] = nonzeros_compressed_;
    }
    DBG_ASSERT(idouble == nonzeros_triplet_-nonzeros_compressed_);

    // Now copy the ja_tmp array to the (shorter) final one and make
    // sure that the correct offset is used
    if (hf_==Triangular_Format) {
      ja_ = new Index[nonzeros_compressed_];
      if (offset_==0) {
        for (Index i=0; i<nonzeros_compressed_; i++) {
          ja_[i] = ja_tmp[i] - 1;
        }
      }
      else {
        for (Index i=0; i<nonzeros_compressed_; i++) {
          ja_[i] = ja_tmp[i];
        }
        for (Index i=0; i<=dim_; i++) {
          ia_[i] = ia_[i] + 1;
        }
      }
      delete[] ja_tmp;

      // Reallocate memory for the "first" array
      ipos_first_ = new Index[nonzeros_compressed_];
      for (Index i=0; i<nonzeros_compressed_; i++) {
        ipos_first_[i] = ipos_first_tmp[i];
      }
      delete[] ipos_first_tmp;

      // Reallocate memory for the "double" arrays
      ipos_double_triplet_ = new Index[idouble];
      ipos_double_compressed_ = new Index[idouble];
      for (Index i=0; i<idouble; i++) {
        ipos_double_triplet_[i] = ipos_double_triplet_tmp[i];
        ipos_double_compressed_[i] = ipos_double_compressed_tmp[i];
      }
      delete[] ipos_double_triplet_tmp;
      delete[] ipos_double_compressed_tmp;
    }
    else { // hf_==Full_Format

      // Setup ia_tmp to contain insert position for column i as ia_tmp[i+1]
      Index *ia_tmp = new Index[dim_+1];
      ia_tmp[0] = 0;
      ia_tmp[1] = 0;
      for (Index i=1; i<dim_; i++) {
        ia_tmp[i+1] = ia_tmp[i] + rc_tmp[i-1];
      }
      delete[] rc_tmp;

      // Loop over elements of matrix, copying them and duplicating as required
      ja_ = new Index[nonzeros_compressed_full];
      ipos_first_ = new Index[nonzeros_compressed_full];
      ipos_double_triplet_ = new Index[idouble_full];
      ipos_double_compressed_ = new Index[idouble_full];
      Index jd1=0; // Entry into ipos_double_compressed_tmp
      Index jd2=0; // Entry into ipos_double_compressed_
      for (Index i=0; i<dim_; i++) {
        for (Index j=ia_[i]; j<ia_[i+1]; j++) {
          Index jrow = ja_tmp[j]-1;
          ja_[ia_tmp[i+1]] = jrow + offset_;
          ipos_first_[ia_tmp[i+1]] = ipos_first_tmp[j];
          while (jd1<idouble && j==ipos_double_compressed_tmp[jd1]) {
            ipos_double_triplet_[jd2] = ipos_double_triplet_tmp[jd1];
            ipos_double_compressed_[jd2] = ia_tmp[i+1];
            jd2++;
            if (jrow!=i) {
              ipos_double_triplet_[jd2] = ipos_double_triplet_tmp[jd1];
              ipos_double_compressed_[jd2] = ia_tmp[jrow+1];
            }
            jd1++;
          }
          ia_tmp[i+1]++;
          if (jrow!=i) {
            ja_[ia_tmp[jrow+1]] = i + offset_;
            ipos_first_[ia_tmp[jrow+1]] = ipos_first_tmp[j];
            ia_tmp[jrow+1]++;
          }
        }
      }
      delete[] ja_tmp;
      delete[] ipos_first_tmp;
      delete[] ipos_double_triplet_tmp;
      delete[] ipos_double_compressed_tmp;

      // Copy ia_tmp to ia_ with offset_ adjustment
      for (Index i=0; i<dim_+1; i++) {
        ia_[i] = ia_tmp[i] + offset_;
      }
      delete[] ia_tmp;

      // Set nonzeros_compressed_ to correct size
      nonzeros_compressed_ = nonzeros_compressed_full;
    }

    initialized_ = true;

    if (DBG_VERBOSITY()>=2) {
      for (Index i=0; i<=dim_; i++) {
        DBG_PRINT((2, "ia[%5d] = %5d\n", i, ia_[i]));
      }
      for (Index i=0; i<nonzeros_compressed_; i++) {
        DBG_PRINT((2, "ja[%5d] = %5d ipos_first[%5d] = %5d\n", i, ja_[i], i, ipos_first_[i]));
      }
      for (Index i=0; i<nonzeros_triplet_-nonzeros_compressed_; i++) {
        DBG_PRINT((2, "ipos_double_triplet[%5d] = %5d ipos_double_compressed[%5d] = %5d\n", i, ipos_double_triplet_[i], i, ipos_double_compressed_[i]));
      }
    }

    return nonzeros_compressed_;
  }
Example #20
0
void RenderActivity::onDestroy (void)
{
	DBG_PRINT(("RenderActivity::onDestroy()"));
}
Example #21
0
int get_lcd_extern_dt_data(struct device_node* of_node, struct lcd_extern_config_t *pdata)
{
	int err;
	int val;
	const char *str;
	
	err = of_property_read_string(of_node, "dev_name", &str);
	if (err) {
		str = "aml_lcd_extern";
		printk("warning: get dev_name failed\n");
	}
	pdata->name = (char *)kmalloc(sizeof(char)*BL_EXT_NAME_LEN_MAX, GFP_KERNEL);
	if (pdata->name == NULL) {
		printk("[get_lcd_extern_dt_data]: Not enough memory\n");
	}
	else {
		memset(pdata->name, 0, BL_EXT_NAME_LEN_MAX);
		strcpy(pdata->name, str);
		printk("load bl_extern in dtb: %s\n", pdata->name);
	}
	err = of_property_read_u32(of_node, "type", &pdata->type);
	if (err) {
		pdata->type = LCD_EXTERN_MAX;
		printk("warning: get type failed, exit\n");
		return -1;
	}
	switch (pdata->type) {
		case LCD_EXTERN_I2C:
			err = of_property_read_u32(of_node,"i2c_address",&pdata->i2c_addr);
			if (err) {
				printk("%s warning: get i2c_address failed\n", pdata->name);
				pdata->i2c_addr = 0;
			}
			DBG_PRINT("%s: i2c_address=0x%02x\n", pdata->name, pdata->i2c_addr);
		  
			err = of_property_read_string(of_node, "i2c_bus", &str);
			if (err) {
				printk("%s warning: get i2c_bus failed, use default i2c bus\n", pdata->name);
				pdata->i2c_bus = AML_I2C_MASTER_A;
			}
			else {
				if (strncmp(str, "i2c_bus_a", 9) == 0)
					pdata->i2c_bus = AML_I2C_MASTER_A;
				else if (strncmp(str, "i2c_bus_b", 9) == 0)
					pdata->i2c_bus = AML_I2C_MASTER_B;
				else if (strncmp(str, "i2c_bus_c", 9) == 0)
					pdata->i2c_bus = AML_I2C_MASTER_C;
				else if (strncmp(str, "i2c_bus_d", 9) == 0)
					pdata->i2c_bus = AML_I2C_MASTER_D;
				else if (strncmp(str, "i2c_bus_ao", 10) == 0)
					pdata->i2c_bus = AML_I2C_MASTER_AO;
				else
					pdata->i2c_bus = AML_I2C_MASTER_A; 
			}
			DBG_PRINT("%s: i2c_bus=%s[%d]\n", pdata->name, str, pdata->i2c_bus);
			break;
		case LCD_EXTERN_SPI:
			err = of_property_read_string(of_node,"gpio_spi_cs", &str);
			if (err) {
				printk("%s warning: get spi gpio_spi_cs failed\n", pdata->name);
				pdata->spi_cs = -1;
			}
			else {
			    val = amlogic_gpio_name_map_num(str);
				if (val > 0) {
					err = lcd_extern_gpio_request(val);
					if (err) {
					  printk("faild to alloc spi_cs gpio (%s)!\n", str);
					}
					pdata->spi_cs = val;
					DBG_PRINT("spi_cs gpio = %s(%d)\n", str, pdata->spi_cs);
				}
				else {
					pdata->spi_cs = -1;
				}
			}
			err = of_property_read_string(of_node,"gpio_spi_clk", &str);
			if (err) {
				printk("%s warning: get spi gpio_spi_clk failed\n", pdata->name);
				pdata->spi_clk = -1;
			}
			else {
			    val = amlogic_gpio_name_map_num(str);
				if (val > 0) {
					err = lcd_extern_gpio_request(val);
					if (err) {
					  printk("faild to alloc spi_clk gpio (%s)!\n", str);
					}
					pdata->spi_clk = val;
					DBG_PRINT("spi_clk gpio = %s(%d)\n", str, pdata->spi_clk);
				}
				else {
					pdata->spi_clk = -1;
				}
			}
			err = of_property_read_string(of_node,"gpio_spi_data", &str);
			if (err) {
				printk("%s warning: get spi gpio_spi_data failed\n", pdata->name);
				pdata->spi_data = -1;
			}
			else {
			    val = amlogic_gpio_name_map_num(str);
				if (val > 0) {
					err = lcd_extern_gpio_request(val);
					if (err) {
					  printk("faild to alloc spi_data gpio (%s)!\n", str);
					}
					pdata->spi_data = val;
					DBG_PRINT("spi_data gpio = %s(%d)\n", str, pdata->spi_data);
				}
				else {
					pdata->spi_data = -1;
				}
			}
			break;
		case LCD_EXTERN_MIPI:
			break;
		default:
			break;
	}
	
	return 0;
}
Example #22
0
void RenderActivity::onNativeWindowCreated (ANativeWindow* window)
{
	DBG_PRINT(("RenderActivity::onNativeWindowCreated()"));
	m_thread->enqueue(Message(MESSAGE_WINDOW_CREATED, window));
}
Example #23
0
/*===========================================================================*
 *
 * GenPFrame
 *
 *	generate a P-frame from previous frame, adding the result to the
 *	given bit bucket
 *
 * RETURNS:	frame appended to bb
 *
 * SIDE EFFECTS:    none
 *
 *===========================================================================*/
void
GenPFrame(BitBucket *bb,
          MpegFrame *current,
          MpegFrame *prev)
{
  extern int **pmvHistogram;
  FlatBlock fba[6], fb[6];
  Block	dec[6];
  int32 y_dc_pred, cr_dc_pred, cb_dc_pred;
  int x, y;
  int	motionX = 0, motionY = 0;
  int	oldMotionX = 0, oldMotionY = 0;
  int	offsetX, offsetY;
  int	tempX, tempY;
  int	motionXrem, motionXquot;
  int	motionYrem, motionYquot;
  int	pattern;
  int	mbAddrInc = 1;
  boolean	useMotion;
  int numIBlocks = 0;
  int	numPBlocks = 0;
  int	numSkipped = 0;
  int	numIBits = 0;
  int numPBits = 0;
  int totalBits;
  int	totalFrameBits;
  int32    startTime, endTime;
  int	lastBlockX, lastBlockY;
  int	lastX, lastY;
  int	fy, fx;
  LumBlock currentBlock;
  register int ix, iy;
  int	mbAddress;
  int slicePos;
  register int index;
  float   snr[3], psnr[3];
  int QScale;
  BlockMV *info;
  int bitstreamMode, newQScale;
  int rc_blockStart = 0;
  boolean overflowChange = FALSE;
  int     overflowValue  = 0;


  if (collect_quant) {fprintf(collect_quant_fp, "# P\n");}
  if (dct==NULL) AllocDctBlocks();
  numFrames++;
  totalFrameBits = bb->cumulativeBits;
  startTime = time_elapsed();

  DBG_PRINT(("Generating pframe\n"));

  QScale = GetPQScale();
  /*   bit allocation for rate control purposes */
  bitstreamMode = getRateMode();
  if (bitstreamMode == FIXED_RATE) {
    targetRateControl(current);
  }
 
  Mhead_GenPictureHeader(bb, P_FRAME, current->id, fCodeP);
  /* Check for Qscale change */  
  if (specificsOn) {
    /* Set a Qscale for this frame? */
    newQScale = SpecLookup(current->id, 0, 0 /* junk */, &info /*junk*/, QScale);
    if (newQScale != -1) {
      QScale = newQScale;
    }
    /* Set for slice? */
    newQScale = SpecLookup(current->id, 1, 1, &info /*junk*/, QScale);
    if (newQScale != -1) {
      QScale = newQScale;
    }
  }

  DBG_PRINT(("Slice Header\n"));
  Mhead_GenSliceHeader(bb, 1, QScale, NULL, 0);

  if ( referenceFrame == DECODED_FRAME ) {
    Frame_AllocDecoded(current, TRUE);
  } else if ( printSNR ) {
    Frame_AllocDecoded(current, FALSE);
  }

  /* don't do dct on blocks yet */
  Frame_AllocBlocks(current);
  BlockifyFrame(current);

  /* for I-blocks */
  y_dc_pred = cr_dc_pred = cb_dc_pred = 128;

  totalBits = bb->cumulativeBits;

  if ( (! pixelFullSearch) && (! prev->halfComputed) ) {
    ComputeHalfPixelData(prev);
  }

  lastBlockX = Fsize_x>>3;
  lastBlockY = Fsize_y>>3;
  lastX = lastBlockX-2;
  lastY = lastBlockY-2;
  mbAddress = 0;

  /* First loop though finding motion/not and DCTing */
  for (y = 0; y < lastBlockY; y += 2) {
    for (x = 0; x < lastBlockX; x += 2) {
      /* compute currentBlock */
      BLOCK_TO_FRAME_COORD(y, x, fy, fx);
      for ( iy = 0; iy < 16; iy++ ) {
	for ( ix = 0; ix < 16; ix++ ) {
	  currentBlock[iy][ix] = (int16)current->orig_y[fy+iy][fx+ix];
	}
      }

      /* See if we have a cached answer */
      if (specificsOn) {
	(void) SpecLookup(current->id, 2, mbAddress, &info, QScale);
	if (info != (BlockMV*)NULL) {
	  if (info->typ == TYP_SKIP) {
	    motionX = motionY = 0;
	    useMotion = TRUE;
	    goto no_search;
	  } else {		/* assume P, since we're a P frame.... */
	    motionX = info->fx;
	    motionY = info->fy;
	    useMotion = TRUE;
	    goto no_search;
	  }}
	/* if unspecified, just look */
      }

      /* see if we should use motion vectors, and if so, what those
       * vectors should be
       */
      if ( ZeroMotionSufficient(currentBlock, prev, y, x) ) {
	motionX = 0;
	motionY = 0;
	useMotion = TRUE;
      } else {
	useMotion = PMotionSearch(currentBlock, prev, y, x,
				  &motionY, &motionX);
	if ( useMotion ) {
	  if ( ZeroMotionBetter(currentBlock, prev, y, x, motionY,
				motionX) ) {
	    motionX = 0;
	    motionY = 0;
	  }
	  if (IntraPBAllowed) 
	    useMotion = (! DoIntraCode(currentBlock, prev, y, x,
				       motionY, motionX));
	}
      }

    no_search:

      dct_data[y][x].useMotion = useMotion;
      if ( ! useMotion ) {
	/* output I-block inside a P-frame */
	numIBlocks++;

	/* calculate forward dct's */
	if (collect_quant && (collect_quant_detailed & 1)) fprintf(collect_quant_fp, "l\n");
	mp_fwd_dct_block2(current->y_blocks[y][x], dct[y][x]);
	mp_fwd_dct_block2(current->y_blocks[y][x+1], dct[y][x+1]);
	mp_fwd_dct_block2(current->y_blocks[y+1][x], dct[y+1][x]);
	mp_fwd_dct_block2(current->y_blocks[y+1][x+1], dct[y+1][x+1]);
	if (collect_quant && (collect_quant_detailed & 1)) fprintf(collect_quant_fp, "c\n");
	mp_fwd_dct_block2(current->cb_blocks[y>>1][x>>1], dctb[y>>1][x>>1]);
	mp_fwd_dct_block2(current->cr_blocks[y>>1][x>>1], dctr[y>>1][x>>1]);

      } else {
	/* USE MOTION VECTORS */
	numPBlocks++;

	pattern = 63;
	ComputeDiffDCTs(current, prev, y, x, motionY, motionX,
			&pattern);

	assert(motionX+searchRangeP+1 >= 0);
	assert(motionY+searchRangeP+1 >= 0);

#ifdef BLEAH
	if ( motionX+searchRangeP+1 > 2*searchRangeP+2 )
	  {
	    fprintf(stdout, "motionX = %d, searchRangeP = %d\n",
		    motionX, searchRangeP);
	  }
#endif

	if ( computeMVHist ) {
	  assert(motionX+searchRangeP+1 <= 2*searchRangeP+2);
	  assert(motionY+searchRangeP+1 <= 2*searchRangeP+2);
	  pmvHistogram[motionX+searchRangeP+1][motionY+searchRangeP+1]++;
	}
	/* Save specs for next loops */
	dct_data[y][x].pattern = pattern;
	dct_data[y][x].fmotionX = motionX;
	dct_data[y][x].fmotionY = motionY;

      }
      mbAddress++;
    }}
Example #24
0
void RenderActivity::onNativeWindowResized (ANativeWindow* window)
{
	DBG_PRINT(("RenderActivity::onNativeWindowResized()"));
	m_thread->enqueue(Message(MESSAGE_WINDOW_RESIZED, window));
}
Example #25
0
/**
 * Cpp: read C++ file and pickup tag entries.
 */
void
Cpp(const struct parser_param *param)
{
	int c, cc;
	int savelevel;
	int startclass, startthrow, startmacro, startsharp, startequal;
	char classname[MAXTOKEN];
	char completename[MAXCOMPLETENAME];
	char *completename_limit = &completename[sizeof(completename)];
	int classlevel;
	struct {
		char *classname;
		char *terminate;
		int level;
	} stack[MAXCLASSSTACK];
	const char *interested = "{}=;~";
	STRBUF *sb = strbuf_open(0);

	*classname = *completename = 0;
	stack[0].classname = completename;
	stack[0].terminate = completename;
	stack[0].level = 0;
	level = classlevel = piflevel = namespacelevel = 0;
	savelevel = -1;
	startclass = startthrow = startmacro = startsharp = startequal = 0;

	if (!opentoken(param->file))
		die("'%s' cannot open.", param->file);
	cmode = 1;			/* allow token like '#xxx' */
	crflag = 1;			/* require '\n' as a token */
	cppmode = 1;			/* treat '::' as a token */

	while ((cc = nexttoken(interested, cpp_reserved_word)) != EOF) {
		if (cc == '~' && level == stack[classlevel].level)
			continue;
		switch (cc) {
		case SYMBOL:		/* symbol	*/
			if (startclass || startthrow) {
				PUT(PARSER_REF_SYM, token, lineno, sp);
			} else if (peekc(0) == '('/* ) */) {
				if (param->isnotfunction(token)) {
					PUT(PARSER_REF_SYM, token, lineno, sp);
				} else if (level > stack[classlevel].level || startequal || startmacro) {
					PUT(PARSER_REF_SYM, token, lineno, sp);
				} else if (level == stack[classlevel].level && !startmacro && !startsharp && !startequal) {
					char savetok[MAXTOKEN], *saveline;
					int savelineno = lineno;

					strlimcpy(savetok, token, sizeof(savetok));
					strbuf_reset(sb);
					strbuf_puts(sb, sp);
					saveline = strbuf_value(sb);
					if (function_definition(param)) {
						/* ignore constructor */
						if (strcmp(stack[classlevel].classname, savetok))
							PUT(PARSER_DEF, savetok, savelineno, saveline);
					} else {
						PUT(PARSER_REF_SYM, savetok, savelineno, saveline);
					}
				}
			} else {
				PUT(PARSER_REF_SYM, token, lineno, sp);
			}
			break;
		case CPP_USING:
			/*
			 * using namespace name;
			 * using ...;
			 */
			if ((c = nexttoken(interested, cpp_reserved_word)) == CPP_NAMESPACE) {
				if ((c = nexttoken(interested, cpp_reserved_word)) == SYMBOL) {
					PUT(PARSER_REF_SYM, token, lineno, sp);
				} else {
					if (param->flags & PARSER_WARNING)
						warning("missing namespace name. [+%d %s].", lineno, curfile);
					pushbacktoken();
				}
			} else
				pushbacktoken();
			break;
		case CPP_NAMESPACE:
			crflag = 0;
			/*
			 * namespace name = ...;
			 * namespace [name] { ... }
			 */
			if ((c = nexttoken(interested, cpp_reserved_word)) == SYMBOL) {
				PUT(PARSER_DEF, token, lineno, sp);
				if ((c = nexttoken(interested, cpp_reserved_word)) == '=') {
					crflag = 1;
					break;
				}
			}
			/*
			 * Namespace block doesn't have any influence on level.
			 */
			if (c == '{') /* } */ {
				namespacelevel++;
			} else {
				if (param->flags & PARSER_WARNING)
					warning("missing namespace block. [+%d %s](0x%x).", lineno, curfile, c);
			}
			crflag = 1;
			break;
		case CPP_EXTERN: /* for 'extern "C"/"C++"' */
			if (peekc(0) != '"') /* " */
				continue; /* If does not start with '"', continue. */
			while ((c = nexttoken(interested, cpp_reserved_word)) == '\n')
				;
			/*
			 * 'extern "C"/"C++"' block is a kind of namespace block.
			 * (It doesn't have any influence on level.)
			 */
			if (c == '{') /* } */
				namespacelevel++;
			else
				pushbacktoken();
			break;
		case CPP_STRUCT:
		case CPP_CLASS:
			DBG_PRINT(level, cc == CPP_CLASS ? "class" : "struct");
			while ((c = nexttoken(NULL, cpp_reserved_word)) == CPP___ATTRIBUTE__ || c == '\n')
				if (c == CPP___ATTRIBUTE__)
					process_attribute(param);
			if (c == SYMBOL) {
				char *saveline;
				int savelineno;
				do {
					if (c == SYMBOL) {
						savelineno = lineno;
						strbuf_reset(sb);
						strbuf_puts(sb, sp);
						saveline = strbuf_value(sb);
						strlimcpy(classname, token, sizeof(classname));
					}
					c = nexttoken(NULL, cpp_reserved_word);
					if (c == SYMBOL)
						PUT(PARSER_REF_SYM, classname, savelineno, saveline);
					else if (c == '<') {
						int templates = 1;
						for (;;) {
							c = nexttoken(NULL, cpp_reserved_word);
							if (c == SYMBOL)
								PUT(PARSER_REF_SYM, token, lineno, sp);
							else if (c == '<')
								++templates;
							else if (c == '>') {
								if (--templates == 0)
									break;
							} else if (c == EOF)
								die("failed to parse template [+%d %s].", savelineno, curfile);
						}
						c = nexttoken(NULL, cpp_reserved_word);
					}
				} while (c == SYMBOL || c == '\n');
				if (c == ':' || c == '{') /* } */ {
					startclass = 1;
					PUT(PARSER_DEF, classname, savelineno, saveline);
				} else
					PUT(PARSER_REF_SYM, classname, savelineno, saveline);
			}
			pushbacktoken();
			break;
		case '{':  /* } */
			DBG_PRINT(level, "{"); /* } */
			++level;
			if ((param->flags & PARSER_BEGIN_BLOCK) && atfirst) {
				if ((param->flags & PARSER_WARNING) && level != 1)
					warning("forced level 1 block start by '{' at column 0 [+%d %s].", lineno, curfile); /* } */
				level = 1;
			}
			if (startclass) {
				char *p = stack[classlevel].terminate;
				char *q = classname;

				if (++classlevel >= MAXCLASSSTACK)
					die("class stack over flow.[%s]", curfile);
				if (classlevel > 1 && p < completename_limit)
					*p++ = '.';
				stack[classlevel].classname = p;
				while (*q && p < completename_limit)
					*p++ = *q++;
				stack[classlevel].terminate = p;
				stack[classlevel].level = level;
				*p++ = 0;
			}
			startclass = startthrow = 0;
			break;
			/* { */
		case '}':
			if (--level < 0) {
				if (namespacelevel > 0)
					namespacelevel--;
				else if (param->flags & PARSER_WARNING)
					warning("missing left '{' [+%d %s].", lineno, curfile); /* } */
				level = 0;
			}
			if ((param->flags & PARSER_END_BLOCK) && atfirst) {
				if ((param->flags & PARSER_WARNING) && level != 0)
					/* { */
					warning("forced level 0 block end by '}' at column 0 [+%d %s].", lineno, curfile);
				level = 0;
			}
			if (level < stack[classlevel].level)
				*(stack[--classlevel].terminate) = 0;
			/* { */
			DBG_PRINT(level, "}");
			break;
		case '=':
			/* dirty hack. Don't mimic this. */
			if (peekc(0) == '=') {
				throwaway_nextchar();
			} else {
				startequal = 1;
			}
			break;
		case ';':
			startthrow = startequal = 0;
			break;
		case '\n':
			if (startmacro && level != savelevel) {
				if (param->flags & PARSER_WARNING)
					warning("different level before and after #define macro. reseted. [+%d %s].", lineno, curfile);
				level = savelevel;
			}
			startmacro = startsharp = 0;
			break;
		/*
		 * #xxx
		 */
		case SHARP_DEFINE:
		case SHARP_UNDEF:
			startmacro = 1;
			savelevel = level;
			if ((c = nexttoken(interested, cpp_reserved_word)) != SYMBOL) {
				pushbacktoken();
				break;
			}
			if (peekc(1) == '('/* ) */) {
				PUT(PARSER_DEF, token, lineno, sp);
				while ((c = nexttoken("()", cpp_reserved_word)) != EOF && c != '\n' && c != /* ( */ ')')
					if (c == SYMBOL)
						PUT(PARSER_REF_SYM, token, lineno, sp);
				if (c == '\n')
					pushbacktoken();
			}  else {
				PUT(PARSER_DEF, token, lineno, sp);
			}
			break;
		case SHARP_IMPORT:
		case SHARP_INCLUDE:
		case SHARP_INCLUDE_NEXT:
		case SHARP_ERROR:
		case SHARP_LINE:
		case SHARP_PRAGMA:
		case SHARP_WARNING:
		case SHARP_IDENT:
		case SHARP_SCCS:
			while ((c = nexttoken(interested, cpp_reserved_word)) != EOF && c != '\n')
				;
			break;
		case SHARP_IFDEF:
		case SHARP_IFNDEF:
		case SHARP_IF:
		case SHARP_ELIF:
		case SHARP_ELSE:
		case SHARP_ENDIF:
			condition_macro(param, cc);
			break;
		case SHARP_SHARP:		/* ## */
			(void)nexttoken(interested, cpp_reserved_word);
			break;
		case CPP_NEW:
			if ((c = nexttoken(interested, cpp_reserved_word)) == SYMBOL)
				PUT(PARSER_REF_SYM, token, lineno, sp);
			break;
		case CPP_ENUM:
		case CPP_UNION:
			while ((c = nexttoken(interested, cpp_reserved_word)) == CPP___ATTRIBUTE__)
				process_attribute(param);
			if (c == SYMBOL) {
				if (peekc(0) == '{') /* } */ {
					PUT(PARSER_DEF, token, lineno, sp);
				} else {
					PUT(PARSER_REF_SYM, token, lineno, sp);
				}
				c = nexttoken(interested, cpp_reserved_word);
			}
			if (c == '{' /* } */ && cc == CPP_ENUM) {
				enumerator_list(param);
			} else {
				pushbacktoken();
			}
			break;
		case CPP_TEMPLATE:
			{
				int level = 0;

				while ((c = nexttoken("<>", cpp_reserved_word)) != EOF) {
					if (c == '<')
						++level;
					else if (c == '>') {
						if (--level == 0)
							break;
					} else if (c == SYMBOL) {
						PUT(PARSER_REF_SYM, token, lineno, sp);
					}
				}
				if (c == EOF && (param->flags & PARSER_WARNING))
					warning("template <...> isn't closed. [+%d %s].", lineno, curfile);
			}
			break;
		case CPP_OPERATOR:
			while ((c = nexttoken(";{", /* } */ cpp_reserved_word)) != EOF) {
				if (c == '{') /* } */ {
					pushbacktoken();
					break;
				} else if (c == ';') {
					break;
				} else if (c == SYMBOL) {
					PUT(PARSER_REF_SYM, token, lineno, sp);
				}
			}
			if (c == EOF && (param->flags & PARSER_WARNING))
				warning("'{' doesn't exist after 'operator'. [+%d %s].", lineno, curfile); /* } */
			break;
		/* control statement check */
		case CPP_THROW:
			startthrow = 1;
		case CPP_BREAK:
		case CPP_CASE:
		case CPP_CATCH:
		case CPP_CONTINUE:
		case CPP_DEFAULT:
		case CPP_DELETE:
		case CPP_DO:
		case CPP_ELSE:
		case CPP_FOR:
		case CPP_GOTO:
		case CPP_IF:
		case CPP_RETURN:
		case CPP_SWITCH:
		case CPP_TRY:
		case CPP_WHILE:
			if ((param->flags & PARSER_WARNING) && !startmacro && level == 0)
				warning("Out of function. %8s [+%d %s]", token, lineno, curfile);
			break;
		case CPP_TYPEDEF:
			{
				/*
				 * This parser is too complex to maintain.
				 * We should rewrite the whole.
				 */
				char savetok[MAXTOKEN];
				int savelineno = 0;
				int typedef_savelevel = level;

				savetok[0] = 0;

				/* skip CV qualifiers */
				do {
					c = nexttoken("{}(),;", cpp_reserved_word);
				} while (IS_CV_QUALIFIER(c) || c == '\n');

				if ((param->flags & PARSER_WARNING) && c == EOF) {
					warning("unexpected eof. [+%d %s]", lineno, curfile);
					break;
				} else if (c == CPP_ENUM || c == CPP_STRUCT || c == CPP_UNION) {
					char *interest_enum = "{},;";
					int c_ = c;

					while ((c = nexttoken(interest_enum, cpp_reserved_word)) == CPP___ATTRIBUTE__)
						process_attribute(param);
					/* read tag name if exist */
					if (c == SYMBOL) {
						if (peekc(0) == '{') /* } */ {
							PUT(PARSER_DEF, token, lineno, sp);
						} else {
							PUT(PARSER_REF_SYM, token, lineno, sp);
						}
						c = nexttoken(interest_enum, cpp_reserved_word);
					}
					if (c_ == CPP_ENUM) {
						if (c == '{') /* } */
							c = enumerator_list(param);
						else
							pushbacktoken();
					} else {
						for (; c != EOF; c = nexttoken(interest_enum, cpp_reserved_word)) {
							switch (c) {
							case SHARP_IFDEF:
							case SHARP_IFNDEF:
							case SHARP_IF:
							case SHARP_ELIF:
							case SHARP_ELSE:
							case SHARP_ENDIF:
								condition_macro(param, c);
								continue;
							default:
								break;
							}
							if (c == ';' && level == typedef_savelevel) {
								if (savetok[0])
									PUT(PARSER_DEF, savetok, savelineno, sp);
								break;
							} else if (c == '{')
								level++;
							else if (c == '}') {
								if (--level == typedef_savelevel)
									break;
							} else if (c == SYMBOL) {
								PUT(PARSER_REF_SYM, token, lineno, sp);
								/* save lastest token */
								strlimcpy(savetok, token, sizeof(savetok));
								savelineno = lineno;
							}
						}
						if (c == ';')
							break;
					}
					if ((param->flags & PARSER_WARNING) && c == EOF) {
						warning("unexpected eof. [+%d %s]", lineno, curfile);
						break;
					}
				} else if (c == SYMBOL) {
					PUT(PARSER_REF_SYM, token, lineno, sp);
				}
				savetok[0] = 0;
				while ((c = nexttoken("(),;", cpp_reserved_word)) != EOF) {
					switch (c) {
					case SHARP_IFDEF:
					case SHARP_IFNDEF:
					case SHARP_IF:
					case SHARP_ELIF:
					case SHARP_ELSE:
					case SHARP_ENDIF:
						condition_macro(param, c);
						continue;
					default:
						break;
					}
					if (c == '(')
						level++;
					else if (c == ')')
						level--;
					else if (c == SYMBOL) {
						if (level > typedef_savelevel) {
							PUT(PARSER_REF_SYM, token, lineno, sp);
						} else {
							/* put latest token if any */
							if (savetok[0]) {
								PUT(PARSER_REF_SYM, savetok, savelineno, sp);
							}
							/* save lastest token */
							strlimcpy(savetok, token, sizeof(savetok));
							savelineno = lineno;
						}
					} else if (c == ',' || c == ';') {
						if (savetok[0]) {
							PUT(PARSER_DEF, savetok, lineno, sp);
							savetok[0] = 0;
						}
					}
					if (level == typedef_savelevel && c == ';')
						break;
				}
				if (param->flags & PARSER_WARNING) {
					if (c == EOF)
						warning("unexpected eof. [+%d %s]", lineno, curfile);
					else if (level != typedef_savelevel)
						warning("unmatched () block. (last at level %d.)[+%d %s]", level, lineno, curfile);
				}
			}
			break;
		case CPP___ATTRIBUTE__:
			process_attribute(param);
			break;
		default:
			break;
		}
	}
	strbuf_close(sb);
	if (param->flags & PARSER_WARNING) {
		if (level != 0)
			warning("unmatched {} block. (last at level %d.)[+%d %s]", level, lineno, curfile);
		if (piflevel != 0)
			warning("unmatched #if block. (last at level %d.)[+%d %s]", piflevel, lineno, curfile);
	}
	closetoken();
}
Example #26
0
void RenderActivity::onNativeWindowDestroyed (ANativeWindow* window)
{
	DBG_PRINT(("RenderActivity::onNativeWindowDestroyed()"));
	m_thread->enqueue(Message(MESSAGE_WINDOW_DESTROYED, window));
	m_thread->sync(); // Block until thread has processed all messages.
}
Example #27
0
void CSysArgMenu::DoActive()
{
	DBG_PRINT(("进入CSysArgMenu::DoActive()函数"));
	
	ReFresh();
}
Example #28
0
void RenderActivity::onInputQueueCreated (AInputQueue* queue)
{
	DBG_PRINT(("RenderActivity::onInputQueueCreated()"));
	m_thread->enqueue(Message(MESSAGE_INPUT_QUEUE_CREATED, queue));
}
Example #29
0
//----------------------------------------------------------------------------------------------------//
//  @func - xilkernel_start
//! @desc
//!   Start the kernel by enabling interrupts and starting to execute the idle task.
//! @return
//!   - Nothing.
//! @note
//!   - Routine does not return.
//! @desc
//----------------------------------------------------------------------------------------------------//
void xilkernel_start (void)
{
    DBG_PRINT("XMK: Process scheduling starts.\r\n");
    Xil_ExceptionEnable();
    idle_task ();                                                       // Does not return
}
Example #30
0
/*******************************************************************************
 *	msf_assert()
 *******************************************************************************
 *
 *  DESCRIPTION:
 *
 *      Print statement used to display asserts from within the HCF. Only called
 *  when asserts in the HCF are turned on. See hcfcfg.h for more information.
 *
 *  PARAMETERS:
 *
 *      file_namep  - the filename in which the assert occurred.
 *      line_number - the line number on which the assert occurred.
 *      trace       - a comment associated with the assert.
 *      qual        - return code or other value related to the assert
 *
 *  RETURNS:
 *
 *      N/A
 *
 ******************************************************************************/
void msf_assert( unsigned int line_number, hcf_16 trace, hcf_32 qual )
{
    DBG_PRINT( "HCF ASSERT: Line %d, VAL: 0x%.8x\n", line_number, /*;?*/(u32)qual );
} // msf_assert