void CTestObjectManager::GetObjectHandlesL(
        const TMTPObjectMgrQueryParams& aParams,
        RMTPObjectMgrQueryContext& aContext, RArray<TUint>& aHandles ) const
    {
    CleanupClosePushL( aHandles ); 
    PRINTF3( ">CTestObjectManager::GetObjectHandlesL storage = 0x%x parent = 0x%x format = 0x%x", aParams.iStorageId, aParams.iParentHandle, aParams.iFormatCode );
    for ( TInt i = 0; i < iMTPObjects.Count(); i++ )
         {
         TUint handle = iMTPObjects[i]->Uint( CMTPObjectMetaData::EHandle );
         TUint formatCode = iMTPObjects[i]->Uint( CMTPObjectMetaData::EFormatCode );
         TUint storageId = iMTPObjects[i]->Uint( CMTPObjectMetaData::EStorageId );
         TInt parentId = iMTPObjects[i]->Int( CMTPObjectMetaData::EParentId );
         if ( ( ( aParams.iStorageId == storageId   ) || ( aParams.iStorageId == KMTPStorageAll ) )
            &&
              ( ( aParams.iFormatCode == formatCode ) || ( aParams.iFormatCode == KMTPFormatsAll ) )
            &&
            ( ( aParams.iParentHandle == parentId ) || ( aParams.iParentHandle == KMTPHandleNone ) || ( ( aParams.iParentHandle == KMTPHandleNoParent ) && ( parentId == KErrNotFound ) ) ) )
             {
             PRINTV1( "Appending handle %d", handle );
             aHandles.AppendL( handle );
             }
         }
    aContext.Close();
    PRINTF0( "<CTestObjectManager::GetObjectHandlesL" );
    CleanupStack::Pop(); 
    }
