V PolymerPropsAd::adsorption(const V& c, const V& cmax_cells) const { const int nc = c.size(); V ads(nc); for (int i = 0; i < nc; ++i) { double c_ads = 0; polymer_props_.adsorption(c(i), cmax_cells(i), c_ads); ads(i) = c_ads; } return ads; }
ADB PolymerPropsAd::adsorption(const ADB& c, const ADB& cmax_cells) const { const int nc = c.value().size(); V ads(nc); V dads(nc); for (int i = 0; i < nc; ++i) { double c_ads = 0; double dc_ads = 0; polymer_props_.adsorptionWithDer(c.value()(i), cmax_cells.value()(i), c_ads, dc_ads); ads(i) = c_ads; dads(i) = dc_ads; } ADB::M dads_diag(dads.matrix().asDiagonal()); int num_blocks = c.numBlocks(); std::vector<ADB::M> jacs(num_blocks); for (int block = 0; block < num_blocks; ++block) { jacs[block] = dads_diag * c.derivative()[block]; } return ADB::function(std::move(ads), std::move(jacs)); }
void register_pluginx_js_extensions(JSContext* cx, JS::HandleObject global) { JS::RootedObject ns(cx); pluginx::get_or_create_js_obj(cx, global, "plugin", &ns); JS::RootedObject iap(cx, jsb_cocos2d_plugin_ProtocolIAP_prototype); JS_DefineFunction(cx, iap, "setListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, iap, "getListener", js_pluginx_ProtocolIAP_getResultListener, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, iap, "payForProduct", js_pluginx_ProtocolIAP_payForProduct, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS::RootedObject ads(cx, jsb_cocos2d_plugin_ProtocolAds_prototype); JS_DefineFunction(cx, ads, "setListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ads, "getListener", js_pluginx_ProtocolAds_getAdsListener, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS::RootedObject share(cx, jsb_cocos2d_plugin_ProtocolShare_prototype); JS_DefineFunction(cx, share, "setListener", js_pluginx_ProtocolShare_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, share, "getListener", js_pluginx_ProtocolShare_getResultListener, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, share, "share", js_pluginx_ProtocolShare_share, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS::RootedObject social(cx, jsb_cocos2d_plugin_ProtocolSocial_prototype); JS_DefineFunction(cx, social, "setListener", js_pluginx_ProtocolSocial_setListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, social, "getListener", js_pluginx_ProtocolSocial_getListener, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, social, "submitScore", js_pluginx_ProtocolSocial_submitScore, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, social, "unlockAchievement", js_pluginx_ProtocolSocial_unlockAchievement, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS::RootedObject user(cx, jsb_cocos2d_plugin_ProtocolUser_prototype); JS_DefineFunction(cx, user, "setActionListener", js_pluginx_ProtocolUser_setActionListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, user, "getActionListener", js_pluginx_ProtocolUser_getActionListener, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, user, "login", js_pluginx_ProtocolUser_login, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, user, "logout", js_pluginx_ProtocolUser_logout, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS::RootedObject protocol(cx, jsb_cocos2d_plugin_PluginProtocol_prototype); JS_DefineFunction(cx, protocol, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, protocol, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, protocol, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, protocol, "callFloatFuncWithParam", js_pluginx_PluginProtocol_callFloatFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, protocol, "callBoolFuncWithParam", js_pluginx_PluginProtocol_callBoolFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS::RootedObject facebook(cx, jsb_cocos2d_plugin_FacebookAgent_prototype); JS_DefineFunction(cx, facebook, "login", js_pluginx_FacebookAgent_login, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, facebook, "_api", js_pluginx_FacebookAgent_api, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, facebook, "appRequest", js_pluginx_FacebookAgent_appRequest, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, facebook, "dialog", js_pluginx_FacebookAgent_dialog, 0, JSPROP_READONLY | JSPROP_PERMANENT); js_register_pluginx_protocols_PluginParam(cx, ns); }
ADSRangeLastAfter::ADSRangeLastAfter( EnvisatFile & envfile, int ads_idx , int mds_idx, const TimeDelta & line_interval ) { int idx ; TimeDelta t_mds , t_ads , t_ads_prev ; /* abs.time tolerance */ TimeDelta atol = line_interval * 0.5 ; /* MDS and ADS descriptor classes */ DataSet mds( envfile, mds_idx ) ; DataSet ads( envfile, ads_idx ) ; /* read the times of the first and last measurements */ mjd_m_first = mds.getMJD(0) ; /* MDJ time of the first MDS record */ mjd_m_last = mds.getMJD(-1) ; /* MDJ time of the last MDS record */ /* look-up the the first applicable ADSR */ idx = 0 ; t_mds = mjd_m_first + atol ; /*time of the first MDSR + tolerance */ t_ads = ads.getMJD(0) ; /*time of the first ADSR */ t_ads_prev = t_ads ; /* holds previous ADSR */ if ( t_ads < t_mds ) { for( idx = 1 ; idx < ads.nrec ; ++idx ) { t_ads = ads.getMJD(idx) ; if ( t_ads >= t_mds ) break ; t_ads_prev = t_ads ; } } /* store the first applicable ASDR */ idx_first = idx - 1 ; /* sets -1 if no match */ mjd_first = t_ads_prev ; /* set time of the first rec. if no match */ /* look-up the the last applicable ADSR */ idx = ads.nrec-2 ; t_mds = mjd_m_last - atol ; /* time of the last MDSR - tolerance */ t_ads = ads.getMJD(-1) ; /* time of the first ADSR */ t_ads_prev = t_ads ; /* holds previous ADSR */ if ( t_ads > t_mds ) { for( idx = ads.nrec-2 ; idx >= 0 ; --idx ) { t_ads = ads.getMJD(idx) ; if ( t_ads <= t_mds ) break ; t_ads_prev = t_ads ; } } /* store the last applicable ASDR */ idx_last = idx + 1 ; /* sets ads.nrec if no match */ mjd_last = t_ads_prev ; /* set time of the last rec. if no match */ /* valuate the line offsets */ off_first = (int)floor( 0.5 + ( mjd_m_first - mjd_first ) / line_interval ) ; off_last = (int)floor( 0.5 + ( mjd_last - mjd_m_last ) / line_interval ) ; } ;
int16_t VoltageMeter::voltage(int probe) { Adafruit_ADS1015 ads(_adsAddress); //adc int16_t voltageRawV = 0; voltageRawV = ads.readADC_SingleEnded(probe); return voltageRawV; }
VoltageMeter::VoltageMeter(uint8_t adsAddress) { _adsAddress = adsAddress; Adafruit_ADS1015 ads(_adsAddress); //adc ads.begin(); ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV (default) }