示例#1
0
void Prep(int x){
	dep[x] = dep[fa[x]] + 1;
	size[x] = 1;
	son[x] = 0;
	for (int i = g[x]; i; i = nxt[i]){
		int y = adj[i];
		if (y == fa[x]) continue;
		fa[y] = x;
		Prep(y);
		size[x] += size[y];
		if (size[y] > size[son[x]]) son[x] = y;
	}
}
示例#2
0
   void Draw(void) {
      Prep();	
      ShapeHeader();
      GetVertexes();
      GetNormals();	
      NormalCorrection();	

      fprintf(TIVFile::File, "\tSeparator {\n");

      Draw2File();

      for(int i = 1; i < TIVTube::NCDiv; i ++) fprintf(
         TIVFile::File,
         "\t    Rotation { rotation 0 0 1 %f }\n"
         "\t    Separator { USE TubeUpperSector }\n",
         TIVTube::Xa
         );
      fprintf(TIVFile::File, "\t}\n");

   }   	
示例#3
0
   void Draw(void) {
      for(int i = 0; i < Nz - 1; i++) {
         if(vDz[i] == vDz[i + 1]) continue;  
         Prep(i);
         GetVertexes(i);
         GetNormals();	
         TIVCone::NormalCorrection();	

         fprintf(TIVFile::File, "\tSeparator {\n");

         Draw2File();

         for(int j = 1; j < TIVTube::NCDiv; j++) fprintf(
            TIVFile::File,
            "\t    Rotation { rotation 0 0 1 %f }\n"
            "\t    Separator { USE TubeUpperSector }\n",
            TIVTube::Xa
            );
         fprintf(TIVFile::File, "\t}\n");

      }

   }
