예제 #1
0
void CSystemStateMachine::onAuthenticationAppAvailable()
{
   LOG4CPLUS_TRACE(sLogger, "onAuthenticationAppAvailable()");
   LOG4CPLUS_INFO(sLogger, "OK!!! AuthenticationApp  started and ready for communication");
}
예제 #2
0
bool CAppManConnectController::checkConnection () const
{
    LOG4CPLUS_TRACE(msLogger,"checkConnection()");
    return mpClient->checkConnection();
}
예제 #3
0
 virtual void channelDeletedCallback(const UInt32 channel_id)
 {
    LOG4CPLUS_TRACE(msLogger, "Observer::channelDeletedCallback channel_id = " + convertIntegerToString(channel_id));
 }
예제 #4
0
  std::shared_ptr<ErrorContext> PlacementContentHandler::start_data_set(
      uint16_t id,
      uint16_t length,
      const uint8_t* buf) {
    LOG4CPLUS_TRACE(logger,
                    "ENTER start_data_set"
                    << ", id=" << id
                    << ", length=" << length);

    // Find out who is interested in data from this data set
    const IETemplate* wire_template = find_wire_template(id);

    LOG4CPLUS_TRACE(logger, "  wire_template=" << wire_template);

    if (wire_template == 0) {
      if (unhandled_data_set_handler == 0) {
        if (unmatched_template_ids.count(make_template_key(id)) == 0) {
          LOG4CPLUS_WARN(logger, "  No placement for data set with "
                         "observation domain " << observation_domain
                         << " and template id " << id << "; skipping"
                         " (this warning will appear only once)");
          unmatched_template_ids.insert(make_template_key(id));
        }
        libfc_RETURN_OK();
      } else {
        std::shared_ptr<ErrorContext> e 
          = unhandled_data_set_handler->unhandled_data_set(
              observation_domain, id, length, buf);
        if (e->get_error() == Error::again) {
          wire_template = find_wire_template(id);
          if (wire_template == 0) {
            if (unmatched_template_ids.count(make_template_key(id)) == 0) {
              LOG4CPLUS_WARN(logger, "  No placement for data set with "
                             "observation domain " << observation_domain
                             << " and template id " << id 
                             << "; skipping after second chance"
                             " (this warning will appear only once)");
              unmatched_template_ids.insert(make_template_key(id));
            }
            libfc_RETURN_OK();
          }
        }
      }
    }

    assert(wire_template != 0);

    const PlacementTemplate* placement_template
      = match_placement_template(id, wire_template);

    LOG4CPLUS_TRACE(logger, "  placement_template=" << placement_template);

    if (placement_template == 0) {
      LOG4CPLUS_TRACE(logger, "  no one interested in this data set; skipping");
      libfc_RETURN_OK();
    }

    DecodePlan plan(placement_template, wire_template);

    const uint8_t* buf_end = buf + length;
    const uint8_t* cur = buf;
    const uint16_t min_length = wire_template_min_length(wire_template);
    
    auto callback = callbacks.find(placement_template);
    assert(callback != callbacks.end());

    while (cur < buf_end && length >= min_length) {
      CH_REPORT_CALLBACK_ERROR(
        callback->second->start_placement(placement_template));
      uint16_t consumed = plan.execute(cur, length);
      CH_REPORT_CALLBACK_ERROR(
        callback->second->end_placement(placement_template));
      cur += consumed;
      length -= consumed;
    }

    libfc_RETURN_OK();
  }
예제 #5
0
IAppMan * CAppManConnectController::applicationManager()
{
    LOG4CPLUS_TRACE(msLogger,"applicationManager()");
    return mpCore;
}
예제 #6
0
 std::shared_ptr<ErrorContext> PlacementContentHandler::end_session() {
   LOG4CPLUS_TRACE(logger, "Session ends");
   return std::shared_ptr<ErrorContext>(0);
 }
예제 #7
0
  std::shared_ptr<ErrorContext> PlacementContentHandler::end_template_record() {
    LOG4CPLUS_TRACE(logger, "ENTER end_template_record");
    assert(current_wire_template != 0);

    if (current_wire_template->size() > 0) {

      const IETemplate *my_wire_template 
        = find_wire_template(current_template_id);
      if (my_wire_template != 0 
          && *my_wire_template != *current_wire_template) {
        LOG4CPLUS_WARN(logger, "  Overwriting template for domain " 
                       << observation_domain 
                       << ", ID "
                       << current_template_id);

        incomplete_template_ids.erase(current_template_id);

        delete wire_templates[make_template_key(current_template_id)];
        wire_templates[make_template_key(current_template_id)]
          = current_wire_template;

        matched_templates.erase(my_wire_template);
      } else if (my_wire_template == 0) {
        LOG4CPLUS_INFO(logger, "  New template for domain " 
                       << observation_domain 
                       << ", ID " << current_template_id);
        wire_templates[make_template_key(current_template_id)]
          = current_wire_template;
      } else {
        assert (my_wire_template != 0 
                && *my_wire_template == *current_wire_template);
        LOG4CPLUS_TRACE(logger, "  Duplicate template for domain " 
                       << observation_domain 
                       << ", ID "
                       << current_template_id);
      }


#if defined(_libfc_HAVE_LOG4CPLUS_)
      if (logger.getLogLevel() <= log4cplus::TRACE_LOG_LEVEL) {
        LOG4CPLUS_TRACE(logger,
                        "  current wire template has "
                        << current_wire_template->size()
                        << " entries, there are now "
                        << wire_templates.size()
                        << " registered wire templates");
        unsigned int n = 1;
        for (auto i = current_wire_template->begin(); i != current_wire_template->end(); i++)
          LOG4CPLUS_TRACE(logger, "  " << n++ << " " << (*i)->toIESpec());
      }
#endif /* defined(_libfc_HAVE_LOG4CPLUS_) */
    }

    if (current_field_count != current_field_no)
      CH_REPORT_ERROR(format_error, 
                      "Template field mismatch: expected "
                      << current_field_count << " fields, got " 
                      << current_field_no);

    current_wire_template = 0;
    libfc_RETURN_OK();
  }
