Example #1
0
sc_time &tdma_bus::get_CurrentP2Pdelay(phy_link_t &plink,
									unsigned int msg_size
									) {
		
		std::string msg;
		
		unsigned int slots_allocated, first_slot;
		sc_time current_offset_delay, data_tx_delay;
		
		link_info_t *plink_info_p;
		
		// retrieve properties stored (by the base comm_res)
		plink_info_p = get_properties(plink, msg_size);
		
		if(plink_info_p==NULL) { // property for the link-msg_size combination not found
			this->set_CurrentP2Pdelay(plink,msg_size); // refer to plinks info
			
			// retrieve the properties again
			plink_info_p = get_properties(plink, msg_size);
			// ... and it should not fail again
			if(plink_info_p==NULL) { 
				std::string rpt_msg;
				std::ostringstream os;
				rpt_msg = "Setting properties of link ";
				os << plink;
				rpt_msg += os.str();
				rpt_msg += " in TDMA bus ";
				rpt_msg += name();
				rpt_msg += " failed.";
				SC_REPORT_ERROR("KisTA",rpt_msg.c_str());
			}
		}
		
		data_tx_delay = plink_info_p->getMaxP2Pdelay(msg_size);
		
		// NOTE:
		//   Notice that in the CurrentP2P call, only the time invariant component 
		//   was cached.
		// Now, the time dependent component is added.
		// A faster alternative is to use the L1 accuracy level, which provides
		// a random offset bounded by the maximum offset
		switch(accuracy_level) {
			case 0:
				first_slot = first_slot_allocation_table[plink.src];
				current_offset_delay = current_offset_delay_L0(sc_time_stamp(),first_slot);
				break;
			case 1:
				slots_allocated = channel_allocation_table[plink.src];
				current_offset_delay = current_offset_delay_L1(slots_allocated);
				break;
			default:
				msg = "TDMA bus ";
				msg += name();
				msg += ": unknown accuracy level calculating Current P2P delay. Supported ones range 0(most accurate, slower) to 1(faster-less accurate)";
				SC_REPORT_ERROR("KisTA",msg.c_str());					
		}
		current_tx_delay = current_offset_delay + data_tx_delay; // Note that we use a member variable of tdma_bus class (instead a local variable)
		                                                         // to enable the return of a refernce
		return current_tx_delay;
}
std::string get_name( t_artifact_type artifact, bool include_article )
{
	assert( !is_cut( artifact ) );
	if (include_article)
		return get_properties( artifact ).name_with_article;
	return get_properties( artifact ).name;
}
Example #3
0
sc_time &tdma_bus::get_MaxP2Pdelay(phy_link_t &plink,
									unsigned int msg_size
									) {
		
		link_info_t *plink_info_p;
		
		// retrieve properties stored (by the base comm_res)
		plink_info_p = get_properties(plink, msg_size);
		
		if(plink_info_p==NULL) { // property for the link-msg_size combination not found
			this->set_MaxP2Pdelay(plink,msg_size); // refer to plinks info
			
			// retrieve the properties again
			plink_info_p = get_properties(plink, msg_size);
			// ... and it should not fail again
			if(plink_info_p==NULL) { 
				std::string rpt_msg;
				std::ostringstream os;
				rpt_msg = "Setting properties of link ";
				os << plink;
				rpt_msg += os.str();
				rpt_msg += " in TDMA bus ";
				rpt_msg += name();
				rpt_msg += " failed.";
				SC_REPORT_ERROR("KisTA",rpt_msg.c_str());
			}
		}
		
		return plink_info_p->getMaxP2Pdelay(msg_size);

}
Example #4
0
File: scan.c Project: jolin90/dbus
int main(int argc, char *argv[])
{
    DBusConnection *conn;
    struct ADAPTER_PROPERTIES *p;

    conn = init_dbus();

    p = (struct ADAPTER_PROPERTIES *)malloc(sizeof(struct ADAPTER_PROPERTIES));
    p->DiscoverableTimeout = 0;
    p->PairableTimeout = 0;
    p->Pairable = true;
    p->Discoverable = true;
    set_property(conn, "DiscoverableTimeout", p);
    set_property(conn, "PairableTimeout", p);
    set_property(conn, "Pairable", p);
    set_property(conn, "Discoverable", p);
    free(p);

    get_properties(conn);

    printf("%s %d\n", __func__, __LINE__);
    start_discovery(conn);
    printf("%s %d\n", __func__, __LINE__);

    return 0;
}
gboolean
gst_vaapiencode_init_properties (GstVaapiEncode * encode)
{
  GPtrArray *const props = get_properties (GST_VAAPIENCODE_GET_CLASS (encode));
  guint i;

  /* XXX: use base_init()/base_finalize() to avoid multiple initializations */
  if (!props)
    return FALSE;

  encode->prop_values =
      g_ptr_array_new_full (props->len, (GDestroyNotify) prop_value_free);
  if (!encode->prop_values) {
    g_ptr_array_unref (props);
    return FALSE;
  }

  for (i = 0; i < props->len; i++) {
    PropValue *const prop_value = prop_value_new ((GstVaapiEncoderPropInfo *)
        g_ptr_array_index (props, i));
    if (!prop_value)
      return FALSE;
    g_ptr_array_add (encode->prop_values, prop_value);
  }
  return TRUE;
}
Example #6
0
std::unique_ptr<n0::NodeComp> CompLight::Clone(const n0::SceneNode& node) const
{
	auto comp = std::make_unique<CompLight>();
    if (!m_light) {
        return comp;
    }

    auto type = m_light->get_type();
    auto ctor = type.get_constructor();
    auto var = ctor.invoke();
    auto dst = var.get_value<std::shared_ptr<pt3::Light>>();
    comp->SetLight(dst);

    for (auto& prop : type.get_properties())
    {
        if (prop.get_metadata(js::RTTR::NoSerializeTag())) {
            continue;
        }

        rttr::variant prop_value = prop.get_value(m_light);
        if (!prop_value) {
            continue;
        }

        prop.set_value(dst, prop_value);
    }

	return comp;
}
Example #7
0
void BuyChipLayer::click_btn_sub(Ref* sender)
{
    if(amount_ <= 0){
        return;
    }
    auto user = static_pointer_cast<user_texas>( GetRoom()->get_user(GDM->get_user_id()));
    
    int buyin_min = GetRoom()->get_buyin_min();
    int buyin_max = GetRoom()->get_buyin_max();
    
    bool need_credit = false;//permission_.needcredit();
    if (need_credit)
    {
        uint32_t credit = permission_.credit();
        if (credit < buyin_max)
            buyin_max = credit;
    }
    
    int min_chip = buyin_min - user->get_properties()->chips();
    int max_chip = buyin_max - user->get_properties()->chips();
    
    uint32_t unit = GetRoom()->get_buy_min_unit();
    
    uint32_t sub = max_chip - std::max(min_chip, 0);
    int32_t value = amount_ - unit;
    if(value >= min_chip && value <= max_chip) {
        float percent = (value - std::max(0, min_chip)) * 100.0f / sub;
        slider_chip_->setPercent(percent);
        amount_ = value;
        text_buy_number_->setString(tools::to_string(amount_));
    }
}
Example #8
0
int					main(int argc, char **argv)
{
	GLFWwindow			*window;
	t_properties		*properties;

	properties = get_properties();
	properties->map = (argc > 1 ? argv[1] : NULL);
	window = setup_program(properties);
	properties->ires = glGetUniformLocation(properties->program, "iResolution");
	properties->itime = glGetUniformLocation(properties->program,
			"iGlobalTime");
	glfwSetCursorPosCallback(window, cursor_position_callback);
	glfwSetWindowSizeCallback(window, window_size_callback);
	main_loop(window, properties);
	ft_putnbr(glGetError());
	ft_putendl(" 2");
	glDeleteShader(properties->shaders[0]);
	glDeleteShader(properties->shaders[1]);
	glDeleteProgram(properties->program);
	glDeleteVertexArrays(1, &(properties->model));
	glDeleteBuffers(1, &(properties->verts));
	glDeleteBuffers(1, &(properties->indices));
	glfwTerminate();
	return (0);
}
Example #9
0
 XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_properties()") std::map<std::string, std::string>* getProperties()
 {
   std::map<std::string, std::string>* res             = new std::map<std::string, std::string>();
   std::unordered_map<std::string, std::string>* props = get_properties();
   for (auto const& kv : *props)
     res->insert(kv);
   return res;
 }
