예제 #1
0
static gboolean
gst_interleave_src_event (GstPad * pad, GstEvent * event)
{
  GstInterleave *self = GST_INTERLEAVE (gst_pad_get_parent (pad));

  gboolean result;

  switch (GST_EVENT_TYPE (event)) {
    case GST_EVENT_QOS:
      /* QoS might be tricky */
      result = FALSE;
      break;
    case GST_EVENT_SEEK:
    {
      GstSeekFlags flags;

      GstSeekType curtype;

      gint64 cur;

      /* parse the seek parameters */
      gst_event_parse_seek (event, &self->segment_rate, NULL, &flags, &curtype,
          &cur, NULL, NULL);

      /* check if we are flushing */
      if (flags & GST_SEEK_FLAG_FLUSH) {
        /* make sure we accept nothing anymore and return WRONG_STATE */
        gst_collect_pads_set_flushing (self->collect, TRUE);

        /* flushing seek, start flush downstream, the flush will be done
         * when all pads received a FLUSH_STOP. */
        gst_pad_push_event (self->src, gst_event_new_flush_start ());
      }

      /* now wait for the collected to be finished and mark a new
       * segment */
      GST_OBJECT_LOCK (self->collect);
      if (curtype == GST_SEEK_TYPE_SET)
        self->segment_position = cur;
      else
        self->segment_position = 0;
      self->segment_pending = TRUE;
      GST_OBJECT_UNLOCK (self->collect);

      result = forward_event (self, event);
      break;
    }
    case GST_EVENT_NAVIGATION:
      /* navigation is rather pointless. */
      result = FALSE;
      break;
    default:
      /* just forward the rest for now */
      result = forward_event (self, event);
      break;
  }
  gst_object_unref (self);

  return result;
}
예제 #2
0
static void proxy_http_handler(nsock_pool nspool, nsock_event nsevent, void *udata) {
  int rc = 0;
  struct npool *nsp = (struct npool *)nspool;
  struct nevent *nse = (struct nevent *)nsevent;

  switch (nse->iod->px_ctx->px_state) {
    case PROXY_STATE_INITIAL:
      rc = handle_state_initial(nsp, nse, udata);
      break;

    case PROXY_STATE_HTTP_TCP_CONNECTED:
      if (nse->type == NSE_TYPE_READ)
        rc = handle_state_tcp_connected(nsp, nse, udata);
      break;

    case PROXY_STATE_HTTP_TUNNEL_ESTABLISHED:
      forward_event(nsp, nse, udata);
      break;

    default:
      fatal("Invalid proxy state!");
  }

  if (rc) {
    nse->status = NSE_STATUS_PROXYERROR;
    forward_event(nsp, nse, udata);
  }
}
sc::result CellStateChart_CellCycle_Mitosis::react( const EvCellStateChart_CellCycleUpdate & ){
    CellPtr myCell=context<CellStatechart>().pCell;
    if(state_cast<const CellStateChart_GLD1_Active*>()!=0 && GetTime()>1){
        return transit<CellStateChart_CellCycle_Meiosis>();
    }
    return forward_event();
};
예제 #4
0
static gboolean
gst_live_adder_src_event (GstPad * pad, GstEvent * event)
{
    GstLiveAdder *adder;
    gboolean result;

    adder = GST_LIVE_ADDER (gst_pad_get_parent (pad));

    switch (GST_EVENT_TYPE (event)) {
    case GST_EVENT_QOS:
        /* TODO : QoS might be tricky */
        result = FALSE;
        break;
    case GST_EVENT_NAVIGATION:
        /* TODO : navigation is rather pointless. */
        result = FALSE;
        break;
    default:
        /* just forward the rest for now */
        result = forward_event (adder, event);
        break;
    }

    gst_event_unref (event);
    gst_object_unref (adder);

    return result;
}
예제 #5
0
static int handle_state_tcp_connected(struct npool *nsp, struct nevent *nse, void *udata) {
  struct proxy_chain_context *px_ctx = nse->iod->px_ctx;
  char *res;
  int reslen;

  res = nse_readbuf(nse, &reslen);

  /* TODO string check!! */
  if (!((reslen >= 15) && strstr(res, "200 OK"))) {
    struct proxy_node *node = px_ctx->px_current;

    nsock_log_debug("Connection refused from proxy %s", node->nodestr);
    return -EINVAL;
  }

  px_ctx->px_state = PROXY_STATE_HTTP_TUNNEL_ESTABLISHED;

  if (proxy_ctx_node_next(px_ctx) == NULL) {
    forward_event(nsp, nse, udata);
  } else {
    px_ctx->px_current = proxy_ctx_node_next(px_ctx);
    px_ctx->px_state   = PROXY_STATE_INITIAL;
    nsock_proxy_ev_dispatch(nsp, nse, udata);
  }
  return 0;
}
sc::result StGetBackOnTrackAStar::react(const EvProcess&) {
  if (detectedErrornousTransitions()) return transit<StGlobalRecover> ();

  //   TODO: reactivate gpp / emergency planner
  throw VLRException("Recover mode not reimplemented..");
  return transit<StDrive> ();
  return forward_event();
}
sc::result CellStateChart_GLP1_Active::react( const EvCellStateChart_GLP1Update & ){
    CellPtr myCell=context<CellStatechart>().pCell;

    if(GetDistanceFromDTC(myCell)>100){
        return transit<CellStateChart_GLP1_Absent>();
    }
    return forward_event();
};
sc::result CellStateChart_GLD1_Inactive::react( const EvCellStateChart_GLD1Update & ){
    CellPtr myCell=context<CellStatechart>().pCell;

    if(state_cast<const CellStateChart_LAG1_Inactive*>()!=0){
        return transit<CellStateChart_GLD1_Active>();
    }
    return forward_event();
};
sc::result CellStateChart_Life_Living::react( const EvCellStateChart_LifeUpdate & ){
    CellPtr myCell=context<CellStatechart>().pCell;

    if(IsDead(myCell)==true){
        return transit<CellStateChart_Life_Dead>();
    }
    return forward_event();
};
sc::result CellStateChart_GLP1_Unbound::react( const EvCellStateChart_GLP1Update & ){
    CellPtr myCell=context<CellStatechart>().pCell;

    if(GetDistanceFromDTC(myCell)<15){
        return transit<CellStateChart_GLP1_Bound>();
    }
    return forward_event();
};
예제 #11
0
static gboolean
gst_frei0r_mixer_src_event (GstPad * pad, GstEvent * event)
{
  GstFrei0rMixer *self = GST_FREI0R_MIXER (gst_pad_get_parent (pad));
  gboolean ret = FALSE;

  switch (GST_EVENT_TYPE (event)) {
    case GST_EVENT_QOS:
      /* QoS might be tricky */
      ret = FALSE;
      break;
    case GST_EVENT_SEEK:
    {
      GstSeekFlags flags;

      /* parse the seek parameters */
      gst_event_parse_seek (event, NULL, NULL, &flags, NULL, NULL, NULL, NULL);

      /* check if we are flushing */
      if (flags & GST_SEEK_FLAG_FLUSH) {
        /* make sure we accept nothing anymore and return WRONG_STATE */
        gst_collect_pads_set_flushing (self->collect, TRUE);

        /* flushing seek, start flush downstream, the flush will be done
         * when all pads received a FLUSH_STOP. */
        gst_pad_push_event (self->src, gst_event_new_flush_start ());
      }

      ret = forward_event (self, event);
      break;
    }
    case GST_EVENT_NAVIGATION:
      /* navigation is rather pointless. */
      ret = FALSE;
      break;
    default:
      /* just forward the rest for now */
      ret = forward_event (self, event);
      break;
  }

  gst_object_unref (self);

  return ret;
}
예제 #12
0
void nsock_proxy_ev_dispatch(nsock_pool nspool, nsock_event nsevent, void *udata) {
  struct nevent *nse = (struct nevent *)nsevent;

  if (nse->status == NSE_STATUS_SUCCESS) {
    struct proxy_node *current;

    current = nse->iod->px_ctx->px_current;
    assert(current);
    current->spec->ops->handler(nspool, nsevent, udata);
  } else {
    forward_event(nspool, nsevent, udata);
  }
}
sc::result StReplanStop::react(const EvProcess&) {
  if (detectedErrornousTransitions()) return transit<StGlobalRecover> ();

  ChsmPlanner& planner = context<ChsmPlanner> ();

  if (planner.currentPose().v() < 0.5 || !planner.stop_before_replanning) {
    return (transit<StReroute> ());
  }
  else {
    planner.generateCurvePoints(0.001);
  }
  return forward_event();

}
sc::result StStopping::react(const EvProcess&) {
  if (detectedErrornousTransitions()) return transit<StGlobalRecover> ();
  // calculate distance to stop point
  double goal_dist = context<ChsmPlanner> ().topology_->distToMissionEnd();

  // generate curve points
  context<ChsmPlanner> ().generateCurvePoints(context<ChsmPlanner> ().params().max_speed_goal);

  // transitions
  if (goal_dist < STOP_DIST_THRESHOLD && context<ChsmPlanner> ().currentPose().v() < STOP_SPEED_THRESHOLD) {
    return transit<StPause> ();
  }

  return forward_event();
}
sc::result StWaitForActivation::react(const sc::exception_thrown&) {
  if (detectedErrornousTransitions()) return transit<StGlobalRecover> ();
  try {
    throw ;
  }
  /* we can catch special exceptions here and handle them
   catch ( const std::runtime_error & )
   {
   // only std::runtime_errors will lead to a transition
   // to Defective ...
   return transit< StError >();
   }*/
  catch ( ... ) {
    return forward_event();
  }
}
sc::result StGetBackOnTrackPrepare::react(const EvProcess&) {
  if (detectedErrornousTransitions()) return transit<StGlobalRecover> ();

  //	return transit<StDrive>();
  //	return transit<StPause>();

  ChsmPlanner& planner = context<ChsmPlanner> ();

  if (isExpired(context<StGetBackOnTrack> ().map_timer)) {
    return transit<StGetBackOnTrackAStar> ();
  }
  else {
    planner.generateStopTrajectory();
    return forward_event();
  }
}
sc::result CellStateChart_CellCycle_Mitosis_S::react( const EvCellStateChart_CellCycleUpdate & ){
    CellPtr myCell=context<CellStatechart>().pCell;

    double dist=GetDistanceFromDTC(myCell);
    double TotalDuration;
    if(dist>=0 && dist<7){
         TotalDuration = 32-24*dist/7.0;
    }else if(dist>7 ){
         TotalDuration = 8+24*(dist-7.0)/93.0;
    }
    double Duration=TotalDuration*0.4165;

  context<CellStatechart>().TimeInPhase+=GetTimestep();
    if(context<CellStatechart>().TimeInPhase>=Duration){
        return transit<CellStateChart_CellCycle_Mitosis_G2>();
    }
    return forward_event();
};
예제 #18
0
int intercept(struct libevdev_uinput *uidev, struct libevdev *dev){
	int ret;
	struct input_event ev;
	struct chord state;
	chord_reset(&state);
	lookup_init("dat/test-keymap-minimal.dat");

	do {
		ret = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL|LIBEVDEV_READ_FLAG_BLOCKING, &ev);
		if (ret == LIBEVDEV_READ_STATUS_SUCCESS){
			//forward key down and key up events
			if(ev.type == EV_KEY && (ev.value == 1 || ev.value == 0))
				forward_event(uidev, &ev, &state);
		}
	} while (ret == LIBEVDEV_READ_STATUS_SYNC || ret == LIBEVDEV_READ_STATUS_SUCCESS || ret == -EAGAIN);

	if (ret != LIBEVDEV_READ_STATUS_SUCCESS && ret != -EAGAIN)
		fprintf(stderr, "Failed to handle events: %s\n", strerror(-ret));

	return 0;}
