Пример #1
0
BOOL CCrashInfoReader::UpdateUserInfo(CString sEmail, CString sDesc)
{
	// This method validates user-provided Email and problem description
	// and (if valid) uptdates internal fields.
	BOOL bResult = TRUE;

	// If an email address was entered, verify that
    // it [1] contains a @ and [2] the last . comes
    // after the @.
    
    if (sEmail.GetLength()!=0 &&
        (sEmail.Find(_T('@')) < 0 ||
        sEmail.ReverseFind(_T('.')) < 
        sEmail.Find(_T('@'))))
    {
        // Invalid email            
		bResult = FALSE;
    }
	else
	{
		// Update email
		GetReport(0)->m_sEmailFrom = sEmail;
	}

	// Update problem description
	GetReport(0)->m_sDescription = sDesc;	

    // Write user email and problem description to XML
    AddUserInfoToCrashDescriptionXML(
        GetReport(0)->m_sEmailFrom, 
        GetReport(0)->m_sDescription);

	// Save E-mail entered by user to INI file for later reuse.
	SetPersistentUserEmail(sEmail);

	return bResult;
}
Пример #2
0
int CStock::PrepareData( int type, int period, BOOL bReload )
{
	SP_ASSERT( m_pDatabase );
	if( ! m_pDatabase )	return 0;

	switch( type )
	{
	case dataInfo:
		return AfxGetStockContainer().GetStockInfo( m_stockinfo.GetStockCode(), &m_stockinfo );
	case dataK:
		{
			switch( period )
			{
			case CKData::ktypeMonth:
				if( bReload || GetKDataMonth().GetSize() == 0 )
					m_pDatabase->LoadKData( this, CKData::ktypeMonth );
				break;
			case CKData::ktypeWeek:
				if( bReload || GetKDataWeek().GetSize() == 0 )
					m_pDatabase->LoadKData( this, CKData::ktypeWeek );
				break;
			case CKData::ktypeDay:
				if( bReload || GetKDataDay().GetSize() == 0 )
					m_pDatabase->LoadKData( this, CKData::ktypeDay );
				break;		// month, week, and day willnot extract from min60,min30...

			case CKData::ktypeMin60:
				if( bReload || GetKDataMin60().GetSize() == 0 )
					m_pDatabase->LoadKData( this, CKData::ktypeMin60 );
				break;
			case CKData::ktypeMin30:
				if( bReload || GetKDataMin30().GetSize() == 0 )
					m_pDatabase->LoadKData( this, CKData::ktypeMin30 );
				break;
			case CKData::ktypeMin15:
				if( bReload || GetKDataMin15().GetSize() == 0 )
					m_pDatabase->LoadKData( this, CKData::ktypeMin15 );
				break;
			case CKData::ktypeMin5:
				if( bReload || GetKDataMin5().GetSize() == 0 )
					m_pDatabase->LoadKData( this, CKData::ktypeMin5 );
				break;
			case CKData::ktypeMin1:
				if( bReload || GetKDataMin1().GetSize() == 0 )
					m_pDatabase->LoadKData( this, CKData::ktypeMin1 );
				break;
			default:
				SP_ASSERT( FALSE );
				return 0;
			}
			return ExtractKData( period, FALSE );
		}
	case dataDR:
		if( bReload || GetDRData().GetSize() == 0 )
			return m_pDatabase->LoadDRData( this );
		else
			return GetDRData().GetSize();
	case dataBasetable:
		return AfxGetStockContainer().GetStockInfo( m_stockinfo.GetStockCode(), &m_stockinfo );
	case dataBasetext:
		if( bReload || !GetBaseTextPtr() )
			return m_pDatabase->LoadBaseText( this );
		else
			return GetBaseTextLength();
	case dataReport:
		if( bReload || GetReport().GetSize() == 0 )
			return m_pDatabase->LoadReport( this );
		else
			return GetReport().GetSize();
	case dataMinute:
		if( bReload || GetMinute().GetSize() == 0 )
			return m_pDatabase->LoadMinute( this );
		else
			return GetMinute().GetSize();
	case dataOutline:
		if( bReload || GetOutline().GetSize() == 0 )
			return m_pDatabase->LoadOutline( this );
		else
			return GetOutline().GetSize();
	default:
		SP_ASSERT( FALSE );
		return 0;
	}
}
int main(int argc, char* argv[])
{
	int retval;
	int ii;
	int jj;
	int this_arg = 1;
	int found = 0;
	int readings = 1;
	int reading;;
	int cartesian = 0;
	int patience = PATIENCE;
	int report_type;
	int report_size;
	int rx_num;
	int tx_num;
	char *report_data_8;
	short *report_data_16;
	int *report_data_32;
	unsigned char data_8;
	struct stat st;

	if (argc == 1) {
		usage(argv[0]);
		error_exit(EINVAL);
	}

	for (ii = 0; ii < NUMBER_OF_INPUTS_TO_SCAN; ii++) {
		memset(input_detect, 0x00, MAX_STRING_LEN);
		snprintf(input_detect, MAX_STRING_LEN, "%s%d/%s", INPUT_PATH,
				(unsigned int)ii, DETECT_FILENAME);
		retval = stat(input_detect, &st);
		if (retval == 0) {
			snprintf(mySensor, MAX_STRING_LEN, "%s%d", INPUT_PATH,
					(unsigned int)ii);
			found = 1;
			break;
		}
	}

	if (!found) {
		printf("ERROR: input driver not found\n");
		error_exit(ENODEV);
	}

	while (this_arg < argc) {
		if (!strcmp((const char *)argv[this_arg], "-n")) {
			this_arg++;
			readings = (unsigned int)strtoul(argv[this_arg], NULL, 0);
		} else if (!strcmp((const char *)argv[this_arg], "-c")) {
			cartesian = 1;
		} else {
			report_type = strtoul(argv[this_arg], NULL, 0);
		}
		this_arg++;
	}

	if (cartesian) {
		rx_num = GetRxElectrodes();
		tx_num = GetTxElectrodes();
	}

	switch (report_type) {
	case F54_16BIT_IMAGE:
	case F54_RAW_16BIT_IMAGE:
	case F54_SENSOR_SPEED:
	case F54_ADC_RANGE:
	case F54_ABS_CAP:
	case F54_ABS_DELTA:
		break;
	default:
		DoPreparation(1);
		break;
	}

	for (reading = 0; reading < readings; reading++) {
		patience = PATIENCE;
		SetReportType(report_type);
		GetReport(1);
		do {
			if (GetStatus() == 0)
				break;
		} while (--patience > 0);

		report_size = ReadReportSize();
		if (report_size == 0) {
			printf("ERROR: unable to read report\n");
			DoReset(1);
			error_exit(EINVAL);
		}

		if (!data_buffer) {
			data_buffer = malloc(report_size);
			if (!data_buffer) {
				printf("ERROR: failed to allocate report data buffer\n");
				DoReset(1);
				error_exit(ENOMEM);
			}
		}
		ReadBlockData((char *)&data_buffer[0], report_size);

		printf("Reading %d\r\n", reading + 1);

		switch (report_type) {
		case F54_8BIT_IMAGE:
			report_data_8 = (char *)data_buffer;
			for (ii = 0; ii < report_size; ii++) {
				printf("%03d: %d\r\n", ii, *report_data_8);
				report_data_8++;
			}
			break;
		case F54_16BIT_IMAGE:
		case F54_RAW_16BIT_IMAGE:
		case F54_TRUE_BASELINE:
		case F54_FULL_RAW_CAP:
		case F54_FULL_RAW_CAP_RX_COUPLING_COMP:
			report_data_16 = (short *)data_buffer;
			if (cartesian) {
				printf("   ");
				for (ii = 0; ii < rx_num; ii++)
					printf("     %2d", ii);
				printf("\r\n");

				for (ii = 0; ii < tx_num; ii++) {
					printf("%2d ", ii);
					for (jj = 0; jj < rx_num; jj++) {
						printf("  %5d", *report_data_16);
						report_data_16++;
					}
					printf("\r\n");
				}
			} else {
				for (ii = 0; ii < report_size; ii += 2) {
					printf("%03d: %d\r\n", ii / 2, *report_data_16);
					report_data_16++;
				}
			}
			break;
		case F54_HIGH_RESISTANCE:
		case F54_FULL_RAW_CAP_MIN_MAX:
		case F54_SENSOR_SPEED:
		case F54_ADC_RANGE:
			report_data_16 = (short *)data_buffer;
			for (ii = 0; ii < report_size; ii += 2) {
				printf("%03d: %d\r\n", ii / 2, *report_data_16);
				report_data_16++;
			}
			break;
		case F54_ABS_CAP:
		case F54_ABS_DELTA:
			report_data_32 = (int *)data_buffer;
			if (cartesian) {
				printf("Rx ");
				for (ii = 0; ii < rx_num; ii++)
					printf("     %2d", ii);
				printf("\r\n");

				printf("   ");
				for (ii = 0; ii < rx_num; ii++) {
					printf("  %5d", *report_data_32);
					report_data_32++;
				}
				printf("\r\n");

				printf("Tx ");
				for (ii = 0; ii < tx_num; ii++)
					printf("     %2d", ii);
				printf("\r\n");

				printf("   ");
				for (ii = 0; ii < tx_num; ii++) {
					printf("  %5d", *report_data_32);
					report_data_32++;
				}
				printf("\r\n");
			} else {
				for (ii = 0; ii < report_size; ii += 4) {
					printf("%03d: %d\r\n", ii / 4, *report_data_32);
					report_data_32++;
				}
			}
			break;
		case F54_ABS_ADC:
			report_data_16 = (short *)data_buffer;
			for (ii = 0; ii < report_size; ii += 2) {
				data_8 = (unsigned char)*report_data_16;
				printf("%03d: %d\r\n", ii / 2, data_8);
				report_data_16++;
			}
			break;
		default:
			for (ii = 0; ii < report_size; ii++)
				printf("%03d: 0x%02x\r\n", ii, data_buffer[ii]);
			break;
		}
	}

	switch (report_type) {
	case F54_16BIT_IMAGE:
	case F54_RAW_16BIT_IMAGE:
	case F54_SENSOR_SPEED:
	case F54_ADC_RANGE:
	case F54_ABS_CAP:
	case F54_ABS_DELTA:
		ResumeTouch(1);
		break;
	default:
		DoReset(1);
		break;
	}

	if (data_buffer)
		free(data_buffer);

	return 0;
}