void externalTransition( const vle::devs::ExternalEventList& events, const vle::devs::Time& time) { vle::devs::ExternalEventList::const_iterator it = events.begin(); while (it != events.end()) { if ((*it)->onPort("available")) { bool available = (*it)->getBooleanAttributeValue("available"); unsigned int number = (*it)->getIntegerAttributeValue("number"); std::string type = (*it)->getStringAttributeValue("type"); if (available) { mAvailableResourceNumber += number; } else { mUnavailableResources[type] = mResourceConstraints->quantity(type) - number; } ++mResponseNumber; TraceModel( vle::fmt(" [%1%:%2%] at %3% -> available: %4% / %5%") % getModel().getParentName() % getModelName() % time % mAvailableResourceNumber % mResourceConstraints->quantity()); if (mAvailableResourceNumber == mResourceConstraints->quantity()) { mPhase = SEND_ASSIGN; } else { if (mResponseNumber == mResourceConstraints->size()) { clearDemand(); mPhase = SEND_UNAVAILABLE; } else { mPhase = WAIT_AVAILABLE; } } } else if ((*it)->onPort("demand")) { mResourceConstraints = ResourceConstraints::build(Resources::get(*it)); TraceModel(vle::fmt(" [%1%:%2%] at %3% -> demand: %4%") % getModel().getParentName() % getModelName() % time % mResourceConstraints->quantity()); mPhase = SEND_DEMAND; } else if ((*it)->onPort("release")) { mReleasedResources = Resources::build(Resources::get(*it)); TraceModel(vle::fmt(" [%1%:%2%] at %3% -> release: %4%") % getModel().getParentName() % getModelName() % time % *mReleasedResources); mPhase = SEND_RELEASE; } ++it; } }
TimeSlicingMethod(DifferentialEquation& eq, const vd::InitEventList& events) : DifferentialEquationImpl(eq, events), devs_state(INIT), devs_options(), devs_guards(), devs_internal(), int_method(*this, events) { if (events.exist("output_period")) { const value::Value& v = *(events.get("output_period")); devs_options.output_period = 0; if (v.isInteger()) { devs_options.output_period = v.toInteger().value(); } if (devs_options.output_period < 1) { throw utils::ModellingError(vle::utils::format( "[%s] Parameter 'output_period' should be an int > 0", getModelName().c_str())); } } if (events.exist("time_step")) { devs_options.dt = events.getDouble("time_step"); if (devs_options.dt <= 0) { throw utils::ModellingError(vle::utils::format( "[%s] Parameter 'time_step' should be > 0", getModelName().c_str())); } } }
Generator(const vd::DynamicsInit& init, const vd::InitEventList& events) : vd::Dynamics(init, events) { vg::ConnectionList my_list; // m_duration = vv::toDouble(events.get("duration")); m_duration = 0.1; if (events.end() != events.find("source_init_level")) { m_val = vv::toDouble(events.get("source_init_level")); } else { m_val = 1; Trace(6, "Warning : Model %s got no init" " output level (source_init_level) : assuming 1\n", getModelName().c_str()); } if (events.end() != events.find("source_trend")) { m_trend = vv::toDouble(events.get("source_trend")); if (events.end() != events.find("source_quantum")) { m_quantum = vv::toDouble(events.get("source_quantum")); } else { m_quantum = 0.01; Trace(6, "Warning : Model %s got no output" " quantum (source_quantum) : assuming 0.01\n", getModelName().c_str()); } } else { m_trend = 0; Trace(6, "%s got no output trend (source_trend)" " : assuming 0\n", getModelName().c_str()); // no trend => quantum is useless but.. m_quantum = 0.01; } if (0 == m_quantum) { throw vu::ModellingError("Model %s has null output quantum.", getModelName().c_str()); } m_has_output_port = false; my_list = getModel().getOutputPortList(); if (my_list.size() > 0) { m_output_port_label = (my_list.begin())->first; m_has_output_port = true; } if (my_list.size() > 1) { Trace(6, "Warning: multiple output ports." " Will use only port %s\n", m_output_port_label.c_str()); } }
ThothWindow::ThothWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::ThothWindow) { ui->setupUi(this); // ALERT! Use the following code to get keyboard focus at your OpenGL widget ui->contextGL->setFocusPolicy(Qt::StrongFocus); ui->contextGL->setFocus(); message = new QLabel(this); popUp = new QLabel(this); mode = new QLabel(this); picked = new QLabel(this); ui->statusBar->addWidget(popUp); ui->statusBar->addPermanentWidget(picked); ui->statusBar->addPermanentWidget(mode); ui->statusBar->addPermanentWidget(message); mode->setText("Selecting"); message->setText("No model selected"); ui->statusBar->showMessage("Ready", 5000); //Tree file. //treeview of tabs TreeFile *m_build = new TreeFile(ui->treeViewBuild, "Build"); m_buildModel = m_build->getQFileSystemModel(); TreeFile *m_decorate = new TreeFile(ui->treeViewDecorate, "Decorate"); m_decorateModel = m_decorate->getQFileSystemModel(); TreeFile *m_furnish = new TreeFile(ui->treeViewFurnish, "Furnish"); m_furnishModel = m_furnish->getQFileSystemModel(); connect(ui->actionSave_project, SIGNAL(triggered()), this, SLOT(actionSave_project_triggered())); QTimer *tim = new QTimer(this); connect(tim, SIGNAL(timeout()), ui->contextGL, SLOT(updateGL())); tim->start(TICK_PER_SECOND); connect(tim, SIGNAL(timeout()), ui->contextGL, SLOT(checkActiveModel())); connect(ui->SldR, SIGNAL(valueChanged(int)), SLOT(onColorChanged())); connect(ui->SldG, SIGNAL(valueChanged(int)), SLOT(onColorChanged())); connect(ui->SldB, SIGNAL(valueChanged(int)), SLOT(onColorChanged())); onColorChanged(); connect(CScenary::getInstance(), SIGNAL(setNameModel(string)), SLOT(getModelName(string))); connect(RenderManager::GetInstance(), SIGNAL(sendChangeTab()), SLOT(changeTab())); RenderManager::GetInstance()->GetRenderMode(EDITOR_2D)->SetCameraProjection(INIT_WIDTH, INIT_HEIGHT); connect(this, SIGNAL(changeMouseMove(bool)), RenderManager::GetInstance()->GetRenderMode(EXPLORER), SLOT(setMouseMove(bool))); connect(this, SIGNAL(changeCursor(Qt::CursorShape)), ui->contextGL, SLOT(changeCursor(Qt::CursorShape))); connect(ui->ColorButton, SIGNAL(clicked(bool)), SLOT(on_colorButton_clicked())); connect(this, SIGNAL(newModel(ModelInfo, int)), RenderManager::GetInstance()->GetRenderMode(EXPLORER), SLOT(changeModelTexture(ModelInfo, int))); connect(ui->actionOpen_project, SIGNAL(triggered()), this, SLOT(actionOpen_project_triggered())); connect(CScenary::getInstance(), SIGNAL(setNameModel(string)), SLOT(getModelName(string))); connect(RenderManager::GetInstance(), SIGNAL(sendChangeTab()), SLOT(changeTab())); connect(CScenary::getInstance(), SIGNAL(activeFloorChanged(int)), ui->floorBox, SLOT(setValue(int))); connect(RenderManager::GetInstance()->GetRenderMode(EDITOR_2D), SIGNAL(changedMode(string)), SLOT(getModeName(string))); connect(RenderManager::GetInstance()->GetRenderMode(EDITOR_2D), SIGNAL(pickedInfo(string)), SLOT(getPicked(string))); connect(RenderManager::GetInstance()->GetRenderMode(EXPLORER), SIGNAL(pickedInfo(string)), SLOT(getPicked(string))); connect(RenderManager::GetInstance()->GetRenderMode(EXPLORER), SIGNAL(setMessage(string, int)), SLOT(getMessage(string, int))); connect(RenderManager::GetInstance()->GetRenderMode(EDITOR_2D), SIGNAL(setMessage(string, int)), SLOT(getMessage(string, int))); connect(CScenary::getInstance(), SIGNAL(setMessage(string, int)), SLOT(getMessage(string, int))); }
void clear(const vd::Time& time) { std::cout << std::setprecision(8) << time << " OS::clear model:" << getModelName() << " " << signal << std::endl; signal.clear(); std::cout << std::setprecision(8) << time << " OS::clear model:" << getModelName() << " " << signal << std::endl; }
static void updateConsole() { consoleClear(); iprintf("\n \x1b[36mLots of models\n Draw mode: %s\n Model: %s\n\n", drawMode ? "LINES" : "TRIANGLES", getModelName()); }
void searchTransport(const vle::devs::Time& time) { bool found = false; Transports::const_iterator it = mTransports.begin(); std::cout << time << " - [" << getModelName() << "] DECISION: SEARCH TRANSPORT"; mSelectedArrivedTransport = 0; while (not found and it != mTransports.end()) { double e = std::abs((*it)->departureDate() - time); if (e < 1e-5) { found = true; } else { ++it; } } if (found) { mSelectedArrivedTransport = *it; std::cout << " => " << mSelectedArrivedTransport->id() << std::endl; } else { std::cout << " => NOT FOUND ---> PB !!!!!!" << std::endl; } }
void Executive::dump(std::ostream& out, const std::string& name) const { vpz::Vpz f; f.project().setAuthor(getModelName()); f.project().model().setModel(coupledmodel().clone()); f.project().dynamics().add(m_coordinator.dynamics()); f.project().experiment().addConditions(m_coordinator.conditions()); f.project().experiment().setName(name); f.project().experiment().setBegin(0.0); f.project().experiment().setDuration(1.0); if (not f.project().dynamics().exist("unknow")) { f.project().dynamics().add(vpz::Dynamic("unknow")); } // std::vector < vpz::AtomicModel* > lst; // vpz::BaseModel::getAtomicModelList(f.project().model().model(), lst); // for (std::vector < vpz::AtomicModel* >::iterator it = lst.begin(); // it != lst.end(); ++it) { // f.project().model().atomicModels().add( // *it, vpz::AtomicModelTemp("", "unknow", "")); // } f.write(out); delete f.project().model().model(); f.project().model().setModel(0); }
void externalTransition( const vle::devs::ExternalEventList& events, const vle::devs::Time& time) { vle::devs::ExternalEventList::const_iterator it = events.begin(); while (it != events.end()) { if ((*it)->onPort("start")) { if (mPhase == INIT) { mActivities.starting(time); if (mActivities.startingActivities().empty()) { mPhase = WAIT; } else { mPhase = SEND; } } } else if ((*it)->onPort("done")) { Activity* a = Activity::build(Activity::get(*it)); TraceModel(vle::fmt(" [%1%:%2%] at %3% -> %4% DONE") % getModel().getParentName() % getModelName() % time % a->name()); mDoneActivities.push_back(a); } ++it; } if (mSigma > 0) { mSigma -= (time - mLastTime); mLastTime = time; } }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * evntInState functions * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void act(const vd::Time& time, const vd::ExternalEvent* evt) { signal.assign(evt->getStringAttributeValue("signal")); std::cout << vle::utils::DateTime::toJulianDayNumber(time) << " OS::act model:" << getModelName() << " evt:" << *evt << " signal=" << signal << std::endl; }
void confluentTransitions( const vle::devs::Time& time, const vle::devs::ExternalEventList& /* events */) { TraceModel(vle::fmt(" [%1%:%2%] at %3% -> confluent !") % getModel().getParentName() % getModelName() % time); }
AdaptativeQuantifier(const vd::DynamicsInit &init, const vd::InitEventList &events) : vd::Dynamics(init, events) { const auto& my_list = getModel().getOutputPortList(); if (not my_list.empty()) { m_output_port_label = (my_list.begin())->first; m_has_output_port = true; } if (my_list.size() > 1) Trace(context(), 6, "Warning: multiple output ports." " Will use only port %s\n", m_output_port_label.c_str()); m_adaptative = true; if (events.end() != events.find("allow_offsets")) { m_adaptative = vv::toBoolean(events.get("allow_offsets")); } if (m_adaptative) { m_adapt_state = POSSIBLE; } else { m_adapt_state = IMPOSSIBLE; } m_zero_init_offset = false; if (events.end() != events.find("zero_init_offset")) { m_zero_init_offset = vv::toBoolean(events.get("zero_init_offset")); } if (events.end() != events.find("quantum")) { m_step_size = vv::toDouble(events.get("quantum")); } else { Trace(context(), 6, "Warning : no quantum value provided for" " Quantifier %s. Using default value (0.1)\n", getModelName().c_str()); m_step_size = 0.1; } if (0 >= m_step_size) throw vu::ModellingError("Bad quantum value (provided value : %f, " "should be strictly positive)", m_step_size); if (events.end() != events.find("archive_length")) { m_past_length = vv::toInteger(events.get("archive_length")); } else { m_past_length = 3; } if (2 >= m_past_length) { throw vu::ModellingError("Bad archive length value ( provided value" ": %u, should at least 3)", m_past_length); } }
virtual void start(const vle::devs::Time& time, Activity* a) { TraceModel(vle::fmt(" [%1%:%2%] at %3% -> %4% starts") % getModel().getParentName() % getModelName() % time % a->name()); a->start(time); mRunningActivities.push_back(a); }
void out(const vd::Time& time, vd::ExternalEventList& output) const { if(signal == "stop") { std::cout << std::setprecision(8) << time << " OS::out model:" << getModelName() << std::endl; vd::ExternalEvent* evt = new vd::ExternalEvent("act"); evt->putAttribute("name", new vv::String("Stade")); evt->putAttribute("value", new vv::Double(RECOLTE)); output.push_back(evt); } }
string AbstractNumberModel<T>::dump() const{ std::stringstream sstream; string modelDumpStr = dictModelPtr->dump(); string encoderDumpStr = dumpFlagEncoder(); sstream << getModelName() << "\n" << encoderDumpStr.size() << "\n" << encoderDumpStr << modelDumpStr.size() << "\n" << modelDumpStr; return sstream.str(); }
void objectsCallback(const visualization_msgs::Marker::ConstPtr& msg) { if (msg->color.r < 1.0 && msg->color.r > 0.0 && msg->id >= 0) { ROS_INFO("Got object: [%s] id: [%d] in frame: [%s] at: [%4.2f,%4.2f,%4.2f,%4.2f,%4.2f,%4.2f,%4.2f] with color: [%4.2f,%4.2f,%4.2f,%4.2f]", msg->text.c_str(), msg->id, msg->header.frame_id.c_str(), msg->pose.position.x, msg->pose.position.y, msg->pose.position.z, msg->pose.orientation.x, msg->pose.orientation.y, msg->pose.orientation.z, msg->pose.orientation.w, msg->color.r, msg->color.g, msg->color.b, msg->color.a ); //TODO check for clusters (no pose given) and calculate pose from //point(s) std::string object_label = getModelName(msg->id); if (object_label.size() > 0) { //check for spawned models if (0 == spawned_models.count(object_label)) { // spawn a new object FluentSimObject sim_object; sim_object.name = object_label; sim_object.pose_map.setOrigin(tf::Vector3( msg->pose.position.x, msg->pose.position.y, msg->pose.position.z )); sim_object.pose_map.setRotation(tf::Quaternion( msg->pose.orientation.x, msg->pose.orientation.y, msg->pose.orientation.z, msg->pose.orientation.w )); sim_object.pose_map = sim_object.pose_map * pr2_gz_tf; auto it = spawned_models.end(); sim_manipulator.spawnFromFluent(sim_object); spawned_models.insert(it, std::pair<std::string, tf::Pose >(object_label, sim_object.pose_map)); } else { //TODO move object instead } } } }
QString GMMfitData::resultToString(const QString name) const { QString str; QTextStream out(&str); for(int i=0;i<gmm->getNumberOfComponents();++i) { out<<name<<"\t"<<getModelName(GMMmodel)<<"\t"<<i<<"/"<<gmm->getNumberOfComponents()<<"\t"<<gmm->getPrior(i)<<"\t"<<gmm->getMu(i,0)<<"\t" <<gmm->getMu(i,1)<<"\t"<<gmm->getGauss(i).getSigma()(0,0)<<"\t"<<gmm->getGauss(i).getSigma()(1,1)<<"\t" <<gmm->getGauss(i).getSigma()(0,1)<<"\t"<<gmm->getN()<<"\n"; } return str; }
foreach(lib_t cur_lib, libs_array) { if(cur_lib.target_name == target) { QLibrary lib(cur_lib.lib); //lib.unload(); if (getModelName(cur_lib.lib) != "unknown") { mCurTarget = cur_lib.lib; return tryResolve(); } } }
void output(const vle::devs::Time& time, vle::devs::ExternalEventList& output) const { if (mPhase == SEND_LOAD) { vle::devs::ExternalEvent* ee = new vle::devs::ExternalEvent("load"); std::cout << time << " - [" << getModelName() << "] DECISION LOAD: " << mSelectedArrivedTransport->toString() << std::endl; ee << vle::devs::attribute( "type",mSelectedArrivedTransport->contentType()); ee << vle::devs::attribute("transport", mSelectedArrivedTransport->toValue()); output.addEvent(ee); } else if (mPhase == SEND_DEPART) { Transports::const_iterator it = mReadyTransports.begin(); std::cout << time << " - [" << getModelName() << "] DECISION DEPART: { "; while (it != mReadyTransports.end()) { vle::devs::ExternalEvent* ee = new vle::devs::ExternalEvent("depart"); std::cout << (*it)->id() << " "; ee << vle::devs::attribute("type", (*it)->contentType()); ee << vle::devs::attribute("id", (int)(*it)->id()); output.addEvent(ee); ++it; } std::cout << "}" << std::endl; } }
void externalTransition( const vle::devs::ExternalEventList& events, const vle::devs::Time& time) { vle::devs::ExternalEventList::const_iterator it = events.begin(); std::cout.precision(12); std::cout << time << " - [" << getModelName() << "] externalTransition: " << mPhase << std::endl; while (it != events.end()) { if ((*it)->onPort("transport")) { Transport* transport = new Transport( vle::value::toMapValue( (*it)->getAttributeValue("transport"))); std::cout << time << " - [" << getModelName() << "] DECISION TRANSPORT: " << transport->toString() << " => " << mPhase << std::endl; transport->arrived(time); mTransports.push_back(transport); } else if ((*it)->onPort("loaded")) { TransportID transportID = (*it)->getIntegerAttributeValue("id"); std::cout << time << " - [" << getModelName() << "] DECISION LOADED: transport -> " << transportID << std::endl; removeWaitingTransport(transportID); mPhase = SEND_DEPART; } ++it; } updateSigma(time); }
QList<QString> QWpsDrawer::getTargets() { QList<QString> list ; QDir d = QDir(qApp->applicationDirPath()); QFileInfoList libs = d.entryInfoList(QStringList("libwps_*")); qDebug() << libs.size()<<"libs found"; for (int i = 0; i < libs.size(); i++) { QString modelName = getModelName(libs[i].absoluteFilePath()); qDebug() << libs[i].fileName()<<modelName; if (modelName == "unknown") continue; list.append(modelName); libs_array[i].target_name = modelName; libs_array[i].lib = libs[i].absoluteFilePath(); } return list; }
void updateSunLightInteraction() { if ( ent->hasStageWithoutBlendFunc() == false ) { if ( shadowVolume ) { delete shadowVolume; shadowVolume = 0; } return; } if ( shadowVolume == 0 ) { shadowVolume = new rIndexedShadowVolume_c; } else { if ( ent->isAnimated() == false ) { if ( absSilChangeCount == ent->getSilChangeCount() ) { if ( rf_sunLight_printUnchangedInteractions.getInt() ) { g_core->Print( "sunLightEntityInteraction_c::updateSunLightInteraction: %s didnt change\n", ent->getModelName() ); } addDrawCall(); return; } } } ent->updateAnimatedEntity(); absSilChangeCount = ent->getSilChangeCount(); if ( rf_usePointLightForSun.getInt() ) { vec3_c pos = rf_sunLight->getFakePointLightPosition(); ent->getMatrix().getInversed().transformPoint( pos ); shadowVolume->createShadowVolumeForEntity( ent, pos, rf_sunLight->getFakePointLightRadius() ); } else { vec3_c dir = RF_GetSunDirection(); ent->getMatrix().getInversed().transformNormal( dir ); shadowVolume->createDirectionalShadowVolumeForEntity( ent, dir, 5000 ); } addDrawCall(); }
virtual void internalTransition(const vle::devs::Time &time) { current_time = time; if (!date.empty() && index < date.size()) { auto low = std::lower_bound(date.begin() + index, date.end(), current_time, [] (const data& d, vle::devs::Time value) { return d.dmin <= value; }); index += std::distance(date.begin() + index, low); DTraceModel(vle::fmt("%1% internalTransition index=%2%") % getModelName() % index); } }
void printDialog::printSetup() { QString str = tr("<h2>General Model Settings</h2><br>"); str.append(fv(tr("Name"), getModelName())); str.append(fv(tr("Timer"), getTimer())); //value, mode, count up/down str.append(fv(tr("Protocol"), getProtocol())); //proto, numch, delay, str.append(fv(tr("Pulse Polarity"), g_model->pulsePol ? "NEG" : "POS")); str.append(fv(tr("Throttle Trim"), g_model->thrTrim ? tr("Enabled") : tr("Disabled"))); str.append(fv(tr("Throttle Expo"), g_model->thrExpo ? tr("Enabled") : tr("Disabled"))); str.append(fv(tr("Trim Switch"), getSWName(g_model->trimSw,0))); str.append(fv(tr("Trim Increment"), getTrimInc())); str.append(fv(tr("Center Beep"), getCenterBeep())); // specify which channels beep str.append("<br><br>"); te->append(str); }
void output(const vle::devs::Time& time, vle::devs::ExternalEventList& output) const { if (mPhase == SEND_ASSIGN) { for (ResourceConstraints::const_iterator it = mResourceConstraints->begin(); it != mResourceConstraints->end(); ++it) { vle::devs::ExternalEvent* ee = new vle::devs::ExternalEvent("assign"); ee << vle::devs::attribute("type", it->type()); ee << vle::devs::attribute("quantity", (int)it->quantity()); output.push_back(ee); } } else if (mPhase == SEND_DEMAND) { for (ResourceConstraints::const_iterator it = mResourceConstraints->begin(); it != mResourceConstraints->end(); ++it) { vle::devs::ExternalEvent* ee = new vle::devs::ExternalEvent("demand"); TraceModel( vle::fmt(" [%1%:%2%] at %3% -> demand: %4% = %5%") % getModel().getParentName() % getModelName() % time % it->type() % it->quantity()); ee << vle::devs::attribute("type", it->type()); ee << vle::devs::attribute("quantity", (int)it->quantity()); output.push_back(ee); } } else if (mPhase == SEND_RELEASE) { vle::devs::ExternalEvent* ee = new vle::devs::ExternalEvent("release"); ee << vle::devs::attribute("resources", mReleasedResources->toValue()); output.push_back(ee); } else if (mPhase == SEND_UNAVAILABLE) { vle::devs::ExternalEvent* ee = new vle::devs::ExternalEvent("unavailable"); ee << vle::devs::attribute("resources", mUnavailableResources.toValue()); output.push_back(ee); } }
void Executive::dump(std::ostream &out, const std::string &name) const { vpz::Vpz f; f.project().setAuthor(getModelName()); f.project().model().setGraph( std::unique_ptr<vpz::BaseModel>(coupledmodel().clone())); f.project().dynamics().add(m_coordinator.dynamics()); f.project().experiment().addConditions(m_coordinator.conditions()); f.project().experiment().setName(name); f.project().experiment().setBegin(0.0); f.project().experiment().setDuration(1.0); if (not f.project().dynamics().exist("unknown")) { f.project().dynamics().add(vpz::Dynamic("unknown")); } f.write(out); }
static bool init_reg_setting(void) { struct i2c_client* pClient = pDrvData->client; I2CWByte(0x04,0x80); // reset pDrvData->chipid_reg = I2CRByte(RT9450_REG_CHIP_ID); if (pDrvData->chipid_reg<0) { ERR("Error : i2c i/o error (%d)\n",pDrvData->chipid_reg); return false; } if ((pDrvData->chipid_reg&0xe0)!= 0x80) { ERR("Error : Not RT9450x(0x%x)\n",pDrvData->chipid_reg); return false; } pDrvData->chip_model = getModel(pDrvData->chipid_reg); if (pDrvData->chip_model==ID_RT9450_UNKNOW) WARNING("Warning : unknow 9450 id (0x%x)\n",pDrvData->chipid_reg); INFO("Chip Model = %s\n",getModelName(pDrvData->chip_model)); pDrvData->control_reg = CONFIG_RT9450_CTRL; pDrvData->voltage_reg = CONFIG_RT9450_VOLTAGE; pDrvData->current_reg = CONFIG_RT9450_CURRENT; I2CWByte(RT9450_REG_CTRL,pDrvData->control_reg); I2CWByte(RT9450_REG_VOLTAGE,pDrvData->voltage_reg); I2CWByte(RT9450_REG_CURRENT,pDrvData->current_reg); pDrvData->status_reg = I2CRByte(RT9450_REG_STATUS); if (pDrvData->chip_model == ID_RT9450A || pDrvData->chip_model == ID_RT9450C) { pDrvData->bmfs_reg = I2CRByte(RT9450_REG_BMFS); pDrvData->cmfs_reg = I2CRByte(RT9450_REG_CMFS); } if ((pDrvData->status_reg&0x30)==0x10) { INFO("Already started charaing\n"); pDrvData->active =0x01; schedule_delayed_work(&pDrvData->rt9450_charger_work,DELAY0); } else { pDrvData->active =0x00; } return true; }
void internalTransition(const vle::devs::Time& time) { std::cout.precision(12); std::cout << time << " - [" << getModelName() << "] internalTransition: " << mPhase << std::endl; if (mPhase == IDLE) { searchTransport(time); mPhase = SEND_LOAD; } else if (mPhase == SEND_LOAD) { waitContainer(); updateSigma(time); mPhase = IDLE; } else if (mPhase == SEND_DEPART) { mReadyTransports.clear(); mPhase = IDLE; } }
virtual void finish(const vle::devs::Time& time) { Activities::iterator it = mRunningActivities.begin(); while (it != mRunningActivities.end()) { if ((*it)->done(time)) { TraceModel(vle::fmt(" [%1%:%2%] at %3% -> %4% finishs") % getModel().getParentName() % getModelName() % time % (*it)->name()); (*it)->finish(time); mDoneActivities.push_back(*it); mRunningActivities.erase(it); it = mRunningActivities.begin(); } else { ++it; } } }
/** * @brief Handles external event and registers if necesserary * updates of external events (ExtUp), perturabations and discontinuities. * @param t, the current time * @param ext, the list of external event */ void handleExtEvt(const vd::Time& /*t*/, const vd::ExternalEventList& ext) { vd::ExternalEventList::const_iterator itb = ext.begin(); vd::ExternalEventList::const_iterator ite = ext.end(); for (; itb != ite; itb++) { //get port name const std::string& portName = itb->getPortName(); //find internal variable Variables::iterator itf = vars().find(portName); if (itf == vars().end()) { throw utils::InternalError(vle::utils::format( "[%s] Unrecognised variable '%s'", getModelName().c_str(), portName.c_str())); } if (itb->attributes()->isMap() and itb->attributes()->toMap().exist("value")) { itf->second->setVal( itb->attributes()->toMap().getDouble("value")); } else { itf->second->setVal(itb->attributes()->toDouble().value()); } } }