Example #1
0
static bool rebuild__(Packages *out)
{
    namespace fs = boost::filesystem;

    fs::path pkgsdir(utils::Path::path().getPackagesDir());
    PackageParser parser;

    if (fs::exists(pkgsdir) and fs::is_directory(pkgsdir)) {
        for (fs::directory_iterator it(pkgsdir), end; it != end; ++it) {
            if (fs::is_directory(it->status())) {
                fs::path descfile = *it;
                descfile /= "Description.txt";

                if (fs::exists(descfile)) {
                    parser.extract(descfile.string(), std::string());
                } else {
                    TraceAlways(
                        fmt(_("Remote manager: failed to open Description from"
                              " `%1%'")) % descfile.string());
                }
            }
        }

        out->reserve(parser.size());
        out->insert(out->rbegin().base(), parser.begin(),
                    parser.end());

        return true;
    } else {
        TraceAlways(fmt(_("failed to open directory `%1%'")) %
                    pkgsdir.string());

        return false;
    }
}
Example #2
0
	void interaction_pMMSExecute(const vd::Time& time) {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute::interaction_pMMSExecute - request at time : " + time.toString());
		try
		{
			_pMMSExecute(this->time,this->timestep,this->NID);
		}
		catch(...)
		{
			TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute::interaction_pMMSExecute - Error in calling function pMMSExecute at time : " + time.toString());
		}
	}
Example #3
0
	void transition_INIT_to_RUNNING_for_ModelState(const vd::Time& time) {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute::transition_INIT_to_RUNNING_for_ModelState] - request at time : " + time.toString());
		if(guard_initializing(time)) {
			action_test2(time);
			this->_ModelState_state = RUNNING;
		}
	}
Example #4
0
	virtual void output(const vd::Time& time, vd::ExternalEventList& output) const {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute - Output at time : " + time.toString());
		//Send event on external port (port "OUT")
		vd::ExternalEvent* evt = NULL;
		evt = new vd::ExternalEvent("bfalse");
		if(evt != NULL)
		{
			vv::Value* val = Logical_toValue(this->bfalse);
			if(val != NULL)
			{			
				evt << vd::attribute("bfalse", val);
				output.addEvent(evt);
				TraceModel(vu::DateTime::simpleCurrentDate() + " - Output port bfalse is changed to " + val->writeToString() + " at time " + time.toString());
			}
		} 
		evt = new vd::ExternalEvent("btrue");
		if(evt != NULL)
		{
			vv::Value* val = Logical_toValue(this->btrue);
			if(val != NULL)
			{			
				evt << vd::attribute("btrue", val);
				output.addEvent(evt);
				TraceModel(vu::DateTime::simpleCurrentDate() + " - Output port btrue is changed to " + val->writeToString() + " at time " + time.toString());
			}
		} 
	}
Example #5
0
bool LocalPackageManager::extract(Packages *out)
{
    try {
        return extract__(out, RemoteManager::getLocalPackageFilename());
    } catch (const std::exception& e) {
        TraceAlways(
            fmt(_("Remote manager: internal error when reading local package:"
                  " %1%")) % e.what());

        return false;
    }
}
Example #6
0
bool LocalPackageManager::rebuild(Packages *out)
{
    try {
        return rebuild__(out);
    } catch (const std::exception& e) {
        TraceAlways(
            fmt(_("Remote manager: failed to rebuild cache of installed"
                  " package: %1%")) % e.what());

        return false;
    }
}
Example #7
0
	virtual void internalTransition(const vd::Time& time) {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute - internal transition at time : " + time.toString());
		switch(this->_ModelState_state) {
		case INIT:
			transition_INIT_to_RUNNING_for_ModelState(time);
			
			break;
		case RUNNING:
			interaction_pMMSExecute(time);
			
			break;
		default:
			this->_ModelState_state = INIT;
		};
	} 
Example #8
0
	virtual vd::Time init(const vd::Time& time) {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute - Init at time : " + time.toString());
	
	_pMMSExecute = (void (*)(const Long& time, const Long& timestep, const Long& NID)) _pFuncDirectory->getFunction("pMMSExecute");
	
	
		this->time = 0;
		TraceModel(vu::DateTime::simpleCurrentDate() + " - Initialize reference \"time\" to \"0\" at time : " + time.toString());
		this->timestep = 0;
		TraceModel(vu::DateTime::simpleCurrentDate() + " - Initialize reference \"timestep\" to \"0\" at time : " + time.toString());
		this->cycle = 0;
		TraceModel(vu::DateTime::simpleCurrentDate() + " - Initialize reference \"cycle\" to \"0\" at time : " + time.toString());
		this->NID = 0;
		TraceModel(vu::DateTime::simpleCurrentDate() + " - Initialize reference \"NID\" to \"0\" at time : " + time.toString());
	this->timestep = 1;
	this->time = 0;
	return vd::Time(0.0);
	}
