示例#1
0
文件: header.c 项目: dbrooke/wsrdr
void* getFieldValue(int location, int type) {
    char buffer[8];
    long retval = 0;
    switch(type) {

        case INT:
            dread(buffer, location, 2);
            retval = (long) getSignedInt(buffer);
            break;

        case UINT:
            dread(buffer, location, 2);
            retval = (long) getUnsignedInt(buffer);
            break;

        case ULINT:
            dread(buffer, location, 3);
            retval = getUnsignedLong(buffer);
            break;

        case DATE:
            dread(buffer, location, 5);
            //printf("DEBUG: getFieldValue DATE[%04x] - %d %d %d %d %d\n", location, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]);
            retval = (long) strDate(buffer);
            break;

        case CHAR:
        default:
            dread(buffer, location, 1);
            retval = (long) buffer[0];
            break;
    }
    return (void*) retval;
}
示例#2
0
void GLIB::FetchFirmWare()
{
  ValWord< uint32_t > mem;
  char regName[12];
  for(int i=1 ; i<=6 ; i++)
    {
      sprintf(regName,"firmware_REG_%d",i);
      mem = hw.getNode ( regName ).read();
      hw.dispatch();
      //std::cout<<mem.value()<<" . ";
      char *pEnd;
      char firmChar[1];
      sprintf(firmChar,"%d",int(mem.value()));
      long int li1;
      li1 = strtol (firmChar,&pEnd,16);
      //std::cout<<li1<<" . ";
      //int c = int(mem.value());
      if(i==1)
	_firmWare_Id_Ver_MAJOR=li1;

      if(i==2)
	_firmWare_Id_Ver_MINOR=li1;

      if(i==3)
	_firmWare_Id_Ver_BUILD=li1;

      if(i==4)
	_firmWare_Id_YY=li1;

      if(i==5)
	_firmWare_Id_MM=li1;

      if(i==6)
	_firmWare_Id_DD=li1;

      //std::cout<<li1<<" . ";
    }
  //std::cout<<_firmWare_Id_Ver_MAJOR<<" . "<<_firmWare_Id_Ver_MINOR<<" . "<<_firmWare_Id_Ver_BUILD<<" . "<<_firmWare_Id_YY<<" . "<<_firmWare_Id_MM << " . "<<_firmWare_Id_DD<<std::endl;


  char version[20]="";
  char frmDat[20]="";
  //char *frmDat;
  sprintf(frmDat,"%x/%x/%x",_firmWare_Id_DD,_firmWare_Id_MM,_firmWare_Id_YY);
  sprintf(version,"%x.%x.%x",_firmWare_Id_Ver_MAJOR,_firmWare_Id_Ver_MINOR,_firmWare_Id_Ver_BUILD);
  std::string strVer(version);
  std::string strDate(frmDat);
  _firmWareVersion.append(strVer);
  _firmWareDate.append(strDate);
  //std::cout<<frmDat<<std::endl;
  //std::cout<<_firmWareVersion<<" : "<<_firmWareDate<<std::endl;
  //std::cout<<_firmWare_Id_Ver_MAJOR<<" . "<<_firmWare_Id_Ver_MINOR<<" . "<<_firmWare_Id_Ver_BUILD<<" . "<<_firmWare_Id_YY<<" . "<<_firmWare_Id_MM << " . "<<_firmWare_Id_DD<<std::endl;
  //std::cout<<std::endl;
}
//++ ------------------------------------------------------------------------------------
// Details: Retrieve system local current date. Format is MM/DD/YYYY.
// Type:    Method.
// Args:    None.
// Return:  CMIUtilString - Text description.
// Throws:  None.
//--
CMIUtilString
CMIUtilDateTimeStd::GetDate(void)
{
    CMIUtilString strDate(MIRSRC(IDS_WORD_INVALIDBRKTS));

    std::time(&m_rawTime);
    const std::tm *pTi = std::localtime(&m_rawTime);
    if (std::strftime(&m_pScratch[0], sizeof(m_pScratch), "%d/%m/%y", pTi) > 0)
        strDate = m_pScratch;

    return strDate;
}
    void onAlbEventStart(const QXmlAttributes& attrs)
    {
        string strDate (convStr(attrs.value("date")));
        if (!strDate.empty())
        {
            m_albumInfo.m_strReleased = m_albumInfo.m_strReleased.empty() ? strDate : min(m_albumInfo.m_strReleased, strDate);
        }

        string strFormat (convStr(attrs.value("format")));
        if (!strFormat.empty() && string::npos == m_albumInfo.m_strFormat.find(strFormat))
        {
            addIfMissing(m_albumInfo.m_strFormat, strFormat);
        }
    }