예제 #8
0
Polygon_2 cut_ear(const Polygon_2& polygon, Triangle_iter triangles, 
		  const boost::unordered_map<Point_3, boost::unordered_set<Segment_3_undirected> >& point2edges)
{
  static log4cplus::Logger logger = log4cplus::Logger::getInstance("polygon_utils");

  LOG4CPLUS_TRACE(logger, "Cutting ear of " << pp(polygon));;

  Polygon_2 ret(polygon);
  Polygon_2::Vertex_circulator start = ret.vertices_circulator();
  Polygon_2::Vertex_circulator c = start;
  Polygon_2::Vertex_circulator p = c - 1;
  Polygon_2::Vertex_circulator n = c + 1;
  // Do a run preferring to get rid of collinear points
  do
  {
    Polygon_2::Vertex_circulator pp = p - 1;
    if (!is_legal(*pp, *p, *c, point2edges) &&
	can_cut(polygon, p, c, n, point2edges))
//     if (!is_legal(*pp, *p, *c, point2edges) &&
// 	is_legal(*p, *c, *n, point2edges))
    {
      *triangles++ = Triangle(*p, *c, *n);
      ret.erase(c);
      return ret;
    }
    Polygon_2::Vertex_circulator ppp = pp - 1;
    if (!is_legal(*pp, *p, *c, point2edges) &&
	can_cut(polygon, ppp, pp, p, point2edges))
//     if (!is_legal(*pp, *p, *c, point2edges) &&
// 	is_legal(*p, *c, *n, point2edges))
    {
      *triangles++ = Triangle(*ppp, *pp, *p);
      ret.erase(pp);
      return ret;
    }
    ++p;
    ++c;
    ++n;
  } while (c != start);

  // Okay, just take any cut
  do
  {
    if (can_cut(polygon, p, c, n, point2edges))
    {
      *triangles++ = Triangle(*p, *c, *n);
      ret.erase(c);
      return ret;
    }
    ++p;
    ++c;
    ++n;
  } while (c != start);

  // Okay, really just take any cut
  do
  {
//     if (can_cut(polygon, p, c, n, point2edges))
    if (is_legal(*p, *c, *n, point2edges))
    {
      *triangles++ = Triangle(*p, *c, *n);
      ret.erase(c);
      return ret;
    }
    ++p;
    ++c;
    ++n;
  } while (c != start);

  LOG4CPLUS_DEBUG(logger, "Polygon is not strictly convex");
  LOG4CPLUS_DEBUG(logger, "  Original: " << pp(polygon));
  LOG4CPLUS_DEBUG(logger, "   Current: " << pp(ret));
  throw logic_error("Polygon is not strictly convex");
}
예제 #9
0
void triangulate_safe(const Polygon_2& P, Triangle_iter triangles,
		      const boost::unordered_map<Point_3, boost::unordered_set<Segment_3_undirected> >& point2edges)
{
  typedef CGAL::Partition_traits_2<Kernel> PT;

  static log4cplus::Logger tlogger = log4cplus::Logger::getInstance("polygon_utils");

  Polygon_2 polygon(P);
  LOG4CPLUS_TRACE(tlogger, "Triangulating " << pp(polygon));
  if (polygon.size() < 3) return;

  bool vertical_yz = is_vertical(polygon);
  bool vertical_xz = false;
  if (vertical_yz)
  {
    LOG4CPLUS_TRACE(tlogger, "Polygon is vertical.  Rotating.");
    Polygon_2 temp = yz_swap_neg(polygon);
    vertical_xz = is_vertical(temp);
    if (vertical_xz) {
      temp = xz_swap_neg(polygon);
      vertical_yz = false;
    }
    polygon = temp;
  }

  if (!polygon.is_simple())
  {
    LOG4CPLUS_WARN(tlogger, "Attempting (and failing) to triangulate non-simple polygon " << pp(polygon));
    LOG4CPLUS_DEBUG(tlogger, "Attempting (and failing) to triangulate non-simple polygon " << pp(polygon));
    return;
  }

  bool reverse = !polygon.is_counterclockwise_oriented();
  if (reverse)
    polygon.reverse_orientation();
  if (!polygon.is_counterclockwise_oriented())
    LOG4CPLUS_TRACE(tlogger, "Unexpected polygon orientation: " << polygon.orientation());

  list<Triangle> tris;

  triangulate_convex(polygon, back_inserter(tris), point2edges);

//   // Split the polygon into convex polygons
//   typedef std::list<PT::Polygon_2> Partition_polygons;
//   Partition_polygons partition_polygons;
//   CGAL::approx_convex_partition_2(polygon.vertices_begin(), polygon.vertices_end(), 
// 				  std::back_inserter(partition_polygons));

//   for (Partition_polygons::iterator it = partition_polygons.begin(); it != partition_polygons.end(); ++it)
//   {
//     Polygon_2 p(it->vertices_begin(), it->vertices_end());
//     triangulate_convex(p, back_inserter(tris), point2edges);
//   }

  for (list<Triangle>::iterator it = tris.begin(); it != tris.end(); ++it)
  {
    Triangle t;
    for (int i = 0; i < 3; ++i)
    {
      int idx = reverse ? 2-i : i;
      if (vertical_yz)
	t[idx] = yz_swap_pos((*it)[i]);
      else if (vertical_xz)
	t[idx] = xz_swap_pos((*it)[i]);
      else
	t[idx] = (*it)[i];
    }
    LOG4CPLUS_TRACE(tlogger, "Adding tile: " << pp_tri(t));
    *triangles++ = t;
  }
}
예제 #10
0
// edges are given as (edges[i], edges[i+1])
void find_non_manifold_verts(const cvcraw_geometry::cvcgeom_t& geom,
                             std::vector<int>& non_manifold_vertices) {
  static log4cplus::Logger logger =
      log4cplus::Logger::getInstance("find_non_manifold_verts");

  const vector<Point_3> vertices = sm_vertices(geom);
  const vector<Triangle> triangles = sm_triangles(geom);

  const vector<vector<Triangle> > v2t = build_v2t(triangles.begin(), triangles.end());

  // set<Edge> non_manifold_edges;
  // vector<int> non_manifold_vertices;
  for (int vi = 0; vi < v2t.size(); ++vi) {
    set<Edge> edges;
    bool manifold = true;
    const vector<Triangle>& tris = v2t[vi];
    if (!tris.empty()){
      set<Triangle> tri_set(tris.begin(), tris.end());

      Triangle start_t = *tri_set.begin();
      Triangle t = *tri_set.begin();

      bool done = false;

      const int li = t.g2l(vi);
      const Edge er(t[(li+1)%3], vi);
      const Edge el(t[(li+2)%3], vi);
      Edge e = er;


      //walk right when count = 0 and left when count =1
      int count = 0;
      while (count < 2){
        while (!done && manifold && !tri_set.empty() && tri_set.find(t) != tri_set.end()) {
          tri_set.erase(t);
          // Local triangle index [012] of vi in triangle t
          const vector<Triangle> adjs = adj_triangles(e, v2t);
          if (adjs.size() < 2) {
            // boundary
            done = true;
          } else if (adjs.size() > 2) {
            // non_manifold edge
            done = true;
            manifold = false;
          } else {
            Triangle adj = adjs[0];
            if (adj == t) {
              adj = adjs[1];
            }
            t = adj;
            e = Edge(adj.opposite(e), vi);
          }
        }
        t = start_t;
        if (count == 0 && !tri_set.empty()){
          tri_set.insert(t); //just so it can be removed again
        }
        done = false;
        e = el;
        count++;
      }

      if (!tri_set.empty() || !manifold) {
        LOG4CPLUS_TRACE(logger, "Non Manifold vert is: " << vi);
        non_manifold_vertices.push_back(vi);
      }
    }
  }
}
예제 #11
0
void triangulate(const Polygon& polygon, Triangle_iter triangles, 
		 const boost::unordered_map<Point_3, boost::unordered_set<Segment_3_undirected> >& point2edges)
{
  typedef CGAL::Triangulation_vertex_base_2<Kernel>                     Vb;
  typedef CGAL::Triangulation_vertex_base_with_info_2<bool, Kernel, Vb>     Info;
  typedef CGAL::Constrained_triangulation_face_base_2<Kernel>           Fb;
  typedef CGAL::Triangulation_data_structure_2<Info,Fb>              TDS;
  typedef CGAL::Exact_predicates_tag                               Itag;
  typedef CGAL::Constrained_Delaunay_triangulation_2<Kernel, TDS, Itag> CDT;

  static log4cplus::Logger tlogger = log4cplus::Logger::getInstance("polygon_utils");

  LOG4CPLUS_TRACE(tlogger, "Triangulating " << pp(polygon));

  if (polygon.size() < 3) return;

  Polygon p = polygon;
  bool vertical = is_vertical(p);
  if (vertical)
  {
    LOG4CPLUS_TRACE(tlogger, "Polygon is vertical.  Rotating.");
    p = yz_swap_neg(p);
  }

  bool reverse = !p.is_counterclockwise_oriented();

  // THIS IS BAD, BAD, BAD!
  {
    typename Polygon::Vertex_circulator start = p.vertices_circulator();
    typename Polygon::Vertex_circulator c = start;
    typename Polygon::Vertex_circulator n = c;
    typename Polygon::Vertex_circulator prev = c;
    ++n;
    --prev;
    Polygon_2 newp;
    do
    {
      if (!CGAL::collinear(*prev, *c, *n))
	newp.push_back(*c);
      ++prev;
      ++c;
      ++n;
    } while (c != start);
    p = newp;
  }

  CDT cdt;
  typename Polygon::Vertex_circulator start = p.vertices_circulator();
  typename Polygon::Vertex_circulator c = start;
  typename Polygon::Vertex_circulator n = c;
  do
  {
    cdt.insert_constraint(*c, *n);
    ++c;
    ++n;
  } while (c != start);

  // Loop through the triangulation and store the vertices of each triangle
  for (CDT::Finite_faces_iterator ffi = cdt.finite_faces_begin();
       ffi != cdt.finite_faces_end();
       ++ffi)
  {
    Triangle t;
    Point_3 center = centroid(ffi->vertex(0)->point(), ffi->vertex(1)->point(), ffi->vertex(2)->point());
    if (p.has_on_bounded_side(center) && 
	is_legal(ffi->vertex(0)->point(), ffi->vertex(1)->point(), ffi->vertex(2)->point(), point2edges))
    {
      for (int i = 0; i < 3; ++i)
      {
	int idx = reverse ? 2-i : i;
	if (!vertical)
	  t[idx] = ffi->vertex(i)->point();
	else
	  t[idx] = yz_swap_pos(ffi->vertex(i)->point());
      }
      LOG4CPLUS_TRACE(tlogger, "Adding tile: " << pp_tri(t));
      *triangles = t;
      ++triangles;
    }
  }
}
예제 #12
0
void protocol_base_t::init(client_t * manipulator) {
    manipulator_ = manipulator;
    LOG4CPLUS_TRACE(log_, "init " << manipulator_);
    init_impl();
}
예제 #13
0
void CSystemStateMachine::startTriggerHandler()
{
   LOG4CPLUS_TRACE(sLogger, "startTriggerHandler()");

   LOG4CPLUS_INFO(sLogger, "Trigger handler is now running...");

   eSSMTriggers trigger;

   while(true)
   {
      LOG4CPLUS_INFO(sLogger, "read trigger");

      trigger = CTriggerQueue::receiveTrigger();

      switch(trigger)
      {
      case EMPTY_TRIGGER_QUEUE:
         LOG4CPLUS_INFO(sLogger, "No incoming triggers");
         break;
      case INITIALIZED:
         LOG4CPLUS_INFO(sLogger, "INITIALIZED trigger");
         mSystemState->launchPhysicalLayer(this);
         break;
      case CONNECTIVITY_AGENT_STARTED:
         LOG4CPLUS_INFO(sLogger, "CONNECTIVITY_AGENT_STARTED trigger");
         break;
      case PHISYCAL_CONNECTION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "PHISYCAL_CONNECTION_ESTABLISHED trigger");
         mSystemState->launchChannelLayer(this);
         break;
      case PHISYCAL_CONNECTION_LOST:
         LOG4CPLUS_WARN(sLogger, "PHISYCAL_CONNECTION_LOST trigger");
         break;
      case CHANNEL_SUPERVISOR_STARTED:
         LOG4CPLUS_INFO(sLogger, "CHANNEL_SUPERVISOR_STARTED trigger");
         break;
      case CHANNEL_CONNECTION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "CHANNEL_CONNECTION_ESTABLISHED trigger");
         mSystemState->launchProfileManager(this);
         break;
      case CHANNEL_CONNECTION_LOST:
         LOG4CPLUS_WARN(sLogger, "CHANNEL_CONNECTION_LOST trigger");
         break;
      case PROFILE_MANAGER_STARTED:
         LOG4CPLUS_INFO(sLogger, "PROFILE_MANAGER_STARTED trigger");
         break;
      case PROFILE_MANAGER_CONNECTION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "PROFILE_MANAGER_CONNECTION_ESTABLISHED trigger");
         mSystemState->launchApplicationManager(this);
         break;
      case APPLICATION_MANAGER_STARTED:
         LOG4CPLUS_INFO(sLogger, "APPLICATION_MANAGER_STARTED trigger");
         break;
      case APPLICATION_MANAGER_CONNECTION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "APPLICATION_MANAGER_CONNECTION_ESTABLISHED trigger");
         if(authOn)
         {
            unlockAuthenticationProfile();
            mSystemState->startAuthentication(this);
         }
         else
         {
            mSystemState->finishAuthentication(this);
         }
         break;
      case AUTHENTICATION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "AUTHENTICATION_ESTABLISHED trigger");
         LOG4CPLUS_WARN(sLogger, "Unlock all profiles and switch to idle state");
         unlockProfiles();
         AuthenticationAppMsgProxy::requestShutDown();
         break;
      case AUTHENTICATION_CANCELED:
         AuthenticationAppMsgProxy::requestShutDown();
         hardReset(true);
         break;
      }
   }
}
예제 #14
0
CError CSystemStateMachine::onAuthenticationNOK()
{
   LOG4CPLUS_TRACE(sLogger, "onAuthenticationNOK()");

   return CError(CError::NO_ERROR, "SystemStateMachine");
}
void CFinalRequestProcessor::processRequest(CRequest request)
{
	LOG4CPLUS_TRACE(logger, "CFinalRequestProcessor::processRequest");

        CProcessTxnResult rc ;

        if (request.txn!= NULL || request.type == OpCode::closeSession) {
            rc = zks->getZKDatabase()->processTxn(request.hdr, request.txn);
            if (request.type == OpCode::createSession) {
                if (typeid(*(request.txn)) == typeid(CreateSessionTxn)) {
                    CreateSessionTxn* cst = (CreateSessionTxn*)(request.txn);
                    zks->sessionTracker->addSession(request.sessionId, cst->getTimeOut());
                } else {
    				 LOG4CPLUS_WARN(logger, "unknow txn class type !!  ");
                }
            } else if (request.type == OpCode::closeSession) {
                zks->sessionTracker->removeSession(request.sessionId);
            }
        }

        if (request.cnxn == NULL) {
        	//expired  do not reply...
        	if(request.txn != NULL) 
        		delete request.txn;
            return;
        }

	    CNIOServerCnxn* cnxn = request.cnxn;

        int err=0;
        CRecord* rsp = NULL;
        bool closeSession = false;
        
        if ( request.hdr.getType() == OpCode::error) {
        	err = rc.err;
        	goto END;
        }
	    
		try{
			switch (request.type) {
	            case OpCode::ping: {
	            	zks->sessionTracker->updateSession(request.sessionId);
                    cnxn->sendResponse(  CReplyHeader(-2 , zks->getZKDatabase()->getDataTreeLastProcessedZxid(), 0) 
                    				    , NULL 
                    				   , "response");
	                goto FREE;
	            }
	            case OpCode::createSession: {
	            	/*zks.serverStats().updateLatency(request.createTime);

	                lastOp = "SESS";
	                ((CnxnStats)cnxn.getStats()).updateForResponse(request.cxid, request.zxid, lastOp,
	                        request.createTime, System.currentTimeMillis());*/

	                cnxn->finishSessionInit(true);
	                goto FREE;
	            }
	            case OpCode::create: {
	            	//lastOp = "CREA";
	                rsp = new CreateResponse(rc.path);
	                err = rc.err;
	                break;
	            }
	            case OpCode::delete_: {
	                err = rc.err;
	                break;
	            }
	            case OpCode::setData: {
	            	rsp = new SetDataResponse(rc.stat);
					err = rc.err;
	                break;
	            }
	            case OpCode::setACL: {
	            	rsp = new SetACLResponse(rc.stat);
	                err = rc.err;
	                break;
	            }
	            case OpCode::closeSession: {
	                //closeSession = true;
                	err = rc.err;
	                break;
	            }
	            case OpCode::sync: {
	                break;
	            }
	            case OpCode::exists: {
	            	CBinMsgRow in;
					int len = request.request.length();
					int ret = in.Decode(request.request.c_str() , len);
					if( ret != 0 ){
			            LOG4CPLUS_ERROR(logger,"request.request Decode fail!  len:"<<len);
	                	goto FREE;
					}
			        CRequestHeader h ;
				    if(h.deserialize(in, "header")== -1)
				    {
				    	 LOG4CPLUS_ERROR(logger,"CRequestHeader deserialize fail!!");
				    }
					LOG4CPLUS_DEBUG(logger,"header type:"<<h.getType()<<" header xid:"<<h.getXid() );



	                CExistsRequest existsRequest;
					existsRequest.deserialize(in,"request");
	                LOG4CPLUS_DEBUG(logger,"CExistsRequest path:"<<existsRequest.getPath()<<" watch:"<<existsRequest.getWatch());

               		CStatPersisted stat = zks->getZKDatabase()->statNode(existsRequest.getPath(),
               								existsRequest.getWatch() ? request.cnxn : NULL);
	                rsp = new CExistsResponse(stat);

	                break;
	            }
	            case OpCode::getData: {
	            	CBinMsgRow in;
					int len = request.request.length();
					int ret = in.Decode(request.request.c_str() , len);
					if( ret != 0 ){
			            LOG4CPLUS_ERROR(logger,"request.request Decode fail!  len:"<<len);
	                	goto FREE;
					}
			        CRequestHeader h ;
				    if(h.deserialize(in, "header")== -1)
				    {
				    	 LOG4CPLUS_ERROR(logger,"CRequestHeader deserialize fail!!");
				    }
					LOG4CPLUS_DEBUG(logger,"header type:"<<h.getType()<<" header xid:"<<h.getXid() );



	                GetDataRequest getDataRequest;
					getDataRequest.deserialize(in,"request");
	                LOG4CPLUS_DEBUG(logger,"GetDataRequest path:"<<getDataRequest.getPath()<<" watch:"<<getDataRequest.getWatch());

	                CDataNode* n = zks->getZKDatabase()->getNode(getDataRequest.getPath());
	                if (n == NULL) {
	                	err = CErrCode::NONODE;
	                    LOG4CPLUS_WARN(logger,"NoNodeException()");
	                    break;
	                }
	                long aclL;
	                n->lockSelf();
	                aclL = n->acl;
	                n->unlockSelf();
	                
	                if( CPrepRequestProcessor::checkACL(zks, zks->getZKDatabase()->convertLong(aclL),
	                       				 Perms::READ, request.authInfo) != 0 )
	                {
                        err = CErrCode::NOAUTH;
                		LOG4CPLUS_WARN(logger,"checkACL failed!");
                		break;
	                }
	                CStatPersisted stat;
	                string b = zks->getZKDatabase()->getData(getDataRequest.getPath(), stat,//NULL);
	                        getDataRequest.getWatch() ? request.cnxn : NULL);
	                rsp = new GetDataResponse(b, stat);
	                break;
	            }
	            case OpCode::setWatches: {
	                break;
	            }
	            case OpCode::getACL: {
	                CBinMsgRow in;
					int len = request.request.length();
					int ret = in.Decode(request.request.c_str() , len);
					if( ret != 0 ){
			            LOG4CPLUS_ERROR(logger,"request.request Decode fail!  len:"<<len);
	                	goto FREE;
					}
			        CRequestHeader h ;
				    if(h.deserialize(in, "header")== -1)
				    {
				    	 LOG4CPLUS_ERROR(logger,"CRequestHeader deserialize fail!!");
				    }
					LOG4CPLUS_DEBUG(logger,"header type:"<<h.getType()<<" header xid:"<<h.getXid() );

	                GetACLRequest getACLRequest;
					getACLRequest.deserialize(in,"request");
	                LOG4CPLUS_DEBUG(logger,"GetACLRequest path:"<<getACLRequest.getPath() );

	                CStatPersisted stat;
	                list<ACL> acl = zks->getZKDatabase()->getACL(getACLRequest.getPath(), stat);
	                rsp = new GetACLResponse(acl, stat);
	                break;
	            }
	            case OpCode::getChildren: {
	                CBinMsgRow in;
					int len = request.request.length();
					int ret = in.Decode(request.request.c_str() , len);
					if( ret != 0 ){
			            LOG4CPLUS_ERROR(logger,"request.request Decode fail!  len:"<<len);
	               		 goto FREE;
					}
			        CRequestHeader h ;
				    if(h.deserialize(in, "header")== -1)
				    {
				    	 LOG4CPLUS_ERROR(logger,"CRequestHeader deserialize fail!!");
				    }
					LOG4CPLUS_DEBUG(logger,"header type:"<<h.getType()<<" header xid:"<<h.getXid() );

	                GetChildrenRequest getChildrenRequest ;
                	getChildrenRequest.deserialize(in,"request");
	                LOG4CPLUS_DEBUG(logger,"GetChildrenRequest path:"<<getChildrenRequest.getPath()<<" watch:"<<getChildrenRequest.getWatch());

	                CDataNode* n = zks->getZKDatabase()->getNode(getChildrenRequest.getPath());
	                if (n == NULL) {
	                	err = CErrCode::NONODE;
	                    LOG4CPLUS_WARN(logger,"NoNodeException()");
	                    break;
	                }
	                long aclL;
	                n->lockSelf();
	                aclL = n->acl;
	                n->unlockSelf();
	                
	                if( CPrepRequestProcessor::checkACL(zks, zks->getZKDatabase()->convertLong(aclL),
	                       				 Perms::READ, request.authInfo) != 0 )
	                {
                        err = CErrCode::NOAUTH;
                		LOG4CPLUS_WARN(logger,"checkACL failed!");
                		break;
	                }

            		CStatPersisted stat;
	                list<string> children = zks->getZKDatabase()->getChildren(
	                        getChildrenRequest.getPath(), stat,
	                        getChildrenRequest.getWatch() ? request.cnxn : NULL);
	                        
	                rsp = new GetChildrenResponse(children);
	                break;
	            }
	            case OpCode::getChildren2: {
	                break;
	            }
	         }//switch
	      }catch(CErrCode::Code e){
	      		LOG4CPLUS_ERROR(logger, "exception:"<<e);
         		err = e;
	      }

		END:
		{
	        CReplyHeader hdr(request.cxid, request.zxid, err);
			LOG4CPLUS_TRACE(logger, "xid:"<<request.cxid<<" zixd::"<<request.zxid<<" err:"<<err);

	        cnxn->sendResponse(hdr, rsp, "response");
		}        
		FREE:
		{
	        if( rsp != NULL ){
	        	delete rsp;
	        }else if(request.txn != NULL){
	        	delete request.txn;
	        }else if (closeSession) {
	            cnxn->sendCloseSession();
	        }
        }
 
}
예제 #16
0
void triangulate(const Polygon_2& polygon, 
		 Cut_iter cuts_begin, Cut_iter cuts_end,
		 const boost::unordered_map<Point_3, boost::unordered_set<Segment_3_undirected> >& point2edges,
		 Out_iter triangles)
{
  typedef CGAL::Triangulation_vertex_base_2<Kernel>                     Vb;
  typedef CGAL::Triangulation_vertex_base_with_info_2<Point_3, Kernel, Vb>     Info;
  typedef CGAL::Constrained_triangulation_face_base_2<Kernel>           Fb;
  typedef CGAL::Triangulation_data_structure_2<Info,Fb>              TDS;
  typedef CGAL::Exact_predicates_tag                               Itag;
  typedef CGAL::Constrained_Delaunay_triangulation_2<Kernel, TDS, Itag> CDT;
  typedef CDT::Vertex_handle Vertex_handle;

  static log4cplus::Logger logger = log4cplus::Logger::getInstance("polygon_utils");

  Polygon_2 p(polygon);
  LOG4CPLUS_TRACE(logger, "Triangulating " << pp(p));
  if (p.size() < 3) return;

  bool vertical = is_vertical(p);
  if (vertical)
  {
    LOG4CPLUS_TRACE(logger, "Polygon is vertical.  Rotating.");
    p = yz_swap_neg(p);
  }

  bool reverse = !p.is_counterclockwise_oriented();
  if (reverse)
    p.reverse_orientation();

  CDT cdt;

  boost::unordered_map<Point_3, Vertex_handle> point2handle;
  for (Polygon_2::Vertex_iterator it = p.vertices_begin(); it != p.vertices_end(); ++it)
  {
    Vertex_handle h = cdt.insert(*it);
    point2handle[*it] = h;
    h->info() = *it;//it->z();
  }

  Polygon_2::Vertex_circulator start = p.vertices_circulator();
  Polygon_2::Vertex_circulator c = start;
  Polygon_2::Vertex_circulator n = c;
  ++n;
  do
  {
    Vertex_handle ch = point2handle[*c];//cdt.insert(*c);
    Vertex_handle nh = point2handle[*n];//cdt.insert(*n);
//     ch->info() = c->z();
//     nh->info() = n->z();
//     cdt.insert_constraint(*c, *n);
    cdt.insert_constraint(ch, nh);
    ++c;
    ++n;
  } while (c != start);

  for (Cut_iter c_it = cuts_begin; c_it != cuts_end; ++c_it)
  {
    Polyline_2 cut = *c_it;
    LOG4CPLUS_TRACE(logger, "Adding cut: " << pp(cut));
    if (vertical)
      cut = yz_swap_neg(cut);
    for (Polyline_2::const_iterator c = cut.begin(); c != cut.end(); ++c)
    {
      Polyline_2::const_iterator n = c;
      ++n;
      if (n != cut.end())
      {
	const Point_3& cp = *c;
	const Point_3& np = *n;
	if (point2handle.find(cp) == point2handle.end())
	{
	  Vertex_handle h = cdt.insert(cp);
	  point2handle[cp] = h;
	  h->info() = cp;//cp.z();
	}
	if (point2handle.find(np) == point2handle.end())
	{
	  Vertex_handle h = cdt.insert(np);
	  point2handle[np] = h;
	  h->info() = np;//np.z();
	}

	Vertex_handle ch = point2handle[*c];//cdt.insert(*c);
	Vertex_handle nh = point2handle[*n];//cdt.insert(*n);
// 	ch->info() = c->z();
// 	nh->info() = n->z();
// 	cdt.insert_constraint(*c, *n);
	cdt.insert_constraint(ch, nh);
	LOG4CPLUS_TRACE(logger, "  " << pp(Segment_2(*c, *n)));
      }
    }
  }

  // Loop through the triangulation and store the vertices of each triangle
  for (CDT::Finite_faces_iterator ffi = cdt.finite_faces_begin();
       ffi != cdt.finite_faces_end();
       ++ffi)
  {
    Triangle t;
    Point_3 center = centroid(ffi->vertex(0)->info(), ffi->vertex(1)->info(), ffi->vertex(2)->info());
    if (p.has_on_bounded_side(center) && 
	is_legal(ffi->vertex(0)->info(), ffi->vertex(1)->info(), ffi->vertex(2)->info(), point2edges))
    {
      for (int i = 0; i < 3; ++i)
      {
	int idx = reverse ? 2-i : i;
	if (!vertical)
	{
// 	  Point_3 p(ffi->vertex(i)->point());
// 	  p = Point_3(p.x(), p.y(), ffi->vertex(i)->info());
	  Point_3 p(ffi->vertex(i)->info());
	  t[idx] = p;
	}
	else
	{
// 	  Point_3 p(ffi->vertex(i)->point());
// 	  p = Point_3(p.x(), p.y(), ffi->vertex(i)->info());
	  Point_3 p(ffi->vertex(i)->info());
	  t[idx] = yz_swap_pos(p);
	}
      }
      LOG4CPLUS_TRACE(logger, "Adding tile: " << pp_tri(t));
      *triangles++ = t;
    }
  }
}
예제 #17
0
void AcdEventtDispatcher::fireSend(const std::string &strContent)
{
	chilli::ACD::ACDModule::recEvtBuffer.addData(strContent);
	LOG4CPLUS_TRACE(log, ": recive a Send event:" << strContent);
}
예제 #18
0
void AuthenticationStateMachine::onAuthenticationIsRequired()
{
    LOG4CPLUS_TRACE_METHOD(sLogger, __PRETTY_FUNCTION__);
    mGUI->showNumPad();
    LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT("profiler.ComponentIsOperable")), "AuthenticationApplication");
}
예제 #19
0
 std::shared_ptr<ErrorContext> PlacementContentHandler::end_message() {
   LOG4CPLUS_TRACE(logger, "ENTER end_message");
   assert(current_wire_template == 0);
   LOG4CPLUS_TRACE(logger, "LEAVE end_message");
   return std::shared_ptr<ErrorContext>(0);
 }
