Ejemplo n.º 1
0
void Transfer::setState(State newState)
{
	bool now,was = isActive();
	m_lastState = m_state;
	
	if(newState == m_lastState)
		return;
	
	enterLogMessage(tr("Changed state: %1 -> %2").arg(state2string(m_state)).arg(state2string(newState)));
	
	m_state = newState;
	now = isActive();
	
	if(now != was)
	{
		m_bWorking = false;
		changeActive(now);
		
		if(now)
			m_timeStart = QDateTime::currentDateTime();
		else
			m_nTimeRunning += m_timeStart.secsTo(QDateTime::currentDateTime());
	}
	
	if(!m_bLocal)
	emit stateChanged(m_state, newState);
}
static void
player_state_changed_cb (GstElement * recorder, KmsUriEndpointState newState,
    gpointer loop)
{
  GST_INFO ("Element %s changed its state to %s.", GST_ELEMENT_NAME (recorder),
      state2string (newState));
}
Ejemplo n.º 3
0
// Prints out the data in the Counts
void print_counts(Counts &data, std::ostream &s) {
  unsigned int i;
  State sta;
  std::string str;
  create_state(sta, data.nspecies, data.nalpha);

  s << "species:  ";
  for (i=0; i < data.species.size(); i++) {
    s << data.species[i] << "  ";
  }
  s << std::endl;
  s << "nalpha:   " << data.nalpha << std::endl;
  s << "nspecies: " << data.nspecies << std::endl;
  s << "nstates:  " << data.nstates << std::endl;
  s << "total:    " << data.N << std::endl;
  s << "counts:   " << std::endl;
  for (i=0; i < data.c.size(); i++) {
    if (data.c[i] > 0) {
      index2state(i, sta);
      state2string(sta, str);
      s << "  " << str << ": " << data.c[i] << std::endl;
    }
  }
  s << std::endl;
}
static void
state_changed_cb2 (GstElement * recorder, KmsUriEndpointState newState,
    gpointer loop)
{
  GST_DEBUG ("State changed %s.", state2string (newState));

  if (newState == KMS_URI_ENDPOINT_STATE_STOP)
    g_idle_add (quit_main_loop_idle, loop);
}
static void
recorder_state_changed_cb (GstElement * recorder, KmsUriEndpointState newState,
    gpointer loop)
{
  GST_INFO ("Element %s changed its state to %s.", GST_ELEMENT_NAME (recorder),
      state2string (newState));
  if (newState == KMS_URI_ENDPOINT_STATE_STOP)
    g_main_loop_quit (loop);
}
static void
state_changed_cb (GstElement * recorder, KmsUriEndpointState newState,
    gpointer loop)
{
  const struct state_controller *transitions = get_transtions ();
  guint seconds = transitions[state].seconds;

  GST_DEBUG ("State changed %s. Time %d seconds.", state2string (newState),
      seconds);
  g_timeout_add (seconds * 1000, transite_cb, loop);
}
Ejemplo n.º 7
0
static void state_changed(struct connman_technology *technology)
{
	const char *str;

	str = state2string(technology->state);
	if (str == NULL)
		return;

	connman_dbus_property_changed_basic(technology->path,
				CONNMAN_TECHNOLOGY_INTERFACE, "State",
						DBUS_TYPE_STRING, &str);
}
Ejemplo n.º 8
0
static void state_changed(struct connman_peer *peer)
{
	const char *state;

	state = state2string(peer->state);
	if (!state || !allow_property_changed(peer))
		return;

	connman_dbus_property_changed_basic(peer->path,
					 CONNMAN_PEER_INTERFACE, "State",
					 DBUS_TYPE_STRING, &state);
}
Ejemplo n.º 9
0
static DBusMessage *get_properties(DBusConnection *conn,
					DBusMessage *message, void *user_data)
{
	struct connman_technology *technology = user_data;
	DBusMessage *reply;
	DBusMessageIter array, dict;
	const char *str;

	reply = dbus_message_new_method_return(message);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &array);

	connman_dbus_dict_open(&array, &dict);

	str = state2string(technology->state);
	if (str != NULL)
		connman_dbus_dict_append_basic(&dict, "State",
						DBUS_TYPE_STRING, &str);

	str = get_name(technology->type);
	if (str != NULL)
		connman_dbus_dict_append_basic(&dict, "Name",
						DBUS_TYPE_STRING, &str);

	str = __connman_service_type2string(technology->type);
	if (str != NULL)
		connman_dbus_dict_append_basic(&dict, "Type",
						DBUS_TYPE_STRING, &str);

	connman_dbus_dict_append_basic(&dict, "Tethering",
					DBUS_TYPE_BOOLEAN,
					&technology->tethering);

	if (technology->tethering_ident != NULL)
		connman_dbus_dict_append_basic(&dict, "TetheringIdentifier",
						DBUS_TYPE_STRING,
						&technology->tethering_ident);

	if (technology->tethering_passphrase != NULL)
		connman_dbus_dict_append_basic(&dict, "TetheringPassphrase",
						DBUS_TYPE_STRING,
						&technology->tethering_passphrase);

	connman_dbus_dict_close(&array, &dict);

	return reply;
}
Ejemplo n.º 10
0
/**
 * \brief Get command implementation
 */
