access_afc.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:5k
- /*****************************************************************************
- * 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_afc.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * AFC calibration 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_AFC_H_
- #include "access_afc.h"
- #endif
- #ifndef _RF_AFC_H_
- #include "rf_afc.h"
- #endif
- //===========================================================================
- //===========================================================================
- CACCESSAFC::CACCESSAFC( void )
- {
- }
- //---------------------------------------------------------------------------
- CACCESSAFC::~CACCESSAFC( )
- {
- }
- //------------------------------------------------------------------------------
- void CACCESSAFC::SetTabNameToAFC_PARAMETERS( TADOTable *p_ADOTab )
- {
- p_ADOTab->Active = false;
- p_ADOTab->TableName = "AFC_PARAMETERS";
- p_ADOTab->Active = true;
- }
- //------------------------------------------------------------------------------
- void CACCESSAFC::ActivateADOTab( TADOTable *p_ADOTab )
- {
- p_ADOTab->Active = true;
- }
- //------------------------------------------------------------------------------
- void CACCESSAFC::InsertNewRecordToAccess( TADOTable *p_ADOTab )
- {
- p_ADOTab->Insert();
- }
- //------------------------------------------------------------------------------
- void CACCESSAFC::SetADOTableToEditMode( TADOTable *p_ADOTab )
- {
- p_ADOTab->Edit();
- }
- //----------------------------------------------------------------------------
- void CACCESSAFC::PostRecordToAccess( TADOTable *p_ADOTab )
- {
- p_ADOTab->Post();
- }
- //------------------------------------------------------------------------------
- bool CACCESSAFC::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 CACCESSAFC::AddBarcodeToAccess( TADOTable *p_ADOTab, AnsiString as_ID )
- {
- if(! AddFieldToAccess( p_ADOTab, "BARCODE", as_ID ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSAFC::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 CACCESSAFC::AddDateToAccess( TADOTable *p_ADOTab )
- {
- if(! AddFieldToAccess( p_ADOTab, "DATE", DateToStr(Date()) ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSAFC::AddTimeToAccess( TADOTable *p_ADOTab )
- {
- if(! AddFieldToAccess( p_ADOTab, "TIME", CurrentTimeStr() ) ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool CACCESSAFC::AddCommonFieldToAccess( TADOTable *p_ADOTab, AnsiString as_ID )
- {
- if( ! AddBarcodeToAccess( p_ADOTab, as_ID ) ) return false;
- if( ! AddPcToAccess( p_ADOTab ) ) return false;
- if( ! AddDateToAccess( p_ADOTab ) ) return false;
- if( ! AddTimeToAccess( p_ADOTab ) ) return false;
- return false;
- }
- //------------------------------------------------------------------------------
- bool CACCESSAFC::AddTcvcxoAFCParameterToAccess( TADOTable *p_ADOTab, int AfcSlope, int InitAfcDac)
- {
- try
- {
- p_ADOTab->FieldByName("SLOPE")->AsString = Double_To_AnsiString( 1.0*AFC_SLOPE_SCALE/AfcSlope );
- p_ADOTab->FieldByName("INITIAL_VALUE")->AsString = IntToStr( InitAfcDac );
- }
- catch(...)
- {
- AnsiString as_msg = "add TCVCXO AFC fields error";
- throw EDatabaseError(as_msg);
- return false;
- }
- return true;
- }