예제 #20
0
void FB::Log::trace(const std::string& src, const std::string& msg, const char *file, int line, const char *fn)
{
    LOG4CPLUS_TRACE(log4cplus::Logger::getInstance(L"FireBreath"), 
                    file << ":" << line << " - " << fn << " - " << FB::utf8_to_wstring(msg));
}
예제 #21
0
 std::shared_ptr<ErrorContext> PlacementContentHandler::end_options_template_set() {
   LOG4CPLUS_TRACE(logger, "ENTER end_option_template_set");
   libfc_RETURN_OK();
 }
예제 #22
0
 CAmpPmpConnection::~CAmpPmpConnection()
 {
    LOG4CPLUS_TRACE(msLogger, "~CAmpPmpConnection()");
 }
예제 #23
0
 std::shared_ptr<ErrorContext> PlacementContentHandler::end_data_set() {
   LOG4CPLUS_TRACE(logger, "ENTER end_data_set");
   LOG4CPLUS_TRACE(logger, "LEAVE end_data_set");
   libfc_RETURN_OK();
 }
예제 #24
0
 void CAmpPmpConnection::connect()
 {
    LOG4CPLUS_TRACE(msLogger, "connect()");
    start();
 }
예제 #25
0
void CAppManConnectController::uninit()
{
    LOG4CPLUS_TRACE(msLogger,"uninit()");
    init(0);
}
예제 #26
0
 void CAmpPmpConnection::disconnect()
 {
    LOG4CPLUS_TRACE(msLogger, "disconnect()");
    mpClient->disconnect();
 }