int	command_get(MountPrx mount) {
    RaDec	radec = mount->getRaDec();
    astro::Angle	ra;
    ra.hours(radec.ra);
    astro::Angle	dec;
    dec.degrees(radec.dec);
    if (decimal) {
        std::cout << ra.hms() << " " << dec.dms() << " ";
    } else {
        std::cout << ra.hours() << " " << dec.degrees() << " ";
    }
    std::cout << state2string(mount->state());
    std::cout << std::endl;
    return EXIT_SUCCESS;
}
Ejemplo n.º 11
0
static void
state_changed_cb3 (GstElement * recorder, KmsUriEndpointState newState,
    gpointer loop)
{
  GST_DEBUG ("State changed %s.", state2string (newState));

  if (newState == KMS_URI_ENDPOINT_STATE_START) {
    if (RUNNING_ON_VALGRIND) {
      g_timeout_add (15000, stop_recorder, NULL);
    } else {
      g_timeout_add (3000, stop_recorder, NULL);
    }
  } else if (newState == KMS_URI_ENDPOINT_STATE_STOP) {
    g_idle_add (quit_main_loop_idle, loop);
  }
}
Ejemplo n.º 12
0
static void append_properties(DBusMessageIter *iter, struct connman_peer *peer)
{
	const char *state = state2string(peer->state);
	DBusMessageIter dict;

	connman_dbus_dict_open(iter, &dict);

	connman_dbus_dict_append_basic(&dict, "State",
					DBUS_TYPE_STRING, &state);
	connman_dbus_dict_append_basic(&dict, "Name",
					DBUS_TYPE_STRING, &peer->name);
	connman_dbus_dict_append_dict(&dict, "IPv4", append_ipv4, peer);
	connman_dbus_dict_append_array(&dict, "Services",
					DBUS_TYPE_DICT_ENTRY,
					append_peer_services, peer);
	connman_dbus_dict_close(iter, &dict);
}
Ejemplo n.º 13
0
    static void update_session_state(struct connman_session *session)
{
    enum connman_service_state service_state;
    enum connman_session_state state = CONNMAN_SESSION_STATE_DISCONNECTED;

    if (session->service) {
        service_state = __connman_service_get_state(session->service);
        state = service_to_session_state(service_state);
        session->info->state = state;
    }
    session->info->state = state;

    DBG("session %p state %s", session, state2string(state));

    update_routing_table(session);
    update_nat_rules(session);
    session_notify(session);
}
Ejemplo n.º 14
0
/**
 * \brief Implementation of the get command
 */
