Ejemplo n.º 1
0
// constructor
static DigitalOutputPin* NAMESPACE(getDigitalOutputPin)() {
#ifdef HAS_ANALOG_INTERFACE
	NAMESPACE(ANSELx).ANSxx = 0;
#endif
	NAMESPACE(GPIOPin_setDirection)(true);
	return &NAMESPACE(digitalOutputPin);
}
Ejemplo n.º 2
0
// --------------------------------------------------------------------
// DigitalPin
// --------------------------------------------------------------------
static bool NAMESPACE(DigitalPin_getValue)() {
	if (NAMESPACE(TRISx).TRISxx == 1) {
		return NAMESPACE(DigitalInputPin_getValue)();
	} else {
		return NAMESPACE(DigitalOutputPin_getValue)();
	}
}
// field methods
static void NAMESPACE(setPeriodCount)(uint16_t periodCount) {
#ifdef IS_16BIT_TIMER
	NAMESPACE(periodCount) = periodCount;
#elif defined IS_8BIT_TIMER
	NAMESPACE(PRx) = periodCount;
#endif
}
Ejemplo n.º 4
0
static void NAMESPACE(onReceived)(uint8_t data) {
	// 受信データをバッファに格納
	NAMESPACE(receiveBuffer)[NAMESPACE(receiveBufferIndex)] = data;
	// インデックスを1増やす
	NAMESPACE(receiveBufferIndex) = (NAMESPACE(receiveBufferIndex) + 1) & BUF_SIZE_LIMIT_MASK;
	// 読み出し可能数を1増やす
	NAMESPACE(availableReadCounter)++;
}
// constructor
static PeriodicInterruptController* NAMESPACE(getPeriodicInterruptController)() {
#ifdef IS_16BIT_TIMER
	NAMESPACE(periodCount) = 0xFFFF;
#elif defined IS_8BIT_TIMER
	NAMESPACE(PRx) = 0xFF;
#endif
	return &NAMESPACE(periodicInterruptController);
}
void NAMESPACE(handleInterrupt)() {
	if (NAMESPACE(PIEx).TMRx(IE) == 1 && NAMESPACE(PIRx).TMRx(IF) == 1) {
		// 次回割り込みまでのカウント数を取得する
		uint16_t nextPeriodCount;
		// リスナ呼び出し
		for (int8_t index = 0; index < NAMESPACE(numOfListener); index++) {
			nextPeriodCount = NAMESPACE(listener)[index]->onInterrupt();
		}
		// 次回割り込みが指定した値になるようにする
#ifdef IS_16BIT_TIMER
		if (nextPeriodCount == 0) {
			nextPeriodCount = NAMESPACE(periodCount);
		} else {
			NAMESPACE(periodCount) = nextPeriodCount;
		}
		if (nextPeriodCount != 0xFFFF) {
			NAMESPACE(setCount)(nextPeriodCount);
		}
#elif defined IS_8BIT_TIMER
		if (nextPeriodCount == 0) {
			// do nothing
		} else {
			NAMESPACE(setPeriodCount)(nextPeriodCount);
		}
#endif
		// フラグはタイマの値を書き換えたあとにクリアする
		NAMESPACE(PIRx).TMRx(IF) = 0;
	}
}
static void NAMESPACE(setCount)(uint16_t count) {
	// 書き込み順はH->Lとすること(16bit mode)
	uint8_t tmrl = count;
	uint8_t tmrh = count >> 8;
	NAMESPACE(TMRxH).TMRx(H) = tmrl;
	NAMESPACE(TMRxL).TMRx(L) = tmrh;
	if (count == 0) {
		TMR5Hbits.TMR5H = 0;
		TMR5Lbits.TMR5L = 0;
	}
}
Ejemplo n.º 8
0
static uint8_t NAMESPACE(read)() {
	// 読み出すものがない場合は0を返す
	if (NAMESPACE(availableReadCounter == 0)) {
		return 0;
	}
	uint8_t data = NAMESPACE(receiveBuffer)[
		(NAMESPACE(receiveBufferIndex) - NAMESPACE(availableReadCounter))
		& BUF_SIZE_LIMIT_MASK];
	// 読み出し可能数を1減らす
	NAMESPACE(availableReadCounter)--;
	return data;
}
Ejemplo n.º 9
0
static uint8_t NAMESPACE(onTransmitted)() {
	// 送信するものがない場合は0を返す
	if (NAMESPACE(stillTransmittingCounter) == 0) {
		return 0;
	}
	// バッファポインタが示すデータを見る
	uint8_t nextData = NAMESPACE(transmitBuffer)[
		(NAMESPACE(transmitBufferIndex) - NAMESPACE(stillTransmittingCounter))
		& BUF_SIZE_LIMIT_MASK];
	// 未送信数を1つ減らす
	NAMESPACE(stillTransmittingCounter)--;
	// 0以外なら送信が続けられ,0なら送信をやめて送信割り込みを無効にする
	return nextData;
}
Ejemplo n.º 10
0
     /* Generated */ TA_RetCode TA_S_APO( int    startIdx,
                                          /* Generated */                      int    endIdx,
                                          /* Generated */                      const float  inReal[],
                                          /* Generated */                      int           optInFastPeriod, /* From 2 to 100000 */
                                          /* Generated */                      int           optInSlowPeriod, /* From 2 to 100000 */
                                          /* Generated */                      TA_MAType     optInMAType,
                                          /* Generated */                      int          *outBegIdx,
                                          /* Generated */                      int          *outNbElement,
                                          /* Generated */                      double        outReal[] )
     /* Generated */ #endif
     /* Generated */ {
     /* Generated */    ARRAY_REF(tempBuffer);
     /* Generated */    TA_RetCode retCode;
     /* Generated */  #ifndef TA_FUNC_NO_RANGE_CHECK
     /* Generated */     if( startIdx < 0 )
         /* Generated */        return NAMESPACE(TA_RetCode)TA_OUT_OF_RANGE_START_INDEX;
     /* Generated */     if( (endIdx < 0) || (endIdx < startIdx))
         /* Generated */        return NAMESPACE(TA_RetCode)TA_OUT_OF_RANGE_END_INDEX;
     /* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
         /* Generated */     if( !inReal ) return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
     /* Generated */     #endif
     /* Generated */     if( (int)optInFastPeriod == TA_INTEGER_DEFAULT )
         /* Generated */        optInFastPeriod = 12;
     /* Generated */     else if( ((int)optInFastPeriod < 2) || ((int)optInFastPeriod > 100000) )
         /* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
     /* Generated */     if( (int)optInSlowPeriod == TA_INTEGER_DEFAULT )
         /* Generated */        optInSlowPeriod = 26;
     /* Generated */     else if( ((int)optInSlowPeriod < 2) || ((int)optInSlowPeriod > 100000) )
         /* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
     /* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
         /* Generated */     if( (int)optInMAType == TA_INTEGER_DEFAULT )
             /* Generated */        optInMAType = 0;
         /* Generated */     else if( ((int)optInMAType < 0) || ((int)optInMAType > 8) )
             /* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
     /* Generated */     #endif
     /* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
         /* Generated */     if( !outReal )
             /* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
     /* Generated */     #endif
     /* Generated */  #endif
     /* Generated */    ARRAY_ALLOC(tempBuffer, (endIdx-startIdx+1) );
     /* Generated */    #if !defined(_JAVA)
         /* Generated */       if( !tempBuffer )
             /* Generated */          return NAMESPACE(TA_RetCode)TA_ALLOC_ERR;
     /* Generated */    #endif
     /* Generated */    retCode = FUNCTION_CALL(INT_PO)( startIdx, endIdx,
     /* Generated */                                     inReal,
     /* Generated */                                     optInFastPeriod,
     /* Generated */                                     optInSlowPeriod,
     /* Generated */                                     optInMAType,
     /* Generated */                                     outBegIdx,
     /* Generated */                                     outNbElement,
     /* Generated */                                     outReal,
     /* Generated */                                     tempBuffer,
     /* Generated */                                     0  );
     /* Generated */    ARRAY_FREE( tempBuffer );
     /* Generated */    return retCode;
     /* Generated */
 }