예제 #27
0
 virtual void bufferOverflowCallback(const UInt32 channel_id)
 {
    LOG4CPLUS_TRACE(msLogger, "Observer::bufferOverflowCallback channel_id = " + convertIntegerToString(channel_id));
 }
예제 #28
0
 void CAmpPmpConnection::threadFunc()
 {
    LOG4CPLUS_TRACE(msLogger, "threadFunc()");
    mpClient->loop();
 }
예제 #29
0
 virtual void connectionLostCallback()
 {
    LOG4CPLUS_TRACE(msLogger, "Observer::connectionLostCallback");
 }
예제 #30
0
int RTSPMJPEGClient::_init(RTSPMJPEGClientStruct *pClient)
{
    // state is set to ERROR by the caller
    if (pClient->address.empty())
        return -1;

    pClient->state = RTSPMJPEGCLIENT_STATE_INITIALIZING;
    LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] STATE = " << state_to_string(pClient->state));

    pClient->_pCodecCtxOrig = NULL;
    pClient->_pCodecCtx = NULL;
    pClient->_pCodec = NULL;

    LOG4CPLUS_DEBUG(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] Trying to open address " << pClient->address);

    // open rtsp
    pClient->_pFormatCtx = avformat_alloc_context();
    pClient->_pFormatCtx->interrupt_callback = int_cb;
    pClient->_pFormatCtx->interrupt_callback.opaque = pClient;

    int ret = 0;

    // open input
    LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] avformat_open_input() [TCP]... ");

    // try with TCP
    AVDictionary *options = NULL;
    av_dict_set(&options, "rtsp_transport", "tcp", 0);
    ret = avformat_open_input(&pClient->_pFormatCtx, pClient->address.c_str(), NULL, &options);
    av_dict_free(&options);

    if (ret < 0)
    {
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not open address [TCP] " << pClient->address << "!");
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not open address [TCP] " << pClient->address << "!");
        _logAVError(pClient, ret);

        // this to avoid to try UDP while stopping or aborting
        if (pClient->state != RTSPMJPEGCLIENT_STATE_INITIALIZING)
            return -1;

        // try with UDP
        LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] avformat_open_input() [UDP]... ");
        ret = avformat_open_input(&pClient->_pFormatCtx, pClient->address.c_str(), NULL, NULL);

        if (ret < 0)
        {
            LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not open address [UDP] " << pClient->address << "!");
            LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not open address [UDP] " << pClient->address << "!");
        _logAVError(pClient, ret);

        return -1;
    }
    }

    // find stream info
    LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] avformat_find_stream_info()... ");

    // see https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=1211
    int64_t max_analyze_duration = pClient->_pFormatCtx->max_analyze_duration;

    pClient->_pFormatCtx->max_analyze_duration = 0;
    ret = avformat_find_stream_info(pClient->_pFormatCtx, NULL);
    pClient->_pFormatCtx->max_analyze_duration = max_analyze_duration;

    if (ret < 0)
    {
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not get stream info! ");
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not get stream info! ");
        _logAVError(pClient, ret);

        return - 1;
    }

    // search video stream
    pClient->_videoStream = -1;

    for (int i = 0; i < (int ) pClient->_pFormatCtx->nb_streams; i++)
    {
        if (pClient->_pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO
            && pClient->_pFormatCtx->streams[i]->codec->codec_id == AV_CODEC_ID_MJPEG)
        {
            pClient->_videoStream = i;
            break;
        }
    }

    if (pClient->_videoStream == -1)
    {
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not find any MJPEG stream!");
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not find any MJPEG stream!");

        return - 1;
    }

    pClient->_pCodecCtxOrig = pClient->_pFormatCtx->streams[pClient->_videoStream]->codec;

    LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] avcodec_alloc_context3()... ");
    pClient->_pCodecCtx = avcodec_alloc_context3(NULL);

    // find the decoder for the video stream
    LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] avcodec_find_decoder()... ");
    pClient->_pCodec = avcodec_find_decoder(pClient->_pCodecCtxOrig->codec_id);

    if (pClient->_pCodec == NULL)
    {
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] Unsupported codec!");
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] Unsupported codec!");

        return -1; // codec not found
    }

    // copy context
    LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] avcodec_copy_context()... ");
    ret = avcodec_copy_context(pClient->_pCodecCtx, pClient->_pCodecCtxOrig);

    if (ret != 0)
    {
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not copy codec context!");
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not copy codec context!");
        _logAVError(pClient, ret);

        return - 1; // error copying codec context
    }

    // open codec
    LOG4CPLUS_TRACE(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] avcodec_open2()... ");
    ret = avcodec_open2(pClient->_pCodecCtx, pClient->_pCodec, NULL);

    if (ret < 0)
    {
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_ERROR_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not open codec!");
        LOG4CPLUS_ERROR(Logger::getInstance(LOG4CPLUS_TEXT(DEFAULT_OUTPUT_LOGGER)), "[CLIENT " << pClient->clientId << "] Could not open codec!");
        _logAVError(pClient, ret);

        return - 1;
    }

    return 0;
}