Example #9
0
static bool extract__(Packages *out, const std::string& filepath)
{
    namespace fs = boost::filesystem;

    fs::path pkg(filepath);
    PackageParser parser;

    if (fs::exists(pkg) and fs::is_regular_file(pkg)) {
        parser.extract(pkg.string(), std::string());
        out->reserve(parser.size());
        out->insert(out->rbegin().base(), parser.begin(), parser.end());

        return true;
    } else {
        TraceAlways(fmt(_("can not open file `%1%'")) % pkg.string());
    }

    return false;
}
Example #10
0
	MMSExecute(const vd::DynamicsInit& init, const vd::InitEventList& events) : vd::Dynamics(init, events) {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute::MMSExecute");
		this->_signal_test2 = false;
		this->_ModelState_state = Initial;
	} 
Example #11
0
	void action_test2 (const vd::Time& time) {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute::action_test2 - request at time : " + time.toString());
		this->_signal_test2 = true; }
Example #12
0
	bool guard_initializing(const vd::Time& time) const {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute::guard_initializing - request at time : " + time.toString());
		bool result = true;
		result &= (this->time==0); 
		return result;
	};
Example #13
0
	virtual vv::Value* observation(const vd::ObservationEvent& event) const {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute - observation");
		return vd::Dynamics::observation(event);
	}
Example #14
0
	virtual void externalTransition(const vd::ExternalEventList& eventList, const vd::Time& time) {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute - externalTransition at time : " + time.toString());
		//Update input port 
	    vd::ExternalEventList::const_iterator it = eventList.begin();
	    for (;it != eventList.end(); it++)
	    {
			const vd::ExternalEvent& event = *(*it);
			if (event.onPort("time"))
		    {
				TraceModel(vu::DateTime::simpleCurrentDate() + " - Trying to update \"time\" port");
				if(event.existAttributeValue("time"))
				{
				    const vv::Value& val = event.getAttributeValue("time");
						
					this->time = Long_fromValue(&val);
					if(val.isNull() == false)
					{
						TraceModel(vu::DateTime::simpleCurrentDate() + " - Update \"time\" input port to \"" + val.writeToString() + "\" at time " + time.toString());
					}
					else
					{
						TraceModel(vu::DateTime::simpleCurrentDate() + " - NULL value for  \"time\" input port at time " + time.toString());
					}
							
				}
				else
				{
					TraceModel(vu::DateTime::simpleCurrentDate() + " - Unknown attribute value \"time\" for the port \"time\"");
				}
		    }
			if (event.onPort("timestep"))
		    {
				TraceModel(vu::DateTime::simpleCurrentDate() + " - Trying to update \"timestep\" port");
				if(event.existAttributeValue("timestep"))
				{
				    const vv::Value& val = event.getAttributeValue("timestep");
						
					this->timestep = Long_fromValue(&val);
					if(val.isNull() == false)
					{
						TraceModel(vu::DateTime::simpleCurrentDate() + " - Update \"timestep\" input port to \"" + val.writeToString() + "\" at time " + time.toString());
					}
					else
					{
						TraceModel(vu::DateTime::simpleCurrentDate() + " - NULL value for  \"timestep\" input port at time " + time.toString());
					}
							
				}
				else
				{
					TraceModel(vu::DateTime::simpleCurrentDate() + " - Unknown attribute value \"timestep\" for the port \"timestep\"");
				}
		    }
			if (event.onPort("cycle"))
		    {
				TraceModel(vu::DateTime::simpleCurrentDate() + " - Trying to update \"cycle\" port");
				if(event.existAttributeValue("cycle"))
				{
				    const vv::Value& val = event.getAttributeValue("cycle");
						
					this->cycle = Long_fromValue(&val);
					if(val.isNull() == false)
					{
						TraceModel(vu::DateTime::simpleCurrentDate() + " - Update \"cycle\" input port to \"" + val.writeToString() + "\" at time " + time.toString());
					}
					else
					{
						TraceModel(vu::DateTime::simpleCurrentDate() + " - NULL value for  \"cycle\" input port at time " + time.toString());
					}
							
				}
				else
				{
					TraceModel(vu::DateTime::simpleCurrentDate() + " - Unknown attribute value \"cycle\" for the port \"cycle\"");
				}
		    }
			if (event.onPort("NID"))
		    {
				TraceModel(vu::DateTime::simpleCurrentDate() + " - Trying to update \"NID\" port");
				if(event.existAttributeValue("NID"))
				{
				    const vv::Value& val = event.getAttributeValue("NID");
						
					this->NID = Long_fromValue(&val);
					if(val.isNull() == false)
					{
						TraceModel(vu::DateTime::simpleCurrentDate() + " - Update \"NID\" input port to \"" + val.writeToString() + "\" at time " + time.toString());
					}
					else
					{
						TraceModel(vu::DateTime::simpleCurrentDate() + " - NULL value for  \"NID\" input port at time " + time.toString());
					}
							
				}
				else
				{
					TraceModel(vu::DateTime::simpleCurrentDate() + " - Unknown attribute value \"NID\" for the port \"NID\"");
				}
		    }
		}
	}
Example #15
0
	virtual ~MMSExecute() {
		TraceAlways(vu::DateTime::simpleCurrentDate() + " - MMSExecute::~MMSExecute");
	}