Ejemplo n.º 11
0
static void NAMESPACE(write)(uint8_t data) {
	// SerialPortは0を送信できない仕様
	if (data == 0){
		return;
	}
	// バッファを変更している間に割り込みが起こらないようにする
	NAMESPACE(uart)->disableTXInterrupt();
	// 送信データをバッファに格納
	NAMESPACE(transmitBuffer)[NAMESPACE(transmitBufferIndex)] = data;
	// バッファポインタを1増やす
	NAMESPACE(transmitBufferIndex) = (NAMESPACE(transmitBufferIndex) + 1) & BUF_SIZE_LIMIT_MASK;
	// 未送信数を1増やす
	NAMESPACE(stillTransmittingCounter)++;
	// 送信割り込みを有効にする
	NAMESPACE(uart)->enableTXInterrupt();
}
static void NAMESPACE(enableInterrupt)(int priority) {
	switch ((Hardware_InterruptPriority)priority) {
		case LOW_PRIORITY:
			NAMESPACE(IPRx).TMRx(IP) = 0;
			break;
		case HIGH_PRIORITY:
			NAMESPACE(IPRx).TMRx(IP) = 1;
			break;
	}
#ifdef IS_16BIT_TIMER
	// 割り込みを有効にする前にTMRxL, TMRxH, TMRxIFはクリアしなければならない
	NAMESPACE(TMRxL).TMRx(L) = 0;
	NAMESPACE(TMRxH).TMRx(H) = 0;
#endif
	NAMESPACE(PIRx).TMRx(IF) = 0;
	NAMESPACE(PIEx).TMRx(IE) = 1;
}
Ejemplo n.º 13
0
GPIOPort* getPORTC() {
	return (GPIOPort*)&NAMESPACE(gpioPort);
}
Ejemplo n.º 14
0
     /* Generated */ TA_RetCode TA_PREFIX(INT_PO)( int    startIdx,
             /* Generated */                               int    endIdx,
             /* Generated */                               const INPUT_TYPE *inReal,
             /* Generated */                               int    optInFastPeriod,
             /* Generated */                               int    optInSlowPeriod,
             /* Generated */                               TA_MAType optInMethod_2,
             /* Generated */                               int   *outBegIdx,
             /* Generated */                               int   *outNbElement,
             /* Generated */                               double      *outReal,
             /* Generated */                               double      *tempBuffer,
             /* Generated */                               int  doPercentageOutput )
     /* Generated */ #endif
     /* Generated */ {
     /* Generated */    TA_RetCode retCode;
     /* Generated */    double tempReal;
     /* Generated */    int tempInteger;
     /* Generated */    VALUE_HANDLE_INT(outBegIdx1);
     /* Generated */    VALUE_HANDLE_INT(outNbElement1);
     /* Generated */    VALUE_HANDLE_INT(outBegIdx2);
     /* Generated */    VALUE_HANDLE_INT(outNbElement2);
     /* Generated */    int i, j;
     /* Generated */    if( optInSlowPeriod < optInFastPeriod )
         /* Generated */    {
         /* Generated */        tempInteger     = optInSlowPeriod;
         /* Generated */        optInSlowPeriod = optInFastPeriod;
         /* Generated */        optInFastPeriod = tempInteger;
         /* Generated */
     }
     /* Generated */    retCode = FUNCTION_CALL(MA)( startIdx, endIdx,
     /* Generated */                                 inReal,
     /* Generated */                                 optInFastPeriod,
     /* Generated */                                 optInMethod_2,
     /* Generated */                                 VALUE_HANDLE_OUT(outBegIdx2), VALUE_HANDLE_OUT(outNbElement2),
     /* Generated */ 							    tempBuffer );
     /* Generated */    if( retCode == NAMESPACE(TA_RetCode)TA_SUCCESS )
         /* Generated */    {
         /* Generated */       retCode = FUNCTION_CALL(MA)( startIdx, endIdx,
         /* Generated */                                    inReal,
         /* Generated */                                    optInSlowPeriod,
         /* Generated */                                    optInMethod_2,
         /* Generated */                                    VALUE_HANDLE_OUT(outBegIdx1), VALUE_HANDLE_OUT(outNbElement1),
         /* Generated */ 							       outReal );
         /* Generated */       if( retCode == NAMESPACE(TA_RetCode)TA_SUCCESS )
             /* Generated */       {
             /* Generated */          tempInteger = VALUE_HANDLE_GET(outBegIdx1) - VALUE_HANDLE_GET(outBegIdx2);
             /* Generated */          if( doPercentageOutput != 0 )
                 /* Generated */          {
                 /* Generated */             for( i=0,j=tempInteger; i < VALUE_HANDLE_GET(outNbElement1); i++, j++ )
                     /* Generated */             {
                     /* Generated */                tempReal = outReal[i];
                     /* Generated */                if( !TA_IS_ZERO(tempReal) )
                         /* Generated */                   outReal[i] = ((tempBuffer[j]-tempReal)/tempReal)*100.0;
                     /* Generated */                else
                         /* Generated */                   outReal[i] = 0.0;
                     /* Generated */
                 }
                 /* Generated */
             }
             /* Generated */          else
                 /* Generated */          {
                 /* Generated */             for( i=0,j=tempInteger; i < VALUE_HANDLE_GET(outNbElement1); i++, j++ )
                     /* Generated */                outReal[i] = tempBuffer[j]-outReal[i];
                 /* Generated */
             }
             /* Generated */          VALUE_HANDLE_DEREF(outBegIdx)     = VALUE_HANDLE_GET(outBegIdx1);
             /* Generated */          VALUE_HANDLE_DEREF(outNbElement)  = VALUE_HANDLE_GET(outNbElement1);
             /* Generated */
         }
         /* Generated */
     }
     /* Generated */    if( retCode != NAMESPACE(TA_RetCode)TA_SUCCESS )
         /* Generated */    {
         /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
         /* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outNbElement);
         /* Generated */
     }
     /* Generated */    return retCode;
     /* Generated */
 }
