access_cal.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:8k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2001
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * access_cal.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Calibration result export to Microsoft Access source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include <IniFiles.hpp>
- #pragma hdrstop
- #ifndef _ACCESS_CAL_H_
- #include "access_cal.h"
- #endif
- //===========================================================================
- //===========================================================================
- CACCESSCAL::CACCESSCAL( void )
- {
- }
- //---------------------------------------------------------------------------
- CACCESSCAL::~CACCESSCAL( )
- {
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddFieldToAccess( TADOTable *p_ADOTab, AnsiString as_fieldname, AnsiString as_fieldvalue )
- {
- try
- {
- p_ADOTab->FieldByName(as_fieldname)->AsString = as_fieldvalue;
- }
- catch(...)
- {
- AnsiString as_msg = "add " + as_fieldname + " fields error";
- throw EDatabaseError(as_msg);
- return false;
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddBarcodeToAccess( TADOTable *p_ADOTab, AnsiString as_ID )
- {
- if(! AddFieldToAccess( p_ADOTab, "BARCODE", as_ID ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddPcToAccess( TADOTable *p_ADOTab )
- {
- char hostname[256];
- unsigned long len=256;
- GetComputerName( hostname, &len );
- if(! AddFieldToAccess( p_ADOTab, "PC", hostname ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddDateToAccess( TADOTable *p_ADOTab )
- {
- if(! AddFieldToAccess( p_ADOTab, "DATE", DateToStr(Date()) ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddTimeToAccess( TADOTable *p_ADOTab )
- {
- if(! AddFieldToAccess( p_ADOTab, "TIME", CurrentTimeStr() ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddPassFailToAccess( TADOTable *p_ADOTab, int pass_fail )
- {
- if(! AddFieldToAccess( p_ADOTab, "PASS_FAIL", IntToStr(pass_fail) ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddFailStepToAccess( TADOTable *p_ADOTab, int fail_step )
- {
- if(! AddFieldToAccess( p_ADOTab, "FAIL_STEP", IntToStr(fail_step) ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddAfcFailReasonToAccess( TADOTable *p_ADOTab, int fail_reason_code )
- {
- if(! AddFieldToAccess( p_ADOTab, "AFC_FAIL_REASON", IntToStr(fail_reason_code) ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddRxPathLossFailReasonToAccess( TADOTable *p_ADOTab, int fail_reason_code )
- {
- if(! AddFieldToAccess( p_ADOTab, "RX_PATH_LOSS_FAIL_REASON", IntToStr(fail_reason_code) ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddApcFailReasonToAccess( TADOTable *p_ADOTab, int fail_reason_code )
- {
- if(! AddFieldToAccess( p_ADOTab, "APC_FAIL_REASON", IntToStr(fail_reason_code) ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddAdcFailReasonToAccess( TADOTable *p_ADOTab, int fail_reason_code )
- {
- if(! AddFieldToAccess( p_ADOTab, "ADC_FAIL_REASON", IntToStr(fail_reason_code) ) ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- bool CACCESSCAL::AddCalTimeToAccess( TADOTable *p_ADOTab, AnsiString as_field, int i_time )
- {
- float f_time;
- f_time = 1.0*i_time /1000.0;
- try
- {
- p_ADOTab->FieldByName(as_field)->AsFloat = f_time;
- }
- catch(...)
- {
- AnsiString as_msg = "add " + as_field + " field error";
- throw EDatabaseError(as_msg);
- return false;
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddInitTimeToAccess( TADOTable *p_ADOTab, int i_INIT_time )
- {
- m_sCalTime.i_INIT_time = i_INIT_time;
- if( ! AddCalTimeToAccess( p_ADOTab, "INIT_TIME", i_INIT_time ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddAFCTimeToAccess( TADOTable *p_ADOTab, int i_AFC_time )
- {
- m_sCalTime.i_AFC_time = i_AFC_time;
- if( ! AddCalTimeToAccess( p_ADOTab, "AFC_TIME", i_AFC_time ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddRxPathLossTimeToAccess( TADOTable *p_ADOTab, int i_RX_PATH_LOSS_time )
- {
- m_sCalTime.i_RX_PATH_LOSS_time = i_RX_PATH_LOSS_time;
- if( ! AddCalTimeToAccess( p_ADOTab, "RX_PATH_LOSS_TIME", i_RX_PATH_LOSS_time ) ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- bool CACCESSCAL::AddIP2TimeToAccess( TADOTable *p_ADOTab, int i_IP2_time )
- {
- m_sCalTime.i_IP2_time = i_IP2_time;
- if( ! AddCalTimeToAccess( p_ADOTab, "IP2_TIME", i_IP2_time ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddAPCTimeToAccess( TADOTable *p_ADOTab, int i_APC_time )
- {
- m_sCalTime.i_APC_time = i_APC_time;
- if( ! AddCalTimeToAccess( p_ADOTab, "APC_TIME", i_APC_time ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddADCTimeToAccess( TADOTable *p_ADOTab, int i_ADC_time )
- {
- m_sCalTime.i_ADC_time = i_ADC_time;
- if( ! AddCalTimeToAccess( p_ADOTab, "ADC_TIME", i_ADC_time ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSCAL::AddTotalCalTimeToAccess( TADOTable *p_ADOTab )
- {
- m_sCalTime.i_Total_cal_time = m_sCalTime.i_INIT_time + m_sCalTime.i_AFC_time +
- m_sCalTime.i_RX_PATH_LOSS_time + m_sCalTime.i_IP2_time +
- m_sCalTime.i_APC_time + m_sCalTime.i_ADC_time;
- if( ! AddCalTimeToAccess( p_ADOTab, "TOTAL_CAL_TIME", m_sCalTime.i_Total_cal_time ) ) return false;
- return true;
- }