int sceNpTrophyRegisterContext(u32 context, u32 handle, u32 statusCb_addr, u32 arg_addr, u64 options) { sceNpTrophy.Warning("sceNpTrophyRegisterContext(context=%d, handle=%d, statusCb_addr=0x%x, arg_addr=0x%x, options=0x%llx)", context, handle, statusCb_addr, arg_addr, options); if (!(s_npTrophyInstance.m_bInitialized)) return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED; if (!Memory.IsGoodAddr(statusCb_addr)) return SCE_NP_TROPHY_ERROR_INVALID_ARGUMENT; if (options & (~(u64)1)) SCE_NP_TROPHY_ERROR_NOT_SUPPORTED; // TODO: There are other possible errors int ret; sceNpTrophyInternalContext& ctxt = s_npTrophyInstance.contexts[context]; TRPLoader trp(*(ctxt.trp_stream)); // TODO: Get the path of the current user if (trp.Install("/dev_hdd0/home/00000001/trophy/" + ctxt.trp_name)) ret = CELL_OK; else ret = SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; // TODO: Callbacks trp.Close(); return ret; }
void bmImage::render(wxDC& dc) { bitmap = wxBitmap(aswxImage); dc.Clear(); // few variables to make life easier cv::Vec2f pScale = cv::Vec2f(((bmImageFrame*)this->GetParent())->scale); cv::Vec2f pVOffScale = cv::Vec2f(((bmImageFrame*)this->GetParent())->voff); cv::Vec2f pScroll = cv::Vec2f(((bmImageFrame*)this->GetParent())->scroll); wxPoint orgp = dc.GetLogicalOrigin(); wxPoint trp(pScroll[0], pScroll[1]); if (asCvMat.cols * pScale[0] < this->GetSize().GetWidth()) { trp.x = -(this->GetSize().GetWidth() - asCvMat.cols * pScale[0]) / 2 / pScale[0]; } if (asCvMat.rows * pScale[1] < this->GetSize().GetHeight()) { trp.y = -(this->GetSize().GetHeight() - asCvMat.rows * pScale[1]) / 2 / pScale[1]; }/* trp += wxPoint( -(this->GetSize().GetWidth() - asCvMat.cols * pVOffScale[0]) / 2 / pVOffScale[0], -(this->GetSize().GetHeight() - asCvMat.rows * pVOffScale[1]) / 2 / pVOffScale[1] );*/ trp += wxPoint( -asCvMat.cols * (pVOffScale[0] - 1.0f) / 2, -asCvMat.rows * (pVOffScale[1] - 1.0f) / 2 ); dc.SetLogicalOrigin(trp.x, trp.y); dc.SetUserScale(pScale[0], pScale[1]); dc.DrawBitmap(bitmap, wxPoint(0, 0), false); dc.SetLogicalOrigin(orgp.x, orgp.y); }
/** * A função executa_comando é uma das funções mais importantes pois é ela que vai reagir aos comandos dados pelo utilizador. * A função irá receber a linha de comando separa la em dois, no comando e nos argumentos do comando, e passa los para as funções associadas aos comandos. * @param Tab Tabuleiro do jogo * @param DIM dimensão do tabuleiro * @param linha Recebe uma string que corresponde á linha lida da shell. * @returns torna um inteiro que verifica se foi ou não bem sucedida a função. */ int executa_comando(char *linha,int *DIM,Elem **Tab) { char cmd[1025]; char args[1025]; int nargs=sscanf(linha, "%s %[^\n]", cmd, args); if((strcmp(cmd, "b") == 0 || strcmp(cmd, "p") == 0 || strcmp(cmd, "i") == 0)) return executaJogada(args,cmd,DIM,Tab); if(strcmp(cmd, "cr") == 0 ) return executaCriaJogo(args,DIM,Tab); if(strcmp(cmd,"gr")==0 ) return executaGravaJogo(args,DIM,Tab); if(strcmp(cmd,"?")==0 && nargs==1) return ajuda(); if(strcmp(cmd,"trp")==0 && nargs==1) return trp(Tab,DIM); if(strcmp(cmd,"snd")==0 && nargs==1) return snd(Tab,DIM); if(strcmp(cmd,"pis")==0 && nargs==1) return pis(Tab,DIM); if(strcmp(cmd,"pds")==0 && nargs==1) return pds(Tab,DIM); if(strcmp(cmd,"vb")==0 && nargs==1) return vb(Tab,DIM); if(strcmp(cmd,"vp")==0 && nargs==1) return vp(Tab,DIM); if(strcmp(cmd,"vl")==0 && nargs==1) return vl(Tab,DIM); if(strcmp(cmd,"q")==0) exit(0); return mensagem_de_erro(E_COMMAND); }
bool Matrix::ort() { Matrix *notrp = this->copy(); trp(); /* untransponierte mit transponierter Matrix multiplizieren */ Matrix *result = *notrp * *this; delete notrp; notrp = 0; /* Test auf Einheitsmatrix */ for (int i = 0; i < M; i++) { for (int j = 0; j < M; j++) { if ((i != j && result->getElem(i, j) != 0) || (i == j && result->getElem(i, j) != 1)) { delete result; result = 0; return false; } } } delete result; result = 0; return true; }
int sceNpTrophyRegisterContext(u32 context, u32 handle, u32 statusCb_addr, u32 arg_addr, u64 options) { sceNpTrophy.Warning("sceNpTrophyRegisterContext(context=%d, handle=%d, statusCb_addr=0x%x, arg_addr=0x%x, options=0x%llx)", context, handle, statusCb_addr, arg_addr, options); if (!(s_npTrophyInstance.m_bInitialized)) return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED; if (!Memory.IsGoodAddr(statusCb_addr)) return SCE_NP_TROPHY_ERROR_INVALID_ARGUMENT; if (options & (~(u64)1)) return SCE_NP_TROPHY_ERROR_NOT_SUPPORTED; if (context >= s_npTrophyInstance.contexts.size()) return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT; // TODO: There are other possible errors sceNpTrophyInternalContext& ctxt = s_npTrophyInstance.contexts[context]; if (!ctxt.trp_stream) return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST; TRPLoader trp(*(ctxt.trp_stream)); if (!trp.LoadHeader()) return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; // Rename or discard certain entries based on the files found char target [32]; sprintf(target, "TROP_%02d.SFM", Ini.SysLanguage.GetValue()); if (trp.ContainsEntry(target)) { trp.RemoveEntry("TROPCONF.SFM"); trp.RemoveEntry("TROP.SFM"); trp.RenameEntry(target, "TROPCONF.SFM"); } else if (trp.ContainsEntry("TROP.SFM")) { trp.RemoveEntry("TROPCONF.SFM"); trp.RenameEntry("TROP.SFM", "TROPCONF.SFM"); } else if (!trp.ContainsEntry("TROPCONF.SFM")) { return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } // Discard unnecessary TROP_XX.SFM files for (int i=0; i<=18; i++) { sprintf(target, "TROP_%02d.SFM", i); if (i != Ini.SysLanguage.GetValue()) trp.RemoveEntry(target); } // TODO: Get the path of the current user std::string trophyPath = "/dev_hdd0/home/00000001/trophy/" + ctxt.trp_name; if (!trp.Install(trophyPath)) return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; TROPUSRLoader* tropusr = new TROPUSRLoader(); tropusr->Load(trophyPath + "/TROPUSR.DAT", trophyPath + "/TROPCONF.SFM"); ctxt.tropusr = tropusr; // TODO: Callbacks return CELL_OK; }
/** * @brief FacialModule::onTrainRequest * On cherche le dernier label du fichier csv * On vérifie que le nom envoyé n'est pas contenu dans le csv * * 2 - Absence de la personne * --- on ouvre le fichier csv en écriture et on enregiste la personne * --- sous la forme "dernierlabel;nom". On entraine ensuite le modele * --- et on met à jour les informations contenues dans le fichier csv * * 1 - Présence de la personne * --- on met juste à jour le modele en donnant l'image de personne * --- et son label associé * * @param p */ void FacialModule::onTrainRequest(Packet *p) { *this << DEBUG << "Train Request" << endl; *this << DEBUG << "Loading FaceRecognizer..." << endl; FacialUtils::loadFaceRecognizer(_faceRecognizer, FACERECO); *this << DEBUG << "FaceRecognizer loaded" << endl; TrainRequestPacket trp(p); string name = trp.getPerson()->getId(); //nom de la personne vector<uint8> img(trp.getTrainData(), trp.getTrainData() + trp.getTrainDataSize()); char a[50]; Mat m = imdecode(img, CV_LOAD_IMAGE_GRAYSCALE); int labelName = FacialUtils::labelFromName(FICHIER, name); vector<Mat> newImage; vector<int> newLabel; newImage.push_back(m); if(labelName == -1) { labelName = FacialUtils::lastClassLabel(FICHIER); FacialUtils::newUser(FICHIER, labelName, name); } newLabel.push_back(labelName); _faceRecognizer->update(newImage, newLabel); *this << DEBUG << "Train Request complete" << endl; _faceRecognizer->save(FACERECO); TrainResultPacket pReturn(p); pReturn.doSend(); }
error_code sceNpTrophyGetRequiredDiskSpace(u32 context, u32 handle, vm::ptr<u64> reqspace, u64 options) { sceNpTrophy.warning("sceNpTrophyGetRequiredDiskSpace(context=0x%x, handle=0x%x, reqspace=*0x%x, options=0x%llx)", context, handle, reqspace, options); if (!reqspace) { return SCE_NP_TROPHY_ERROR_INVALID_ARGUMENT; } const auto ctxt = idm::get<trophy_context_t>(context); if (!ctxt) { return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT; } const auto hndl = idm::get<trophy_handle_t>(handle); if (!hndl) { return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE; } if (!fs::is_dir(vfs::get("/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/" + ctxt->trp_name))) { TRPLoader trp(ctxt->trp_stream); if (trp.LoadHeader()) { *reqspace = trp.GetRequiredSpace(); return CELL_OK; } } *reqspace = 0; return CELL_OK; }
int sceNpTrophyRegisterContext(u32 context, u32 handle, vm::ptr<SceNpTrophyStatusCallback> statusCb, u32 arg_addr, u64 options) { sceNpTrophy->Warning("sceNpTrophyRegisterContext(context=%d, handle=%d, statusCb_addr=0x%x, arg_addr=0x%x, options=0x%llx)", context, handle, statusCb.addr(), arg_addr, options); if (!(sceNpTrophyInstance.m_bInitialized)) return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED; if (options & (~(u64)1)) return SCE_NP_TROPHY_ERROR_NOT_SUPPORTED; if (context >= sceNpTrophyInstance.contexts.size()) return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT; // TODO: There are other possible errors sceNpTrophyInternalContext& ctxt = sceNpTrophyInstance.contexts[context]; if (!ctxt.trp_stream) return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST; TRPLoader trp(*(ctxt.trp_stream)); if (!trp.LoadHeader()) return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; // Rename or discard certain entries based on the files found const size_t kTargetBufferLength = 31; char target[kTargetBufferLength+1]; target[kTargetBufferLength] = 0; strcpy_trunc(target, fmt::Format("TROP_%02d.SFM", Ini.SysLanguage.GetValue())); if (trp.ContainsEntry(target)) { trp.RemoveEntry("TROPCONF.SFM"); trp.RemoveEntry("TROP.SFM"); trp.RenameEntry(target, "TROPCONF.SFM"); } else if (trp.ContainsEntry("TROP.SFM")) { trp.RemoveEntry("TROPCONF.SFM"); trp.RenameEntry("TROP.SFM", "TROPCONF.SFM"); } else if (!trp.ContainsEntry("TROPCONF.SFM")) { return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } // Discard unnecessary TROP_XX.SFM files for (int i=0; i<=18; i++) { strcpy_trunc(target, fmt::Format("TROP_%02d.SFM", i)); if (i != Ini.SysLanguage.GetValue()) trp.RemoveEntry(target); } // TODO: Get the path of the current user std::string trophyPath = "/dev_hdd0/home/00000001/trophy/" + ctxt.trp_name; if (!trp.Install(trophyPath)) return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; TROPUSRLoader* tropusr = new TROPUSRLoader(); std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT"; std::string trophyConfPath = trophyPath + "/TROPCONF.SFM"; tropusr->Load(trophyUsrPath, trophyConfPath); ctxt.tropusr.reset(tropusr); // TODO: Callbacks statusCb(context, SCE_NP_TROPHY_STATUS_INSTALLED, 100, 100, arg_addr); statusCb(context, SCE_NP_TROPHY_STATUS_PROCESSING_COMPLETE, 100, 100, arg_addr); return CELL_OK; }
void buildFakeAngTree(const Char_t* outtag, const Float_t timereso, // ns const UInt_t simevts=1, const Float_t thetaOpt=400, // deg const Float_t phiOpt=400, // deg const Float_t coneOpt=400, // deg const UInt_t rseed=23192, const Float_t norm=100.0, // mV const Float_t noise=20.0, // mV const Char_t* outdir="/data/users/cjreed/work/simEvts", const Char_t* infn="/w2/arianna/jtatar/nt.sigtemps.root", const Char_t* geofn="/data/users/cjreed/work/" "BounceStudy/Stn10/" "CampSiteGeometry.root") { // if any of the angles (thetaOpt, phiOpt, coneOpt) > 360, a random // value will be used instead // // expect angles in the Templates tree to be in degrees // // expect the waveforms in the Templates tree to have amplitude 1 TRandom3 rnd(rseed); geof = TFile::Open(geofn); gg = dynamic_cast<TGeoManager*>(geof->Get("CampSite2013")); site = dynamic_cast<const TSnGeoStnSite*>(gg->GetTopVolume()); TVector3 pos[NSnConstants::kNchans], nvec[NSnConstants::kNchans]; for (UChar_t ch=0; ch<NSnConstants::kNchans; ++ch) { site->SetLPDAPosition(ch, pos[ch]); site->SetLPDANormalVec(ch, nvec[ch]); Printf("pos ch%d:",ch); pos[ch].Print(); Printf("normal ch%d:",ch); nvec[ch].Print(); } TArrayD zeros(6); inf = TFile::Open(infn); nnt = dynamic_cast<TTree*>(inf->Get("Templates")); TString infns(infn); TString indir; Int_t fl(0); if (infns.Contains('/')) { fl = infns.Last('/') + 1; indir = infns(0, fl-1); } TString plaininfn = infns(fl, infns.Length()-fl); TString outfn = Form("%s/FakeEvts.%s.%s", outdir, outtag, plaininfn.Data()); outf = TFile::Open(outfn.Data(),"recreate"); outf->cd(); TParameter<Float_t> trp("TimeResolution", timereso); trp.Write(); TParameter<Float_t> nmp("Normalization", norm); nmp.Write(); TParameter<Float_t> nop("NoiseRMS", noise); nop.Write(); TParameter<UInt_t> rsp("RandomSeed", rseed); rsp.Write(); TSnCalWvData* wave = new TSnCalWvData; Float_t eang(0), hang(0), hpf(0), limiter(0), coneang(0); Bool_t bice(kFALSE); nnt->SetBranchAddress("wave.",&wave); nnt->SetBranchAddress("EAng",&eang); nnt->SetBranchAddress("HAng",&hang); nnt->SetBranchAddress("hpf",&hpf); nnt->SetBranchAddress("limiter",&limiter); nnt->SetBranchAddress("coneAng",&coneang); nnt->SetBranchAddress("bIce",&bice); // to look up waveform for EAng, HAng nnt->BuildIndex("EAng + (1000*HAng)","coneAng"); // find the max angles Printf("finding allowed angles..."); std::set<Float_t> Eangs, Hangs, Cangs; const Long64_t nnents = nnt->GetEntries(); for (Long64_t i=0; i<nnents; ++i) { nnt->GetEntry(i); Eangs.insert(eang); Hangs.insert(hang); Cangs.insert(coneang); } #ifdef DEBUG std::set<Float_t>::const_iterator ang, end = Eangs.end(); Printf("EAngs:"); for (ang=Eangs.begin(); ang!=end; ++ang) { Printf("%g",*ang); } Printf("HAngs:"); for (ang=Hangs.begin(), end=Hangs.end(); ang!=end; ++ang) { Printf("%g",*ang); } Printf("ConeAngs:"); for (ang=Cangs.begin(), end=Cangs.end(); ang!=end; ++ang) { Printf("%g",*ang); } #endif Float_t theta(0), phi(0), cone(0); Float_t EAng[NSnConstants::kNchans], HAng[NSnConstants::kNchans]; Float_t CAng(0); TSnCalWvData* evdat = new TSnCalWvData; TSnEventMetadata* meta = new TSnEventMetadata; TSnEventHeader* hdr = new TSnEventHeader; //ot = nnt->CloneTree(0); //ot->SetName("SimTemplEvts"); ot = new TTree("SimTemplEvts","simulated events from templates",1); ot->SetDirectory(outf); ot->Branch("EventMetadata.",&meta); ot->Branch("EventHeader.",&hdr); ot->Branch("EAng",&(EAng[0]),Form("EAng[%hhu]/F",NSnConstants::kNchans)); ot->Branch("HAng",&(HAng[0]),Form("HAng[%hhu]/F",NSnConstants::kNchans)); ot->Branch("CAng",&CAng,"CAng/F"); ot->Branch("theta",&theta,"theta/F"); ot->Branch("phi",&phi,"phi/F"); ot->Branch("NuData.",&evdat); // some useful aliases TString an; for (UChar_t ch=0; ch<NSnConstants::kNchans; ++ch) { // to use as a cut for a particular channel: an = Form("Ch%d",ch); ot->SetAlias(an.Data(), Form("(Iteration$>=(%hhu*%hhu)) && (Iteration$<(%hhu*%hhu))", NSnConstants::kNsamps, ch, NSnConstants::kNsamps, static_cast<UChar_t>(ch+1))); // to use as a variable showing the sample number [0,127] for any chan an = Form("SmpCh%d",ch); ot->SetAlias(an.Data(), Form("Iteration$-%u", static_cast<UInt_t>(ch) *static_cast<UInt_t>(NSnConstants::kNsamps))); // e.g. Draw("RawData.fData:SmpCh2","EventHeader.fNum==21 && Ch2","l") } Printf("generating events..."); TStopwatch timer; timer.Start(); for (UInt_t i=0; i<simevts; ++i) { if ( (i%1000)==0 ) { fprintf(stderr,"Processing %u/%u ... \r",i,simevts); } // choose angles theta = (thetaOpt>360.) ? TMath::ACos( rnd.Uniform(-1.0, 0.0) ) : thetaOpt * TMath::DegToRad(); phi = (phiOpt>360.) ? rnd.Uniform(0.0, TMath::TwoPi()) : phiOpt * TMath::DegToRad(); cone = (coneOpt>360.) ? rnd.Uniform(*(Cangs.begin()), *(Cangs.rbegin())) : coneOpt; // leave this one in degrees (as in the tree) CAng = findNearestAllowedAngle(Cangs, cone); #ifdef DEBUG Printf("--- theta=%g, phi=%g, cone=%g", theta*TMath::RadToDeg(), phi*TMath::RadToDeg(), cone); #endif // calculate channel shifts TArrayD pwdt = NSnChanCorl::GetPlaneWaveOffsets(theta, phi, zeros, pos, kNgTopFirn); TVector3 dir; dir.SetMagThetaPhi(1.0, theta, phi); #ifdef DEBUG TObjArray graphs; graphs.SetOwner(kTRUE); TCanvas* c1 = new TCanvas("c1","c1",800,700); c1->Divide(2,2); #endif for (UChar_t ch=0; ch<NSnConstants::kNchans; ++ch) { // look up the EAng, fhang for this antenna Float_t feang(0), fhang(0); findEangHang(nvec[ch], dir, feang, fhang); feang = TMath::Abs(TVector2::Phi_mpi_pi(feang)); fhang = TMath::Abs(TVector2::Phi_mpi_pi(fhang)); feang *= TMath::RadToDeg(); fhang *= TMath::RadToDeg(); // find closest allowed angle EAng[ch] = findNearestAllowedAngle(Eangs, feang); HAng[ch] = findNearestAllowedAngle(Hangs, fhang); const Long64_t ni = nnt->GetEntryNumberWithIndex(EAng[ch] + (1000*HAng[ch]), CAng); #ifdef DEBUG Printf("EAng=%g (%g), HAng=%g (%g), CAng=%g, ni=%lld", EAng[ch],feang,HAng[ch],fhang,CAng,ni); #endif if (ni>-1) { nnt->GetEntry(ni); #ifdef DEBUG c1->cd(ch+1); TGraph* och = wave->NewGraphForChan(0, kTRUE); const Int_t ochnp = och->GetN(); Double_t* ochy = och->GetY(); for (Int_t k=0; k<ochnp; ++k, ++ochy) { *ochy *= norm; } graphs.Add(och); och->SetLineColor(kBlack); och->SetMarkerColor(kBlack); och->SetMarkerStyle(7); och->Draw("apl"); #endif // first calculate the shift between chans due to the angle // ch0 is always unshifted; other chans shifted w.r.t. ch0 // jitter the shift by the specified timing resolution const Double_t shift = rnd.Gaus( (ch==0) ? 0.0 : -pwdt.At( TSnRecoChanOffsets::IndexFor(ch, 0) ), timereso); // get a graph of the waveform // data only in channel 0 of the template TGraph* gch = wave->NewGraphForChan(0, kTRUE); // "fit" the graph with an spline interpolation TSpline3* gsp = new TSpline3("stmp", gch); // evaluate the spline at the new sample positions // (shifted, but NOT wrapped) // and save that into the event data waveform Float_t* d = evdat->GetData(ch); const Float_t tstep = 1.0 / NSnConstants::kSampRate; const Float_t tlast = static_cast<Float_t>(NSnConstants::kNsamps-1) / NSnConstants::kSampRate; Float_t xloc = shift; for (UChar_t s=0; s<NSnConstants::kNsamps; ++s, ++d, xloc+=tstep) { if ( (xloc<0.0) || (xloc>=tlast) ) { *d = 0.0; } else { *d = gsp->Eval( xloc ); } } #ifdef DEBUG Printf("ch%hhu: shift=%g, dt=%g", ch, shift, (ch==0) ? 0.0 : pwdt.At( TSnRecoChanOffsets::IndexFor(ch, 0) )); TGraph* fch = evdat->NewGraphForChan(ch, kTRUE); Double_t* y = gch->GetY(); Double_t* fy = fch->GetY(); for (UChar_t s=0; s<NSnConstants::kNsamps; ++s, ++y, ++fy) { *y *= norm; *fy *= norm; } gch->SetLineColor(kRed+1); gch->SetMarkerColor(kRed+1); gch->SetMarkerStyle(7); gch->Draw("pl"); delete gsp; gsp = new TSpline3("stmp",gch); gsp->SetLineColor(kAzure-6); gsp->SetMarkerColor(kAzure-6); gsp->SetMarkerStyle(7); gsp->Draw("pl same"); graphs.Add(fch); fch->SetLineColor(kOrange+7); fch->SetMarkerColor(kOrange+7); fch->SetMarkerStyle(7); fch->Draw("pl"); #endif d = evdat->GetData(ch); // finally add noise to the waveform for (UChar_t s=0; s<NSnConstants::kNsamps; ++s, ++d) { *d = rnd.Gaus( (*d) * norm, noise ); } #ifdef DEBUG TGraph* nch = evdat->NewGraphForChan(ch, kTRUE); graphs.Add(nch); nch->SetLineColor(kGreen+2); nch->SetMarkerColor(kGreen+2); nch->SetMarkerStyle(7); nch->Draw("pl"); #endif // cleanup #ifdef DEBUG graphs.Add(gch); graphs.Add(gsp); #else delete gch; delete gsp; #endif } } // end channel loop #ifdef DEBUG TObject* o(0); while ( (o=c1->WaitPrimitive())!=0 ) { gSystem->ProcessEvents(); } delete c1; #endif // save this event ot->Fill(); } // end event loop fprintf(stderr,"\n"); timer.Stop(); Printf("Finished generating events in:"); timer.Print(); outf->Write(); Printf("Wrote [%s]",outf->GetName()); delete outf; outf=0; // close file }
GV2(C,m2){r=u!=1?tmv(t,(I *)r,(I *)a,v):trp(t,(I *)r,(I *)a,v);u!=2?tmv(t,(I *)r,(I *)w,n-v):trp(t,(I *)r,(I *)w,n-v);}
s32 sceNpTrophyRegisterContext(PPUThread& CPU, u32 context, u32 handle, vm::ptr<SceNpTrophyStatusCallback> statusCb, vm::ptr<u32> arg, u64 options) { sceNpTrophy.Error("sceNpTrophyRegisterContext(context=0x%x, handle=0x%x, statusCb=*0x%x, arg=*0x%x, options=0x%llx)", context, handle, statusCb, arg, options); const auto ctxt = idm::get<trophy_context_t>(context); if (!ctxt) { sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT"); return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT; } const auto hndl = idm::get<trophy_handle_t>(handle); if (!hndl) { sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE"); return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE; } TRPLoader trp(*ctxt->trp_stream); if (!trp.LoadHeader()) { sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE"); return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } // Rename or discard certain entries based on the files found const size_t kTargetBufferLength = 31; char target[kTargetBufferLength + 1]; target[kTargetBufferLength] = 0; strcpy_trunc(target, fmt::format("TROP_%02d.SFM", Ini.SysLanguage.GetValue())); if (trp.ContainsEntry(target)) { trp.RemoveEntry("TROPCONF.SFM"); trp.RemoveEntry("TROP.SFM"); trp.RenameEntry(target, "TROPCONF.SFM"); } else if (trp.ContainsEntry("TROP.SFM")) { trp.RemoveEntry("TROPCONF.SFM"); trp.RenameEntry("TROP.SFM", "TROPCONF.SFM"); } else if (!trp.ContainsEntry("TROPCONF.SFM")) { return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } // Discard unnecessary TROP_XX.SFM files for (s32 i = 0; i <= 18; i++) { strcpy_trunc(target, fmt::format("TROP_%02d.SFM", i)); if (i != Ini.SysLanguage.GetValue()) { trp.RemoveEntry(target); } } // TODO: Get the path of the current user std::string trophyPath = "/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name; if (!trp.Install(trophyPath)) { sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE"); return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } TROPUSRLoader* tropusr = new TROPUSRLoader(); std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT"; std::string trophyConfPath = trophyPath + "/TROPCONF.SFM"; tropusr->Load(trophyUsrPath, trophyConfPath); ctxt->tropusr.reset(tropusr); // TODO: Callbacks statusCb(CPU, context, SCE_NP_TROPHY_STATUS_INSTALLED, 100, 100, arg); statusCb(CPU, context, SCE_NP_TROPHY_STATUS_PROCESSING_COMPLETE, 100, 100, arg); return CELL_OK; }
Double_t GausBF::Gfit(Int_t is1, Int_t is9, Double_t rgt, TGraph *gr, TGraph *gb) { if ((is1 == 59 && is9 == 98) || (is1 == 59 && is9 == 109) || (is1 == 73 && is9 == 98) || (is1 == 86 && is9 == 97) || (is1 == 86 && is9 == 98) || (is1 == 97 && is9 == 98)) return -1; AMSPoint p1 = GetP1(is1); AMSPoint p9 = GetP9(is9); if (rgt == 0) { TGraph grb; if (!gb) gb = &grb; TrProp trp(p1, p9-p1, rgt); for (Int_t i = 0; i < 200; i++) { Double_t z = -200+(i+0.5)*2; trp.Propagate(z); gb->SetPoint(i, z, trp.GuFld(trp.GetP0()).x()); } TF1 *func = Bfit(gb); Double_t *par = GausBF::Head()->GetPar(is1, is9); for (Int_t i = 0; i < func->GetNpar() && i < Np; i++) par[i] = func->GetParameter(i); if (par[0] == 0) cout << "Failed: " << is1 << " " << is9 << endl; for (Int_t i = 0; i < Np/3; i++) if (par[i*3] != 0) { if (par[i*3+2] < 0) par[i*3+2] *= -1; if (par[i*3+2] < 1 || TMath::Abs(par[i*3+1]) > 200) { par[i*3] = par[i*3+1] = 0; par[i*3+2] = 1; } } Double_t err = 1e-3; Double_t csq = 0; for (Int_t i = 0; i < gb->GetN(); i++) { Double_t d = gb->GetY()[i]-func->Eval(gb->GetX()[i]); csq += d*d/err/err; } return csq; } TGraph grp; if (!gr) gr = &grp; TrProp trp(p1, p9-p1, rgt); AMSPoint pnt; AMSDir dir; if (_Zref == 0) _Zref = TkDBc()->GetZlayerAJ(1); for (Int_t i = 0; i < 9; i++) { Double_t z = TkDBc()->GetZlayerAJ(i+1); trp.Propagate(z); gr->SetPoint(i, z, trp.GetP0y()); if (i == 0) { pnt = trp.GetP0(); dir = trp.GetDir(); } } TF1 *func = GausBF::Head()->GetPr(is1, is9, rgt); gr->Fit(func, "q0"); for (Int_t i = 0; i < Np; i++) GausBF::Head()->SetPar(is1, is9, i, func->GetParameter(i+5)); Double_t csq = 0; for (Int_t i = 0; i < gr->GetN(); i++) { Double_t res = (gr->GetY()[i]-func->Eval(gr->GetX()[i]))*1e4; // cout << Form("%6.1f %7.3f %7.3f %6.1f", gr->GetX()[i], gr->GetY()[i], // func->Eval(gr->GetX()[i]), res) << endl; gr->GetY()[i] = res; csq += res*res; } delete func; return csq/gr->GetN(); }
error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle, vm::ptr<SceNpTrophyStatusCallback> statusCb, vm::ptr<void> arg, u64 options) { sceNpTrophy.error("sceNpTrophyRegisterContext(context=0x%x, handle=0x%x, statusCb=*0x%x, arg=*0x%x, options=0x%llx)", context, handle, statusCb, arg, options); if (!statusCb) { return SCE_NP_TROPHY_ERROR_INVALID_ARGUMENT; } const auto ctxt = idm::get<trophy_context_t>(context); if (!ctxt) { return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT; } const auto hndl = idm::get<trophy_handle_t>(handle); if (!hndl) { return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE; } TRPLoader trp(ctxt->trp_stream); if (!trp.LoadHeader()) { return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } // Rename or discard certain entries based on the files found const size_t kTargetBufferLength = 31; char target[kTargetBufferLength + 1]; target[kTargetBufferLength] = 0; strcpy_trunc(target, fmt::format("TROP_%02d.SFM", static_cast<s32>(g_cfg.sys.language))); if (trp.ContainsEntry(target)) { trp.RemoveEntry("TROPCONF.SFM"); trp.RemoveEntry("TROP.SFM"); trp.RenameEntry(target, "TROPCONF.SFM"); } else if (trp.ContainsEntry("TROP.SFM")) { trp.RemoveEntry("TROPCONF.SFM"); trp.RenameEntry("TROP.SFM", "TROPCONF.SFM"); } else if (!trp.ContainsEntry("TROPCONF.SFM")) { return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } // Discard unnecessary TROP_XX.SFM files for (s32 i = 0; i <= 18; i++) { strcpy_trunc(target, fmt::format("TROP_%02d.SFM", i)); if (i != g_cfg.sys.language) { trp.RemoveEntry(target); } } std::string trophyPath = "/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/" + ctxt->trp_name; if (!trp.Install(trophyPath)) { return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } TROPUSRLoader* tropusr = new TROPUSRLoader(); std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT"; std::string trophyConfPath = trophyPath + "/TROPCONF.SFM"; tropusr->Load(trophyUsrPath, trophyConfPath); ctxt->tropusr.reset(tropusr); // TODO: Callbacks // From RE-ing a game's state machine, it seems the possible order is one of the following: // * Install (Not installed) - Setup - Progress * ? - Finalize - Complete - Installed // * Reinstall (Corrupted) - Setup - Progress * ? - Finalize - Complete - Installed // * Update (Required update) - Setup - Progress * ? - Finalize - Complete - Installed // * Installed // We will go with the easy path of Installed, and that's it. auto statuses = {SCE_NP_TROPHY_STATUS_NOT_INSTALLED, SCE_NP_TROPHY_STATUS_PROCESSING_SETUP, SCE_NP_TROPHY_STATUS_PROCESSING_PROGRESS, SCE_NP_TROPHY_STATUS_PROCESSING_FINALIZE, SCE_NP_TROPHY_STATUS_PROCESSING_COMPLETE}; for (auto status : statuses) { if (statusCb(ppu, context, status, 100, 100, arg) < 0) { return SCE_NP_TROPHY_ERROR_PROCESSING_ABORTED; } } return CELL_OK; }