sc::result StIntersectionTrafficLightWait::react(const EvProcess&) {
  if (detectedErrornousTransitions()) return transit<StGlobalRecover> ();

  // get global data
  ChsmPlanner& planner = context<ChsmPlanner>();
  Topology* topology = context<ChsmPlanner>().topology_;
  IntersectionManager* isec_man = context<StIntersection>().isec_man;
  assert(isec_man);

  // Transition: Recovery Mode
  if (isec_man->hasPrioMovement()) {
    context<StIntersection> ().clearRecoveryIndicator();
  }

  // measure progress in the parent state
  if (planner.params().enable_recovery && (context<StIntersection> ().checkRecovery())) {
    return transit<StIntersectionRecover> ();
  }

  // Transition: Replanning (because route is blocked)
  if (topology->isRouteBlocked()) return transit<StReplan> ();

  // generate stop trajectory
  planner.generateStopTrajectory();

  // set turn signal
  planner.turn_signal_.signal = context<StIntersection> ().turnDirection;

////     Transition: drive in intersection
////
////     We will go if it's our turn and rely on vehicle prediction
////     to not run into anybody
////     if (isec_man->hasRightOfWay() && !context<StIntersection>().isec_man->hasToStop()) {
  if (isec_man->hasRightOfWay() && !context<StIntersection>().isec_man->hasToStop() && !isec_man->isVehicleOnIntersectionInFront()) {
    return transit<StIntersectionDriveInside> ();
  }


  return forward_event();
}
sc::result StWaitForActivation::react(const EvProcess&) {
  if (detectedErrornousTransitions()) return transit<StGlobalRecover> ();
  ChsmPlanner& planner = context<ChsmPlanner> ();
  Topology* topology = planner.topology_;

  // set velocity to 0 -> park mode
  context<ChsmPlanner> ().generateStopTrajectory();

//  context<ChsmPlanner> ().vehiclecmd.beeper_on = 1;
//  context<ChsmPlanner> ().vehiclecmd.hazard_lights_on = 1;

  if (isExpired(wait_until_)) {

    // Transition: Replanning (because ego vehicle is off track)
    if (topology->isOffTrack() || moved) return transit<StReplan> ();

    // Transition: restore history
    return transit<StActiveHistory> ();

  }
  else {
    return forward_event();
  }
}
예제 #21
0
static gboolean
gst_adder_src_event (GstPad * pad, GstEvent * event)
{
  GstAdder *adder;
  gboolean result;

  adder = GST_ADDER (gst_pad_get_parent (pad));

  GST_DEBUG_OBJECT (pad, "Got %s event on src pad from %s",
      GST_EVENT_TYPE_NAME (event), GST_OBJECT_NAME (GST_EVENT_SRC (event)));

  switch (GST_EVENT_TYPE (event)) {
    case GST_EVENT_SEEK:
    {
      GstSeekFlags flags;
      GstSeekType curtype, endtype;
      gint64 cur, end;
      gboolean flush;

      /* parse the seek parameters */
      gst_event_parse_seek (event, &adder->segment_rate, NULL, &flags, &curtype,
          &cur, &endtype, &end);

      if ((curtype != GST_SEEK_TYPE_NONE) && (curtype != GST_SEEK_TYPE_SET)) {
        result = FALSE;
        GST_DEBUG_OBJECT (adder,
            "seeking failed, unhandled seek type for start: %d", curtype);
        goto done;
      }
      if ((endtype != GST_SEEK_TYPE_NONE) && (endtype != GST_SEEK_TYPE_SET)) {
        result = FALSE;
        GST_DEBUG_OBJECT (adder,
            "seeking failed, unhandled seek type for end: %d", endtype);
        goto done;
      }

      flush = (flags & GST_SEEK_FLAG_FLUSH) == GST_SEEK_FLAG_FLUSH;

      /* check if we are flushing */
      if (flush) {
        /* flushing seek, start flush downstream, the flush will be done
         * when all pads received a FLUSH_STOP.
         * Make sure we accept nothing anymore and return WRONG_STATE.
         * We send a flush-start before, to ensure no streaming is done
         * as we need to take the stream lock.
         */
        gst_pad_push_event (adder->srcpad, gst_event_new_flush_start ());
        gst_collect_pads2_set_flushing (adder->collect, TRUE);

        /* We can't send FLUSH_STOP here since upstream could start pushing data
         * after we unlock adder->collect.
         * We set flush_stop_pending to TRUE instead and send FLUSH_STOP after
         * forwarding the seek upstream or from gst_adder_collected,
         * whichever happens first.
         */
        g_atomic_int_set (&adder->flush_stop_pending, TRUE);
      }
      GST_DEBUG_OBJECT (adder, "handling seek event: %" GST_PTR_FORMAT, event);

      /* now wait for the collected to be finished and mark a new
       * segment. After we have the lock, no collect function is running and no
       * new collect function will be called for as long as we're flushing. */
      GST_COLLECT_PADS2_STREAM_LOCK (adder->collect);
      if (curtype == GST_SEEK_TYPE_SET)
        adder->segment_start = cur;
      else
        adder->segment_start = 0;
      if (endtype == GST_SEEK_TYPE_SET)
        adder->segment_end = end;
      else
        adder->segment_end = GST_CLOCK_TIME_NONE;
      if (flush) {
        /* Yes, we need to call _set_flushing again *WHEN* the streaming threads
         * have stopped so that the cookie gets properly updated. */
        gst_collect_pads2_set_flushing (adder->collect, TRUE);
      }
      GST_COLLECT_PADS2_STREAM_UNLOCK (adder->collect);
      GST_DEBUG_OBJECT (adder, "forwarding seek event: %" GST_PTR_FORMAT,
          event);

      /* we're forwarding seek to all upstream peers and wait for one to reply
       * with a newsegment-event before we send a newsegment-event downstream */
      g_atomic_int_set (&adder->wait_for_new_segment, TRUE);
      result = forward_event (adder, event, flush);
      if (!result) {
        /* seek failed. maybe source is a live source. */
        GST_DEBUG_OBJECT (adder, "seeking failed");
      }
      if (g_atomic_int_compare_and_exchange (&adder->flush_stop_pending,
              TRUE, FALSE)) {
        GST_DEBUG_OBJECT (adder, "pending flush stop");
        gst_pad_push_event (adder->srcpad, gst_event_new_flush_stop ());
      }
      break;
    }
    case GST_EVENT_QOS:
      /* QoS might be tricky */
      result = FALSE;
      break;
    case GST_EVENT_NAVIGATION:
      /* navigation is rather pointless. */
      result = FALSE;
      break;
    default:
      /* just forward the rest for now */
      GST_DEBUG_OBJECT (adder, "forward unhandled event: %s",
          GST_EVENT_TYPE_NAME (event));
      result = forward_event (adder, event, FALSE);
      break;
  }

done:
  gst_object_unref (adder);

  return result;
}
sc::result StIntersectionTrafficLightStop::react(const EvProcess&)
{
	if (detectedErrornousTransitions()) return transit<StGlobalRecover>();

	ChsmPlanner& planner = context<ChsmPlanner>();
	IntersectionManager* isec_man = context<StIntersection>().isec_man;
	Topology* topology = context<ChsmPlanner>().topology_;
	assert(isec_man);


  // Transition: Recovery Mode
	if (isec_man->hasPrioMovement()) {
		context<StIntersection>().clearRecoveryIndicator();
	}
  if (planner.params().enable_recovery && (context<StIntersection>().checkRecovery() || isExpired(context<StIntersection>().max_wait_at_intersection))) { // measure progress in the parent state
    return transit<StIntersectionRecover>();
  }

  // Transition: Replanning (because ego vehicle is off track)
	if (topology->isOffTrack())
	  return transit<StReplan>();

	// Transition: Replanning (because route is blocked)
	if ( topology->isRouteBlocked() )
		return transit<StReplan>();

    // Transition: If traffic light switched to green while slowing down cross intersection
	if(!context<StIntersection>().isec_man->hasToStop()) {
    return transit<StIntersectionDriveInside>();
  }

	// calculate distances
	// TODO: make sure that stop line belongs to intersection
	double traffic_light_dist = topology->distToTrafficLight(isec_man->intersection(), NULL, &planner.stop_point_);
	double intersec_dist = topology->distToIntersection(isec_man->intersection());
	double mv_veh_dist, sv_veh_dist;
	planner.getVehicleDistances(sv_veh_dist, mv_veh_dist);

	// set turn signal
	planner.turn_signal_.signal = context<StIntersection>().turnDirection;

//	printf("STOP IN %f m;\t CURRENT SPEED %f\n", traffic_light_dist, currentPose().v());

  // Transition: Wait at stop line (because ego_vehicle stopped at stopline)
	if ( traffic_light_dist < TRAFFIC_LIGHT_DIST_THRESHOLD && planner.currentPose().v() < STOP_SPEED_THRESHOLD ) {
    return transit<StIntersectionTrafficLightWait>();
	}
	else if (traffic_light_dist == std::numeric_limits<double>::infinity()) {
	  std::cout << "WE RAN OVER A (NON GREEN) TRAFFIC LIGHT!!\n";
    return transit<StIntersectionDriveInside>();
	}

	// Transition: Queueing (if vehicle backed up)
	if ( traffic_light_dist < TRIGGER_DIST_TRAFFIC_LIGHT && (mv_veh_dist < traffic_light_dist || sv_veh_dist < traffic_light_dist) )
		return transit<StIntersectionQueue>();
	// Transition: To get states right if something goes wrong: leave intersection mode if we behind intersection
	if ( intersec_dist <= -0.1 ) {
		return transit<StDrive>();
	}

	// generate curvepoints
	context<StIntersection>().generateCurvepoints(traffic_light_dist, planner.params().max_speed_traffic_light_approach);
	return forward_event();
}
sc::result StStop::react(const EvProcess&) {
  return forward_event();
}
예제 #24
0
sc::result Configuring::react(events::Connected const&)
{
  impl_->connected();
  return forward_event();
}
sc::result CellStateChart_Life_Dead::react( const EvCellStateChart_LifeUpdate & ){
    CellPtr myCell=context<CellStatechart>().pCell;

    return forward_event();
};
sc::result CellStateChart_GLP1_Absent::react( const EvCellStateChart_GLP1Update & ){
    CellPtr myCell=context<CellStatechart>().pCell;

    return forward_event();
};
예제 #27
0
 sc::result react( const EvDiscardInD & )
 {
   outermost_context().Visited( *this );
   return forward_event();
 }
sc::result CellStateChart_CellCycle_Meiosis::react( const EvCellStateChart_CellCycleUpdate & ){
    CellPtr myCell=context<CellStatechart>().pCell;

    UpdateRadius(myCell);
    return forward_event();
};
sc::result StReplan::react(const EvProcess&) {
  if (detectedErrornousTransitions()) return transit<StGlobalRecover> ();

  return forward_event();

}