Beispiel #1
0
static void neard_is_present(DBusConnection *conn, void *user_data)
{
	DBG("");

	if (agent_registered == TRUE)
		return;

	if (g_dbus_register_interface(connection, AGENT_PATH,
					NEARD_AGENT_INTERFACE, neard_methods,
					NULL, NULL, NULL, NULL) == TRUE)
		register_agent();
}
Beispiel #2
0
int main(int argc, char *argv[])
{
    DBusConnection *connection;
    DBusError derr;

    struct sigaction sa;

    memset(&sa, 0, sizeof(sa));
    sa.sa_flags = SA_NOCLDSTOP;
    sa.sa_handler = sig_term;
    sigaction(SIGTERM, &sa, NULL);
    sigaction(SIGINT, &sa, NULL);

    sa.sa_handler = SIG_IGN;
    sigaction(SIGCHLD, &sa, NULL);
    sigaction(SIGPIPE, &sa, NULL);

    main_loop = g_main_loop_new(NULL, FALSE);

    dbus_error_init(&derr);
    connection = dbus_bus_get(DBUS_BUS_SYSTEM, &derr);
    if (connection == NULL) {
        fprintf(stderr, "Failed to open connection: %s\n",
                            derr.message);
        dbus_error_free(&derr);
        exit(EXIT_FAILURE);
    }

    if (!dbus_connection_register_object_path(connection,
                    AGENT_PATH, &agent_table, NULL)) {
        dbus_connection_unref(connection);
        exit(EXIT_FAILURE);
    }

    if (register_agent(connection, "/hci0") < 0) {
        fprintf(stderr, "Failed to register agent: /hci0\n");
        dbus_connection_unref(connection);
        exit(EXIT_FAILURE);
    }

    dbus_connection_setup_with_g_main(connection, NULL);
    g_main_loop_run(main_loop);
    dbus_connection_unref(connection);

    return 0;
}
Beispiel #3
0
/**************************************************************************
...
**************************************************************************/
void simple_historian_init(void)
{
  struct agent self;

  previous_tiles = fc_malloc(MAP_INDEX_SIZE * sizeof(*previous_tiles));
  memset(previous_tiles, 0, MAP_INDEX_SIZE * sizeof(*previous_tiles));

  previous_units = unit_list_new();

  memset(&self, 0, sizeof(self));
  sz_strlcpy(self.name, "Simple Historian");

  self.level = LAST_AGENT_LEVEL;

  self.unit_callbacks[CB_REMOVE] = sha_unit_remove;
  self.unit_callbacks[CB_CHANGE] = sha_unit_change;
  self.unit_callbacks[CB_NEW] = sha_unit_new;
  self.tile_callbacks[CB_REMOVE] = sha_tile_update;
  self.tile_callbacks[CB_CHANGE] = sha_tile_update;
  self.tile_callbacks[CB_NEW] = sha_tile_update;
  register_agent(&self);
}
std::pair< Wt::WWidget*, Wt::WWidget* > generic_sys_coordinator::initialize()
{
	std::lock_guard< std::mutex > guard(m_sys_mutex);

	m_widget = new sys_display_widget(m_sys_mutex);
	//m_widget->set_drawer(m_sys->get_drawer());
	m_widget->interactive_input_sig().connect(this, &generic_sys_coordinator::on_widget_interaction);

	// TODO: This seems hacky, but don't want the selected series to be reset on restart,
	// since the system type is unchanged and therefore so are the properties
	auto temp_sys = m_sys_factory->create_system();
	temp_sys->initialize();
	for(auto const& agent : m_agents_spec.agents)
	{
		auto agent_id = temp_sys->register_agent(agent.spec);// , std::move(controller));
		auto controller = std::unique_ptr< rtp::i_controller >(
			m_agents_spec.controller_factories[agent.controller_id]->create(&temp_sys->get_agent(agent_id))
			);
		temp_sys->register_agent_controller(agent_id, std::move(controller));
	}

	Wt::WWidget* props_wt_wgt = nullptr;
	if(temp_sys->is_instantaneous())
	{
		auto wgt = new properties_table_widget{};
		m_props_widget = wgt;
		props_wt_wgt = wgt;
	}
	else
	{
		auto wgt = new properties_chart_widget{};
		m_props_widget = wgt;
		props_wt_wgt = wgt;
	}
	m_props_widget->reset(temp_sys->get_state_properties());

	return std::pair< Wt::WWidget*, Wt::WWidget* >(m_widget, props_wt_wgt);
}