示例#5
0
std::string dcmAPI::CreateDateFromRawDcmTagDate(const std::string& rawDate)
{
	std::string strDate("");
	if(rawDate.size() == 8)
	{
		char buff[80];
		tm date;

		date.tm_mday = atoi(rawDate.substr(6,2).c_str()); //1-31
		date.tm_mon =  atoi(rawDate.substr(4,2).c_str()) - 1; //0-11
		date.tm_year = atoi(rawDate.substr(0,4).c_str()) - 1900; // since 1900
		strftime(buff, 80, "%d %m %Y", &date);
		strDate = buff;
	}
	return strDate;
}
示例#6
0
void BoostDateTimeTestCase::test_gregorian_dateAsString()
{
    try
    {
        //The following date is in ISO 8601 extended format (CCYY-MM-DD)
        std::string strDate("2012-12-12");
        boost::gregorian::date d(boost::gregorian::from_simple_string(strDate));

        std::cout<< boost::gregorian::to_simple_string(d) << std::endl;

        //Read ISO Standard(CCYYMMDD) and output ISO Extended
        std::string ud("20120117"); // my birth day
        boost::gregorian::date d1(boost::gregorian::from_undelimited_string(ud));

        std::cout << boost::gregorian::to_iso_extended_string(d1) << std::endl;

        
        //Output the parts of the date - Tuesday October 9, 2001
        boost::gregorian::date::ymd_type ymd = d1.year_month_day();
        boost::gregorian::greg_weekday wd = d1.day_of_week();

        std::cout << wd.as_long_string() << " "
                  << ymd.month.as_long_string() << " "
                  << ymd.day << ", " << ymd.year
                  << std::endl;
        
        //Let's send in month 25 by accident and create an exception
        std::string bad_date("20012509"); //2001-??-09
        std::cout << "An expected exception is next: " << std::endl;
        boost::gregorian::date wont_construct(boost::gregorian::from_undelimited_string(bad_date));
        //use wont_construct so compiler doesn't complain, but you wont get here!
        std::cout << "oh oh, you shouldn't reach this line: " 
                  << boost::gregorian::to_iso_string(wont_construct) << std::endl;
            
    }
    catch(std::exception& e)
    {
        std::cout<< "Exception:" << e.what() << std::endl;
    }
}
示例#7
0
void CLogRequest::SaveToFile()
{
    const char *currentFileName = GetLogFileName();
    m.lock();
    CFile backupData(currentFileName);
    if(backupData.GetSize() < kMaxFileSize)
    {
        if(!mHasDate)
        {
            boost::posix_time::ptime now = boost::posix_time::second_clock::universal_time();
            std::string strDate("&date=");
            std::string date = boost::posix_time::to_simple_string(now);
            CleanString(date);
            strDate += date;
            mData += strDate;
        }            
        backupData.WriteLine(mData);
        
    }
    backupData.Close();
    m.unlock();
}
示例#8
0
//----------------------------------------------------------------------------------//
BSTR CTradesCache::GetXMLString(IRisks* pRisks, CTradePtr spTrade)
{
	if (pRisks && spTrade)
	{
		IContractPtr spContract = spTrade->m_spContract;
		EtsContractTypeEnum enContractType = enCtNone;
		if (static_cast<bool>(spContract))
			spContract->get_ContractType(&enContractType);

		IContractPtr spBaseContarct = NULL;
		QuoteUpdateInfo retBaseContractQuotes;
		spContract->get_BaseContract(&spBaseContarct);
		if (static_cast<bool>(spBaseContarct))
			retBaseContractQuotes = spBaseContarct->GetQuotes();


		COleDateTime strDate(0.);
		const LPCTSTR dateFormat = _T("%Y-%m-%d %H:%M:%S");
		
		_bstr_t bstrXPath = L"<root>";

			bstrXPath += L"<Risks TradeID=\"" +		_bstr_t(spTrade->m_nTradeID) + "\" ";
			bstrXPath += L"ContractID=\"" +			_bstr_t(spTrade->m_nContractID) + "\" ";
			bstrXPath += L"TheoPrice=\"" +			_bstr_t(pRisks->TheoPrice) + "\" ";
			bstrXPath += L"Alpha=\"" +				_bstr_t(pRisks->Alpha) + "\" ";
			bstrXPath += L"Delta=\"" +				_bstr_t(pRisks->Delta) + "\" ";
			bstrXPath += L"Gamma=\"" +				_bstr_t(pRisks->Gamma) + "\" ";
			bstrXPath += L"Vega=\"" +				_bstr_t(pRisks->Vega) + "\" ";
			bstrXPath += L"Theta=\"" +				_bstr_t(pRisks->Theta) + "\" ";
			bstrXPath += L"Rho=\"" +				_bstr_t(pRisks->Rho) + "\" ";
			bstrXPath += L"Volga=\"" +				_bstr_t(pRisks->Volga) + "\" ";
			bstrXPath += L"DeltaVega=\"" +			_bstr_t(pRisks->DeltaVega) + "\" ";
			bstrXPath += L"DeltaTheta=\"" +			_bstr_t(pRisks->DeltaTheta) + "\" ";
			bstrXPath += L"GammaVega=\"" +			_bstr_t(pRisks->GammaVega) + "\" ";
			bstrXPath += L"GammaTheta=\"" +			_bstr_t(pRisks->GammaTheta) + "\" ";

			if (enContractType == enCtOption){

				bstrXPath += L"IVola=\"" +						_bstr_t(pRisks->IVola) + "\" ";
				bstrXPath += L"IVolaBid=\"" +					_bstr_t(pRisks->IVolaBid) + "\" ";
				bstrXPath += L"IVolaAsk=\"" +					_bstr_t(pRisks->IVolaAsk) + "\" ";
				bstrXPath += L"TheoVola=\"" +					_bstr_t(pRisks->TheoVola) + "\" ";
				bstrXPath += L"BaseContractPrice=\"" +			_bstr_t(pRisks->BaseContractPrice) + "\" ";

				if (retBaseContractQuotes.BidPrice > DBL_EPSILON){
					bstrXPath += L"BaseContractPriceBid=\"" +		_bstr_t(retBaseContractQuotes.BidPrice) + "\" "; 
				}

				if (retBaseContractQuotes.AskPrice > DBL_EPSILON){
					bstrXPath += L"BaseContractPriceAsk=\"" +		_bstr_t(retBaseContractQuotes.AskPrice) + "\" "; 
				}

				if (retBaseContractQuotes.LastPrice > DBL_EPSILON){
					bstrXPath += L"BaseContractPriceLast=\"" +		_bstr_t(retBaseContractQuotes.LastPrice) + "\" ";
				}

				if (retBaseContractQuotes.BidDateTime > DBL_EPSILON){				
					strDate = COleDateTime(retBaseContractQuotes.BidDateTime);
					bstrXPath += L"BaseContractPriceBidDate=\"" +		_bstr_t(strDate.Format(dateFormat)) + "\" ";
				}
				
				if (retBaseContractQuotes.AskDateTime > DBL_EPSILON){
					strDate = COleDateTime(retBaseContractQuotes.AskDateTime);
					bstrXPath += L"BaseContractPriceAskDate=\"" +		_bstr_t(strDate.Format(dateFormat)) + "\" "; 
				}

				if (retBaseContractQuotes.LastDateTime > DBL_EPSILON){
					strDate = COleDateTime(retBaseContractQuotes.AskDateTime);
					bstrXPath += L"BaseContractPriceLastDate=\"" +		_bstr_t(strDate.Format(dateFormat)) + "\" ";
				}
			};

			bstrXPath += L"ContractPrice=\"" +	_bstr_t(pRisks->ContractPrice) + "\" ";

			if (pRisks->BidPrice > DBL_EPSILON){
				bstrXPath += L"ContractPriceBid=\"" + _bstr_t(pRisks->BidPrice) + "\" "; 
			}

			if (pRisks->AskPrice > DBL_EPSILON){
				bstrXPath += L"ContractPriceAsk=\"" + _bstr_t(pRisks->AskPrice) + "\" "; 
			}

			if (pRisks->LastPrice > DBL_EPSILON){
				bstrXPath += L"ContractPriceLast=\"" + _bstr_t(pRisks->LastPrice) + "\" ";
			}

			if (pRisks->BidDate > DBL_EPSILON){				
				strDate = COleDateTime(pRisks->BidDate);
				bstrXPath += L"ContractPriceBidDate=\"" + _bstr_t(strDate.Format(dateFormat)) + "\" ";
			}

			if (pRisks->AskDate > DBL_EPSILON){
				strDate = COleDateTime(pRisks->AskDate);
				bstrXPath += L"ContractPriceAskDate=\"" + _bstr_t(strDate.Format(dateFormat)) + "\" "; 
			}

			if (pRisks->LastDate > DBL_EPSILON){
				strDate = COleDateTime(pRisks->LastDate);
				bstrXPath += L"ContractPriceLastDate=\"" + _bstr_t(strDate.Format(dateFormat)) + "\" ";
			}

			if (pRisks->UpdateDate > DBL_EPSILON){
				strDate = COleDateTime(pRisks->UpdateDate);
				bstrXPath += L"AnalyticsTimestamp=\"" +	_bstr_t(strDate.Format(dateFormat)) + "\" ";
			}

		bstrXPath += L" /></root>";

		return bstrXPath.Detach();
	}
	return L"";
};