int	get_command(MountPtr mount) {
	RaDec	radec = mount->getRaDec();
	if (decimal) {
		std::cout << radec.ra().hours();
		std::cout << " ";
		if (radec.dec() > Angle(M_PI)) {
			std::cout << (radec.dec() - Angle(2 * M_PI)).degrees();
		} else {
			std::cout << radec.dec().degrees();
		}
	} else {
		std::cout << radec.ra().hms();
		std::cout << " ";
		if (radec.dec() > Angle(M_PI)) {
			std::cout << (radec.dec() - Angle(2 * M_PI)).dms();
		} else {
			std::cout << radec.dec().dms();
		}
	}
	std::cout << " ";
	std::cout << state2string(mount->state());
	std::cout << std::endl;
	return EXIT_SUCCESS;
}
Ejemplo n.º 15
0
static void
change_state (KmsUriEndpointState state)
{
  GstElement *testsrc;
  GstElement *testsink;

  GST_DEBUG ("Setting recorder to state %s", state2string (state));
  g_object_set (G_OBJECT (recorder), "state", state, NULL);

  /* Add more element to the pipeline to check that this does not affect
     to the timestamps */
  testsrc = gst_element_factory_make ("videotestsrc", NULL);
  testsink = gst_element_factory_make ("fakesink", NULL);

  g_object_set (testsink, "async", FALSE, "sync", FALSE, NULL);
  g_object_set (testsrc, "is-live", TRUE, NULL);

  GST_DEBUG_OBJECT (recorder, "Adding more elements");
  gst_bin_add_many (GST_BIN (GST_OBJECT_PARENT (recorder)), testsrc, testsink,
      NULL);
  gst_element_link (testsrc, testsink);
  gst_element_sync_state_with_parent (testsink);
  gst_element_sync_state_with_parent (testsrc);
}
Ejemplo n.º 16
0
static void append_notify(DBusMessageIter *dict,
                          struct connman_session *session)
{
    struct session_info *info = session->info;
    struct session_info *info_last = session->info_last;
    struct connman_service *service;
    enum connman_service_type type;
    const char *name, *bearer;
    char *ifname;
    int idx;

    if (session->append_all || info->state != info_last->state) {
        const char *state = state2string(info->state);

        connman_dbus_dict_append_basic(dict, "State",
                                       DBUS_TYPE_STRING,
                                       &state);
        info_last->state = info->state;
    }

    if (session->append_all || session->service != session->service_last) {
        if (session->service) {
            service = session->service;
            name = __connman_service_get_name(service);
            idx = __connman_service_get_index(service);

            ifname = connman_inet_ifname(idx);
            if (!ifname)
                ifname = g_strdup("");

            type = connman_service_get_type(service);
            bearer = service2bearer(type);
        } else {
            service = NULL;
            name = "";
            ifname = g_strdup("");
            bearer = "";
        }

        connman_dbus_dict_append_basic(dict, "Name",
                                       DBUS_TYPE_STRING,
                                       &name);

        connman_dbus_dict_append_dict(dict, "IPv4",
                                      append_ipconfig_ipv4,
                                      service);

        connman_dbus_dict_append_dict(dict, "IPv6",
                                      append_ipconfig_ipv6,
                                      service);

        connman_dbus_dict_append_basic(dict, "Interface",
                                       DBUS_TYPE_STRING,
                                       &ifname);

        connman_dbus_dict_append_basic(dict, "Bearer",
                                       DBUS_TYPE_STRING,
                                       &bearer);

        g_free(ifname);

        session->service_last = session->service;
    }

    if (session->append_all ||
            info->config.type != info_last->config.type) {
        const char *type = type2string(info->config.type);

        connman_dbus_dict_append_basic(dict, "ConnectionType",
                                       DBUS_TYPE_STRING,
                                       &type);
        info_last->config.type = info->config.type;
    }

    if (session->append_all ||
            info->config.allowed_bearers != info_last->config.allowed_bearers) {
        connman_dbus_dict_append_array(dict, "AllowedBearers",
                                       DBUS_TYPE_STRING,
                                       append_allowed_bearers,
                                       info);
        info_last->config.allowed_bearers = info->config.allowed_bearers;
    }

    session->append_all = false;
}
static void
change_state (KmsUriEndpointState state)
{
  GST_DEBUG ("Setting recorder to state %s", state2string (state));
  g_object_set (G_OBJECT (recorder), "state", state, NULL);
}
Ejemplo n.º 18
0
static void append_notify(DBusMessageIter *dict,
					struct connman_session *session)
{
	struct session_info *info = session->info;
	struct session_info *info_last = session->info_last;
	struct connman_service *service;
	const char *name, *ifname, *bearer;