Example #10
0
GlslManager::GlslManager()
	: Mlt::Filter( mlt_filter_new() )
	, pbo(0)
	, initEvent(0)
	, closeEvent(0)
{
	mlt_filter filter = get_filter();
	if ( filter ) {
		// Set the mlt_filter child in case we choose to override virtual functions.
		filter->child = this;
		mlt_properties_set_data(mlt_global_properties(), "glslManager", this, 0,
			(mlt_destructor) deleteManager, NULL);

		mlt_events_register( get_properties(), "init glsl", NULL );
		mlt_events_register( get_properties(), "close glsl", NULL );
		initEvent = listen("init glsl", this, (mlt_listener) GlslManager::onInit);
		closeEvent = listen("close glsl", this, (mlt_listener) GlslManager::onClose);
	}
}
Example #11
0
QStringList GumboInterface::get_all_properties()
{
    QStringList properties;
    if (!m_source.isEmpty()) {
        if (m_output == NULL) {
            parse();
        }
        properties = get_properties(m_output->root);
    }
    return properties;
}
/**
 * Read the next rule from the input data
 * @param data the CSS data to read from
 * @param offset VAR param of the offset into data to read from
 * @return the rule or NULL
 */
static css_rule *get_css_rule( const char *data, int *offset )
{
	int pos = *offset;
	int state = 0;
	int bodyStart=-1,bodyEnd=-1;
	css_rule *rule = NULL;
	while ( state >= 0 && data[pos] != 0 )
	{
		switch ( state )
		{
			case 0:	// collecting selector
				if ( data[pos] == '{' )
				{
					bodyStart = pos;
					state = 1;
				}
				pos++;
				break;
			case 1:	// collecting body
				if ( data[pos] == '}' )
				{
					bodyEnd = pos;
					state = -1;
				}
				pos++;
				break;
		}
	}
	if ( (bodyStart == -1 || bodyEnd == -1)&&state!=0 )
	{
		warning("failed to find css rule body", 0 );
		return NULL;
	}
	else
	{
		rule = css_rule_create();
		if ( rule != NULL )
        {
            int res = get_selectors( data, *offset, bodyStart-(*offset), rule );
            if ( res )
                res = get_properties( &data[bodyStart+1], (bodyEnd-bodyStart), 
                    rule );
        }
        // update pos even if rule-reading fails
        *offset = pos;
        if ( css_rule_valid(rule) )
            return rule;
        else if ( rule != NULL )
            css_rule_dispose( rule );
        return NULL;
	}
}
Example #13
0
// -------------------------------------------------------------------------
// get properties for a given artifact image
// -------------------------------------------------------------------------
t_bitmap_layer_ptr get_icon( t_artifact_type artifact )
{
	assert( !is_cut( artifact ) );

	static bool					initialized = false;
	static t_bitmap_pool		k_artifact_icons;
	static int                  icon_ids[ k_artifact_type_count ];
	static t_bitmap_group_cache caches[] = 
	{
		"icons.artifacts.armor",
		"icons.artifacts.item",
		"icons.artifacts.special",
		"icons.artifacts.weapon"
	};

	if (!initialized)
	{
		std::vector<t_string_pair> layer_names( k_artifact_type_count );
		t_artifact_type            artifact;

		initialized = true;
		for (artifact = t_artifact_type(0); artifact < k_artifact_type_count; enum_incr(artifact))
		{
			t_string_pair & layer_name = layer_names[ artifact ];
			t_artifact_properties const & properties = get_properties( artifact );
			if ( !properties.cut )
			{
				layer_name.value = get_properties( artifact ).file_id;
				layer_name.keyword = get_keyword( artifact );
			}
			else
				layer_name.value = 0;
		}

		k_artifact_icons = t_bitmap_pool( caches, &(*layer_names.begin()), layer_names.size() );
	}
	return k_artifact_icons.get( artifact );
}
void RectangularMesh::
write_binary_files_in_cells(const std::string &prop_filename,
                            std::vector<std::string> &filenames_out) const
{
  std::cout << "Writing binary files in cells..." << std::endl;
  double t_begin = get_wall_time();

  // Create the map between the material IDs and the media properties. The
  // material IDs must exactly the same as in the given triangular mesh.
  std::map<int, std::vector<double> > properties;

  get_properties(prop_filename, properties);

  const int n_properties = properties.begin()->second.size();

  filenames_out.resize(n_properties);

  std::ofstream *out = new std::ofstream[n_properties];
  for (int i = 0; i < n_properties; ++i)
  {
    filenames_out[i] = "property" + d2s(i) + "_cells.bin";
    out[i].open(filenames_out[i].c_str(), std::ios::binary);
    require(out[i], "File '" + filenames_out[i] + "' can't be opened");
  }

  for (int i = 0; i < _n_elements_x*_n_elements_z; ++i)
  {
    const int matID = _cells_ID[i];
    std::map<int, std::vector<double> >::const_iterator iter =
        properties.find(matID);
    require(iter != properties.end(), "The material ID " + d2s(matID) +
            " wasn't found in the properties file");
    const std::vector<double> values = iter->second;

    for (int p = 0; p < n_properties; ++p)
    {
      OUT_FLOAT_TYPE val = values[p];
      out[p].write(reinterpret_cast<char*>(&val), sizeof(OUT_FLOAT_TYPE));
    }
  }

  for (int i = 0; i < n_properties; ++i)
    out[i].close();

  delete[] out;

  std::cout << "Writing binary files in cells is done. Time = "
            << get_wall_time() - t_begin << std::endl;
}
Example #15
0
static void get_device_list_cb (DBusPendingCall *pending, void *user_data)
{

    DBusMessage *reply = NULL;
    gchar **devices = NULL;
    int n_devices = 0;

    (void) user_data;

    if (pending == NULL) 
        goto error;

    reply = dbus_pending_call_steal_reply(pending);
    dbus_pending_call_unref(pending);
    pending = NULL;

    if (reply == NULL) {
        goto error;
    }

    if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) {
        goto error;
    }

    if (!dbus_message_get_args (reply, NULL,
                DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &devices, &n_devices,
                DBUS_TYPE_INVALID)) {
        goto error;
    }

    /* ok, then ask the adapter (whose object path we now know) about
     * the listed devices */

    for (; n_devices > 0; n_devices--) {
        OHM_DEBUG(DBG_BT, "getting properties of device '%s'\n", devices[n_devices-1]);
        get_properties(devices[n_devices-1], BT_INTERFACE_DEVICE, get_properties_cb);
    }

    dbus_free_string_array(devices);

    return;

