void execute(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
		{
			xmlrpc_c::value_array
			/*std::vector<xmlrpc_c::value>*/ symbols = paramList.getArray(0);
			std::vector<xmlrpc_c::value> csymbols = symbols.vectorValueValue();

			vector<string> ss;
			for(unsigned int i=0; i<csymbols.size(); i++)
				ss.push_back(xmlrpc_c::value_string(csymbols[i]).cvalue());

			subscribed_symbols = ss;

			*retvalP = xmlrpc_c::value_boolean(true);
		}
	void set_fill_pattern(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* retvalP) {
		ACE_TRACE("modTM_VC_Gen_Packet_Interface::set_fill_pattern");
		const std::vector<xmlrpc_c::value> xml_rpc_pattern = paramList.getArray(2);

		std::vector<uint8_t> fillPattern;

		for (unsigned i = 0; i < xml_rpc_pattern.size(); i++ ) {
			fillPattern[i] = xmlrpc_c::value_int(xml_rpc_pattern[i]);
		}

		find_handler(paramList)->setFillPattern(fillPattern);

		*retvalP = xmlrpc_c::value_nil();
	}
	virtual void set_rate_limit(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* retvalP) {
		ACE_TRACE("modEmulateRate_Interface::set_rate");
		int rate = 0, startTime = -1.0;

		if ( paramList[2].type() != xmlrpc_c::value::TYPE_ARRAY ) {
			rate = paramList.getInt(2);
		}
		else {
			const std::vector<xmlrpc_c::value> arrayData = paramList.getArray(2);
			startTime = xmlrpc_c::value_double(arrayData[0]);
			rate = xmlrpc_c::value_double(arrayData[1]);
		}

		find_handler(paramList)->setRateLimit(rate, startTime);

		*retvalP = xmlrpc_c::value_nil();
	}
Beispiel #4
0
void RemoteKinematics::PositionMethod::execute(xmlrpc_c::paramList const& paramList,
                                               xmlrpc_c::value* const resultP) {
    // n:AA
    if (paramList.size() == 2) {
        vector<value> keys = paramList.getArray(0);
        vector<value> values = paramList.getArray(1);
        // Size check
        if (keys.size() != values.size()) throw girerr::error("Keys vector and values vector doesn't have same size");
        // Empty check
        if (keys.empty()) return;
        bool integer_keys = keys[0].type() == xmlrpc_c::value::TYPE_INT;
        vector<double> data(values.size());
        for (int i = 0; i < values.size(); ++i) data[i] = value_double(values[i]);
        if (integer_keys) {
            vector<int> joint_names(keys.size());
            for (int i = 0; i < keys.size(); ++i) joint_names[i] = value_int(keys[i]);
            this->m_kinematics->setPosition(joint_names, data);
        } else {
            vector<string> joint_names(keys.size());
            for (int i = 0; i < keys.size(); ++i) joint_names[i] = value_string(keys[i]);
            this->m_kinematics->setPosition(joint_names, data);
        }
        *resultP = value_nil();
        return;
    }
    // S:
    SensorData<double>::Ptr data;
    if (paramList.size() == 0) {
        data = this->m_kinematics->getPosition();
        // S:A
    } else if (paramList.size() == 1) {
        // Empty check
        vector<value> keys = paramList.getArray(0);
        if (keys.empty()) return;
        bool integer_keys = keys[0].type() == xmlrpc_c::value::TYPE_INT;
        if (integer_keys) {
            vector<int> joint_names(keys.size());
            for (int i = 0; i < keys.size(); ++i) joint_names[i] = (int) value_int(keys[i]);
            data = this->m_kinematics->getPosition(joint_names);
        } else {
            vector<string> joint_names(keys.size());
            for (int i = 0; i < keys.size(); ++i) joint_names[i] = (string) value_string(keys[i]);
            data = this->m_kinematics->getPosition(joint_names);
        }
    } else throw girerr::error("Unknown signature for hardness function");
    // TODO Check for memory leaks
    // Some optimisation by using C library of xmlrpc-c
    xmlrpc_env env;
    xmlrpc_env_init(&env);

    xmlrpc_value* elem;
    xmlrpc_value* values;
    xmlrpc_value* result;
    // Init result array
    values = xmlrpc_array_new(&env);
    for (int i = 0; i < data->data.size(); ++i) {
        elem = xmlrpc_double_new(&env, data->data[i]);
        xmlrpc_array_append_item(&env, values, elem);
        xmlrpc_DECREF(elem);
    }
    // XMLRPC-C timestamp
    elem = xmlrpc_double_new(&env, data->timestamp);
    // Create result struct
    result = xmlrpc_struct_new(&env);
    xmlrpc_struct_set_value(&env, result, "data", values);
    xmlrpc_struct_set_value(&env, result, "timestamp", elem);
    // Apply result
    resultP->instantiate(result);
    // Clean this shit!
    xmlrpc_DECREF(elem);
    xmlrpc_DECREF(values);
    xmlrpc_DECREF(result);
    xmlrpc_env_clean(&env);
}
Beispiel #5
0
void METHOD_MESSAGE_SEND::execute(xmlrpc_c::paramList const & paramList,
                                  xmlrpc_c::value *   const   retvalPtr)
{
std::string cookie = paramList.getString(0);
std::vector<xmlrpc_c::value> logins(paramList.getArray(1));
std::map<std::string, xmlrpc_c::value> msgInfo(paramList.getStruct(2));
paramList.verifyEnd(3);

ADMIN_INFO adminInfo;

if (config->GetAdminInfo(cookie, &adminInfo))
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }

STG_MSG message;

std::map<std::string, xmlrpc_c::value>::iterator it;

if ((it = msgInfo.find("version")) == msgInfo.end())
    {
    message.header.ver = 1; // Default value
    }
else
    {
    message.header.ver = xmlrpc_c::value_int(it->second);
    }

if ((it = msgInfo.find("type")) == msgInfo.end())
    {
    message.header.type = 1; // default value
    }
else
    {
    message.header.type = xmlrpc_c::value_int(it->second);
    }

if ((it = msgInfo.find("repeat")) == msgInfo.end())
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }
message.header.repeat = xmlrpc_c::value_int(it->second);

if ((it = msgInfo.find("repeat_period")) == msgInfo.end())
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }
message.header.repeatPeriod = xmlrpc_c::value_int(it->second);

if ((it = msgInfo.find("show_time")) == msgInfo.end())
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }
message.header.showTime = xmlrpc_c::value_int(it->second);

if ((it = msgInfo.find("text")) == msgInfo.end())
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }
message.text = IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "CP1251");

message.header.creationTime = static_cast<int>(stgTime);
message.header.lastSendTime = 0;

std::vector<xmlrpc_c::value>::iterator lit;
for (lit = logins.begin(); lit != logins.end(); ++lit)
    {
    USER_PTR ui;
    if (users->FindByName(xmlrpc_c::value_string(*lit), &ui))
        {
        printfd(__FILE__, "METHOD_MESSAGE_SEND::execute(): 'User '%s' not found'\n", std::string(xmlrpc_c::value_string(*lit)).c_str());
        }
    else
        {
        ui->AddMessage(&message);
        }
    }

*retvalPtr = xmlrpc_c::value_boolean(true);
}