Ejemplo n.º 15
0
/* Generated */ TA_RetCode TA_S_T3( int    startIdx,
/* Generated */                     int    endIdx,
/* Generated */                     const float  inReal[],
/* Generated */                     int           optInTimePeriod, /* From 2 to 100000 */
/* Generated */                     double        optInVFactor, /* From 0 to 1 */
/* Generated */                     int          *outBegIdx,
/* Generated */                     int          *outNbElement,
/* Generated */                     double        outReal[] )
/* Generated */ #endif
/* Generated */ {
/* Generated */    int outIdx, lookbackTotal;
/* Generated */    int today, i;
/* Generated */    double k, one_minus_k;
/* Generated */    double e1, e2, e3, e4, e5, e6;
/* Generated */    double c1, c2, c3, c4;
/* Generated */    double tempReal;
/* Generated */  #ifndef TA_FUNC_NO_RANGE_CHECK
/* Generated */     if( startIdx < 0 )
/* Generated */        return NAMESPACE(TA_RetCode)TA_OUT_OF_RANGE_START_INDEX;
/* Generated */     if( (endIdx < 0) || (endIdx < startIdx))
/* Generated */        return NAMESPACE(TA_RetCode)TA_OUT_OF_RANGE_END_INDEX;
/* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
/* Generated */     if( !inReal ) return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     #endif 
/* Generated */     if( (int)optInTimePeriod == TA_INTEGER_DEFAULT )
/* Generated */        optInTimePeriod = 5;
/* Generated */     else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
/* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     if( optInVFactor == TA_REAL_DEFAULT )
/* Generated */        optInVFactor = 7.000000e-1;
/* Generated */     else if( (optInVFactor < 0.000000e+0) ||  (optInVFactor > 1.000000e+0) )
/* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
/* Generated */     if( !outReal )
/* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     #endif 
/* Generated */  #endif 
/* Generated */    lookbackTotal = 6 * (optInTimePeriod - 1) + TA_GLOBALS_UNSTABLE_PERIOD(TA_FUNC_UNST_T3);
/* Generated */    if( startIdx <= lookbackTotal )
/* Generated */       startIdx = lookbackTotal;
/* Generated */    if( startIdx > endIdx )
/* Generated */    {
/* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outNbElement);
/* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
/* Generated */       return NAMESPACE(TA_RetCode)TA_SUCCESS; 
/* Generated */    }
/* Generated */    VALUE_HANDLE_DEREF(outBegIdx) = startIdx;
/* Generated */    today = startIdx - lookbackTotal;
/* Generated */    k = 2.0/(optInTimePeriod+1.0);
/* Generated */    one_minus_k = 1.0-k;
/* Generated */    tempReal = inReal[today++];
/* Generated */    for( i=optInTimePeriod-1; i > 0 ; i-- ) 
/* Generated */       tempReal += inReal[today++];
/* Generated */    e1 = tempReal / optInTimePeriod;
/* Generated */    tempReal = e1;
/* Generated */    for( i=optInTimePeriod-1; i > 0 ; i-- ) 
/* Generated */    {
/* Generated */       e1 = (k*inReal[today++])+(one_minus_k*e1);
/* Generated */       tempReal += e1;
/* Generated */    }
/* Generated */    e2 = tempReal / optInTimePeriod;
/* Generated */    tempReal = e2;
/* Generated */    for( i=optInTimePeriod-1; i > 0 ; i-- ) 
/* Generated */    {
/* Generated */       e1  = (k*inReal[today++])+(one_minus_k*e1);
/* Generated */       e2  = (k*e1)+(one_minus_k*e2);
/* Generated */       tempReal += e2;
/* Generated */    }
/* Generated */    e3 = tempReal / optInTimePeriod;
/* Generated */    tempReal = e3;
/* Generated */    for( i=optInTimePeriod-1; i > 0 ; i-- ) 
/* Generated */    {
/* Generated */       e1  = (k*inReal[today++])+(one_minus_k*e1);
/* Generated */       e2  = (k*e1)+(one_minus_k*e2);
/* Generated */       e3  = (k*e2)+(one_minus_k*e3);
/* Generated */       tempReal += e3;
/* Generated */    }
/* Generated */    e4 = tempReal / optInTimePeriod;
/* Generated */    tempReal = e4;
/* Generated */    for( i=optInTimePeriod-1; i > 0 ; i-- ) 
/* Generated */    {
/* Generated */       e1  = (k*inReal[today++])+(one_minus_k*e1);
/* Generated */       e2  = (k*e1)+(one_minus_k*e2);
/* Generated */       e3  = (k*e2)+(one_minus_k*e3);
/* Generated */       e4  = (k*e3)+(one_minus_k*e4);
/* Generated */       tempReal += e4;
/* Generated */    }
/* Generated */    e5 = tempReal / optInTimePeriod;
/* Generated */    tempReal = e5;
/* Generated */    for( i=optInTimePeriod-1; i > 0 ; i-- ) 
/* Generated */    {
/* Generated */       e1  = (k*inReal[today++])+(one_minus_k*e1);
/* Generated */       e2  = (k*e1)+(one_minus_k*e2);
/* Generated */       e3  = (k*e2)+(one_minus_k*e3);
/* Generated */       e4  = (k*e3)+(one_minus_k*e4);
/* Generated */       e5  = (k*e4)+(one_minus_k*e5);
/* Generated */       tempReal += e5;
/* Generated */    }
/* Generated */    e6 = tempReal / optInTimePeriod;
/* Generated */    while( today <= startIdx )
/* Generated */    {
/* Generated */       e1  = (k*inReal[today++])+(one_minus_k*e1);
/* Generated */       e2  = (k*e1)+(one_minus_k*e2);
/* Generated */       e3  = (k*e2)+(one_minus_k*e3);
/* Generated */       e4  = (k*e3)+(one_minus_k*e4);
/* Generated */       e5  = (k*e4)+(one_minus_k*e5);
/* Generated */       e6  = (k*e5)+(one_minus_k*e6);
/* Generated */    }
/* Generated */    tempReal = optInVFactor * optInVFactor;
/* Generated */    c1 = -(tempReal * optInVFactor);
/* Generated */    c2 = 3.0 * (tempReal - c1);
/* Generated */    c3 = -6.0 * tempReal - 3.0 * (optInVFactor-c1);
/* Generated */    c4 = 1.0 + 3.0 * optInVFactor - c1 + 3.0 * tempReal;
/* Generated */    outIdx = 0;
/* Generated */   	outReal[outIdx++] = c1*e6+c2*e5+c3*e4+c4*e3;
/* Generated */    while( today <= endIdx )
/* Generated */    {
/* Generated */       e1  = (k*inReal[today++])+(one_minus_k*e1);
/* Generated */       e2  = (k*e1)+(one_minus_k*e2);
/* Generated */       e3  = (k*e2)+(one_minus_k*e3);
/* Generated */       e4  = (k*e3)+(one_minus_k*e4);
/* Generated */       e5  = (k*e4)+(one_minus_k*e5);
/* Generated */       e6  = (k*e5)+(one_minus_k*e6);
/* Generated */       outReal[outIdx++] = c1*e6+c2*e5+c3*e4+c4*e3;
/* Generated */    }
/* Generated */    VALUE_HANDLE_DEREF(outNbElement) = outIdx;
/* Generated */    return NAMESPACE(TA_RetCode)TA_SUCCESS;
/* Generated */ }
Ejemplo n.º 16
0
static DigitalPin* NAMESPACE(getDigitalPin)() {
#ifdef HAS_ANALOG_INTERFACE
	NAMESPACE(ANSELx).ANSxx = 0;
#endif
	return &NAMESPACE(digitalPin);
}
Ejemplo n.º 17
0
static void NAMESPACE(DigitalPin_setValue)(bool value) {
	NAMESPACE(LATx).LATxx = value;
}
TimerModule* NAMESPACE(getter)(EightBitTimer_Priscaler priscaler, EightBitTimer_Postscaler postscaler) {
	NAMESPACE(TxCON).Tx(CKPS) = priscaler;
	NAMESPACE(TxCON).Tx(OUTPS) = postscaler;
	return &NAMESPACE(timerModule);
}
static uint16_t NAMESPACE(getCount)() {
	// 読み込み順はL->Hとすること(16bit mode)
	uint8_t tmrl = NAMESPACE(TMRxL).TMRx(L);
	uint8_t tmrh = NAMESPACE(TMRxH).TMRx(H);
	return tmrl + ((uint16_t)tmrh << 8);
}
static CMPIStatus raise_indication(const CMPIBroker *broker,
                                   const CMPIContext *ctx,
                                   const CMPIObjectPath *ref,
                                   const CMPIInstance *ind)
{
        struct std_indication_ctx *_ctx = NULL;
        CMPIStatus s = {CMPI_RC_OK, NULL};
        struct ind_args *args = NULL;
        CMPIObjectPath *_ref = NULL;

        _ctx = malloc(sizeof(struct std_indication_ctx));
        if (_ctx == NULL) {
                cu_statusf(broker, &s,
                           CMPI_RC_ERR_FAILED,
                           "Unable to allocate indication context");
                goto out;
        }

        _ctx->brkr = broker;
        _ctx->handler = NULL;
        _ctx->filters = filters;
        _ctx->enabled = 1;

        args = malloc(sizeof(struct ind_args));
        if (args == NULL) {
                cu_statusf(broker, &s,
                           CMPI_RC_ERR_FAILED,
                           "Unable to allocate ind_args");
                goto out;
        }

        _ref = CMGetObjectPath(ind, &s);
        if (_ref == NULL) {
                cu_statusf(broker, &s,
                           CMPI_RC_ERR_FAILED,
                           "Got a null object path");
                goto out;
        }

        /* FIXME:  This is a Pegasus work around. Pegsus loses the namespace
                   when an ObjectPath is pulled from an instance */


        CMSetNameSpace(_ref, "root/virt");
        args->ns = strdup(NAMESPACE(_ref));
        args->classname = strdup(CLASSNAME(_ref));
        args->_ctx = _ctx;

        /* This is a workaround for Pegasus, it loses its objectpath by
           CMGetObjectPath. So set it back. */
        ind->ft->setObjectPath((CMPIInstance *)ind, _ref);

        s = stdi_deliver(broker, ctx, args, (CMPIInstance *)ind);
        if (s.rc == CMPI_RC_OK) {
                CU_DEBUG("Indication delivered");
        } else {
                if (s.msg == NULL) {
                        CU_DEBUG("Not delivered: msg is NULL.");
                } else {
                        CU_DEBUG("Not delivered: %s", CMGetCharPtr(s.msg));
                }
        }

 out:
        if (args != NULL)
                stdi_free_ind_args(&args);

        if (_ctx != NULL)
                free(_ctx);

        return s;
}
// --------------------------------------------------------------------
// TimerModule
// --------------------------------------------------------------------
static void NAMESPACE(start)() {
	NAMESPACE(TxCON).TMRx(ON) = 1;
}
	// 割り込みを有効にする前にTMRxL, TMRxH, TMRxIFはクリアしなければならない
	NAMESPACE(TMRxL).TMRx(L) = 0;
	NAMESPACE(TMRxH).TMRx(H) = 0;
