Пример #1
0
/**
 * Access to object dictionary OD_H1010_STORE_PARAM_FUNC
 */
static CO_SDO_abortCode_t CO_ODF_1010_StoreParam(CO_ODF_arg_t *ODF_arg)
{
	CO_DBG_PRINT("CO_ODF_1010 Sub: %d\n", ODF_arg->subIndex);
	CO_DBG_PRINT("sizeof(sCO_OD_ROM): %d", sizeof(CO_OD_ROM));
	uint32_t* value = (uint32_t*)ODF_arg->data;
	if (ODF_arg->reading)
	{
		if(OD_H1010_STORE_PARAM_ALL == ODF_arg->subIndex)
		{
			*value = SAVES_PARAM_ON_COMMAND;
		}
		return CO_SDO_AB_NONE;
	}

	if(OD_H1010_STORE_PARAM_ALL != ODF_arg->subIndex)
	{
		return CO_SDO_AB_NONE;
	}

	if (*value != PARAM_STORE_PASSWORD)
	{
		return CO_SDO_AB_DATA_TRANSF;
	}

    return storeParameters(CO_OD_Flash_Adress, ODF_arg->subIndex);
}
Пример #2
0
/**
 * Access to object dictionary OD_H1010_STORE_PARAM_FUNC
 */
static CO_SDO_abortCode_t CO_ODF_1011_RestoreParam(CO_ODF_arg_t *ODF_arg)
{
	CO_DBG_PRINT("CO_ODF_1010 Sub: %d\n", ODF_arg->subIndex);
	CO_DBG_PRINT("sizeof(sCO_OD_ROM): %d", sizeof(CO_OD_ROM));
	uint32_t* value = (uint32_t*)ODF_arg->data;
	if (ODF_arg->reading)
	{
		if (OD_H1011_RESTORE_PARAM_ALL == ODF_arg->subIndex)
		{
			*value = RESTORES_PARAMETERS;
		}
		return CO_SDO_AB_NONE;
	}

	if (OD_H1011_RESTORE_PARAM_ALL != ODF_arg->subIndex)
	{
		return CO_SDO_AB_NONE;
	}

	if (*value != PARAM_RESTORE_PASSWORD)
	{
		return CO_SDO_AB_DATA_TRANSF;
	}

	CO_SDO_abortCode_t Result = restoreParameters(CO_OD_Flash_Default_Param,
		ODF_arg->subIndex);
	if (Result != CO_SDO_AB_NONE)
	{
		CO_DBG_PRINT("restoreParameters returned error");
		return Result;
	}

	return storeParameters(CO_OD_Flash_Adress, OD_H1011_RESTORE_PARAM_ALL);
}
Пример #3
0
void FractalModel::setParameters( const FractalType& type, const Position& position )
{
    if ( m_fractalType != type || m_position != position ) {
        storeParameters();
        setParametersInternal( type, position );
    }
}
Пример #4
0
int startAlgorithm(TumbleParameters& p) {
   static FunctionEvent tn;   // a Temporary Note for copying into eventBuffer

   int ploc = storeParameters(tparam, p);
   if (ploc < 0) {
      cout << "Warning: Parameter space is full.  Not adding new algorithm"
           << endl;
      return -1;
   }

   // setting the fields of the function note
   tn.setFunction(TumbleNoteFunction);
   tn.setChannel(channel);
   tn.setKeyno(0);
   tn.setVelocity(0);
   tn.charValue(0) = (char)ploc;         // store location of the parameters
   tn.setStatus(EVENT_STATUS_ACTIVE);
   tn.setOnTime(t_time + p.i[0] - anticipation);

   // display the basic algorithm info
   cout << "Tumble: Time: " << t_time << "\tStart = " << (int)p.current
        << "\tPattern = . ";
   for (int i=1; i<p.n.getSize(); i++) {
      cout << (int)p.n[i] << " ";
   }
   cout << "(" << (int)p.n[0] << ")";
   cout << " ioi: " << p.i[0];
   cout << endl;

   return eventBuffer.insert(tn);
}
Пример #5
0
void FractalModel::setPosition( const Position& position )
{
    if ( m_position != position ) {
        storeParameters();
        m_position = position;
        m_presenter->setPosition( position );
        emit positionChanged();
    }
}
Пример #6
0
void FractalModel::setFractalType( const FractalType& type )
{
    if ( m_fractalType != type ) {
        storeParameters();
        m_fractalType = type;
        m_presenter->setFractalType( type );
        emit fractalTypeChanged();
    }
}
Пример #7
0
/**
 * Initialize flash library and data storage in flash
 * We use two blocks in flash for data storage. One block is used for the
 * default data that will be restored. The default parameters are stored
 * at address CO_OD_Flash_Default_Param. The data that will be loaded at
 * startup or saved if user modifies data is store at CO_OD_Flash_Adress.
 */
