Exemple #1
0
void
TimerTicksInit()
{
    Time tmp;

#ifndef FLOATING_POINT_CONVERT
    /*
     * Initailized values used by counter conversion routines.
     */
    {
        double	intPart, modf();
        timeHigh.microseconds = (int)
                                ((ONE_SECOND * modf(TWO_TO_32/TIMER_FREQ,&intPart)) + 0.5);
        timeHigh.seconds = (int) intPart;
        maxMicrosecondMutiple = (unsigned int)(TWO_TO_32/timeHigh.microseconds);
        secondsPerMicrosecondMultiple = (unsigned int) (TWO_TO_32/ONE_SECOND);
    }
#endif
    ConvertIntToTime((unsigned int) 0xFFFFFFFF, &timer_MaxIntervalTime);

    tmp.seconds = 1;
    tmp.microseconds = 0;
    ConvertTimeToInt(tmp, &timer_IntOneSecond);

    tmp.seconds = 0;
    tmp.microseconds = 1000;
    ConvertTimeToInt(tmp, &timer_IntOneMillisecond);

    timer_IntZeroSeconds	= 0;
    timer_IntOneMinute		= timer_IntOneSecond * 60;
    timer_IntOneHour		= timer_IntOneSecond * 3600;



}
Exemple #2
0
void
TimerTicksInit()
{
    Time tmp;

    ConvertIntToTime((unsigned int) 0xFFFFFFFF, &timer_MaxIntervalTime);

    tmp.seconds = 1;
    tmp.microseconds = 0;
    ConvertTimeToInt(tmp, &timer_IntOneSecond);

    tmp.seconds = 0;
    tmp.microseconds = 1000;
    ConvertTimeToInt(tmp, &timer_IntOneMillisecond);

    timer_IntZeroSeconds	= 0;
    timer_IntOneMinute		= timer_IntOneSecond * 60;
    timer_IntOneHour		= timer_IntOneSecond * 3600;

    bzero((Address)&timer_TicksZeroSeconds, sizeof(timer_TicksZeroSeconds));
}
int  TTrdItf_DDABOSS::QryCurTrd()
{
    if (FFix == NULL) return -1;

    char buffer[512];
    char temp[20];
    int  nResult;

		FDll.FixCreate(FFix, FUNC_JY_FBCJCX);
		FDll.FixSet(FFix, FID_KHH,  FKHH);
		if( FRequest.QryCurTrd.OrderID[0] != 0 )
		{
			FDll.FixSet(FFix, FID_WTH,  FRequest.QryCurTrd.OrderID);
    }
		if (FDll.FixWrite(FFix) < 0){SetError(); return -2;}

		TList * lstAns = new TList();
    try
    {
        while (1)
        {
            nResult = FDll.FixReadEx(FFix, 1000);
            FDll.FixGetBuffer(FFix, buffer, sizeof(buffer)-1);
            if (nResult <= 0) break;
            if (FDll.FixGetRecNo(FFix) < 0) break;

            TTradeInfo *ti = new TTradeInfo;
            memset(ti, 0, sizeof(TTradeInfo));

						strncpy(ti->SecuID,   FDll.FixGet(FFix, FID_ZQDM, buffer, 0), CODE_LEN);
						strncpy(ti->ContractID ,FDll.FixGet(FFix,FID_WTH,buffer,0),SEQ_LEN);
						strncpy(ti->TrdID, FDll.FixGet(FFix, FID_CJBH, buffer, 0), SEQ_LEN);
						ti->Time = ConvertTimeToInt(FDll.FixGet(FFix, FID_CJSJ,   buffer, 0));
						ti->Date = ConvertDateToInt(FDll.FixGet(FFix, FID_RQ,   buffer, 0));
						ti->Type = ConvertOrderType(FDll.FixGet(FFix, FID_WTLB, buffer, 0));
						ti->Market = ConvertMarketType(FDll.FixGet(FFix, FID_JYS, buffer, 0));

						ti->Vol   = FDll.FixGetInt(FFix, FID_CJSL);
						FDll.FixGet(FFix,FID_CXBZ,buffer,0);
						if( buffer[0] == 'W' ) ti->Vol = -abs(ti->Vol);
						ti->Price = FDll.FixGetDouble(FFix, FID_CJJG);
						strncpy(ti->Account ,
							FDll.FixGet(FFix,FID_GDH,buffer,0),sizeof(ti->Account));

            lstAns->Add(ti);
        }

        if (lstAns->Count > 0)
        {
            NewAns(lstAns->Count);
            for (int i = 0; i < lstAns->Count; i++)
            {
                TTradeInfo *ti = (TTradeInfo *)lstAns->Items[i];
                memcpy(&(*FAnswer)[i].QryCurTrd.TrdInfo, ti, sizeof(TTradeInfo));
            }
        }

        for (int i = 0; i < lstAns->Count; i++)
        {
            TTradeInfo *ti = (TTradeInfo *)lstAns->Items[i];
            delete ti;
        }
        lstAns->Clear();
    }
    __finally
    {
        delete lstAns;
    }

    return 0;

}
/*
int  TTrdItf_DDABOSS::QryDetail()
{
    if(FRequest.QryDetail.ContractID[0]==0) return -1;
    if (FFix == NULL) return -1;

    char buffer[512];
    FDll.FixCreate(FFix, 14100);
		FDll.FixSet(FFix, FID_WTH,  FRequest.QryDetail.ContractID);
    int nResult = FDll.FixWrite(FFix);
    if (nResult >= 0)
    {
				nResult = FDll.FixReadEx(FFix, 1000);
        FDll.FixGetBuffer(FFix, buffer, sizeof(buffer)-1);
        if (nResult > 0)
        {
            NewAns(1);
            (*FAnswer)[0].QryDetail.Num   = FDll.FixGetInt(FFix, FID_CJSL);
            (*FAnswer)[0].QryDetail.Price = FDll.FixGetDouble(FFix, FID_CJJG);
            (*FAnswer)[0].QryDetail.UndoNum = -FDll.FixGetInt(FFix, FID_CDSL);
        }
        else
        {
            return -3;
        }
    }
    else
    {
        return -2;
    }

    return 0;
}
*/
int  TTrdItf_DDABOSS::QryCurCsn()
{
    if (FFix == NULL) return -1;

    char buffer[512];
    int  nResult;

    FDll.FixCreate(FFix, FUNC_JY_DRWTCX);
		FDll.FixSet(FFix, FID_KHH,  FKHH);
		if( FRequest.QryCurCsn.OrderID[0] != 0 )
		{
			FDll.FixSet(FFix, FID_WTH,  FRequest.QryCurCsn.OrderID);
		}
		if (FDll.FixWrite(FFix) < 0)
		{
			SetError();
			return -2;
		}

    TList * lstAns = new TList();
    try
    {
        while (1)
        {
            nResult = FDll.FixReadEx(FFix, 1000);
            FDll.FixGetBuffer(FFix, buffer, sizeof(buffer)-1);
            if (nResult <= 0) break;
            if (FDll.FixGetRecNo(FFix) < 0) break;

						TOrderInfo *ci = new TOrderInfo;
						memset(ci, 0, sizeof(TOrderInfo));

						lstrcpyn(ci->ContractID,
							FDll.FixGet(FFix, FID_WTH,  buffer, 0), sizeof(ci->ContractID));
						lstrcpyn(ci->SecuID,
							FDll.FixGet(FFix, FID_ZQDM, buffer, 0), sizeof(ci->SecuID));
						ci->Market = ConvertMarketType( FDll.FixGet(FFix,FID_JYS,buffer,0));
						ci->Time = ConvertTimeToInt( FDll.FixGet(FFix, FID_WTSJ,   buffer, 0));
						ci->Date = ConvertDateToInt( FDll.FixGet(FFix, FID_RQ,   buffer, 0));
						ci->Type = ConvertOrderType( FDll.FixGet(FFix, FID_WTLB,   buffer, 0));
						//ci->State= ConvertOrderState(FDll.FixGet(FFix, FID_SBJG, buffer,0));
						ci->State= ConvertOrderState(FDll.FixGet(FFix, FID_SBJGSM, buffer,0));
						ci->CsnVol    = FDll.FixGetInt(FFix, FID_WTSL);
            ci->TrdVol    = FDll.FixGetInt(FFix, FID_CJSL);
            ci->CancelVol = FDll.FixGetInt(FFix, FID_CDSL);
            ci->CsnPrice  = FDll.FixGetDouble(FFix, FID_WTJG);
            ci->TrdPrice  = FDll.FixGetDouble(FFix, FID_CJJG);
						lstrcpyn(ci->Account,
							FDll.FixGet(FFix, FID_GDH, buffer, 0), sizeof(ci->Account));
            lstAns->Add(ci);
        }

        if (lstAns->Count > 0)
        {
            NewAns(lstAns->Count);
            for (int i = 0; i < lstAns->Count; i++)
            {
								TOrderInfo *ci = (TOrderInfo *)lstAns->Items[i];
                memcpy(&(*FAnswer)[i].QryCurCsn.OrderInfo, ci, sizeof(TOrderInfo));
            }
        }

        for (int i = 0; i < lstAns->Count; i++)
        {
						TOrderInfo *ci = (TOrderInfo *)lstAns->Items[i];
            delete ci;
        }
        lstAns->Clear();
    }
    __finally
    {
        delete lstAns;
    }

    return 0;
}