Exemplo n.º 2
0
int main (int argc, char **argv)
{
    STATIC int w, h, bit_num;
    STATIC unsigned char byte_acc;
    STATIC int i;
	 STATIC int iter = 50;
    STATIC double x, y;
    STATIC double Zr, Zi, Cr, Ci, Tr, Ti;
    STATIC double limit = 2.0;

#ifdef COMMAND
    w = argc > 1 ? atoi(argv[1]) : 60;
	 h = argc > 2 ? atoi(argv[2]) : w;
#else
    w = h = 60;
#endif

    PRINTF3("P4\n%d %d\n",w,h);

TIMER_START();

    for(y=0;y<h;++y) 
    {
        for(x=0;x<w;++x)
        {
            Zr = Zi = Tr = Ti = 0.0;
            Cr = (2.0*x/w - 1.5); Ci=(2.0*y/h - 1.0);
        
            for (i=0;i<iter && (Tr+Ti <= limit*limit);++i)
            {
                Zi = 2.0*Zr*Zi + Ci;
                Zr = Tr - Ti + Cr;
                Tr = Zr * Zr;
                Ti = Zi * Zi;
            }
       
            byte_acc <<= 1; 
            if(Tr+Ti <= limit*limit) byte_acc |= 0x01;
                
            ++bit_num; 

            if(bit_num == 8)
            {
                PUTC(byte_acc,stdout);
                byte_acc = 0;
                bit_num = 0;
            }
            else if(x == w-1)
            {
                byte_acc <<= (8-w%8);
                PUTC(byte_acc,stdout);
                byte_acc = 0;
                bit_num = 0;
            }
        }
    }

TIMER_STOP();
}
Exemplo n.º 3
0
void Adapt_AM_TreeNode::iterate_setHelperMatrices_1()
{
  if(childLeft != NULL && childRight != NULL)
  {
    PRINTF3("%p  %p\n",childLeft,childRight);
    childLeft->iterate_setHelperMatrices_1();
    childRight->iterate_setHelperMatrices_1();
  }
  else if(parent != NULL)
  {
    for(int i=0;i<AUGMENTED_MATRIX_SIZE;i++)
    {
      parent->AUGMENTED_ALL[i] += AUGMENTED_ALL[i];
    }    
  }
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
#ifdef COMMAND
    int n = argc > 1 ? atoi(argv[1]) : 7;
#else
    int n = 7;
#endif

    if (n > N_MAX) n = N_MAX;

TIMER_START();

    PRINTF3("Pfannkuchen(%d) = %d\n", n, fannkuchredux(n));

TIMER_STOP();

    return 0;
}
Exemplo n.º 5
0
Arquivo: fasta.c Projeto: z88dk/z88dk
void makeRandomFasta (char * id, char * desc, struct aminoacids * genelist, int count, int n) {
   STATIC int i, m;
#ifdef STATIC
   static int todo;
   static char pick[LINE_LENGTH+1];
   todo = n;
#else
   int todo = n;
   char pick[LINE_LENGTH+1];
#endif

   PRINTF3(">%s %s\n", id, desc);

   for (; todo > 0; todo -= LINE_LENGTH) {
       if (todo < LINE_LENGTH) m = todo; else m = LINE_LENGTH;
       for (i=0; i < m; i++) pick[i] = selectRandom(genelist, count);
       pick[m] = '\0';
       PUTS(pick);
   }
}
TUint CTestObjectManager::CountL( const TMTPObjectMgrQueryParams& aParams ) const
    {
    PRINTF3( ">CTestObjectManager::CountL storage = 0x%x parent = 0x%x format = 0x%x", aParams.iStorageId, aParams.iParentHandle, aParams.iFormatCode );
    TUint count = 0;
    for ( TInt i = 0; i < iMTPObjects.Count(); i++ )
         {
         TUint handle = iMTPObjects[i]->Uint( CMTPObjectMetaData::EHandle );
         TUint formatCode = iMTPObjects[i]->Uint( CMTPObjectMetaData::EFormatCode );
         TUint storageId = iMTPObjects[i]->Uint( CMTPObjectMetaData::EStorageId );
         TInt parentId = iMTPObjects[i]->Int( CMTPObjectMetaData::EParentId );
         if ( ( ( aParams.iStorageId == storageId   ) || ( aParams.iStorageId == KMTPStorageAll ) )
            &&
              ( ( aParams.iFormatCode == formatCode ) || ( aParams.iFormatCode == KMTPFormatsAll ) )
            &&
              ( ( aParams.iParentHandle == parentId ) || ( aParams.iParentHandle == KMTPHandleNone ) || ( ( aParams.iParentHandle == KMTPHandleNoParent ) && ( parentId == KErrNotFound ) ) ) )
             {
             PRINTV1( "Adding handle %d to count", handle );
             count++;
             }
         }
    PRINTF1( "<CTestObjectManager::CountL, count = %d", count );
    return count;
    }