#endif
	NAMESPACE(PIRx).TMRx(IF) = 0;
	NAMESPACE(PIEx).TMRx(IE) = 1;
}

static void NAMESPACE(disableInterrupt)() {
	NAMESPACE(PIEx).TMRx(IE) = 0;
	NAMESPACE(PIRx).TMRx(IF) = 0;
}

// substance of interface
static PeriodicInterruptController NAMESPACE(periodicInterruptController) = {
	NAMESPACE(setPeriodCount),
	NAMESPACE(addInterruptListener),
	NAMESPACE(enableInterrupt),
	NAMESPACE(disableInterrupt),
};

// constructor
static PeriodicInterruptController* NAMESPACE(getPeriodicInterruptController)() {
#ifdef IS_16BIT_TIMER
	NAMESPACE(periodCount) = 0xFFFF;
#elif defined IS_8BIT_TIMER
	NAMESPACE(PRx) = 0xFF;
#endif
	return &NAMESPACE(periodicInterruptController);
}
static void NAMESPACE(disableInterrupt)() {
	NAMESPACE(PIEx).TMRx(IE) = 0;
	NAMESPACE(PIRx).TMRx(IF) = 0;
}
static void NAMESPACE(addInterruptListener)(PeriodicInterruptListener* listener) {
	NAMESPACE(listener)[NAMESPACE(numOfListener)] = listener;
	NAMESPACE(numOfListener)++;
}
static uint16_t NAMESPACE(getCount)() {
	return NAMESPACE(TMRx);
}
static void NAMESPACE(setCount)(uint16_t count) {
	NAMESPACE(TMRx) = count;
}
Ejemplo n.º 27
0
/* Generated */ TA_RetCode TA_S_CDLEVENINGDOJISTAR( int    startIdx,
/* Generated */                                     int    endIdx,
/* Generated */                                     const float  inOpen[],
/* Generated */                                     const float  inHigh[],
/* Generated */                                     const float  inLow[],
/* Generated */                                     const float  inClose[],
/* Generated */                                     double        optInPenetration, /* From 0 to TA_REAL_MAX */
/* Generated */                                     int          *outBegIdx,
/* Generated */                                     int          *outNbElement,
/* Generated */                                     int           outInteger[] )
/* Generated */ #endif
/* Generated */ {
/* Generated */     double BodyDojiPeriodTotal, BodyLongPeriodTotal, BodyShortPeriodTotal;
/* Generated */     int i, outIdx, BodyDojiTrailingIdx, BodyLongTrailingIdx, BodyShortTrailingIdx, lookbackTotal;
/* Generated */  #ifndef TA_FUNC_NO_RANGE_CHECK
/* Generated */     if( startIdx < 0 )
/* Generated */        return NAMESPACE(TA_RetCode)TA_OUT_OF_RANGE_START_INDEX;
/* Generated */     if( (endIdx < 0) || (endIdx < startIdx))
/* Generated */        return NAMESPACE(TA_RetCode)TA_OUT_OF_RANGE_END_INDEX;
/* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
/* Generated */     if(!inOpen||!inHigh||!inLow||!inClose)
/* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     #endif 
/* Generated */     if( optInPenetration == TA_REAL_DEFAULT )
/* Generated */        optInPenetration = 3.000000e-1;
/* Generated */     else if( (optInPenetration < 0.000000e+0) ||  (optInPenetration > 3.000000e+37) )
/* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
/* Generated */     if( !outInteger )
/* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     #endif 
/* Generated */  #endif 
/* Generated */    lookbackTotal = LOOKBACK_CALL(CDLEVENINGDOJISTAR)(optInPenetration);
/* Generated */    if( startIdx < lookbackTotal )
/* Generated */       startIdx = lookbackTotal;
/* Generated */    if( startIdx > endIdx )
/* Generated */    {
/* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
/* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outNbElement);
/* Generated */       return NAMESPACE(TA_RetCode)TA_SUCCESS;
/* Generated */    }
/* Generated */    BodyLongPeriodTotal = 0;
/* Generated */    BodyDojiPeriodTotal = 0;
/* Generated */    BodyShortPeriodTotal = 0;
/* Generated */    BodyLongTrailingIdx = startIdx -2 - TA_CANDLEAVGPERIOD(TA_BodyLong);
/* Generated */    BodyDojiTrailingIdx = startIdx -1 - TA_CANDLEAVGPERIOD(TA_BodyDoji);
/* Generated */    BodyShortTrailingIdx = startIdx - TA_CANDLEAVGPERIOD(TA_BodyShort);
/* Generated */    i = BodyLongTrailingIdx;
/* Generated */    while( i < startIdx-2 ) {
/* Generated */         BodyLongPeriodTotal += TA_CANDLERANGE( TA_BodyLong, i );
/* Generated */         i++;
/* Generated */    }
/* Generated */    i = BodyDojiTrailingIdx;
/* Generated */    while( i < startIdx-1 ) {
/* Generated */         BodyDojiPeriodTotal += TA_CANDLERANGE( TA_BodyDoji, i );
/* Generated */         i++;
/* Generated */    }
/* Generated */    i = BodyShortTrailingIdx;
/* Generated */    while( i < startIdx ) {
/* Generated */         BodyShortPeriodTotal += TA_CANDLERANGE( TA_BodyShort, i );
/* Generated */         i++;
/* Generated */    }
/* Generated */    i = startIdx;
/* Generated */    outIdx = 0;
/* Generated */    do
/* Generated */    {
/* Generated */         if( TA_REALBODY(i-2) > TA_CANDLEAVERAGE( TA_BodyLong, BodyLongPeriodTotal, i-2 ) &&         // 1st: long
/* Generated */             TA_CANDLECOLOR(i-2) == 1 &&                                                             //           white
/* Generated */             TA_REALBODY(i-1) <= TA_CANDLEAVERAGE( TA_BodyDoji, BodyDojiPeriodTotal, i-1 ) &&        // 2nd: doji
/* Generated */             TA_REALBODYGAPUP(i-1,i-2) &&                                                            //           gapping up
/* Generated */             TA_REALBODY(i) > TA_CANDLEAVERAGE( TA_BodyShort, BodyShortPeriodTotal, i ) &&           // 3rd: longer than short
/* Generated */             TA_CANDLECOLOR(i) == -1 &&                                                              //          black real body
/* Generated */             inClose[i] < inClose[i-2] - TA_REALBODY(i-2) * optInPenetration                         //               closing well within 1st rb
/* Generated */           )
/* Generated */             outInteger[outIdx++] = -100;
/* Generated */         else
/* Generated */             outInteger[outIdx++] = 0;
/* Generated */         BodyLongPeriodTotal += TA_CANDLERANGE( TA_BodyLong, i-2 ) - TA_CANDLERANGE( TA_BodyLong, BodyLongTrailingIdx );
/* Generated */         BodyDojiPeriodTotal += TA_CANDLERANGE( TA_BodyDoji, i-1 ) - TA_CANDLERANGE( TA_BodyDoji, BodyDojiTrailingIdx );
/* Generated */         BodyShortPeriodTotal += TA_CANDLERANGE( TA_BodyShort, i ) - TA_CANDLERANGE( TA_BodyShort, BodyShortTrailingIdx );
/* Generated */         i++; 
/* Generated */         BodyLongTrailingIdx++;
/* Generated */         BodyDojiTrailingIdx++;
/* Generated */         BodyShortTrailingIdx++;
/* Generated */    } while( i <= endIdx );
/* Generated */    VALUE_HANDLE_DEREF(outNbElement) = outIdx;
/* Generated */    VALUE_HANDLE_DEREF(outBegIdx)    = startIdx;
/* Generated */    return NAMESPACE(TA_RetCode)TA_SUCCESS;
/* Generated */ }
static void NAMESPACE(stop)() {
	NAMESPACE(TxCON).TMRx(ON) = 0;
}
Ejemplo n.º 29
0
/* Generated */ TA_RetCode TA_S_TRIMA( int    startIdx,
/* Generated */                        int    endIdx,
/* Generated */                        const float  inReal[],
/* Generated */                        int           optInTimePeriod, /* From 2 to 100000 */
/* Generated */                        int          *outBegIdx,
/* Generated */                        int          *outNbElement,
/* Generated */                        double        outReal[] )
/* Generated */ #endif
/* Generated */ {
/* Generated */    int lookbackTotal;
/* Generated */    double numerator;
/* Generated */    double numeratorSub;
/* Generated */    double numeratorAdd;
/* Generated */    int i, outIdx, todayIdx, trailingIdx, middleIdx;
/* Generated */    double factor, tempReal;
/* Generated */  #ifndef TA_FUNC_NO_RANGE_CHECK
/* Generated */     if( startIdx < 0 )
/* Generated */        return NAMESPACE(TA_RetCode)TA_OUT_OF_RANGE_START_INDEX;
/* Generated */     if( (endIdx < 0) || (endIdx < startIdx))
/* Generated */        return NAMESPACE(TA_RetCode)TA_OUT_OF_RANGE_END_INDEX;
/* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
/* Generated */     if( !inReal ) return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     #endif 
/* Generated */     if( (int)optInTimePeriod == TA_INTEGER_DEFAULT )
/* Generated */        optInTimePeriod = 30;
/* Generated */     else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
/* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     #if !defined(_MANAGED) && !defined(_JAVA)
/* Generated */     if( !outReal )
/* Generated */        return NAMESPACE(TA_RetCode)TA_BAD_PARAM;
/* Generated */     #endif 
/* Generated */  #endif 
/* Generated */    lookbackTotal = (optInTimePeriod-1);
/* Generated */    if( startIdx < lookbackTotal )
/* Generated */       startIdx = lookbackTotal;
/* Generated */    if( startIdx > endIdx )
/* Generated */    {
/* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outBegIdx);
/* Generated */       VALUE_HANDLE_DEREF_TO_ZERO(outNbElement);
/* Generated */       return NAMESPACE(TA_RetCode)TA_SUCCESS;
/* Generated */    }
/* Generated */    outIdx = 0;
/* Generated */    if( (optInTimePeriod % 2) == 1 )
/* Generated */    {
/* Generated */       i = (optInTimePeriod>>1);
/* Generated */       factor = (i+1)*(i+1); 
/* Generated */       factor = 1.0/factor;
/* Generated */       trailingIdx = startIdx-lookbackTotal;
/* Generated */       middleIdx   = trailingIdx + i;
/* Generated */       todayIdx    = middleIdx + i;
/* Generated */       numerator   = 0.0;
/* Generated */       numeratorSub = 0.0;
/* Generated */       for( i=middleIdx; i >= trailingIdx; i-- )
/* Generated */       {
/* Generated */          tempReal      = inReal[i];
/* Generated */          numeratorSub += tempReal;
/* Generated */          numerator    += numeratorSub;
/* Generated */       }
/* Generated */       numeratorAdd = 0.0;
/* Generated */       middleIdx++;
/* Generated */       for( i=middleIdx; i <= todayIdx; i++ )
/* Generated */       {
/* Generated */          tempReal      = inReal[i];
/* Generated */          numeratorAdd += tempReal;
/* Generated */          numerator    += numeratorAdd;
/* Generated */       }
/* Generated */       outIdx = 0;
/* Generated */       tempReal = inReal[trailingIdx++]; 
/* Generated */       outReal[outIdx++] = numerator * factor;
/* Generated */       todayIdx++;
/* Generated */       while( todayIdx <= endIdx )
/* Generated */       {
/* Generated */          numerator    -= numeratorSub;
/* Generated */          numeratorSub -= tempReal;
/* Generated */          tempReal      = inReal[middleIdx++];
/* Generated */          numeratorSub += tempReal;
/* Generated */          numerator    += numeratorAdd;
/* Generated */          numeratorAdd -= tempReal;
/* Generated */          tempReal      = inReal[todayIdx++];
/* Generated */          numeratorAdd += tempReal;
/* Generated */          numerator    += tempReal;
/* Generated */          tempReal = inReal[trailingIdx++]; 
/* Generated */          outReal[outIdx++] = numerator * factor;
/* Generated */       }
/* Generated */    }
TimerModule* NAMESPACE(getter)(SixteenBitTimer_ClockSource clockSource, SixteenBitTimer_Prescaler prescaler) {
	// 16bit read/write mode enable
	NAMESPACE(TxCON).Tx(RD16) = 1;
	// select clock source
	switch (clockSource) {
		case SIXTEEN_BIT_TIMER_CLOCKSOURCE_CRYSTAL_OSCILLATOR:
			NAMESPACE(TxCON).Tx(SOSCEN) = 1;
			NAMESPACE(TxCON).TMRx(CS) = 0b10;
			break;
		case SIXTEEN_BIT_TIMER_CLOCKSOURCE_EXTERNAL_CLOCK:
			NAMESPACE(TxCON).Tx(SOSCEN) = 0;
			NAMESPACE(TxCON).TMRx(CS) = 0b10;
			break;
		case SIXTEEN_BIT_TIMER_CLOCKSOURCE_SYSTEM_CLOCK:
			NAMESPACE(TxCON).TMRx(CS) = 0b01;
			break;
		case SIXTEEN_BIT_TIMER_CLOCKSOURCE_INSTRUCTION_CLOCK:
			NAMESPACE(TxCON).TMRx(CS) = 0b00;
			break;
	}
	// select prescaler value
	switch (prescaler) {
		case SIXTEEN_BIT_TIMER_PRISCALER_1_1:
			NAMESPACE(TxCON).Tx(CKPS) = 0b00;
			break;
		case SIXTEEN_BIT_TIMER_PRISCALER_1_2:
			NAMESPACE(TxCON).Tx(CKPS) = 0b01;
			break;
		case SIXTEEN_BIT_TIMER_PRISCALER_1_4:
			NAMESPACE(TxCON).Tx(CKPS) = 0b10;
			break;
		case SIXTEEN_BIT_TIMER_PRISCALER_1_8:
			NAMESPACE(TxCON).Tx(CKPS) = 0b11;
			break;
	}
	return &NAMESPACE(timerModule);
}