error:

    if (reply)
        dbus_message_unref (reply);

    return;
}
Example #16
0
QStringList GumboInterface::get_properties(GumboNode* node)
{
    if (node->type != GUMBO_NODE_ELEMENT) {
        return QStringList();
    }
    QStringList properties;
    std::string tagname = get_tag_name(node);
    if (in_set(manifest_properties, tagname)) {
        properties.append(QString::fromStdString(tagname));
    }
    GumboVector* children = &node->v.element.children;
    for (unsigned int i = 0; i < children->length; ++i) {
        properties.append(get_properties(static_cast<GumboNode*>(children->data[i])));
    }
    return properties;
}
Example #17
0
gboolean
gst_vaapiencode_class_init_properties (GstVaapiEncodeClass * klass)
{
  GObjectClass *const object_class = G_OBJECT_CLASS (klass);
  GPtrArray *const props = get_properties (klass);
  guint i;

  if (!props)
    return FALSE;

  for (i = 0; i < props->len; i++) {
    GstVaapiEncoderPropInfo *const prop = g_ptr_array_index (props, i);
    g_object_class_install_property (object_class, PROP_BASE + i, prop->pspec);
  }
  g_ptr_array_unref (props);
  return TRUE;
}
Example #18
0
void BuyChipLayer::slider_slider_chip(Ref* sender, Slider::EventType event)
{
    
    auto user = static_pointer_cast<user_texas>(GetRoom()->get_user(GDM->get_user_id()));
    //    int min = PDM->get_room()->get_buyin_min() - user->get_chip_amount();
    //    int max = PDM->get_room()->get_buyin_max() - user->get_chip_amount();
    //    int amount = max - min;
    //    int buy_count = min + amount * slider_chip_->getPercent() / 100.0f;
    //    text_buy_number_->setString(tools::to_string(buy_count));
    
    int buyin_min = GetRoom()->get_buyin_min();
    int buyin_max = GetRoom()->get_buyin_max();
    

    if (need_credit_)
    {
        uint32_t credit = permission_.credit();
        if (credit < buyin_max)
            buyin_max = credit;
    }
    
    int min_chip = buyin_min - user->get_properties()->chips();
    int max_chip = buyin_max - user->get_properties()->chips();
    
    
    if (min_chip < 0) {
        min_chip = 0;
    }
    
    int count = (max_chip - min_chip) * slider_chip_->getPercent() / 100.0f + min_chip;
    
    if(count % GetRoom()->get_buy_min_unit() != 0) {
        count = count / GetRoom()->get_buy_min_unit() * GetRoom()->get_buy_min_unit() + GetRoom()->get_buy_min_unit();
    }
    
    if(count <= min_chip) {
        count = min_chip;
    }
    if(count >= max_chip) {
        count = max_chip;
    }
    amount_ = count;
    text_buy_number_->setString(tools::to_string(count));
    //cocos2d::log("BuyChipLayer:slider_chip min:%d,max:%d,count:%d", min_chip, max_chip, count);
}
void RectangularMesh::
write_ASCII_files_at_nodes(const std::string &prop_filename) const
{
  std::cout << "Writing ASCII files at nodes..." << std::endl;
  double t_begin = get_wall_time();

  // Create the map between the material IDs and the media properties. The
  // material IDs must exactly the same as in the given triangular mesh.
  std::map<int, std::vector<double> > properties;

  get_properties(prop_filename, properties);

  const int n_properties = properties.begin()->second.size();

  std::vector<std::string> filenames_out(n_properties);

  std::ofstream *out = new std::ofstream[n_properties];
  for (int i = 0; i < n_properties; ++i)
  {
    filenames_out[i] = "property" + d2s(i) + "_nodes.txt";
    out[i].open(filenames_out[i].c_str(), std::ios::binary);
    require(out[i], "File '" + filenames_out[i] + "' can't be opened");
  }

  for (int i = 0; i < (_n_elements_x+1)*(_n_elements_z+1); ++i)
  {
    const int matID = _verts_ID[i];
    std::map<int, std::vector<double> >::const_iterator iter =
        properties.find(matID);
    require(iter != properties.end(), "The material ID " + d2s(matID) +
            " wasn't found in the properties file");
    const std::vector<double> values = iter->second;

    for (int p = 0; p < n_properties; ++p)
      out[p] << values[p] << "\n";
  }

  for (int i = 0; i < n_properties; ++i)
    out[i].close();

  delete[] out;

  std::cout << "Writing ASCII files at nodes is done. Time = "
            << get_wall_time() - t_begin << std::endl;
}
Example #20
0
std::string
get_defs(GType gtype, GTypeIsAPointerFunc is_a_pointer_func)
{
  std::string strObjectName = g_type_name(gtype);
  std::string strDefs;

  if (G_TYPE_IS_OBJECT(gtype) || G_TYPE_IS_INTERFACE(gtype))
  {
    strDefs = ";; From " + strObjectName + "\n\n";
    strDefs += get_signals(gtype, is_a_pointer_func);
    strDefs += get_properties(gtype);
  }
  else
    strDefs = ";; " + strObjectName +
              " is neither a GObject nor a GInterface. Not checked for signals and properties.\n\n";

  return strDefs;
}
Example #21
0
bool RH_RF24::printRegisters()
{  
#ifdef RH_HAVE_SERIAL
    uint8_t i;
    // First print the commands that return interesting data
    for (i = 0; i < NUM_COMMAND_INFO; i++)
    {
	CommandInfo cmd;
	memcpy_P(&cmd, &commands[i], sizeof(cmd));
	uint8_t buf[10]; // Big enough for the biggest command reply
	if (command(cmd.cmd, NULL, 0, buf, cmd.replyLen))
	{
	    // Print the results:
	    Serial.print("cmd: ");
	    Serial.print(cmd.cmd, HEX);
	    Serial.print(" : ");
	    uint8_t j;
	    for (j = 0; j < cmd.replyLen; j++)
	    {
		Serial.print(buf[j], HEX);
		Serial.print(" ");
	    }
	    Serial.println("");
	}
    }

    // Now print the properties
    for (i = 0; i < NUM_PROPERTIES; i++)
    {
	uint16_t prop;
	memcpy_P(&prop, &properties[i], sizeof(prop));
	uint8_t result;
	get_properties(prop, &result, 1);
	Serial.print("prop: ");
	Serial.print(prop, HEX);
	Serial.print(": ");
	Serial.print(result, HEX);
        Serial.println("");
    }
#endif
    return true;
}
Example #22
0
QStringList GumboInterface::get_properties(GumboNode* node)
{
    if (node->type != GUMBO_NODE_ELEMENT) {
        return QStringList();
    }
    QStringList properties;
    std::string tagname = get_tag_name(node);
    if (in_set(manifest_properties, tagname)) {
        properties.append(QString::fromStdString(tagname));
    }
    GumboAttribute* attr = gumbo_get_attribute(&node->v.element.attributes, "src");
    if (attr && !QUrl(QString::fromUtf8(attr->value)).isRelative()) {
        properties.append(QString("remote-resources"));
    }
    GumboVector* children = &node->v.element.children;
    for (unsigned int i = 0; i < children->length; ++i) {
        properties.append(get_properties(static_cast<GumboNode*>(children->data[i])));
    }
    return properties;
}
static GList *mate_mplayer_properties_get_pages(NemoPropertyPageProvider * provider, GList * files)
{
    GList *pages = NULL;
    NemoFileInfo *file;
    GtkWidget *page, *label;
    NemoPropertyPage *property_page;
    guint i;
    gboolean found = FALSE;
    gchar *uri;

    /* only add properties page if a single file is selected */
    if (files == NULL || files->next != NULL)
        return pages;

    file = files->data;

    /* only add the properties page to these mime types */
    for (i = 0; i < G_N_ELEMENTS(mime_types); i++) {
        if (nemo_file_info_is_mime_type(file, mime_types[i])) {
            found = TRUE;
            break;
        }
    }

    if (found) {
        uri = nemo_file_info_get_uri(file);
        label = gtk_label_new(dgettext(GETTEXT_PACKAGE, "Audio/Video"));
        page = gtk_table_new(20, 2, FALSE);
        gtk_container_set_border_width(GTK_CONTAINER(page), 6);
        if (get_properties(page, uri)) {
            gtk_widget_show_all(page);
            property_page = nemo_property_page_new("video-properties", label, page);
            pages = g_list_prepend(pages, property_page);
        }
        g_free(uri);
    }
    return pages;
}
static void remote_device_properties_callback(bt_status_t status, bt_bdaddr_t *bd_addr,
                                              int num_properties, bt_property_t *properties) {
    if (!checkCallbackThread()) {
       ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
       return;
    }

    ALOGV("%s: Status is: %d, Properties: %d", __FUNCTION__, status, num_properties);

    if (status != BT_STATUS_SUCCESS) {
        ALOGE("%s: Status %d is incorrect", __FUNCTION__, status);
        return;
    }

    callbackEnv->PushLocalFrame(ADDITIONAL_NREFS);

    jobjectArray props;
    jbyteArray addr;
    jintArray types;
    jbyteArray val;
    jclass mclass;

    val = (jbyteArray) callbackEnv->NewByteArray(num_properties);
    if (val == NULL) {
        ALOGE("%s: Error allocating byteArray", __FUNCTION__);
        return;
    }

    mclass = callbackEnv->GetObjectClass(val);

    /* Initialize the jobjectArray and jintArray here itself and send the
     initialized array pointers alone to get_properties */

    props = callbackEnv->NewObjectArray(num_properties, mclass,
                                             NULL);
    if (props == NULL) {
        ALOGE("%s: Error allocating object Array for properties", __FUNCTION__);
        return;
    }

    types = (jintArray)callbackEnv->NewIntArray(num_properties);

    if (types == NULL) {
        ALOGE("%s: Error allocating int Array for values", __FUNCTION__);
        return;
    }
    // Delete the reference to val and mclass
    callbackEnv->DeleteLocalRef(mclass);
    callbackEnv->DeleteLocalRef(val);

    addr = callbackEnv->NewByteArray(sizeof(bt_bdaddr_t));
    if (addr == NULL) goto Fail;
    if (addr) callbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte*)bd_addr);

    if (get_properties(num_properties, properties, &types, &props) < 0) {
        if (props) callbackEnv->DeleteLocalRef(props);
        if (types) callbackEnv->DeleteLocalRef(types);
        callbackEnv->PopLocalFrame(NULL);
        return;
    }

    callbackEnv->CallVoidMethod(sJniCallbacksObj, method_devicePropertyChangedCallback, addr,
                                types, props);
    checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__);
    callbackEnv->DeleteLocalRef(props);
    callbackEnv->DeleteLocalRef(types);
    callbackEnv->DeleteLocalRef(addr);
    callbackEnv->PopLocalFrame(NULL);
    return;