	if (session->append_all == TRUE ||
			info->state != info_last->state) {
		const char *state = state2string(info->state);

		connman_dbus_dict_append_basic(dict, "State",
						DBUS_TYPE_STRING,
						&state);
		info_last->state = info->state;
	}

	if (session->append_all == TRUE ||
			info->entry != info_last->entry) {
		if (info->entry == NULL) {
			name = "";
			ifname = "";
			service = NULL;
			bearer = "";
		} else {
			name = info->entry->name;
			ifname = info->entry->ifname;
			service = info->entry->service;
			bearer = info->entry->bearer;
		}

		connman_dbus_dict_append_basic(dict, "Name",
						DBUS_TYPE_STRING,
						&name);

		connman_dbus_dict_append_dict(dict, "IPv4",
						append_ipconfig_ipv4,
						service);

		connman_dbus_dict_append_dict(dict, "IPv6",
						append_ipconfig_ipv6,
						service);

		connman_dbus_dict_append_basic(dict, "Interface",
						DBUS_TYPE_STRING,
						&ifname);

		connman_dbus_dict_append_basic(dict, "Bearer",
						DBUS_TYPE_STRING,
						&bearer);

		info_last->entry = info->entry;
	}

	if (session->append_all == TRUE ||
			info->config.type != info_last->config.type) {
		const char *type = type2string(info->config.type);

		connman_dbus_dict_append_basic(dict, "ConnectionType",
						DBUS_TYPE_STRING,
						&type);
		info_last->config.type = info->config.type;
	}

	if (session->append_all == TRUE ||
			info->config.allowed_bearers != info_last->config.allowed_bearers) {
		connman_dbus_dict_append_array(dict, "AllowedBearers",
						DBUS_TYPE_STRING,
						append_allowed_bearers,
						info);
		info_last->config.allowed_bearers = info->config.allowed_bearers;
	}

	session->append_all = FALSE;
}
Ejemplo n.º 19
0
CcdState::State	QsiCcd::exposureStatus() {
	std::unique_lock<std::recursive_mutex>	lock(_camera.mutex);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "checking camera state");
	QSICamera::CameraState	qsistate;
	_camera.camera().get_CameraState(&qsistate);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "qsistate = %s",
		state2string(qsistate).c_str());
	switch (state()) {
	case CcdState::idle:
		switch (qsistate) {
		case QSICamera::CameraIdle:
			break;
		case QSICamera::CameraWaiting:
		case QSICamera::CameraExposing:
			state(CcdState::exposing);
			break;
		case QSICamera::CameraReading:
		case QSICamera::CameraDownload:
			debug(LOG_DEBUG, DEBUG_LOG, 0, "turn LED on");
			_camera.camera().put_LEDEnabled(true);
			state(CcdState::exposed);
			break;
		case QSICamera::CameraError:
			break;
		}
		break;
	case CcdState::exposing:
		switch (qsistate) {
		case QSICamera::CameraIdle:
		case QSICamera::CameraWaiting:
			state(CcdState::exposed);
			break;
		case QSICamera::CameraExposing:
			state(CcdState::exposing);
			break;
		case QSICamera::CameraReading:
		case QSICamera::CameraDownload:
			debug(LOG_DEBUG, DEBUG_LOG, 0, "turn LED on");
			_camera.camera().put_LEDEnabled(true);
			state(CcdState::exposed);
			break;
		case QSICamera::CameraError:
			break;
		}
		break;
	case CcdState::exposed:
		switch (qsistate) {
		case QSICamera::CameraIdle:
		case QSICamera::CameraWaiting:
		case QSICamera::CameraExposing:
		case QSICamera::CameraReading:
		case QSICamera::CameraDownload:
		case QSICamera::CameraError:
			break;
		}
		break;
	case CcdState::cancelling:
		switch (qsistate) {
		case QSICamera::CameraIdle:
			state(CcdState::idle);
			break;
		case QSICamera::CameraWaiting:
			break;
		case QSICamera::CameraExposing:
		case QSICamera::CameraReading:
		case QSICamera::CameraDownload:
			state(CcdState::exposing);
			break;
		case QSICamera::CameraError:
			break;
		}
		break;
	}
	debug(LOG_DEBUG, DEBUG_LOG, 0, "new state %s",
		CcdState::state2string(state()).c_str());
	return state();
}