Exemplo n.º 7
0
Arquivo: fasta.c Projeto: z88dk/z88dk
void makeRepeatFasta (char * id, char * desc, char *s, int n) {
   STATIC char * ss;
   STATIC int m;
#ifdef STATIC
   static int k;
   static int todo;
   static int kn;
   
   k = 0;
   todo = n;
   kn = strlen(s);
#else
   int k = 0, todo = n, kn = strlen(s);
#endif

   ss = (char *) malloc (kn + 1);
   memcpy (ss, s, kn+1);

   PRINTF3(">%s %s\n", id, desc);

   for (; todo > 0; todo -= LINE_LENGTH) {
       if (todo < LINE_LENGTH) m = todo; else m = LINE_LENGTH;

       while (m >= kn - k) {
           PRINTF2("%s", s+k);
           m -= kn - k;
           k = 0;
       }

       ss[k + m] = '\0';
       PUTS(ss+k);
       ss[k + m] = s[m+k];
       k += m;
   }

   free (ss);
}
void CTestObjectManager::GetObjectSuidsL( 
        const TMTPObjectMgrQueryParams& aParams,
        RMTPObjectMgrQueryContext& aContext, CDesCArray& aSuids ) const
    {
    PRINTF3( ">CTestObjectManager::GetObjectSuidsL storage = 0x%x parent = 0x%x format = 0x%x", aParams.iStorageId, aParams.iParentHandle, aParams.iFormatCode );
    for ( TInt i = 0; i < iMTPObjects.Count(); i++ )
         {
         TPtrC suid = iMTPObjects[i]->DesC( CMTPObjectMetaData::ESuid );
         TUint formatCode = iMTPObjects[i]->Uint( CMTPObjectMetaData::EFormatCode );
         TUint storageId = iMTPObjects[i]->Uint( CMTPObjectMetaData::EStorageId );
         TInt parentId = iMTPObjects[i]->Int( CMTPObjectMetaData::EParentId );
         if ( ( ( aParams.iStorageId == storageId   ) || ( aParams.iStorageId == KMTPStorageAll ) )
            &&
              ( ( aParams.iFormatCode == formatCode ) || ( aParams.iFormatCode == KMTPFormatsAll ) )
            &&
            ( ( aParams.iParentHandle == parentId ) || ( aParams.iParentHandle == KMTPHandleNone ) || ( ( aParams.iParentHandle == KMTPHandleNoParent ) && ( parentId == KErrNotFound ) ) ) )
             {
             PRINTV1( "Appending suid %S", &suid );
             aSuids.AppendL( suid );
             }
         }
    aContext.Close();
    PRINTF0( "<CTestObjectManager::GetObjectSuidsL" );
    }