void CO_FlashInit(void)
{
	int i = 0;
	//
	// Initialize flash library
	//
	int Result = cyg_flash_init(0);
	CHECK_FLASH_RESULT(Result);
#ifdef CYGDBG_IO_CANOPEN_DEBUG
	cyg_flash_set_global_printf(diag_printf);
#endif

	//
	// Read info about flash device (number of blocks. block size)
	//
	Result = cyg_flash_get_info(0, &flash_info);
	CHECK_FLASH_RESULT(Result);
	CO_DBG_PRINT("Flash info dev %d: 0x%x - 0x%x, %d blocks\n", 0, flash_info.start,
		flash_info.end, flash_info.num_block_infos);
	const cyg_flash_block_info_t* block_info = flash_info.block_info;
	for (i = 0; i < flash_info.num_block_infos; ++i)
	{
		CO_DBG_PRINT("Block %d: block size: %d blocks: %d\n", i,
			block_info->block_size, block_info->blocks);
		block_info++;
	}

	//
	// Calculate addresses for flash data and default flash data
	//
	block_info = &flash_info.block_info[flash_info.num_block_infos - 1];
	CO_DBG_PRINT("Last block - block size: %d blocks: %d\n",
		block_info->block_size, block_info->blocks);
	CO_OD_Flash_Adress = flash_info.end + 1 +
		(CYGNUM_CANOPEN_FLASH_DATA_BLOCK * block_info->block_size);
	CO_DBG_PRINT("CO_OD_Flash_Adress 0x%8x\n", CO_OD_Flash_Adress);
	CO_OD_Flash_Default_Param = CO_OD_Flash_Adress - block_info->block_size;
	CO_DBG_PRINT("CO_OD_Flash_Default_Param 0x%8x\n", CO_OD_Flash_Default_Param);

	//
	// Before we can access the data, we need to make sure, that the flash
	// block are properly initialized. We do this by reading the block into
	// a local sCO_OD_ROM variable and verifying the FirstWord and LastWord
	// members
	//
	cyg_flashaddr_t ErrorAddress;
	struct sCO_OD_ROM DefaultObjDicParam;
	Result = cyg_flash_read(CO_OD_Flash_Default_Param, &DefaultObjDicParam,
		sizeof(DefaultObjDicParam), &ErrorAddress);
	CHECK_FLASH_RESULT(Result);

	//
	// If the default parameters are not present in flash, then we know that
	// we need to create them for later restore
	//
	if ((DefaultObjDicParam.FirstWord != CO_OD_FIRST_LAST_WORD)
	  ||(DefaultObjDicParam.LastWord != CO_OD_FIRST_LAST_WORD))
	{
		storeParameters(CO_OD_Flash_Adress, OD_H1010_STORE_PARAM_ALL);
		storeParameters(CO_OD_Flash_Default_Param, OD_H1010_STORE_PARAM_ALL);
	}
	else
	{
		restoreParameters(CO_OD_Flash_Adress, OD_H1010_STORE_PARAM_ALL);
	}
}
Пример #8
0
void LauncherWindow::closeEvent (QCloseEvent* event) { storeParameters(); }
Пример #9
0
void LauncherWindow::closeEvent(QCloseEvent *event)
{
    QMainWindow::closeEvent(event);
    storeParameters();
    event->accept();
}
Пример #10
0
inline void solver::AugRie<T>::computeNetUpdates (
    const T& i_hLeft,  const T& i_hRight,
    const T& i_huLeft, const T& i_huRight,
    const T& i_bLeft,  const T& i_bRight,

    T& o_hUpdateLeft,
    T& o_hUpdateRight,
    T& o_huUpdateLeft,
    T& o_huUpdateRight,
    T& o_maxWaveSpeed
#if CONFIG_TSUNAMI_AUGMENTED_RIEMANN_EIGEN_COEFFICIENTS
    ,
    T  o_eigenCoefficients[3]
#endif
)
{
    // store parameters to member variables
    storeParameters( i_hLeft, i_hRight,
                     i_huLeft, i_huRight,
                     i_bLeft, i_bRight );

    //set speeds to zero (will be determined later)
    uLeft = uRight = 0.;

    //reset net updates and the maximum wave speed
    o_hUpdateLeft = o_hUpdateRight = o_huUpdateLeft = o_huUpdateRight  = (T)0.;
    o_maxWaveSpeed = (T)0.;

#if CONFIG_TSUNAMI_AUGMENTED_RIEMANN_EIGEN_COEFFICIENTS
    // reset eigen coefficients
    o_eigenCoefficients[0] = o_eigenCoefficients[1] = o_eigenCoefficients[2] = 0;
#endif

    //determine the wet/dry state and compute local variables correspondingly
    determineWetDryState();

    if (wetDryState == DryDry) //nothing to do in a dry region
        return;

    //precompute some terms which are fixed during
    //the computation after some specific point
    sqrt_g = std::sqrt(g);
    sqrt_hLeft = std::sqrt(hLeft);
    sqrt_hRight = std::sqrt(hRight);

    sqrt_g_hLeft = sqrt_g * sqrt_hLeft;
    sqrt_g_hRight = sqrt_g * sqrt_hRight;


    //where to store the three waves
    T fWaves[3][2];
    //and their speeds
    T waveSpeeds[3];

    //compute the augmented decomposition
    //  (thats the place where the computational work is done..)
    computeWaveDecomposition( fWaves,
                              waveSpeeds
#if CONFIG_TSUNAMI_AUGMENTED_RIEMANN_EIGEN_COEFFICIENTS
                              , o_eigenCoefficients
#endif
                            );


    //compute the updates from the three propagating waves
    //A^-\delta Q = \sum{s[i]<0} \beta[i] * r[i] = A^-\delta Q = \sum{s[i]<0} Z^i
    //A^+\delta Q = \sum{s[i]>0} \beta[i] * r[i] = A^-\delta Q = \sum{s[i]<0} Z^i
    for (int waveNumber = 0; waveNumber < 3; waveNumber++) {
        if (waveSpeeds[waveNumber] < -zeroTol) { //left going
            o_hUpdateLeft +=  fWaves[waveNumber][0];
            o_huUpdateLeft += fWaves[waveNumber][1];
        }

        else if (waveSpeeds[waveNumber] > zeroTol) { //right going
            o_hUpdateRight +=  fWaves[waveNumber][0];
            o_huUpdateRight += fWaves[waveNumber][1];
        } else { //TODO: this case should not happen mathematically, but it does. Where is the bug? Machine accuracy only?
            o_hUpdateLeft +=  (T).5 * fWaves[waveNumber][0];
            o_huUpdateLeft += (T).5 * fWaves[waveNumber][1];

            o_hUpdateRight +=  (T).5 * fWaves[waveNumber][0];
            o_huUpdateRight += (T).5 * fWaves[waveNumber][1];
        }

        //no wave speeds => zero strength fWaves
        //        assert( std::fabs(fWaves[waveNumber][0]) < zeroTol );
        //        assert( std::fabs(fWaves[waveNumber][1]) < zeroTol );
    }

#ifndef NDEBUG
    if (wetDryState == DryWetWall)
        assert( std::fabs(o_hUpdateLeft) < zeroTol && std::fabs(o_huUpdateLeft) < zeroTol );
    else if (wetDryState == WetDryWall)
        assert( std::fabs(o_hUpdateRight) < zeroTol && std::fabs(o_huUpdateRight) < zeroTol );
#endif

    //compute maximum wave speed (-> CFL-condition)
    waveSpeeds[0] = std::fabs(waveSpeeds[0]);
    waveSpeeds[1] = std::fabs(waveSpeeds[1]);
    waveSpeeds[2] = std::fabs(waveSpeeds[2]);

    o_maxWaveSpeed = std::max(waveSpeeds[0], waveSpeeds[1]);
    o_maxWaveSpeed = std::max(o_maxWaveSpeed, waveSpeeds[2]);
}