Poco::JSON::Array::Ptr ConnectionMapper::inquire() { createCommand(MQCMD_INQUIRE_CONNECTION); // Required parameters if ( _input->has("ConnectionId") ) { std::string hexId = _input->get("ConnectionId"); if ( hexId.length() > MQ_CONNECTION_ID_LENGTH ) { hexId.erase(MQ_CONNECTION_ID_LENGTH); } Buffer::Ptr id = new Buffer(hexId); pcf()->addParameter(MQBACF_CONNECTION_ID, id); } else { Buffer::Ptr id = new Buffer(MQ_CONNECTION_ID_LENGTH); // Empty buffer memset(id->data(), 0, MQ_CONNECTION_ID_LENGTH); pcf()->addParameter(MQBACF_GENERIC_CONNECTION_ID, id); } // Optional parameters //TODO: ByteStringFilter addParameter<std::string>(MQCACF_COMMAND_SCOPE, "CommandScope"); addAttributeList(MQIACF_CONNECTION_ATTRS, "ConnectionAttrs"); addParameterNumFromString(MQIACF_CONN_INFO_TYPE, "ConnInfoType"); addIntegerFilter(); addStringFilter(); addParameterNumFromString(MQIA_UR_DISP, "URDisposition"); if ( ! _input->has("ConnectionAttrs") ) { // It seems that this is not set by default, so we do // it ourselves. MQLONG attrs[] = { MQIACF_ALL }; pcf()->addParameterList(MQIACF_CONNECTION_ATTRS, attrs, 1); } PCF::Vector commandResponse; execute(commandResponse); Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) continue; if ( (*it)->isExtendedResponse() ) // Skip extended response continue; json->add(createJSON(**it)); } return json; }
void AGOSEngine_PN::opn_opcode13() { char bf[8]; int a = 0; sprintf(bf,"%d", varval()); while (bf[a]) pcf(bf[a++]); pcf((uint8)'\n'); setScriptReturn(true); }
void AGOSEngine_PN::patok(int n) { int x; uint8 *tokbase; tokbase = _textBase + getlong(30); x = n; while (x -= (*tokbase++ > 127)) ; while (*tokbase < 128) pcf(*tokbase++); pcf((uint8)(*tokbase & 127)); }
void AGOSEngine_PN::opn_opcode46() { char *x = _curwrdptr; if (x == NULL) { setScriptReturn(true); return; } pcf(*x); if ((*x == '.') || (*x == '"') || (*x == ',')) { setScriptReturn(true); return; } x++; while ((*x != '.') && (*x != ',') && (*x != '"') && (!Common::isSpace(*x)) && (*x != '\0')) pcf(*x++); setScriptReturn(true); }
// -------------------------------------------------------------------------- // // void Test_PCFData::testCalculateChi2() { // Setup. const double rmin = 0.0; const double rmax = 5.0; const double dr = 0.02; const double sigma = 0.01; const double numberdensity = 0.3; const std::pair<double, double> fit_inteval(0.2, 1.0); const int nbins = 250; const std::pair<int,int> partial(0,1); const std::string reference_data("./testfiles/gr_ref.data"); PCFData pcf(rmin, rmax, dr, sigma, numberdensity, fit_inteval, nbins, partial, reference_data); // Setup a histogram to use for testing. std::vector<double> histogram(nbins, 1.0); for (size_t i = 0; i < histogram.size(); ++i) { histogram[i] += 0.003*i; } // Calculate chi2. double chi2 = pcf.calculate_chi2(histogram); // Check against hardcoded value. CPPUNIT_ASSERT_DOUBLES_EQUAL( chi2, 861059546.103726, 1.0e-12 ); }
void AGOSEngine_PN::opn_opcode15() { int32 x = varval(); if ((x < 0) || (x > 4)) x = 0; pcf((unsigned char)254); _curWindow = x; _xofs = (8 * _windowArray[_curWindow]->textLength) / 6 + 1; setScriptReturn(true); }
bool arlCore::fieldCalibration( PointList::csptr real, PointList::csptr distorded, unsigned int degree, vnl_vector<double> ¶meters, double &RMS ) { if(degree<1) return false; Polynomial_cost_function pcf( real, distorded, degree ); vnl_powell op(&pcf); parameters.set_size(pcf.getNbParameters()); parameters.fill(0.0); op.minimize(parameters); RMS = op.get_end_error(); return true; }
QueueRemove::QueueRemove(CommandServer& commandServer, Poco::JSON::Object::Ptr input) : PCFSimpleCommand(commandServer, MQCMD_DELETE_Q, "Queue", input) { // Required Parameters addParameter<std::string>(MQCA_Q_NAME, "QName"); // Optional Parameters std::string authrec = input->optValue<std::string>("Authrec", "No"); if ( Poco::icompare(authrec, "Yes") == 0 ) { pcf()->addParameter(MQIACF_REMOVE_AUTHREC, MQRAR_YES); } addParameter<std::string>(MQCACF_COMMAND_SCOPE, "CommandScope"); std::string purge = input->optValue<std::string>("Purge", "No"); if ( Poco::icompare(authrec, "Yes") == 0 ) { pcf()->addParameter(MQIACF_PURGE, MQPO_YES); } addParameterNumFromString(MQIA_QSG_DISP, "QSGDisposition"); addParameterNumFromString(MQIA_Q_TYPE, "QType"); }
int main( void ) { //int (*huo) (float); //int (*p2d)[10]; char a[100] = "sdsdsdsd"; char b[20] = "123456789"; pCharFunc pcf = strcpy; pcf( a, b ); printf( "%s\n", a ); return 0; }
// -------------------------------------------------------------------------- // // void Test_PCFData::testCalculatePartialHistogram() { // Setup. const double rmin = 0.0; const double rmax = 5.0; const double dr = 0.02; const double sigma = 0.01; const double numberdensity = 0.3; const std::pair<double, double> fit_inteval(0.2, 1.0); const int nbins = 250; const std::pair<int,int> partial(0,1); const std::string reference_data("./testfiles/gr_ref.data"); PCFData pcf(rmin, rmax, dr, sigma, numberdensity, fit_inteval, nbins, partial, reference_data); // Read in a library. Library library("./testfiles/testlibSmall"); int index = 3; // Get the histogram. std::vector<double> histogram = pcf.calculate_partial_histogram(library, index); CPPUNIT_ASSERT_EQUAL(static_cast<int>(histogram.size()), nbins); // Test. CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[80], 1.0, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[81], 0.0, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[188], 3.0, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[191], 2.0, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[225], 1.0, 1.0e-12 ); // Get another histogram. index = 8; histogram = pcf.calculate_partial_histogram(library, index); CPPUNIT_ASSERT_EQUAL(static_cast<int>(histogram.size()), nbins); // Test. CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[75], 1.0, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[81], 0.0, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[188], 1.0, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[191], 0.0, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( histogram[192], 3.0, 1.0e-12 ); }
// Load Book, Return bool error bool Book::Load( wxString &error_msg, wxString &pgn_file ) { bool error=false; wxString compile_msg = "Digesting book"; wxString pgn_compiled_file; pgn_compiled_file = pgn_file + "_compiled"; wxFileName pcf(pgn_compiled_file); wxFileName pf(pgn_file); bool compile = false; if( pf.FileExists() ) { if( pcf.FileExists() ) { if( pcf.GetModificationTime() < pf.GetModificationTime() ) compile = true; } else compile = true; } if( compile ) error = Compile( error_msg, compile_msg, pgn_file, pgn_compiled_file ); if( !error ) { if( pcf.FileExists() ) { error = LoadCompiled( error_msg, pgn_compiled_file ); if( error ) { compile_msg = "Redigesting book"; error = Compile( error_msg, compile_msg, pgn_file, pgn_compiled_file ); } } else { error_msg = "Cannot find book file " + pgn_file; error = true; } } return error; }
// -------------------------------------------------------------------------- // // void Test_PCFData::testConstruction() { // Test default construction. CPPUNIT_ASSERT_NO_THROW(PCFData pcf); // Setup input. const double rmin = 0.0; const double rmax = 5.0; const double dr = 0.02; const double sigma = 0.01; const double numberdensity = 0.3; const std::pair<double, double> fit_inteval(0.2, 1.0); const int nbins = 250; const std::pair<int,int> partial(0,1); const std::string reference_data("./testfiles/gr_ref.data"); // Check that the correct memberdata was set. PCFData pcf(rmin, rmax, dr, sigma, numberdensity, fit_inteval, nbins, partial, reference_data); CPPUNIT_ASSERT_DOUBLES_EQUAL( rmin, pcf.rmin_, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( rmax, pcf.rmax_, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( dr, pcf.dr_, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0/dr, pcf.one_over_dr_, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( sigma, pcf.sigma_, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0/(sigma*sigma), pcf.one_over_sigma2_, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( numberdensity, pcf.numberdensity_, 1.0e-12 ); CPPUNIT_ASSERT_EQUAL( partial.first, pcf.partial_.first ); CPPUNIT_ASSERT_EQUAL( partial.second, pcf.partial_.second ); CPPUNIT_ASSERT_EQUAL( 10, pcf.fit_interval_.first ); CPPUNIT_ASSERT_EQUAL( 50, pcf.fit_interval_.second ); // Check a few of the reference values. CPPUNIT_ASSERT_DOUBLES_EQUAL( pcf.pcf_reference_[12], 0.000000000, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( pcf.pcf_reference_[39], 0.166035800, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( pcf.pcf_reference_[48], 15.308580000, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( pcf.pcf_reference_[123], 0.547787900, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( pcf.pcf_reference_[168], 1.341329000, 1.0e-12 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( pcf.pcf_reference_[231], 0.955944800, 1.0e-12 ); }
// -------------------------------------------------------------------------- // // void Test_PCFData::testInitNotifyAccept() { // Setup. const double rmin = 0.0; const double rmax = 5.0; const double dr = 0.02; const double sigma = 0.01; const double numberdensity = 0.3; const std::pair<double, double> fit_inteval(0.2, 1.0); const int nbins = 250; const std::pair<int,int> partial(0,1); const std::string reference_data("./testfiles/gr_ref.data"); PCFData pcf(rmin, rmax, dr, sigma, numberdensity, fit_inteval, nbins, partial, reference_data); // Read a library. Library library("./testfiles/testlibSmall"); // Setup a small sampleset. std::vector<int> sampleset(3); sampleset[0] = 1; sampleset[1] = 14; sampleset[2] = 4; // Call init. pcf.init(sampleset, library); // Check that the data was correctly set. CPPUNIT_ASSERT_EQUAL( 3, pcf.nsample_ ); const double chi2 = 266976.424804889; CPPUNIT_ASSERT_DOUBLES_EQUAL( chi2, pcf.chi2_, 1.0e-8 ); for (size_t i = 0; i < pcf.histogram_.size(); ++i) { CPPUNIT_ASSERT_DOUBLES_EQUAL( pcf.histogram_[i], pcf.histogram_new_[i], 1.0e-12 ); } // Call notify. const int from_sample = 1; const int from_basis = 3; pcf.notify(from_sample, from_basis, library); // Check chi2 and chi2_new. const double chi2_new = 266976.424804889; CPPUNIT_ASSERT_DOUBLES_EQUAL( chi2_new, pcf.chi2_new_, 1.0e-8 ); CPPUNIT_ASSERT_DOUBLES_EQUAL( chi2, pcf.chi2_, 1.0e-8 ); // Check that the new histogram is differenct. double sum1 = 0.0; double sum2 = 0.0; for (size_t i = 0; i < pcf.histogram_.size(); ++i) { sum1 += pcf.histogram_[i]; sum2 += pcf.histogram_new_[i]; } CPPUNIT_ASSERT( sum1 != sum2 ); // Call accept. pcf.accept(); // Check that chi2 was set. CPPUNIT_ASSERT_DOUBLES_EQUAL( chi2_new, pcf.chi2_, 1.0e-8 ); // Check that the histograms are identical again. for (size_t i = 0; i < pcf.histogram_.size(); ++i) { CPPUNIT_ASSERT_DOUBLES_EQUAL( pcf.histogram_[i], pcf.histogram_new_[i], 1.0e-12 ); } }
void AGOSEngine_PN::opn_opcode48() { pmesd(varval() * 256 + varval()); pcf((uint8)'\n'); setScriptReturn(true); }
void AGOSEngine_PN::opn_opcode44() { pcf((uint8)254); setScriptReturn(true); }
void AGOSEngine_PN::opn_opcode39() { pcf((uint8)varval()); setScriptReturn(true); }
Poco::JSON::Array::Ptr AuthorityRecordMapper::inquire() { createCommand(MQCMD_INQUIRE_AUTH_RECS); // Required parameters MQLONG options = 0; Poco::JSON::Array::Ptr optionsValue = _input->getArray("Options"); if ( !optionsValue.isNull() ) { for(Poco::JSON::Array::ValueVec::const_iterator it = optionsValue->begin(); it != optionsValue->end(); ++it) { std::string value = *it; if ( value.compare("Name All Matching") == 0 ) { options |= MQAUTHOPT_NAME_ALL_MATCHING; } else if ( value.compare("Name Explicit") == 0 ) { options |= MQAUTHOPT_NAME_EXPLICIT; } else if ( value.compare("Entity Explicit") == 0 ) { options |= MQAUTHOPT_ENTITY_EXPLICIT; } else if ( value.compare("Entity Set") == 0 ) { options |= MQAUTHOPT_ENTITY_SET; } else if ( value.compare("Name As Wildcard") == 0 ) { options |= MQAUTHOPT_NAME_AS_WILDCARD; } } pcf()->addParameter(MQIACF_AUTH_OPTIONS, options); } // When no ProfileName is passed, set to empty string if ( !_input->has("ProfileName") ) _input->set("ProfileName", ""); addParameter<std::string>(MQCACF_AUTH_PROFILE_NAME, "ProfileName"); addParameterNumFromString(MQIACF_OBJECT_TYPE, "ObjectType"); // Optional parameters addParameter<std::string>(MQCACF_ENTITY_NAME, "EntityName"); addParameterNumFromString(MQIACF_ENTITY_TYPE, "EntityType"); addAttributeList(MQIACF_AUTH_PROFILE_ATTRS, "ProfileAttrs"); addParameter<std::string>(MQCACF_SERVICE_COMPONENT, "ServiceComponent"); PCF::Vector commandResponse; execute(commandResponse); Poco::JSON::Array::Ptr json = new Poco::JSON::Array(); for(PCF::Vector::iterator it = commandResponse.begin(); it != commandResponse.end(); it++) { if ( (*it)->isExtendedResponse() ) // Skip extended response continue; if ( (*it)->getReasonCode() != MQRC_NONE ) // Skip errors (2035 not authorized for example) continue; json->add(createJSON(**it)); } return json; }
void AGOSEngine_PN::opn_opcode14() { clearWindow(_windowArray[_curWindow]); pcf((uint8)255); setScriptReturn(true); }
void AGOSEngine_PN::opn_opcode10() { int32 sp = varval(); plocd((int)sp, varval()); pcf((uint8)'\n'); setScriptReturn(true); }
void AGOSEngine_PN::opn_opcode05() { pcf((uint8)'\n'); setScriptReturn(true); }