Exemplo n.º 9
0
tEplKernel PUBLIC AppCbEvent(
    tEplApiEventType        EventType_p,   // IN: event type (enum)
    tEplApiEventArg*        pEventArg_p,   // IN: event argument (union)
    void GENERIC*           pUserArg_p)
{
	tEplKernel          EplRet = kEplSuccessful;

    // check if NMT_GS_OFF is reached
    switch (EventType_p)
    {
        case kEplApiEventNmtStateChange:
        {
            switch (pEventArg_p->m_NmtStateChange.m_NewNmtState)
            {
                case kEplNmtGsOff:
                {   // NMT state machine was shut down,
                    // because of critical EPL stack error
                    // -> also shut down EplApiProcess() and main()
                    EplRet = kEplShutdown;
                    fShutdown_l = TRUE;

                    PRINTF2("%s(kEplNmtGsOff) originating event = 0x%X\n", __func__, pEventArg_p->m_NmtStateChange.m_NmtEvent);
                    break;
                }

                case kEplNmtGsInitialising:
                case kEplNmtGsResetApplication:
                case kEplNmtGsResetConfiguration:
                case kEplNmtCsPreOperational1:
                case kEplNmtCsBasicEthernet:
                case kEplNmtMsBasicEthernet:
                {
                    PRINTF3("%s(0x%X) originating event = 0x%X\n",
                            __func__,
                            pEventArg_p->m_NmtStateChange.m_NewNmtState,
                            pEventArg_p->m_NmtStateChange.m_NmtEvent);
                    break;
                }

                case kEplNmtGsResetCommunication:
                {
                BYTE    bNodeId = 0xF0;
                DWORD   dwNodeAssignment = EPL_NODEASSIGN_NODE_EXISTS;
                WORD    wPresPayloadLimit = 256;

                    PRINTF3("%s(0x%X) originating event = 0x%X\n",
                            __func__,
                            pEventArg_p->m_NmtStateChange.m_NewNmtState,
                            pEventArg_p->m_NmtStateChange.m_NmtEvent);

                    EplRet = EplApiWriteLocalObject(0x1F81, bNodeId, &dwNodeAssignment, sizeof (dwNodeAssignment));
                    if (EplRet != kEplSuccessful)
                    {
                        goto Exit;
                    }

                    bNodeId = 0x04;
                    EplRet = EplApiWriteLocalObject(0x1F81, bNodeId, &dwNodeAssignment, sizeof (dwNodeAssignment));
                    if (EplRet != kEplSuccessful)
                    {
                        goto Exit;
                    }

                    EplRet = EplApiWriteLocalObject(0x1F8D, bNodeId, &wPresPayloadLimit, sizeof (wPresPayloadLimit));
                    if (EplRet != kEplSuccessful)
                    {
                        goto Exit;
                    }

                    break;
                }

                case kEplNmtMsNotActive:
                    break;
                case kEplNmtCsNotActive:
                    break;
                    break;

                case kEplNmtCsOperational:
                    break;
                case kEplNmtMsOperational:
                    break;

                default:
                {
                    break;
                }
            }

            break;
        }

        case kEplApiEventCriticalError:
        case kEplApiEventWarning:
        {   // error or warning occurred within the stack or the application
            // on error the API layer stops the NMT state machine
            PRINTF3("%s(Err/Warn): Source=%02X EplError=0x%03X",
                    __func__,
                    pEventArg_p->m_InternalError.m_EventSource,
                    pEventArg_p->m_InternalError.m_EplError);
            // check additional argument
            switch (pEventArg_p->m_InternalError.m_EventSource)
            {
                case kEplEventSourceEventk:
                case kEplEventSourceEventu:
                {   // error occurred within event processing
                    // either in kernel or in user part
                    PRINTF1(" OrgSource=%02X\n", pEventArg_p->m_InternalError.m_Arg.m_EventSource);
                    break;
                }

                case kEplEventSourceDllk:
                {   // error occurred within the data link layer (e.g. interrupt processing)
                    // the DWORD argument contains the DLL state and the NMT event
                    PRINTF1(" val=%lX\n", pEventArg_p->m_InternalError.m_Arg.m_dwArg);
                    break;
                }

                default:
                {
                    PRINTF0("\n");
                    break;
                }
            }
            break;
        }

        case kEplApiEventHistoryEntry:
        {   // new history entry

            PRINTF("%s(HistoryEntry): Type=0x%04X Code=0x%04X (0x%02X %02X %02X %02X %02X %02X %02X %02X)\n",
                    __func__,
                    pEventArg_p->m_ErrHistoryEntry.m_wEntryType,
                    pEventArg_p->m_ErrHistoryEntry.m_wErrorCode,
                    (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[0],
                    (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[1],
                    (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[2],
                    (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[3],
                    (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[4],
                    (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[5],
                    (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[6],
                    (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[7]);
            break;
        }

        case kEplApiEventLed:
        {   // status or error LED shall be changed

            switch (pEventArg_p->m_Led.m_LedType)
            {
#ifdef LED_STATUS_PIO_BASE
                case kEplLedTypeStatus:
                {
                    if (pEventArg_p->m_Led.m_fOn != FALSE)
                    {
                        IOWR_ALTERA_AVALON_PIO_DATA(LED_STATUS_PIO_BASE, 1);
                    }
                    else
                    {
                        IOWR_ALTERA_AVALON_PIO_DATA(LED_STATUS_PIO_BASE, 0);
                    }
                    break;
                }
#endif
#ifdef LED_ERROR_PIO_BASE
                case kEplLedTypeError:
                {
                    if (pEventArg_p->m_Led.m_fOn != FALSE)
                    {
                        IOWR_ALTERA_AVALON_PIO_DATA(LED_ERROR_PIO_BASE, 1);
                    }
                    else
                    {
                        IOWR_ALTERA_AVALON_PIO_DATA(LED_ERROR_PIO_BASE, 0);
                    }
                    break;
                }
#endif
                default:
                    break;
            }
            break;
        }

        default:
            break;
    }

Exit:
    return EplRet;
}