示例#4
0
void DataFlash_Class::Prep() {
    FOR_EACH_BACKEND(Prep());
}
示例#5
0
void DataFlash_Class::Init(const struct LogStructure *structures, uint8_t num_types)
{
    gcs().send_text(MAV_SEVERITY_INFO, "Preparing log system");
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
    validate_structures(structures, num_types);
    dump_structures(structures, num_types);
#endif
    if (_next_backend == DATAFLASH_MAX_BACKENDS) {
        AP_HAL::panic("Too many backends");
        return;
    }
    _num_types = num_types;
    _structures = structures;

#if defined(HAL_BOARD_LOG_DIRECTORY)
    if (_params.backend_types == DATAFLASH_BACKEND_FILE ||
        _params.backend_types == DATAFLASH_BACKEND_BOTH) {
        DFMessageWriter_DFLogStart *message_writer =
            new DFMessageWriter_DFLogStart(_firmware_string);
        if (message_writer != nullptr)  {
#if HAL_OS_POSIX_IO
            backends[_next_backend] = new DataFlash_File(*this,
                                                         message_writer,
                                                         HAL_BOARD_LOG_DIRECTORY);
#endif
        }
        if (backends[_next_backend] == nullptr) {
            hal.console->printf("Unable to open DataFlash_File");
        } else {
            _next_backend++;
        }
    }
#endif

#if DATAFLASH_MAVLINK_SUPPORT
    if (_params.backend_types == DATAFLASH_BACKEND_MAVLINK ||
        _params.backend_types == DATAFLASH_BACKEND_BOTH) {
        if (_next_backend == DATAFLASH_MAX_BACKENDS) {
            AP_HAL::panic("Too many backends");
            return;
        }
        DFMessageWriter_DFLogStart *message_writer =
            new DFMessageWriter_DFLogStart(_firmware_string);
        if (message_writer != nullptr)  {
            backends[_next_backend] = new DataFlash_MAVLink(*this,
                                                            message_writer);
        }
        if (backends[_next_backend] == nullptr) {
            hal.console->printf("Unable to open DataFlash_MAVLink");
        } else {
            _next_backend++;
        }
    }
#endif

    for (uint8_t i=0; i<_next_backend; i++) {
        backends[i]->Init();
    }

    Prep();

    EnableWrites(true);

    gcs().send_text(MAV_SEVERITY_INFO, "Prepared log system");
}
示例#6
0
void AP_Logger::Init(const struct LogStructure *structures, uint8_t num_types)
{
    gcs().send_text(MAV_SEVERITY_INFO, "Preparing log system");
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
    validate_structures(structures, num_types);
    dump_structures(structures, num_types);
#endif
    if (_next_backend == DATAFLASH_MAX_BACKENDS) {
        AP_HAL::panic("Too many backends");
        return;
    }
    _num_types = num_types;
    _structures = structures;

#if defined(HAL_BOARD_LOG_DIRECTORY)
 #if HAL_OS_POSIX_IO || HAL_OS_FATFS_IO
    if (_params.backend_types & uint8_t(Backend_Type::FILESYSTEM)) {
        LoggerMessageWriter_DFLogStart *message_writer =
            new LoggerMessageWriter_DFLogStart();
        if (message_writer != nullptr)  {
            backends[_next_backend] = new AP_Logger_File(*this,
                                                         message_writer,
                                                         HAL_BOARD_LOG_DIRECTORY);
        }
        if (backends[_next_backend] == nullptr) {
            hal.console->printf("Unable to open AP_Logger_File");
        } else {
            _next_backend++;
        }
    }
 #endif
#endif // HAL_BOARD_LOG_DIRECTORY

#if DATAFLASH_MAVLINK_SUPPORT
    if (_params.backend_types & uint8_t(Backend_Type::MAVLINK)) {
        if (_next_backend == DATAFLASH_MAX_BACKENDS) {
            AP_HAL::panic("Too many backends");
            return;
        }
        LoggerMessageWriter_DFLogStart *message_writer =
            new LoggerMessageWriter_DFLogStart();
        if (message_writer != nullptr)  {
            backends[_next_backend] = new AP_Logger_MAVLink(*this,
                                                            message_writer);
        }
        if (backends[_next_backend] == nullptr) {
            hal.console->printf("Unable to open AP_Logger_MAVLink");
        } else {
            _next_backend++;
        }
    }
#endif

#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
    if (_params.backend_types & uint8_t(Backend_Type::BLOCK)) {
        if (_next_backend == DATAFLASH_MAX_BACKENDS) {
            AP_HAL::panic("Too many backends");
            return;
        }
        LoggerMessageWriter_DFLogStart *message_writer =
            new LoggerMessageWriter_DFLogStart();
        if (message_writer != nullptr)  {
            backends[_next_backend] = new AP_Logger_SITL(*this, message_writer);
        }
        if (backends[_next_backend] == nullptr) {
            hal.console->printf("Unable to open AP_Logger_SITL");
        } else {
            _next_backend++;
        }
    }
#endif

#ifdef HAL_LOGGING_DATAFLASH
    if (_params.backend_types & uint8_t(Backend_Type::BLOCK)) {
        if (_next_backend == DATAFLASH_MAX_BACKENDS) {
            AP_HAL::panic("Too many backends");
            return;
        }
        LoggerMessageWriter_DFLogStart *message_writer =
            new LoggerMessageWriter_DFLogStart();
        if (message_writer != nullptr)  {
            backends[_next_backend] = new AP_Logger_DataFlash(*this, message_writer);
        }
        if (backends[_next_backend] == nullptr) {
            hal.console->printf("Unable to open AP_Logger_DataFlash");
        } else {
            _next_backend++;
        }
    }
#endif
    
    for (uint8_t i=0; i<_next_backend; i++) {
        backends[i]->Init();
    }

    Prep();

    EnableWrites(true);

    gcs().send_text(MAV_SEVERITY_INFO, "Prepared log system");
}
示例#7
0
void AP_Logger::Prep() {
    FOR_EACH_BACKEND(Prep());
}