//Fileoutput int Gene::SaveGene(string InFilename) { if (InFilename.length() == 0) { InFilename = GetData("FILENAME",STRING); if (InFilename.length() == 0) { InFilename = GetData("DATABASE",STRING); if (InFilename.length() == 0) { return FAIL; } } } if (InFilename.substr(1,1).compare(":") != 0 && InFilename.substr(0,1).compare("/") != 0) { InFilename = GetDatabaseDirectory(GetParameter("database"),"new gene directory")+InFilename; } ofstream Output; if (!OpenOutput(Output,InFilename)) { return FAIL; } //First I check to see if the user specified that the input headers be printed in the output file vector<string>* FileHeader = StringToStrings(GetParameter("gene data to print"),";"); vector<string> InputHeaders; for (int i=0; i < int(FileHeader->size()); i++) { if ((*FileHeader)[i].compare("INPUT_HEADER") == 0) { InputHeaders = GetAllData("INPUT_HEADER",STRING); break; } } for (int i=0; i < int(InputHeaders.size()); i++) { string Data; Interpreter(InputHeaders[i],Data,false); Output << InputHeaders[i] << "\t" << Data << endl; } for (int i=0; i < int(FileHeader->size()); i++) { //I check to see if the current file header has already been printed to file if ((*FileHeader)[i].compare("INPUT_HEADER") != 0) { int j =0; for (j=0; j < int(InputHeaders.size()); j++) { if (InputHeaders[j].compare((*FileHeader)[i]) == 0) { break; } } if (j == int(InputHeaders.size())) { //If the current file header has not already been printed to file, it is printed now string Data; Interpreter((*FileHeader)[i],Data,false); if (Data.length() > 0) { Output << (*FileHeader)[i] << "\t" << Data << endl; } } } } Output.close(); return SUCCESS; }
/***************************************** 功能: 解调 从InDataBuf开始Lenth 这么长的数据 里,用MobileType方式,解调出数据,存在OutDataBuf里 反回时,解到哪个点放在OutLenIndix里 本函数调用的函数清单: 无 调用本函数的函数清单: main 输入参数: *InDataBuf 采样值地址 lenth 总长度 输出参数: *OutDataBuf 数据保存的地方 *OutLenIndix 解到哪里 函数返回值说明: 0:出错,1:没有滤波 2:需要滤波 使用的资源 ******************************************/ int Demodulate(BYTE *OutDataBuf, short *InDataBuf, unsigned long lenth,unsigned long *OutLenIndix) { BYTE LoopForSmooth = 0;// 0 是第一次,1是第二次 BYTE DemodulationResult = 0;// 找同步头和解调的结果,1为成功,0为失败 unsigned long lLowF = 0; unsigned long lHighF = 0; int MobileType = 3; // 表示频率5.5k,解调的频率是固定的 for(LoopForSmooth = 0;LoopForSmooth < 2; LoopForSmooth++ ) { if(LoopForSmooth == 1)//两次循环,先不滤波,解不出来再滤波。 { printf("start Smoothing wave\n");// lLowF = (unsigned long)((float)(2000*2/(MobileType+1))*(float)(1.0/32.0 * (float)(MobileType+1)+15.0/16.0)); lHighF = (unsigned long)((float)(15000*2/(MobileType+1))*(float)(1.0/16.0 * (float)(MobileType+1)+7.0/8.0)); memcpy(InDataBuf,(char*)InDataBuf+lenth*2,lenth*2); SmoothingWave(InDataBuf,lenth, lLowF, lHighF, 44100); *OutLenIndix = 0; } DisInterference(InDataBuf,lenth,MobileType);//去扰 DemodulationResult = FindHead(InDataBuf,lenth,OutLenIndix,MobileType);//找同步头 if( DemodulationResult == 1)//如果找到了,则解 { DemodulationResult = GetAllData(OutDataBuf,InDataBuf,lenth,OutLenIndix,MobileType);//解调 } if(LoopForSmooth == 0) { if(DemodulationResult == 1)//continue;//第一次解不出来,滤波后再解 { printf("with no need for Smoothing wave\n");// return 1;//第一次就解出来了,说明是没有滤波就解出来了 } } else if(LoopForSmooth == 1) { if(DemodulationResult == 0) { return 0;//第二次还解不出来,出错了 } else { printf("need Smoothing wave\n");// return 2;//第二次才解出来,说明需要滤波 } } } return 0;//出错了 }
Picture::Picture(HBITMAP gdiBitmap) { IWICStream* stream = nullptr; auto wicFactory = PublicResource::GetGraphicsResource().WicImagingFactory.p; wicFactory->CreateBitmapFromHBITMAP( gdiBitmap, nullptr, WICBitmapIgnoreAlpha, &bitmap); auto data = GetAllData(); InitializeWithBuffer(wicFactory, data.first, data.second); }
// returns success, list of ControllerData static boost::python::tuple GetAllNewestData() { return GetAllData(0); }
//Fileinput int Gene::Interpreter(string DataName, string& DataItem, bool Input) { int DataID = TranslateFileHeader(DataName,GENE); if (DataID == -1) { AddData(DataName.data(),DataItem.data(),STRING); //FErrorFile() << "UNRECOGNIZED REFERENCE: " << GetData("FILENAME",STRING) << " data reference: " << DataName << " not recognized." << endl; //FlushErrorFile(); return FAIL; } switch (DataID) { case GENE_DBLINK: { if (Input) { AddData(DataName.data(),DataItem.data(),DATABASE_LINK); } else { DataItem = GetAllDataString(DataName.data(),DATABASE_LINK); } break; } case GENE_COORD: { if (Input) { vector<string>* Strings = StringToStrings(DataItem,"."); if (Strings->size() >= 2) { AddData("START COORD",atof((*Strings)[0].data())); AddData("END COORD",atof((*Strings)[1].data())); } delete Strings; } else { double Start = GetDoubleData("START COORD"); double End = GetDoubleData("END COORD"); if (Start != FLAG && End != FLAG) { DataItem.assign(dtoa(Start)); DataItem.append(".."); DataItem.append(dtoa(End)); } } break; } case GENE_REACTION: { if (Input) { //Do nothing... reactions will add themselves to the genes } else { for (int i=0; i < int(ReactionList.size()); i++) { DataItem.append(ReactionList[i]->GetData("DATABASE",STRING)); if (i < int(ReactionList.size()-1)) { DataItem.append("\t"); } } } break; } case GENE_PARALOG: { if (Input) { vector<string>* Strings = StringToStrings(DataItem,"\t "); for (int i=0; i < int(Strings->size()); i += 2) { if (AddData("PARALOGS",(*Strings)[i].data(),STRING)) {; AddData("PARA SIMS",atof((*Strings)[i+1].data()),false); } } delete Strings; } else { vector<string> AllParalogs = GetAllData("PARALOGS",STRING); vector<double> AllSims = GetAllData("PARA SIMS"); for (int i=0; i < int(AllParalogs.size()); i++) { DataItem.append(AllParalogs[i]); DataItem.append(" "); DataItem.append(dtoa(AllSims[i])); if (i < int(AllParalogs.size()-1)) { DataItem.append("\t"); } } } break; } case GENE_ORTHOLOG: { if (Input) { vector<string>* Strings = StringToStrings(DataItem,"\t "); for (int i=0; i < int(Strings->size()); i += 2) { if (AddData("ORTHOLOGS",(*Strings)[i].data(),STRING)) {; AddData("ORTHO SIMS",atof((*Strings)[i+1].data()),false); } } delete Strings; } else { vector<string> AllParalogs = GetAllData("ORTHOLOGS",STRING); vector<double> AllSims = GetAllData("ORTHO SIMS"); for (int i=0; i < int(AllParalogs.size()); i++) { DataItem.append(AllParalogs[i]); DataItem.append(" "); DataItem.append(dtoa(AllSims[i])); if (i < int(AllParalogs.size()-1)) { DataItem.append("\t"); } } } break; } case GENE_DOUBLE: { if (Input) { AddData(DataName.data(),DataItem.data(),DOUBLE); } else { DataItem = GetAllDataString(DataName.data(),DOUBLE); } break; } case GENE_STRING: { if (Input) { AddData(DataName.data(),DataItem.data(),STRING); } else { DataItem = GetAllDataString(DataName.data(),STRING); } break; } case GENE_QUERY: { if (Input) { if (GetParameter("save query data on input").compare("1") == 0) { AddData(DataName.data(),DataItem.data(),STRING); } } else { DataItem = Query(DataName); } break; } case GENE_LOAD: { if (Input) { LoadGene(DataItem); } else { DataItem = GetData("DATABASE",STRING); } break; } default: { //FErrorFile() << "UNRECOGNIZED DATA ID: Data ID: " << DataID << " input for data reference: " << DataName << " not recognized. Check gene code."; //FlushErrorFile(); return FAIL; } } return SUCCESS; }
void LinkOptions::OnOk() { GetAllData((LinkGeneral*)m_tabctrl.m_tabdialog[0]); CDialog::OnOK(); return; }