bool CUInt32::operator>(CData &x) { if( x.getType() == UINT32 ) { CUInt32 & d=dynamic_cast<CUInt32&>(x); if(_data > d._data) return true; else return false; } else if(x.getType() == INT64) { CInt64 & d=dynamic_cast<CInt64&>(x); if( d._data < _data) return true; else return false; } else if( x.getType() == UINT64) { CUInt64 & d=dynamic_cast<CUInt64&>(x); if( d._data < _data) return true; else return false; } else if(x.getType() == FLOAT) { CFloat & d=dynamic_cast<CFloat&>(x); if( d._data < _data) return true; else return false; } else if(x.getType() == DOUBLE) { CDouble & d=dynamic_cast<CDouble&>(x); if( d._data < _data) return true; else return false; } else return false; }
int EventMgr_FireEvent(lua_State* l) { //args: event name, [parameter or parameter table] int ArgCount = lua_gettop(l); if (ArgCount < 1 || ArgCount > 2 || !lua_isstring(l, 1)) { lua_settop(l, 0); return 0; } PParams Params; if (ArgCount > 1 && !lua_isnil(l, 2)) { CData Data; ScriptSrv->LuaStackToData(Data, 2, l); if (lua_istable(l, 2)) Params = (PParams)Data; else if (Data.IsValid()) { //???for all args read and push into array? Params = n_new(CParams(1)); Params->Set(CStrID::Empty, Data); } } EventMgr->FireEvent(CStrID(lua_tostring(l, 1)), Params); return 0; }
bool loadScript(CFile* f) { if( !f->isOpen() ) return false; CData d; d.fromFile(f); d.write("\x0",1); String s = d.data(); try{ object main_module(( handle<>(borrowed (PyImport_AddModule("__main__"))))); object main_namespace = main_module.attr("__dict__"); boost::algorithm::replace_all(s,"\r\n","\n"); handle<> ignored(PyRun_String( s.c_str() , Py_file_input , main_namespace.ptr() , main_namespace.ptr() )); } catch(error_already_set) { PyErr_Print(); return false; }; return true; };
void CChatCDlg::Send_LOGIN(CString id, CString pass) { CData data; data.SetLogindata(D_LOGIN, id, pass); *m_pDataSocket << data; }
int CFeasibilityMap::count_x_out_fn(CData &Data,int i_tau, int i_original,int n_simul, Uniform &randUnif) { // double case2_count_out = 0; int case2_count_out = 0; // Changed by Hang on 5/16/2015 ColumnVector s_i = tau_to_s_fn( i_tau, Data.n_var ); ColumnVector item_by_joint = Data.copy_non_balance_edit(s_i); ColumnVector tilde_y_i = Data.log_D_Observed.row(i_original).t(); for (int i_simul=1; i_simul<=n_simul; i_simul++){ //Generate from uniform distribution ColumnVector y_q = tilde_y_i; for ( int temp_j=1; temp_j<=Data.n_var; temp_j++ ){ if ( item_by_joint(temp_j)==1 ){ y_q(temp_j) = Data.logB_L(temp_j)+Data.logB_U_L(temp_j)*randUnif.Next(); } } ColumnVector x_q = exp_ColumnVector(y_q) ; Data.update_full_x_for_balance_edit(x_q); // if (!Data.PassEdits(x_q)) { case2_count_out += 1.0;} if (!Data.PassEdits(x_q)) { case2_count_out += 1;} // Changed by Hang on 5/16/2015 } if (case2_count_out ==0) { case2_count_out = 1; } return case2_count_out; // ADDED by Hang on 5/16/2015 }
bool CInt32::operator<(const CData &x) { if( x.getType() == INT32 ) { const CInt32 & d=dynamic_cast<const CInt32&>(x); if(_data < d._data) return true; else return false; } else if(x.getType() == INT64) { const CInt64 & d=dynamic_cast<const CInt64&>(x); if( d._data > _data) return true; else return false; } else if( x.getType() == UINT64) { const CUInt64 & d=dynamic_cast<const CUInt64&>(x); if( _data<0 || d._data > (uint64_t)_data) return true; else return false; } else if(x.getType() == FLOAT) { const CFloat & d=dynamic_cast<const CFloat&>(x); if( d._data > _data) return true; else return false; } else if(x.getType() == DOUBLE) { const CDouble & d=dynamic_cast<const CDouble&>(x); if( d._data > _data) return true; else return false; } else return false; }
int CClientSocket::Write(CData& data) { if (m_sock == -1) { m_error = "socket closed"; return FAIL; } int bytestowrite = data.GetSize(); int byteswritten = 0; //loop until we've written all bytes while (byteswritten < bytestowrite) { //wait until socket becomes writeable int returnv = WaitForSocket(true, "Write"); if (returnv == FAIL || returnv == TIMEOUT) return returnv; int size = send(m_sock, data.GetData() + byteswritten, data.GetSize() - byteswritten, 0); if (size == -1) { m_error = "send() " + m_address + ":" + ToString(m_port) + " " + GetErrno(); return FAIL; } byteswritten += size; } return SUCCESS; }
void CChatCDlg::Send_JOIN_MEMBER(CString id, CString pass, CString name, CString serverip) { CDataSocket sock; CData data; //////// 임시 서버 접속 // 클라이언트 소켓 생성 if(!sock.Create()) { AfxMessageBox(_T("클라이언트 소켓 생성 실패")); return; } // 서버에 접속 요청 if(!sock.Connect(serverip, 3666)) // 서버아이피와 포트번호 { AfxMessageBox(_T("서버를 찾을 수 없습니다.")); sock.Close(); return; } // 클라이언트 소켓 초기화 sock.Init(this); //////// 데이터 전송 data.Setdata(D_JOIN_MEMBER, true, id, name, "", "", pass); sock << data; AfxMessageBox(_T("로그인 해 주세요..")); ::Sleep(1000); // 접속해제 sock.Close(); }
void CInstructor::Initialize() { if (m_pCurrentPanel) { RootPanel()->RemoveControl(m_pCurrentPanel); } m_pCurrentPanel = NULL; Clear(); FILE* fp = tfopen_asset("scripts/instructor.txt", "r"); if (!fp) { TMsg("Couldn't load instructor script.\n"); return; } std::shared_ptr<CData> pData(new CData()); CDataSerializer::Read(fp, pData.get()); for (size_t i = 0; i < pData->GetNumChildren(); i++) { CData* pChildData = pData->GetChild(i); if (pChildData->GetKey() == "Lesson") ReadLesson(pChildData); } }
CData* CDecodeFlowData::readData ( const QDomElement& data) { bool bOk = false; CData* d = NULL; QDomElement id = data.firstChildElement("id"); QDomElement name = data.firstChildElement("name"); QDomElement cl = data.firstChildElement("class"); QDomElement flowType = data.firstChildElement("flow-type"); if (!id.isNull() && !name.isNull() && !cl.isNull() && !flowType.isNull()) { bOk = true; d = new CData(name.text()); d->setID(id.text().toInt(&bOk)); d->setDataType((CData::dataType) (flowType.text().toInt(&bOk)) ); CClass* c = m_typeFactory->getTypeById(d->getID()); if (c != NULL) d->setClass(c); else bOk = false; } if ((d != NULL) && (bOk == false)) { delete d; d = NULL; } return d; }
void CCMWorldContext::removeChar(uint id) { CData data; data.wrt((byte)(SIGNALS_START+4)); data << id; write(data); };
void CSeriDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here ar << m_List.GetCount(); for(POSITION pos = m_List.GetHeadPosition(); pos != NULL; ) m_List.GetNext(pos)->Serialize(ar); } else { m_List.RemoveAll(); // TODO: add loading code here int nCount; CData *pData; ar >> nCount; for(int i=0; i<nCount; i++) { pData = new CData; pData->Serialize(ar); m_List.AddTail(pData); } } }
/*================================================================= * Function ID : SMT_GetCurrFileName * Input : void * Output : void * Author : * Date : 2006 2 * Return : void * Description : 获取当前文件 * Notice : *=================================================================*/ bool CSmartCommunicationDlg::SMT_GetCurrFileName(char* cCurFileName,char* sBakFileName) { char sCurFileName[256]; char FileName[256]; CMyLog cLog; CData cData; memset(sCurFileName,0,sizeof sCurFileName); memset(FileName,0,sizeof FileName); strcpy(sBakFileName,m_DealPath); strcat(sBakFileName,"\\Bak\\Bak_"); memcpy(sBakFileName+strlen(sBakFileName),cData.GetSysTime(),8); strcat(sBakFileName,"_DealData.txt"); strcpy(FileName,m_DealPath); strcat(FileName,"\\"); memcpy(FileName+strlen(FileName),cData.GetSysTime(),8); strcat(FileName,"_DealData"); strcpy(sCurFileName,FileName); strcat(sCurFileName,".txt"); if( cData.FileIsExist(sCurFileName) ) { if( rename(sCurFileName,FileName)>=0 ) { strcpy(cCurFileName,FileName); return true; } } return false; }
void CParam::CalculateInitProbA(CData &Data) { // initial value of Y_out_compact and z_out int count_out = 0; int count_in = 0; ColumnVector z_out_large(toolarge_nout); Matrix Y_out_compact_large(toolarge_nout,n_var_independent); while ( (count_in < Data.n_sample) && (count_out < toolarge_nout) ) { int k = rdiscrete_fn(pi); ColumnVector mu_k = Mu.column(k); // Note that mu_k is Mu.column(k) ColumnVector y_compact_i = rMVN_fn( mu_k,LSIGMA[k-1] ); ColumnVector x_compact_i = exp_ColumnVector(y_compact_i); ColumnVector x_i(Data.n_var) ; Data.UpdateFullVector(x_compact_i, x_i); Data.update_full_x_for_balance_edit(x_i); if (Data.PassEdits(x_i)) { count_in++; } else { count_out++; Y_out_compact_large.row(count_out) = y_compact_i.t(); z_out_large(count_out)=k; } } Matrix Y_out_compact = Y_out_compact_large.rows(1,count_out) ; // cut extra space ColumnVector z_out = z_out_large.rows(1,count_out) ; // cut extra space // calculate n_z and Sum_groupX Matrix Y_aug_compact = Y_in_compact & Y_out_compact; ColumnVector z_aug = z_in & z_out; int n_out = z_out.nrows(); Prob_A = (1.0 * Data.n_sample / (Data.n_sample+n_out)); }
void CQModelValue::slotBtnCopy() { std::string name = "quantity"; int i = 1; assert(mpDataModel != NULL); while (!(mpModelValue = mpDataModel->getModel()->createModelValue(name))) { i++; name = "quantity_"; name += TO_UTF8(QString::number(i)); } CData ToCopy = mpObject->toData(); ToCopy.addProperty(CData::Property::OBJECT_NAME, name); ToCopy.removeProperty(CData::Property::OBJECT_INDEX); ToCopy.removeProperty(CData::OBJECT_UUID); ToCopy.removeProperty(CData::OBJECT_REFERENCES); CUndoData::CChangeSet Changes; mpModelValue->applyData(ToCopy, Changes); CUndoData UndoData(CUndoData::Type::INSERT, mpModelValue); ListViews::addUndoMetaData(this, UndoData); UndoData.addMetaDataProperty("Widget Object CN (after)", mpModelValue->getCN()); UndoData.addMetaDataProperty("Widget Object Name (after)", mpModelValue->getObjectName()); slotNotifyChanges(mpDataModel->recordData(UndoData)); }
void CParam::Initialize(CData &Data){ n_pheno = Data.Y.n_rows ; n_SNP = Data.Y.n_cols ; // constants but stored in CParam for convienence Data.logY = arma::zeros<arma::mat>(n_pheno,n_SNP) ; // Note 1. This is used to calculate sum of log y_it when e_it=1. // 2. (Weak signal) Because e_it=0 with y_it <= 0 by definition (model assumption), // we will not use log y_it for e_it=0 and store zero here. // 3. (Strong signal) Also, we put e_it=1 when y_it > threshold // V 1.3.1 for (int i_pheno=0; i_pheno<n_pheno; i_pheno++ ){ for (int i_SNP=0; i_SNP<n_SNP; i_SNP++ ){ if ( Data.Y(i_pheno,i_SNP) > 0){ // V 2.0.2 Data.logY(i_pheno,i_SNP) = log(Data.Y(i_pheno,i_SNP)) ; if ( Data.Y(i_pheno,i_SNP) > Data.threshold_on ) E_mat(i_pheno,i_SNP) = 1 ; } else { E_mat(i_pheno,i_SNP) = 0 ; } } } normC = normC_fn(Beta, Data) ; // Ver_1_4_1 if ( normC < 0 ){ Rcpp::stop("The initialized normC has a negative value.") ; } Data.msg_level = 0; //0 errors only; 1: errors and warnings; 2: errors, warnings and information sum_E_ijt = arma::zeros<arma::cube>(n_pheno,n_pheno,n_SNP) ; is_initialized = 1 ; }
/*================================================================= * Function ID : CheckIsChangeYear * Input : char* cpath * Output : void * Author : DengJun * Date : Apr 2005 * Return : void * Description : * Notice : 检查是否已经是新的一年开始 * : cpath-->路径 *=================================================================*/ void CMyLog::CheckIsChangeYear(char* cpath) { char oldPath[256],cyear[16]; char NewPath[256]; int len=0; CData mData; memset(cyear, 0x00,sizeof cyear); memset(oldPath,0x00,sizeof oldPath); memset(NewPath,0x00,sizeof NewPath); memcpy(cyear,mData.GetSysTime(),6); strcpy(oldPath,cpath); len=strlen(cpath); if( !len ) return ; while( len--) { if( cpath[len]=='\\') { if( memcmp(cpath+len-6,cyear,6) ) { memcpy(NewPath,cpath,len-6); strcat(NewPath,cyear); CreateDirectory(NewPath,NULL); memcpy(cpath+len-6,cyear,6); } break; } } }
void CPCRCHelloState::onLoginSignal(CData &data) { CLog::instance()->log(CLog::msgLvlInfo,_("Sending login request to root server.\n")); CData request; request.wrt((ireon::net::commandId)ireon::net::rspcCodes::scHelloLogin); request.append(data.data(), data.length()); m_ownerConnection->write(request); }
void CCMWorldContext::sendNewChar(ClientOwnCharData *ch,uint acc) { CData data; data.wrt((byte)(SIGNALS_START+3)); ch->serialize(data); data << acc; write(data); };
void CDataManager::CleanArrivalData() { for(map<string, CData*>::iterator mapiter = m_mapData.begin(); mapiter != m_mapData.end(); mapiter++) { tagArrival stArrival; CData* pData = mapiter->second; pData->UpdateBusInfo(stArrival); } }
void CNode::print() { CData * curElement = mFirst; while (curElement) { printf( "%s\n", curElement->getStr() ); curElement = curElement->getNext() ; } printf( "\n" ); }
// ----------------------------------------------------------------------------- // CProEngToneHandler::IsProtectedL // ----------------------------------------------------------------------------- // TBool CProEngToneHandler::IsProtectedL( const TDesC& aFileName ) const { TInt isProtected( EFalse ); ContentAccess::TVirtualPathPtr path( aFileName, ContentAccess::KDefaultContentObject ); CData* data = CData::NewLC( path, EContentShareReadWrite ); TInt result = data->GetAttribute( EIsProtected, isProtected ); CleanupStack::PopAndDestroy(); // data return( ( result == DRMCommon::EOk ) && isProtected ); }
void ValueWidget::init(int idx, QString style ) { m_dataIndex = idx; m_label->setText( gData.GetL( idx ) ); m_value->display( gData.GetV( idx ) ); m_value->setStyleSheet( CSS_LCDDISPLAY ); setStyleSheet( style ); }
bool CModel::LoadSourceFile() { #ifdef TINKER_NO_TOOLS return false; #else CConversionScene* pScene = new CConversionScene(); CModelConverter c(pScene); if (!c.ReadModel(m_sFilename)) { delete pScene; return false; } g_asTextures.clear(); g_aaflData.clear(); g_aabbVisBounds = AABB(Vector(999, 999, 999), Vector(-999, -999, -999)); g_aabbPhysBounds = AABB(Vector(999, 999, 999), Vector(-999, -999, -999)); LoadSceneIntoToy(pScene); size_t iTextures = g_asTextures.size(); m_ahMaterials.resize(iTextures); m_aiVertexBuffers.resize(iTextures); m_aiVertexBufferSizes.resize(iTextures); for (size_t i = 0; i < iTextures; i++) { if (g_aaflData[i].size() == 0) continue; m_aiVertexBuffers[i] = CRenderer::LoadVertexDataIntoGL(g_aaflData[i].size()*4, &g_aaflData[i][0]); m_aiVertexBufferSizes[i] = g_aaflData[i].size()/FIXED_FLOATS_PER_VERTEX; CData oMaterialData; CData* pShader = oMaterialData.AddChild("Shader", "model"); pShader->AddChild("DiffuseTexture", g_asTextures[i]); m_ahMaterials[i] = CMaterialLibrary::AddMaterial(&oMaterialData); //TAssert(m_aiMaterials[i]); if (!m_ahMaterials[i].IsValid()) TError(tstring("Couldn't create fake material for texture \"") + g_asTextures[i] + "\"\n"); } m_aabbVisBoundingBox = g_aabbVisBounds; m_aabbPhysBoundingBox = g_aabbPhysBounds; delete pScene; return true; #endif }
// _____________________________________________________________________ void CRaspiGPIO::onDataChangeWritePWM(double percent) { // récupère la data et par son nom, on connaitra le numéro de GPIO concerné CData* data = qobject_cast<CData*>(sender()); if (!data) return; bool ok; unsigned int gpio_num = data->getName().remove(PREFIX_RASPI_OUT_DATANAME).toInt(&ok); if (ok) { writePwmPin(gpio_num, (float)percent); } }
void CCampaignData::ReadData(const tstring& sFile) { FILE* fp = tfopen_asset(sFile, "r"); CData* pData = new CData(); CDataSerializer::Read(fp, pData); CData* pCampaign = pData->FindChild("Campaign"); m_iHighestLevelReached = pCampaign->FindChild("HighestLevel")->GetValueInt(); m_iCurrentLevel = pCampaign->FindChild("CurrentLevel")->GetValueInt(); delete pData; }
CData *CDataFactory::createData(QString data_type_name) const { if(!m_makers.contains(data_type_name)) { return nullptr; } data_maker_fnc make = m_makers.value(data_type_name); CData *data = make(); data->setTypeName(data_type_name); return data; }
bool CDataManager::SetArrivalData(const tagArrival& stArrival) { string strLineID = stArrival.strLineID; map<string, CData*>::iterator mapiter = m_mapData.find(strLineID); if(mapiter != m_mapData.end()) { CData* pData = mapiter->second; pData->UpdateBusInfo(stArrival); } return true; }
/* * Synthesis using pitch marks. * * Derived instances of FBAproc should override method * SynthesizePM() to add the desired functionality * * @return O_K if successfull, NOT_EXEC otherwise */ INT16 CGEN_VPROTECTED CFBAproc::SynthesizeUsingPM(data *idFea, data *idPm, data *idSyn) { CData *idExcite = NULL; FLOAT64 *excitation = NULL; FLOAT64 *synthesis = NULL; INT32 nSamples = 0; INT16 nPer = 0; INT32 nCompVuv = idFea->FindComp("v/uv"); INT16 nCompFea = idFea->GetNNumericComps() - (nCompVuv >= 0 ? 1 : 0); INT32 iRecFea = 0; INT32 nRecFea = 0; AlignFramesToPitch(idPm, idFea, idFea); nRecFea = idFea->GetNRecs(); if(m_bSynEnhancement) { for(iRecFea = 0; iRecFea < nRecFea; iRecFea++) { FeaEnhancement((FLOAT64*)idFea->XAddr(iRecFea,0), nCompFea); } } Smooth(idFea, idPm, idFea); // Generate modulated excitation ICREATEEX(CData,idExcite,"~idExcite",NULL); DLPASSERT(O_K==ModEx(idPm,idExcite)); DLPASSERT(!idExcite->IsEmpty()); nSamples = idExcite->GetNRecs(); idSyn->Reset(); idSyn->AddComp("syn", T_DOUBLE); idSyn->Allocate(nSamples); excitation = (FLOAT64*)idExcite->XAddr(0, 0); synthesis = (FLOAT64*)idSyn->XAddr(0, 0); for(INT32 currSample = 0, currPer = 0; (currSample < nSamples) && (currPer < idFea->GetNRecs()); currSample += nPer, currPer++) { nPer = (INT16)idPm->Dfetch(currPer,0); if(SynthesizeFrame((FLOAT64*)idFea->XAddr(currPer,0), nCompFea, excitation+currSample, nPer, synthesis+currSample) != O_K) { IDESTROY(idExcite); return IERROR(this,FBA_SYNTHESISE, currPer, 0,0); } } IDESTROY(idExcite); if (m_nMinLog != 0.0) for (INT32 i=0; i<idSyn->GetNRecs(); i++) *((FLOAT64*)idSyn->XAddr(0, 0)+i) *= exp(m_nMinLog); return O_K; }
void CCampaignData::SaveData(const tstring& sFile) { FILE* fp = tfopen_asset(sFile, "w"); CData* pData = new CData(); CData* pCampaign = pData->AddChild("Campaign"); pCampaign->AddChild("HighestLevel")->SetValue(m_iHighestLevelReached); pCampaign->AddChild("CurrentLevel")->SetValue(m_iCurrentLevel); CDataSerializer::Save(fp, pData); delete pData; }