//--------------------------------------------------------------------------- void __fastcall TFrDeviceExplorer::btnWriteClick(TObject *Sender) { TBluetoothLEDevice * ADevice = NULL; ADevice = GetCurrentDevice(); if(ADevice != NULL) { TBluetoothGattService * AService = ADevice->Services->Items[CurrentService]; TBluetoothGattCharacteristic * AChar = AService->Characteristics->Items[CurrentCharacteristic]; if((AChar->Properties.Contains(TBluetoothProperty::Write)) || (AChar->Properties.Contains(TBluetoothProperty::WriteNoResponse)) || (AChar->Properties.Contains(TBluetoothProperty::SignedWrite))) { if(CbWriteTypes->ItemIndex == 0) AChar->SetValueAsString(EdCharacWrite->Text); if(CbWriteTypes->ItemIndex == 1) AChar->SetValueAsString(EdCharacWrite->Text, false); if(CbWriteTypes->ItemIndex == 2) AChar->SetValueAsUInt8(UInt8(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 3) AChar->SetValueAsUInt16(UInt16(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 4) AChar->SetValueAsUInt32(UInt32(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 5) AChar->SetValueAsUInt64(StrToInt(EdCharacWrite->Text)); if(CbWriteTypes->ItemIndex == 6) AChar->SetValueAsInt8(Int8(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 7) AChar->SetValueAsInt16(Int16(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 8) AChar->SetValueAsInt32(Int32(StrToInt(EdCharacWrite->Text))); if(CbWriteTypes->ItemIndex == 9) AChar->SetValueAsInt64(StrToInt(EdCharacWrite->Text)); if(CbWriteTypes->ItemIndex == 10) AChar->SetValueAsDouble(StrToFloat(EdCharacWrite->Text)); if(CbWriteTypes->ItemIndex == 11) AChar->SetValueAsSingle(StrToFloat(EdCharacWrite->Text)); ADevice->WriteCharacteristic(AChar); } else { ShowMessage("This characteristic doesn''t allow Write"); } } else { ShowMessage(EdCurrentDevice->Text + " is not available"); } }
void runTests(bool write,BinaryDataHandler &pMem) { runTest (write,pMem, std::string("Hallo") ); runTest1 (write,pMem, Time(222.22) ); runTest (write,pMem, Color3f(1.1,2.2,3.3) ); runTest (write,pMem, Color4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Color3ub(1,2,3) ); runTest (write,pMem, Color4ub(1,2,3,4) ); runTest (write,pMem, DynamicVolume(DynamicVolume::BOX_VOLUME) ); runTest (write,pMem, DynamicVolume(DynamicVolume::SPHERE_VOLUME) ); runTest1 (write,pMem, BitVector(0xabcd) ); runTest (write,pMem, Plane(Vec3f(1.0,0),0.222) ); runTest (write,pMem, Matrix(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) ); runTest (write,pMem, Quaternion(Vec3f(1,2,3),22) ); runTest2<bool>(write,pMem, true ); runTest (write,pMem, Int8(-22) ); runTest (write,pMem, UInt8(11) ); runTest (write,pMem, Int16(-10233) ); runTest (write,pMem, UInt16(20233) ); runTest (write,pMem, Int32(-222320233) ); runTest (write,pMem, UInt32(522320233) ); runTest<Int64> (write,pMem, Int64(-522323334) ); runTest (write,pMem, UInt64(44523423) ); runTest (write,pMem, Real32(22.333224) ); runTest (write,pMem, Real64(52.334534533224) ); runTest (write,pMem, Vec2f(1.1,2.2) ); runTest (write,pMem, Vec3f(1.1,2.2,3.3) ); runTest (write,pMem, Vec4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt2f(1.1,2.2) ); runTest (write,pMem, Pnt2d(1.1,2.2) ); runTest (write,pMem, Pnt3f(1.1,2.2,3.3) ); runTest (write,pMem, Pnt3d(1.1,2.2,3.3) ); runTest (write,pMem, Pnt4f(1.1,2.2,3.3,4.4) ); runTest (write,pMem, Pnt4d(1.1,2.2,3.3,4.4) ); }
CValueConvert<SSafeSqlCP, CDB_Object>::operator Int8(void) const { if (m_Value.IsNULL()) { return Int8(); } const EDB_Type cur_type = m_Value.GetType(); switch (cur_type) { case eDB_BigInt: return ConvertSafe(static_cast<const CDB_BigInt&>(m_Value).Value()); case eDB_Int: return ConvertSafe(static_cast<const CDB_Int&>(m_Value).Value()); case eDB_SmallInt: return ConvertSafe(static_cast<const CDB_SmallInt&>(m_Value).Value()); case eDB_TinyInt: return ConvertSafe(static_cast<const CDB_TinyInt&>(m_Value).Value()); case eDB_Bit: return ConvertSafe(static_cast<const CDB_Bit&>(m_Value).Value()); default: ReportTypeConvError(cur_type, "Int8"); } return 0; }
dmz::Boolean dmz::NetExtPacketCodecObjectNative::encode_object ( const Handle ObjectHandle, const NetObjectEncodeEnum EncodeMode, Marshal &data) { Boolean result (False); if (_attrMod && _objMod) { UUID objectID; if (_objMod->lookup_uuid (ObjectHandle, objectID)) { data.set_next_uuid (_SysID); data.set_next_uuid (objectID); if (EncodeMode == NetObjectDeactivate) { data.set_next_int8 (0); result = True; } else { const ObjectType Type (_objMod->lookup_object_type (ObjectHandle)); ArrayUInt32 typeArray; if (_attrMod->to_net_object_type (Type, typeArray)) { const Int32 TypeSize (typeArray.get_size ()); data.set_next_int8 (Int8 (TypeSize)); for (Int32 ix = 0; ix < TypeSize; ix++) { data.set_next_uint8 (UInt8 (typeArray.get (ix))); } ObjectAttributeAdapter *current (_adapterList); while (current) { current->encode (ObjectHandle, *_objMod, data); current = current->next; } result = True; } _objMod->store_time_stamp ( ObjectHandle, _lnvHandle, _time.get_last_frame_time ()); } } } return result; }
void CSeqDBAtlas::PossiblyGarbageCollect(Uint8 space_needed, bool returning) { Verify(true); // Use Int8 to avoid "unsigned rollunder" Int8 bound = m_Strategy.GetMemoryBound(returning); Int8 capacity_left = bound - m_CurAlloc; if (Int8(space_needed) > capacity_left) { x_GarbageCollect(bound - space_needed); } Verify(true); }
void CBlastNucleotideOptionsHandle::SetVecScreenDefaults() { m_Opts->SetDefaultsMode(true); m_Opts->SetRemoteProgramAndService_Blast3("blastn", "vecscreen"); m_Opts->SetProgram(eVecScreen); if (m_Opts->GetLocality() == CBlastOptions::eRemote) { return; } // based on VSBlastOptionNew from tools/vecscrn.c m_Opts->SetGapOpeningCost(3); m_Opts->SetGapExtensionCost(3); m_Opts->SetMaskAtHash(true); m_Opts->SetDustFiltering(true); m_Opts->SetMatchReward(1); m_Opts->SetMismatchPenalty(-5); m_Opts->SetEvalueThreshold(700); m_Opts->SetEffectiveSearchSpace(Int8(1.75e12)); }
BEGIN_NCBI_SCOPE /////////////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(Test_Procedure) { try { // Test a regular IStatement with "exec" // Parameters are not allowed with this construction. { auto_ptr<IStatement> auto_stmt( GetConnection().GetStatement() ); // Execute it first time ... auto_stmt->SendSql( "exec sp_databases" ); while( auto_stmt->HasMoreResults() ) { if( auto_stmt->HasRows() ) { auto_ptr<IResultSet> rs( auto_stmt->GetResultSet() ); switch ( rs->GetResultType() ) { case eDB_RowResult: while( rs->Next() ) { // int col1 = rs->GetVariant(1).GetInt4(); } break; case eDB_ParamResult: while( rs->Next() ) { // int col1 = rs->GetVariant(1).GetInt4(); } break; case eDB_StatusResult: while( rs->Next() ) { int status = rs->GetVariant(1).GetInt4(); status = status; } break; case eDB_ComputeResult: case eDB_CursorResult: break; } } } // Execute it second time ... auto_stmt->SendSql( "exec sp_databases" ); while( auto_stmt->HasMoreResults() ) { if( auto_stmt->HasRows() ) { auto_ptr<IResultSet> rs( auto_stmt->GetResultSet() ); switch ( rs->GetResultType() ) { case eDB_RowResult: while( rs->Next() ) { // int col1 = rs->GetVariant(1).GetInt4(); } break; case eDB_ParamResult: while( rs->Next() ) { // int col1 = rs->GetVariant(1).GetInt4(); } break; case eDB_StatusResult: while( rs->Next() ) { int status = rs->GetVariant(1).GetInt4(); status = status; } break; case eDB_ComputeResult: case eDB_CursorResult: break; } } } // Same as before but do not retrieve data ... auto_stmt->SendSql( "exec sp_databases" ); auto_stmt->SendSql( "exec sp_databases" ); } // Test ICallableStatement // No parameters at this time. { // Execute it first time ... auto_ptr<ICallableStatement> auto_stmt( GetConnection().GetCallableStatement("sp_databases") ); auto_stmt->Execute(); while(auto_stmt->HasMoreResults()) { if( auto_stmt->HasRows() ) { auto_ptr<IResultSet> rs( auto_stmt->GetResultSet() ); switch( rs->GetResultType() ) { case eDB_RowResult: while(rs->Next()) { // retrieve row results } break; case eDB_ParamResult: while(rs->Next()) { // Retrieve parameter row } break; default: break; } } } // Get status auto_stmt->GetReturnStatus(); // Execute it second time ... auto_stmt.reset( GetConnection().GetCallableStatement("sp_databases") ); auto_stmt->Execute(); while(auto_stmt->HasMoreResults()) { if( auto_stmt->HasRows() ) { auto_ptr<IResultSet> rs( auto_stmt->GetResultSet() ); switch( rs->GetResultType() ) { case eDB_RowResult: while(rs->Next()) { // retrieve row results } break; case eDB_ParamResult: while(rs->Next()) { // Retrieve parameter row } break; default: break; } } } // Get status auto_stmt->GetReturnStatus(); // Same as before but do not retrieve data ... auto_stmt.reset( GetConnection().GetCallableStatement("sp_databases") ); auto_stmt->Execute(); auto_stmt.reset( GetConnection().GetCallableStatement("sp_databases") ); auto_stmt->Execute(); } // Temporary test ... // !!! This is a bug ... if (false) { auto_ptr<IConnection> conn( GetDS().CreateConnection( CONN_OWNERSHIP ) ); BOOST_CHECK( conn.get() != NULL ); conn->Connect( "anyone", "allowed", "PUBSEQ_OS_LXA", "" ); auto_ptr<ICallableStatement> auto_stmt( conn->GetCallableStatement("id_seqid4gi") ); auto_stmt->SetParam( CVariant(1), "@gi" ); auto_stmt->Execute(); while(auto_stmt->HasMoreResults()) { if( auto_stmt->HasRows() ) { auto_ptr<IResultSet> rs( auto_stmt->GetResultSet() ); switch( rs->GetResultType() ) { case eDB_RowResult: while(rs->Next()) { // retrieve row results } break; case eDB_ParamResult: _ASSERT(false); while(rs->Next()) { // Retrieve parameter row } break; default: break; } } } // Get status int status = auto_stmt->GetReturnStatus(); status = status; // Get rid of warnings. } if (false) { const string query("[db_alias] is not null"); auto_ptr<IConnection> conn( GetDS().CreateConnection( CONN_OWNERSHIP ) ); BOOST_CHECK( conn.get() != NULL ); conn->Connect( "*****", "******", "MSSQL31", "AlignDb_Info" ); auto_ptr<ICallableStatement> auto_stmt( conn->PrepareCall("[dbo].[FindAttributesEx]") ); auto_stmt->SetParam( CVariant(1), "@userid" ); auto_stmt->SetParam( CVariant("ALIGNDB"), "@application" ); auto_stmt->SetParam( CVariant("AlignDbMasterInfo"), "@classname" ); // LongChar doesn't work. // auto_stmt->SetParam( CVariant(new CDB_LongChar(query.length(), query)), "@query" ); // auto_stmt->SetParam( CVariant::LongChar(query.data(), query.length()), "@query" ); auto_stmt->SetParam( CVariant(query), "@query" ); auto_stmt->SetParam( CVariant(1), "@max_results" ); auto_stmt->Execute(); while(auto_stmt->HasMoreResults()) { if( auto_stmt->HasRows() ) { auto_ptr<IResultSet> rs( auto_stmt->GetResultSet() ); switch( rs->GetResultType() ) { case eDB_RowResult: while(rs->Next()) { // retrieve row results } break; case eDB_ParamResult: _ASSERT(false); while(rs->Next()) { // Retrieve parameter row } break; default: break; } } } // Get status int status = auto_stmt->GetReturnStatus(); status = status; // Get rid of warnings. } // Test returned recordset ... { // In case of MS SQL 2005 sp_databases returns empty result set. // It is not a bug. It is a difference in setiings for MS SQL // 2005. if (GetArgs().GetServerType() != CDBConnParams::eMSSqlServer) { int num = 0; // Execute it first time ... auto_ptr<ICallableStatement> auto_stmt( GetConnection().GetCallableStatement("sp_databases") ); auto_stmt->Execute(); BOOST_CHECK(auto_stmt->HasMoreResults()); BOOST_CHECK(auto_stmt->HasRows()); auto_ptr<IResultSet> rs(auto_stmt->GetResultSet()); BOOST_CHECK(rs.get() != NULL); while (rs->Next()) { BOOST_CHECK(rs->GetVariant(1).GetString().size() > 0); BOOST_CHECK(rs->GetVariant(2).GetInt4() > 0); BOOST_CHECK_EQUAL(rs->GetVariant(3).IsNull(), true); ++num; } BOOST_CHECK(num > 0); DumpResults(auto_stmt.get()); } { int num = 0; auto_ptr<ICallableStatement> auto_stmt( GetConnection().GetCallableStatement("sp_server_info") ); auto_stmt->Execute(); BOOST_CHECK(auto_stmt->HasMoreResults()); BOOST_CHECK(auto_stmt->HasRows()); auto_ptr<IResultSet> rs(auto_stmt->GetResultSet()); BOOST_CHECK(rs.get() != NULL); while (rs->Next()) { BOOST_CHECK(rs->GetVariant(1).GetInt4() > 0); BOOST_CHECK(rs->GetVariant(2).GetString().size() > 0); BOOST_CHECK(rs->GetVariant(3).GetString().size() > 0); ++num; } BOOST_CHECK(num > 0); DumpResults(auto_stmt.get()); } } // Test ICallableStatement // With parameters. { { auto_ptr<ICallableStatement> auto_stmt( GetConnection().GetCallableStatement("sp_server_info") ); // Set parameter to NULL ... auto_stmt->SetParam( CVariant(eDB_Int), "@attribute_id" ); auto_stmt->Execute(); if (GetArgs().GetServerType() == CDBConnParams::eSybaseSQLServer) { BOOST_CHECK_EQUAL( size_t(30), GetNumOfRecords(auto_stmt) ); } else { BOOST_CHECK_EQUAL( size_t(29), GetNumOfRecords(auto_stmt) ); } // Set parameter to 1 ... auto_stmt->SetParam( CVariant( Int4(1) ), "@attribute_id" ); auto_stmt->Execute(); BOOST_CHECK_EQUAL( size_t(1), GetNumOfRecords(auto_stmt) ); } // NULL value with CVariant ... { auto_ptr<ICallableStatement> auto_stmt( GetConnection().GetCallableStatement("sp_statistics") ); auto_stmt->SetParam(CVariant((const char*) NULL), "@table_name"); auto_stmt->Execute(); DumpResults(auto_stmt.get()); } // Doesn't work for some reason ... if (false) { // Execute it first time ... auto_ptr<ICallableStatement> auto_stmt( GetConnection().GetCallableStatement("sp_statistics") ); auto_stmt->SetParam(CVariant(GetTableName()), "@table_name"); auto_stmt->Execute(); { BOOST_CHECK(auto_stmt->HasMoreResults()); BOOST_CHECK(auto_stmt->HasRows()); auto_ptr<IResultSet> rs(auto_stmt->GetResultSet()); BOOST_CHECK(rs.get() != NULL); BOOST_CHECK(rs->Next()); DumpResults(auto_stmt.get()); } // Execute it second time ... auto_stmt->SetParam(CVariant("#bulk_insert_table"), "@table_name"); auto_stmt->Execute(); { BOOST_CHECK(auto_stmt->HasMoreResults()); BOOST_CHECK(auto_stmt->HasRows()); auto_ptr<IResultSet> rs(auto_stmt->GetResultSet()); BOOST_CHECK(rs.get() != NULL); BOOST_CHECK(rs->Next()); DumpResults(auto_stmt.get()); } } if (false) { auto_ptr<ICallableStatement> auto_stmt( GetConnection().GetCallableStatement("DBAPI_Sample..TestBigIntProc") ); auto_stmt->SetParam(CVariant(Int8(1234567890)), "@num"); auto_stmt->ExecuteUpdate(); } } // Test output parameters ... if (false) { CRef<CDB_UserHandler_Diag> handler(new CDB_UserHandler_Diag()); I_DriverContext* drv_context = GetDS().GetDriverContext(); drv_context->PushDefConnMsgHandler(handler); auto_ptr<ICallableStatement> auto_stmt( GetConnection().GetCallableStatement("DBAPI_Sample..SampleProc3") ); auto_stmt->SetParam(CVariant(1), "@id"); auto_stmt->SetParam(CVariant(2.0), "@f"); auto_stmt->SetOutputParam(CVariant(eDB_Int), "@o"); auto_stmt->Execute(); // auto_stmt->SendSql( "exec DBAPI_Sample..TestProc4 @test_out output" ); while(auto_stmt->HasMoreResults()) { if( auto_stmt->HasRows() ) { auto_ptr<IResultSet> rs( auto_stmt->GetResultSet() ); switch( rs->GetResultType() ) { case eDB_RowResult: while(rs->Next()) { // retrieve row results } break; case eDB_ParamResult: BOOST_CHECK(rs->Next()); NcbiCout << "Output param: " << rs->GetVariant(1).GetInt4() << endl; break; case eDB_ComputeResult: break; case eDB_StatusResult: break; case eDB_CursorResult: break; default: break; } } } // BOOST_CHECK(auto_stmt->HasMoreResults()); // BOOST_CHECK(auto_stmt->HasRows()); // auto_ptr<IResultSet> rs(auto_stmt->GetResultSet()); // BOOST_CHECK(rs.get() != NULL); // // while (rs->Next()) { // BOOST_CHECK(rs->GetVariant(1).GetString().size() > 0); // BOOST_CHECK(rs->GetVariant(2).GetInt4() > 0); // BOOST_CHECK_EQUAL(rs->GetVariant(3).IsNull(), true); // ++num; // } // // BOOST_CHECK(num > 0); DumpResults(auto_stmt.get()); drv_context->PopDefConnMsgHandler(handler); } // Temporary test ... if (false) { auto_ptr<IConnection> conn( GetDS().CreateConnection( CONN_OWNERSHIP ) ); BOOST_CHECK( conn.get() != NULL ); conn->Connect( "anyone", "allowed", "", "GenomeHits" ); auto_ptr<ICallableStatement> auto_stmt( conn->GetCallableStatement("NewSub") ); auto_stmt->SetParam(CVariant("tsub2"), "@name"); auto_stmt->SetParam(CVariant("tst"), "@center"); auto_stmt->SetParam(CVariant("9606"), "@taxid"); auto_stmt->SetParam(CVariant("H**o sapiens"), "@organism"); auto_stmt->SetParam(CVariant(""), "@notes"); auto_stmt->Execute(); while(auto_stmt->HasMoreResults()) { if( auto_stmt->HasRows() ) { auto_ptr<IResultSet> rs( auto_stmt->GetResultSet() ); switch( rs->GetResultType() ) { case eDB_RowResult: while(rs->Next()) { // retrieve row results } break; case eDB_ParamResult: _ASSERT(false); while(rs->Next()) { // Retrieve parameter row } break; default: break; } } } // Get status int status = auto_stmt->GetReturnStatus(); status = status; // Get rid of warnings. } // Temporary test ... if (false && GetArgs().GetServerType() != CDBConnParams::eSybaseSQLServer) { auto_ptr<IConnection> conn( GetDS().CreateConnection( CONN_OWNERSHIP ) ); BOOST_CHECK( conn.get() != NULL ); conn->Connect( "pmcupdate", "*******", "PMC3QA", "PMC3QA" ); auto_ptr<ICallableStatement> auto_stmt( conn->PrepareCall("id_new_id") ); auto_stmt->SetParam(CVariant("tsub2"), "@IdName"); auto_stmt->Execute(); while(auto_stmt->HasMoreResults()) { if( auto_stmt->HasRows() ) { auto_ptr<IResultSet> rs( auto_stmt->GetResultSet() ); switch( rs->GetResultType() ) { case eDB_RowResult: while(rs->Next()) { // retrieve row results } break; case eDB_ParamResult: _ASSERT(false); while(rs->Next()) { // Retrieve parameter row } break; default: break; } } } // Get status int status = auto_stmt->GetReturnStatus(); status = status; // Get rid of warnings. } } catch(const CException& ex) { DBAPI_BOOST_FAIL(ex); } }
void CSeqDBAtlas::UnregisterExternal(CSeqDBMemReg & memreg) { size_t bytes = memreg.m_Bytes; if (bytes > 0) { //_ASSERT((size_t)m_CurAlloc >= bytes); //m_CurAlloc -= bytes; memreg.m_Bytes = 0; } } // 16 GB should be enough const Int8 CSeqDBMapStrategy::e_MaxMemory64 = Int8(16) << 30; Int8 CSeqDBMapStrategy::m_GlobalMaxBound = 0; bool CSeqDBMapStrategy::m_AdjustedBound = false; /// Constructor CSeqDBMapStrategy::CSeqDBMapStrategy(CSeqDBAtlas & atlas) : m_Atlas (atlas), m_MaxBound (0), m_RetBound (0), m_SliceSize (0), m_Overhang (0), m_Order (0.95, .901), m_InOrder (true), m_MapFailed (false),