bool SystemDefaultImplementation::isConsistent()
{
  if(IEvent* system = dynamic_cast<IEvent*>(this))
  {
    unsigned int dim = system->getDimZeroFunc();
    bool* conditions0 = new bool[dim];
    bool* conditions1 = new bool[dim];
    getConditions(conditions0);
    IContinuous::UPDATETYPE pre_call_type=_callType;
    _callType = IContinuous::DISCRETE;
    for(int i=0;i<dim;i++)
    {
      system->getCondition(i);
    }
    getConditions(conditions1);
    bool isConsistent =  std::equal (conditions1, conditions1+_dimZeroFunc,conditions0);
    _callType = pre_call_type;
    setConditions(conditions0);
    delete[] conditions0;
    delete[] conditions1;
    return isConsistent;
  }
  else
    return true;
}
示例#2
0
文件: ObjCapture.cpp 项目: Gerjo/PCCS
void ObjCapture::onCollision(Composite* entity) {
    if(entity->isType("Soldier")) {
        if(!isCapturing) {
            cout << "capturing!" << endl;
            setConditions();
        }
    }
}
bool SystemDefaultImplementation::isConsistent()
{
  if(_dimZeroFunc > 0)
  {
     getConditions(_conditions0);
    IContinuous::UPDATETYPE pre_call_type=_callType;
    _callType = IContinuous::DISCRETE;
    for(int i=0;i<_dimZeroFunc;i++)
    {
      _event_system->getCondition(i);
    }
    bool isConsistent =  std::equal (_conditions, _conditions+_dimZeroFunc,_conditions0);
    _callType = pre_call_type;
    setConditions(_conditions0);
    return isConsistent;
  }
  else
    return true;
}
示例#4
0
void WeatherPlugin::element_end(const char *el)
{
    if (!strcmp(el, "obst")){
        setLocation(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "lsup")){
        setUpdated(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "sunr") && m_bCC){
        setSun_raise(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "suns") && m_bCC){
        setSun_set(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "vis") && m_bCC){
        setVisibility(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "tmp") && m_bCC){
        setTemperature(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "flik") && m_bCC){
        setFeelsLike(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "devp") && m_bCC){
        setDewPoint(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "hmid") && m_bCC){
        setHumidity(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "low") && m_day){
        setMinT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "hi") && m_day){
        setMaxT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "t")){
        if (!m_bBar && !m_bWind && !m_bUv){
			if (m_bCC){
				setConditions(m_data.c_str());
			}else{
				setDayConditions(m_day, m_data.c_str());
			}
		}
        if (m_bWind && m_bCC)
            setWind(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "icon")){
		if (m_bCC){
			setIcon(atol(m_data.c_str()));
		}else{
			setDayIcon(m_day, m_data.c_str());
		}
        m_data = "";
        return;
    }
    if (!strcmp(el, "ut")){
        setUT(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "up")){
        setUP(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "us")){
        setUS(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "gust") && m_bCC){
        setWindGust(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "bar")){
        m_bBar = false;
        return;
    }
    if (!strcmp(el, "cc")){
        m_bCC = false;
        return;
    }
    if (!strcmp(el, "r") && m_bBar && m_bCC){
        unsigned long v = 0;
        for (const char *p = m_data.c_str(); *p; p++){
            if (*p == '.')
                break;
            if (*p == ',')
                continue;
            v = (v * 10) + (*p - '0');
        }
        setPressure(v);
        return;
    }
    if (!strcmp(el, "d") && m_bBar && m_bCC){
		setPressureD(m_data.c_str());
		m_data = "";
		return;
	}
    if (!strcmp(el, "wind")){
        m_bWind = false;
        return;
    }
    if (!strcmp(el, "s") && m_bWind && m_bCC){
        setWind_speed(atol(m_data.c_str()));
        return;
    }
    if (!strcmp(el, "uv")){
        m_bUv = false;
        return;
    }
}
示例#5
0
void WeatherPlugin::element_end(const char *el)
{
    if (!strcmp(el, "day")){
        if ((*getMinT(m_day) == 0) || (*getMaxT(m_day) == 0))
            m_day--;
        return;
    }
    if (!strcmp(el, "obst")){
        setLocation(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "lsup")){
        setUpdated(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "sunr") && (m_day == 0)){
        setSun_raise(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "suns") && (m_day == 0)){
        setSun_set(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "vis") && m_bCC){
        setVisibility(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "tmp") && m_bCC){
        setTemperature(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "flik") && m_bCC){
        setFeelsLike(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "dewp") && m_bCC){
        setDewPoint(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "ppcp") && (m_day == 1) ) {
        if (((m_bDayPart == 'd') && m_bDayForecastIsValid) || ((m_bDayPart == 'n') && ! m_bDayForecastIsValid )){
    	    setPrecipitation(atol(m_data.c_str()));
    	    m_data = "";
    	    return;
	}
    }	
    if (!strcmp(el, "hmid") && m_bCC){
        setHumidity(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "low") && m_day){
        if (m_data == "N/A")
            m_data = "";
        setMinT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "hi") && m_day){
        if (m_data == "N/A")
            m_data = "-255";
        setMaxT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "t")){
        if (!m_bBar && !m_bWind && !m_bUv && !m_bMoon){
            if (m_bCC){
                setConditions(m_data.c_str());
            }else{
                setDayConditions(m_day, m_data.c_str());
		if ((m_data == "N/A") && (m_bDayPart == 'd')) 
		    m_bDayForecastIsValid = false;
            }
        }
        if (m_bWind && m_bCC)
            setWind(m_data.c_str());
        if (m_bUv && m_bCC)
            setUV_Description(m_data.c_str());
        if (m_bMoon && m_bCC)
            setMoonPhase(m_data.c_str());

        m_data = "";
        return;
    }
    if (!strcmp(el, "i")) {
        if (m_bUv && m_bCC)
            setUV_Intensity(strtol(m_data.c_str(),NULL,10));
        m_data = "";
        return;
    }
    if (!strcmp(el, "icon")){
        if (m_bMoon && m_bCC) {
            setMoonIcon(atol(m_data.c_str()));
        } else if (m_bCC){
            setIcon(atoul(m_data.c_str()));
        }else{
            setDayIcon(m_day, m_data.c_str());
        }
        m_data = "";
        return;
    }
    if (!strcmp(el, "ut")){
        setUT(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "up")){
        setUP(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "us")){
        setUS(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "ud")){
        setUD(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "gust") && m_bCC){
        setWindGust(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "bar")){
        m_bBar = false;
        return;
    }
    if (!strcmp(el, "cc")){
        m_bCC = false;
        return;
    }
    if (!strcmp(el, "r") && m_bBar && m_bCC){
        unsigned long v = 0;
        for (const char *p = m_data.c_str(); *p; p++){
            if (*p == '.')
                break;
            if (*p == ',')
                continue;
            v = (v * 10) + (*p - '0');
        }
        setPressure(v);
        return;
    }
    if (!strcmp(el, "d") && m_bBar && m_bCC){
        setPressureD(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "wind")){
        m_bWind = false;
        return;
    }
    if (!strcmp(el, "s") && m_bWind && m_bCC){
        setWind_speed(atol(m_data.c_str()));
        return;
    }
    if (!strcmp(el, "uv")){
        m_bUv = false;
        return;
    }
    if (!strcmp(el, "moon")){
        m_bMoon = false;
        return;
    }
}
示例#6
0
void WeatherPlugin::element_end(const char *el)
{
	if (!strcmp(el, "obst")){
		setLocation(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "lsup")){
		setUpdated(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "sunr")){
		setSun_raise(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "suns")){
		setSun_set(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "tmp")){
		setTemperature(atol(m_data.c_str()));
		m_data = "";
		return;
	}
	if (!strcmp(el, "hmid")){
		setHumidity(atol(m_data.c_str()));
		m_data = "";
		return;
	}
	if (!strcmp(el, "t")){
		if (!m_bBar && !m_bWind && !m_bUv)
			setConditions(m_data.c_str());
		if (m_bWind)
			setWind(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "icon")){
		setIcon(atol(m_data.c_str()));
		m_data = "";
		return;
	}
	if (!strcmp(el, "ut")){
		setUT(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "up")){
		setUP(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "us")){
		setUS(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "bar")){
		m_bBar = false;
		return;
	}
	if (!strcmp(el, "r") && m_bBar){
		unsigned long v = 0;
		for (const char *p = m_data.c_str(); *p; p++){
			if (*p == '.')
				break;
			if (*p == ',')
				continue;
			v = (v * 10) + (*p - '0');
		}
		setPressure(v);
		return;
	}
	if (!strcmp(el, "wind")){
		m_bWind = false;
		return;
	}
	if (!strcmp(el, "s") && m_bWind){
		setWind_speed(atol(m_data.c_str()));
		return;
	}
	if (!strcmp(el, "uv")){
		m_bUv = false;
		return;
	}
}
示例#7
0
void *WeatherPlugin::processEvent(Event *e)
{
	if (e->type() == EventLanguageChanged)
		updateButton();
    if (e->type() == EventInit)
        showBar();
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->id == CmdWeather) && *getURL()){
            Event eGo(EventGoURL, (void*)getURL());
            eGo.process();
            return e->param();
        }
    }
    if (e->type() == EventFetchDone){
        fetchData *d = (fetchData*)(e->param());
        if (d->req_id != m_fetch_id)
            return NULL;
        m_fetch_id = 0;
        if (d->result != 200)
            return NULL;
        WeatherParser p(*d->data);
        setStr(p.m_updated.c_str(), data.Updated);
        setStr(p.m_location.c_str(), data.Location);
        setLong(p.m_temperature_f.c_str(), data.Temperature_f);
        setLong(p.m_temperature_c.c_str(), data.Temperature_c);
        setLong(p.m_humidity.c_str(), data.Humidity);
        setLong(p.m_pressure_in.c_str(), data.Pressure_in);
        setLong(p.m_pressure_hpa.c_str(), data.Pressure_hpa);
        setStr(p.m_conditions.c_str(), data.Conditions);
        setStr(p.m_wind.c_str(), data.Wind);
        setLong(p.m_wind_speed_mph.c_str(), data.Wind_speed_mph);
        setLong(p.m_wind_speed_km.c_str(), data.Wind_speed_km);
        setStr(p.m_sun_raise.c_str(), data.Sun_raise);
        setStr(p.m_sun_set.c_str(), data.Sun_set);
        QString condition = getConditions();
        condition = condition.lower();
        if (condition.find("fog") >= 0)
            condition = "Fog";
        if (condition.find("overcast") >= 0)
            condition = "Overcast";
        if (condition.find("mist") >= 0)
            condition = "Fog";
        if (condition.find("storm") >= 0)
            condition = "Storm";
        if (condition.find("rain") >= 0)
            condition = "Rain";
        if (condition.find("snow") >= 0)
            condition = "Snow";
        if (condition.find("clear") >= 0)
            condition = "Clear";
        if (condition.find("cloudy") >= 0){
            if (condition.find("part") >= 0){
                condition = "Partial cloudy";
            }else{
                condition = "Cloudy";
            }
        }
        if (condition.find("clouds") >= 0)
            condition = "Partial cloudy";
        setConditions(condition.latin1());
        time_t now;
        time(&now);
        setTime(now);
        updateButton();
        Event eUpdate(EventWeather);
        eUpdate.process();
    }
    return NULL;
}