Fail:
    ALOGE("Error while allocation byte array in %s", __FUNCTION__);
}
static void adapter_properties_callback(bt_status_t status, int num_properties,
                                        bt_property_t *properties) {
    jobjectArray props;
    jintArray types;
    jbyteArray val;
    jclass mclass;

    if (!checkCallbackThread()) {
       ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
       return;
    }

    ALOGV("%s: Status is: %d, Properties: %d", __FUNCTION__, status, num_properties);

    if (status != BT_STATUS_SUCCESS) {
        ALOGE("%s: Status %d is incorrect", __FUNCTION__, status);
        return;
    }

    val = (jbyteArray) callbackEnv->NewByteArray(num_properties);
    if (val == NULL) {
        ALOGE("%s: Error allocating byteArray", __FUNCTION__);
        return;
    }

    mclass = callbackEnv->GetObjectClass(val);

    /* (BT) Initialize the jobjectArray and jintArray here itself and send the
     initialized array pointers alone to get_properties */

    props = callbackEnv->NewObjectArray(num_properties, mclass,
                                             NULL);
    if (props == NULL) {
        ALOGE("%s: Error allocating object Array for properties", __FUNCTION__);
        return;
    }

    types = (jintArray)callbackEnv->NewIntArray(num_properties);

    if (types == NULL) {
        ALOGE("%s: Error allocating int Array for values", __FUNCTION__);
        return;
    }
    // Delete the reference to val and mclass
    callbackEnv->DeleteLocalRef(mclass);
    callbackEnv->DeleteLocalRef(val);

    if (get_properties(num_properties, properties, &types, &props) < 0) {
        if (props) callbackEnv->DeleteLocalRef(props);
        if (types) callbackEnv->DeleteLocalRef(types);
        return;
    }

    callbackEnv->CallVoidMethod(sJniCallbacksObj, method_adapterPropertyChangedCallback, types,
                                props);
    checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__);
    callbackEnv->DeleteLocalRef(props);
    callbackEnv->DeleteLocalRef(types);
    return;

}
Example #26
0
mapping get_all()					{
    return get_properties();
}
// Implementation of "agent_properties" command.
static jint get_agent_properties(AttachOperation* op, outputStream* out) {
  return get_properties(op, out, vmSymbols::serializeAgentPropertiesToByteArray_name());
}
Example #28
0
static void scan_results_reply(DBusPendingCall *call, void *user_data)
{
	struct supplicant_task *task = user_data;
	DBusMessage *reply;
	DBusError error;
	char **results;
	int i, num_results;

	_DBG_SUPPLICANT("task %p", task);

	reply = dbus_pending_call_steal_reply(call);
	if (reply == NULL)
		goto noscan;

	if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
		goto done;

	dbus_error_init(&error);

	if (dbus_message_get_args(reply, &error,
				DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH,
						&results, &num_results,
						DBUS_TYPE_INVALID) == FALSE) {
		if (dbus_error_is_set(&error) == TRUE) {
			connman_error("%s", error.message);
			dbus_error_free(&error);
		} else
			connman_error("Wrong arguments for scan result");
		goto done;
	}

	if (num_results == 0)
		goto done;

	task->scangen++;

	for (i = 0; i < num_results; i++) {
		char *path = g_strdup(results[i]);
		if (path == NULL)
			continue;

		task->scan_results = g_slist_append(task->scan_results, path);
	}

	g_strfreev(results);

	dbus_message_unref(reply);

	get_properties(task);

	return;

done:
	dbus_message_unref(reply);

noscan:
	task->result_call = NULL;

	if (task->scanning == TRUE) {
		connman_device_set_scanning(task->device, FALSE);
		task->scanning = FALSE;
	}
}
Example #29
0
SEXP Riproc_recv_model(SEXP ytime, SEXP ysender, SEXP yreceiver,
		       SEXP xtime, SEXP xsender, SEXP xreceiver,
		       SEXP factors, SEXP variables, SEXP nsend, SEXP nrecv,
		       SEXP loops)
{
	struct properties p;
	struct history hx, hy;
	struct design s, r;
	struct design2 d;
	struct terms_object tm;
	const struct message *msgs;
	size_t nmsg;
	size_t iter, dim, nc, ntot, rank;
	size_t ncextra;
	struct recv_fit fit;
	const struct recv_loglik *ll;
	const struct recv_model *model;
	const struct constr *constr;
	const double *beta, *nu;
	double dev;
	SEXP names;
	SEXP ret = NULL_USER_OBJECT;
	int k;
	int err = 0;

	err = get_properties(nsend, nrecv, loops, &p);
	if (err < 0)
		goto properties_fail;

	history_init(&hy, p.nsend, p.nrecv);
	err = get_history(ytime, ysender, yreceiver, &hy);
	if (err < 0)
		goto yhistory_fail;

	history_init(&hx, p.nsend, p.nrecv);
	err = get_history(xtime, xsender, xreceiver, &hx);
	if (err < 0)
		goto xhistory_fail;

	design_init(&s, &hx, p.nsend);
	design_init(&r, &hx, p.nrecv);
	design2_init(&d, &hx, p.nsend, p.nrecv);

	err = get_terms_object(factors, variables, &s, &r, &d, &tm);
	if (err < 0)
		goto terms_fail;

	history_get_messages(&hy, &msgs, &nmsg);

	recv_fit_init(&fit, &r, &d, p.exclude_loops, msgs, nmsg, NULL, NULL);

	ncextra = recv_fit_extra_constr_count(&fit);
	if (ncextra)
		warning("adding %zd %s to make parameters identifiable\n",
			ncextra, ncextra == 1 ? "constraint" : "constraints");

	err = do_fit(&fit, NULL, NULL, &iter);
	if (err < 0)
		goto fit_fail;

	constr = recv_fit_constr(&fit);
	nc = constr_count(constr);
	ll = recv_fit_loglik(&fit);
	ntot = recv_loglik_count(ll);
	model = recv_loglik_model(ll);
	beta = (recv_model_params(model))->recv.traits; /* HACK */
	nu = recv_fit_duals(&fit);
	dim = recv_model_dim(model);
	rank = dim - nc;
	dev = recv_loglik_dev(ll);

	PROTECT(ret = NEW_LIST(16));
	PROTECT(names = NEW_CHARACTER(16));
	SET_NAMES(ret, names);
	k = 0;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("coefficients"));
	SET_VECTOR_ELT(ret, k, alloc_vector_copy(beta, dim));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("duals"));
	SET_VECTOR_ELT(ret, k, alloc_vector_copy(nu, nc));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("constraints"));
	SET_VECTOR_ELT(ret, k, alloc_matrix_copy(constr_all_wts(constr), nc, dim));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("constraint.values"));
	SET_VECTOR_ELT(ret, k, alloc_vector_copy(constr_all_vals(constr), nc));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("rank"));
	SET_VECTOR_ELT(ret, k, ScalarInteger((int)rank));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("deviance"));
	SET_VECTOR_ELT(ret, k, ScalarReal(dev));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("aic"));
	SET_VECTOR_ELT(ret, k, ScalarReal(dev + (double) 2 * rank));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("null.deviance"));
	SET_VECTOR_ELT(ret, k, ScalarReal(recv_fit_dev0(&fit)));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("iter"));
	SET_VECTOR_ELT(ret, k, ScalarInteger((int)iter));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("df.residual"));
	SET_VECTOR_ELT(ret, k, ScalarReal((double)(ntot - rank)));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("df.null"));
	SET_VECTOR_ELT(ret, k, ScalarReal((double)ntot));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("converged"));
	SET_VECTOR_ELT(ret, k, ScalarLogical(TRUE));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("names"));
	SET_VECTOR_ELT(ret, k, alloc_term_labels(&tm.terms));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("perm"));
	SET_VECTOR_ELT(ret, k, alloc_terms_permute(&tm.terms, &r, &d));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("score"));
	SET_VECTOR_ELT(ret, k, alloc_score(ll));
	k++;

	SET_STRING_ELT(names, k, COPY_TO_USER_STRING("imat"));
	SET_VECTOR_ELT(ret, k, alloc_imat(&fit));
	k++;

	UNPROTECT(2);


fit_fail:
	recv_fit_deinit(&fit);
terms_fail:
	design2_deinit(&d);
	design_deinit(&r);
	design_deinit(&s);
xhistory_fail:
	history_deinit(&hx);
yhistory_fail:
	history_deinit(&hy);
properties_fail:
	return ret;
}
void save_properties(GtkWidget *widget, FileProps *props)
{
   get_properties(props, props->current);
}