void Shooter::Execute() { Log(); if(!initialized){ angleMotor.Set(GOTO_LOWER_SPEED); if(AtLowerLimit()) SetInitialized(); } }
// =========================================================================================================== // Holder::Execute // =========================================================================================================== // Called repeatedly from Default Command (ExecHolder) while in Teleop Mode // - if !initialized, goto lower limit switch (close gate) // - else if ball is present pinch ball (open gate) // =========================================================================================================== void Holder::Execute() { Log(); if(!initialized) { if(IsGateClosed()) SetInitialized(); else gateMotor.Set(GATE_CLOSE_SPEED); } }
void OpHashTable::RemoveAll() { if (IsInitialized()) { hash_backend.CleanUp(); nr_of_elements = 0; hash_size_index = 0; SetInitialized(FALSE); } }
OP_STATUS OpHashTable::Init() { if (hash_functions == NULL) { hash_functions = this; } OP_STATUS ret_val = hash_backend.Init(hash_functions, hashTableSizes[hash_size_index], maximumNrOfElements[hash_size_index]); if (OpStatus::IsError(ret_val)) { hash_backend.CleanUp(); SetInitialized(FALSE); return OpStatus::ERR_NO_MEMORY; } else { SetInitialized(TRUE); return OpStatus::OK; } }
void SerialPortC::SetSpeed(PortSpeedE NewSpeed) { Speed = NewSpeed; int rs_Baud; switch (NewSpeed) { default: assert(FALSE); case PS_300: { rs_Baud = 2; break; } case PS_600: { rs_Baud = 3; break; } case PS_1200: { rs_Baud = 4; break; } case PS_2400: { rs_Baud = 5; break; } case PS_4800: { rs_Baud = 6; break; } case PS_9600: { rs_Baud = 7; break; } case PS_19200: { rs_Baud = 8; break; } case PS_38400: { rs_Baud = 9; break; } case PS_57600: { rs_Baud = 10; break; } case PS_115200: { rs_Baud = 11; break; } } // disable interrupts for baud change if (IsInitialized()) { Deinit(); } assert(initrs); (*initrs)((cfg.mdata - 1), rs_Baud, 0, 0, 3, cfg.checkCTS); SetInitialized(); if (cfg.baudPause) { pause(cfg.baudPause); } }
void Game::GameScene::Init(){ // スクリーンの設定 { ANAS::Screen::Adjust( 0, 0, ANAS::SO_DEFAULT ); ANAS::Screen::ApplyToViewPort( pContainer->pGraphic ); ANAS::Screen::ApplyToTouchScreen( pContainer->pInput ); } // シェーダーの読み込み ANAS::ResourceHolder *pHolder = pResource->Get("SimpleShader"); if( pHolder == NULL ) { ANAS::Log::i("Scene Init", "Create Shader"); ANAS::AssetData vString( pContainer->pActivity->assetManager ); vString.Load( "simple2d.vsh" ); ANAS::AssetData fString( pContainer->pActivity->assetManager ); fString.Load( "simple2d.fsh" ); pSimple2D = new Simple2D( vString.GetData(), fString.GetData() ); pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::bind( &ANAS::ShaderBase::Init, pSimple2D)) ); // リソースマネージャへ登録 pResource->Set( "SimpleShader", new ANAS::ResourceItem<Simple2D>(pSimple2D) ); } else { ANAS::Log::i("Scene Init", "Get Exist Shader"); // ホルダーから取得 pSimple2D = ((ANAS::ResourceItem<Simple2D>*)pHolder)->Get(); } // スプライトの初期化 { // Tile pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mTileSprite, pSimple2D) )) ); mTileSprite.Scale[0] = TileSize; mTileSprite.Scale[1] = TileSize; // Bomb pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mBombSprite, pSimple2D) )) ); mBombSprite.Scale[0] = TileSize; mBombSprite.Scale[1] = TileSize; // Shadow pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mShadowSprite, pSimple2D) )) ); mShadowSprite.Scale[0] = TileSize*2; mShadowSprite.Scale[1] = TileSize*2; // BombLine pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mBombLineSprite, pSimple2D) )) ); mBombLineSprite.Scale[0] = 256; mBombLineSprite.Scale[1] = 256; // Enemy pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Sprite::Init, &mEnemySprite, pSimple2D) )) ); mEnemySprite.Scale[0] = Enemy::ImageSize; mEnemySprite.Scale[1] = Enemy::ImageSize; } // テクスチャの初期化 { // Tile ANAS::AssetData aTile( pContainer->pActivity->assetManager ); aTile.Load( "tile.png" ); mTileImage.Load<ANAS::IFT_PNG>( aTile.GetData() ); pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mTileTexture, mTileImage.Get(), 2,2) )) ); mTileTexture.SetFilter(GL_NEAREST, GL_NEAREST); // Bomb ANAS::AssetData aBomb( pContainer->pActivity->assetManager ); aBomb.Load( "bomb.png" ); mBombImage.Load<ANAS::IFT_PNG>( aBomb.GetData() ); pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mBombTexture, mBombImage.Get(), 128, 128) )) ); // Shadow ANAS::AssetData aShadow( pContainer->pActivity->assetManager ); aShadow.Load( "shadow.png" ); mShadowImage.Load<ANAS::IFT_PNG>( aShadow.GetData() ); pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mShadowTexture, mShadowImage.Get(), 16, 16) )) ); // BombLine ANAS::AssetData aBombLine( pContainer->pActivity->assetManager ); aBombLine.Load( "line.png" ); mBombLineImage.Load<ANAS::IFT_PNG>( aBombLine.GetData() ); pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mBombLineTexture, mBombLineImage.Get(), 256, 256) )) ); for(int i=0; i<1; i++){ ANAS::AssetData aEnemy( pContainer->pActivity->assetManager ); aEnemy.Load( Enemy::ImageName[i] ); mEnemyImage[i].Load<ANAS::IFT_PNG>( aEnemy.GetData() ); pContainer->pGraphic->Add( new ANAS::AnyTasking( boost::function<void()>(boost::bind( &ANAS::Texture::Init, &mEnemyTexture[i], mEnemyImage[i].Get(), 256, 256) )) ); } } /* ANAS::Sound *pSound = new ANAS::Sound(); ANAS::AssetData TestSound( pContainer->pActivity->assetManager ); int dst[3]; TestSound.GetFileDescriptor( "data.mp3", &dst[0], &dst[1], &dst[2] ); ANAS::Log::i( "ASSET",(boost::format("%1%:%2%:%3%")%dst[0]%dst[1]%dst[2]).str().c_str() ); pSound->Load( dst[0], dst[1], dst[2] ); */ AttackIntervalCounter = AttackInterval; // set flag initialized. SetInitialized(); }
void CRowInfo_SP_SQL_Server::Initialize(void) const { impl::CConnection& conn = GetCConnection(); unsigned int step = 0; CDBConnParams::EServerType server_type = conn.GetServerType(); if (server_type == CDBConnParams::eUnknown) { server_type = conn.CalculateServerType(server_type); ++step; } while (step++ < 3) { if (server_type == CDBConnParams::eSybaseSQLServer || server_type == CDBConnParams::eMSSqlServer) { string sql; string db_name; string db_owner; string sp_name; auto_ptr<CDB_LangCmd> cmd; { vector<string> arr_param; NStr::Tokenize(GetSPName(), ".", arr_param); size_t pos = 0; switch (arr_param.size()) { case 3: db_name = arr_param[pos++]; case 2: db_owner = arr_param[pos++]; case 1: sp_name = arr_param[pos++]; break; default: DATABASE_DRIVER_ERROR("Invalid format of stored procedure's name: " + GetSPName(), 1); } } if (db_name.empty()) { sql = "SELECT '' from sysobjects WHERE name = @name \n" "UNION \n" "SELECT 'master' from master..sysobjects WHERE name = @name \n" ; if (server_type == CDBConnParams::eSybaseSQLServer) { sql += "UNION \n" "SELECT 'sybsystemprocs' from sybsystemprocs..sysobjects WHERE name = @name \n" "UNION \n" "SELECT 'sybsystemdb' from sybsystemdb..sysobjects WHERE name = @name" ; } CMsgHandlerGuard guard(conn); cmd.reset(conn.LangCmd(sql)); CDB_VarChar sp_name_value(sp_name); try { cmd->GetBindParams().Bind("@name", &sp_name_value); cmd->Send(); while (cmd->HasMoreResults()) { auto_ptr<CDB_Result> res(cmd->Result()); if (res.get() != NULL && res->ResultType() == eDB_RowResult ) { CDB_VarChar db_name_value; while (res->Fetch()) { res->GetItem(&db_name_value); if (!db_name_value.IsNULL()) { db_name = db_name_value.Value(); } } } } } catch (const CDB_Exception&) { // Something is wrong. Probably we do not have enough permissios. // We assume that the object is located in the current database. What // else can we do? // Probably, this method was supplied with a wrong // server_type value; if (step < 2) { server_type = conn.CalculateServerType(CDBConnParams::eUnknown); ++step; continue; } } } // auto_ptr<CDB_RPCCmd> sp(conn.RPC("sp_sproc_columns")); // We cannot use CDB_RPCCmd here because of recursion ... sql = "exec " + db_name + "." + db_owner + ".sp_sproc_columns @procedure_name"; cmd.reset(conn.LangCmd(sql)); CDB_VarChar name_value(sp_name); try { cmd->GetBindParams().Bind("@procedure_name", &name_value); cmd->Send(); while (cmd->HasMoreResults()) { auto_ptr<CDB_Result> res(cmd->Result()); if (res.get() != NULL && res->ResultType() == eDB_RowResult ) { CDB_VarChar column_name; CDB_SmallInt column_type; CDB_SmallInt data_type; CDB_Int data_len = 0; while (res->Fetch()) { res->SkipItem(); res->SkipItem(); res->SkipItem(); res->GetItem(&column_name); res->GetItem(&column_type); res->GetItem(&data_type); res->SkipItem(); res->SkipItem(); res->GetItem(&data_len); // Decode data_type EDB_Type edb_data_type(eDB_UnsupportedType); switch (data_type.Value()) { case SQL_LONGVARCHAR: edb_data_type = eDB_VarChar; break; case SQL_BINARY: edb_data_type = eDB_Binary; break; case SQL_VARBINARY: edb_data_type = eDB_VarBinary; break; case SQL_LONGVARBINARY: edb_data_type = eDB_Binary; break; case SQL_BIGINT: edb_data_type = eDB_BigInt; break; case SQL_TINYINT: edb_data_type = eDB_TinyInt; break; case SQL_BIT: edb_data_type = eDB_Bit; break; // case SQL_GUID: case -9: edb_data_type = eDB_VarChar; break; case SQL_CHAR: edb_data_type = eDB_Char; break; case SQL_NUMERIC: case SQL_DECIMAL: edb_data_type = eDB_Numeric; break; case SQL_INTEGER: edb_data_type = eDB_Int; break; case SQL_SMALLINT: edb_data_type = eDB_SmallInt; break; case SQL_FLOAT: case SQL_REAL: edb_data_type = eDB_Float; break; case SQL_DOUBLE: edb_data_type = eDB_Double; break; case SQL_DATETIME: case SQL_TIME: case SQL_TIMESTAMP: edb_data_type = eDB_DateTime; break; case SQL_VARCHAR: edb_data_type = eDB_VarChar; break; // case SQL_TYPE_DATE: // case SQL_TYPE_TIME: // case SQL_TYPE_TIMESTAMP: default: edb_data_type = eDB_UnsupportedType; } EDirection direction = CDBParams::eIn; if (column_type.Value() == 2 /*SQL_PARAM_TYPE_OUTPUT*/ || column_type.Value() == 4 /*SQL_PARAM_OUTPUT*/ || column_type.Value() == 5 /*SQL_RETURN_VALUE*/ ) { direction = CDBParams::eOut; } Add(column_name.Value(), size_t(data_len.Value()), edb_data_type, direction ); } } // if ... } // while HasMoreresults ... // Break the loop, Everything seems to be fine. ... break; } catch (const CDB_Exception&) { // Something is wrong ... // We may not have permissions to run stored procedures ... // Probably, this method was supplied with a wrong // server_type value; if (step < 2) { server_type = conn.CalculateServerType(CDBConnParams::eUnknown); ++step; } } } // if server_type } SetInitialized(); }