Example #1
0
ServerContextImpl::ServerContextImpl():
    _state(NOT_INITIALIZED),
    _beaconAddressList(),
    _ignoreAddressList(),
    _autoBeaconAddressList(true),
    _beaconPeriod(15.0),
    _broadcastPort(PVA_BROADCAST_PORT),
    _serverPort(PVA_SERVER_PORT),
    _receiveBufferSize(MAX_TCP_RECV),
    _timer(),
    _beaconEmitter(),
    _acceptor(),
    _transportRegistry(),
    _channelProviderRegistry(),
    _channelProviderNames(PVACCESS_DEFAULT_PROVIDER),
    _channelProviders(),
    _beaconServerStatusProvider(),
    _startTime()

{
    epicsTimeGetCurrent(&_startTime);

    // TODO maybe there is a better place for this (when there will be some factory)
    epicsSignalInstallSigAlarmIgnore ();
    epicsSignalInstallSigPipeIgnore ();

    generateGUID();
    initializeLogger();
}
Example #2
0
void xai_param_normal_set(_xai_packet_param_normal* normal_param,XAITYPEAPSN  from_apsn,XAITYPELUID from_luid,
                          XAITYPEAPSN to_apsn,XAITYPELUID to_luid,uint8_t flag , uint16_t msgid , uint16_t magic_number
                          ,void* data ,size_t dataSize){
    
    
    if (NULL == normal_param) {
        return;
    }
    
    
    
    void* from_guid = generateGUID(from_apsn, from_luid);
    void* to_guid = generateGUID(to_apsn , to_luid);
    
    
    byte_data_copy(normal_param->from_guid, from_guid, sizeof(normal_param->from_guid), lengthOfGUID());
    byte_data_copy(normal_param->to_guid, to_guid, sizeof(normal_param->to_guid), lengthOfGUID());
    
    purgeGUID(from_guid);
    purgeGUID(to_guid);
    
    normal_param->flag  = flag;
    normal_param->msgid = msgid;
    normal_param->magic_number = magic_number;
    normal_param->length  =   dataSize;
    
    if (NULL != normal_param->data) {
        
        free(normal_param->data);
        normal_param->data = NULL;
    }
    
    if (dataSize > 0) {
        
        normal_param->data = malloc(dataSize);
        memset(normal_param->data, 0, dataSize);
        
        byte_data_copy(normal_param->data, data, dataSize, dataSize);
    }
    
    
    
}
Example #3
0
guidType TimeManager::appendTime(int offset) {
    auto timeGuid = generateGUID();
    auto timeValue = SDL_GetTicks() + offset;
    auto timePair = timeTuple(timeValue, timeGuid);

    //if the offset is greater than zero, we add to active container
    if (offset > 0) {
	activeTimeContainer.insert(timePair);
    }
    else {
	inActiveTimeContainer.insert(timePair);
    }
    
    return timeGuid;
}
//TODO:  I do NOT set the image positions or 3D positions anymore!!!
void LshKBM::create(const FeatureDatabase& db,
    std::vector<unsigned int> image_ids)
{
  generateGUID();
  uint32_t dims = db.dims(); // number of bytes per feature descriptor
  assert(dims==BriefDesc::BRIEF_K);// BRIEF32 features

  Timer t0;
  const db_index_t& dbIndex=db.index(); // for each image
  vector<BriefDesc*> mapDs;
  mapDs.reserve(db.descCount()); // reserve storage for all descriptors

  for(uint32_t j=0; j<image_ids.size(); ++j)
  { // iterate over images in image_ids
    uint32_t i=image_ids[j];
    uint8_t* desc = ((uint8_t*)db.firstDescriptor(i)); // for each feature
//    const meta_file_entry* dbMeta=db.firstMetaEntry(i); // for each feature
    for(int j=0; j<dbIndex[i].desc_count; ++j)
    {// iterate over the features found in image with index i
      // dont copy data just set pointer to the data
       BriefDescM* bD = new BriefDescM(&desc[j*dims]);
      mapDs.push_back(bD);
    }
  }
  cout<<" dt for loading: "<<t0.toc()<<"ms"<<endl;

  num_images=image_ids.size();
  if(mLshKbmP.getMaxSamples()>0)
  {
    cout<<"LshKBM::create: Randomly subsampling "<<mapDs.size()<<" to "<<mLshKbmP.getMaxSamples()<<endl;
    assert(mLshKbmP.getMaxSamples()<=mapDs.size());
    num_descriptors=mLshKbmP.getMaxSamples();
    vector<BriefDesc*> mapDSamples(mLshKbmP.getMaxSamples());
    __gnu_cxx::random_sample(mapDs.begin(),mapDs.end(),mapDSamples.begin(),mapDSamples.end());
    cout<<"LshKBM::create: random subsampling done!"<<endl;
    t0.tic();
    prepare(mapDSamples);
    t0.toc();
  }else{
    num_descriptors=mapDs.size();
    t0.tic();
    prepare(mapDs);
    t0.toc();
  }
  mDtKBinMeans=t0.lastDt();
}
void FMUCodeGen::gen()
{
	std::string guid = generateGUID();

	UdmDom::DomDataNetwork fmiDN(FMI::diagram);
	fmiDN.CreateNew(_fmiFile, "FMI.xsd", FMI::fmiModelDescription::meta);

	FMI::fmiModelDescription fmiMD = FMI::fmiModelDescription::Cast(fmiDN.GetRootObject());
	fmiMD.fmiVersion() = "1.0";
	fmiMD.modelName() = _topSubsystemName;
	fmiMD.modelIdentifier() = _topSubsystemName;
	fmiMD.guid() = guid;
	fmiMD.numberOfContinuousStates() = 0;
	fmiMD.numberOfEventIndicators() = 0;

	FMI::ModelVariables mvars = FMI::ModelVariables::Create(fmiMD);
	genModelVariables(mvars);
	
	fmiDN.CloseWithUpdate();
	
	std::ofstream fmu_file;
	fmu_file.open(_cWrapperFile.c_str());

	fmu_file << "// define class name and unique id\n";
	fmu_file << "#define MODEL_IDENTIFIER " << _topSubsystemName << "\n";
	fmu_file << "#define MODEL_GUID \"" << guid << "\"\n";
	fmu_file <<	"\n";
	fmu_file << "// define model size\n";
	fmu_file << "#define NUMBER_OF_REALS "+boost::lexical_cast<string>(_nReal)+"\n";
	fmu_file << "#define NUMBER_OF_INTEGERS "+boost::lexical_cast<string>(_nInt)+"\n";
	fmu_file << "#define NUMBER_OF_BOOLEANS 0\n";
	fmu_file << "#define NUMBER_OF_STRINGS "+boost::lexical_cast<string>(_nStr)+"\n";
	fmu_file << "#define NUMBER_OF_STATES 0\n";
	fmu_file << "#define NUMBER_OF_EVENT_INDICATORS 0\n";
	fmu_file <<	"\n";
	fmu_file << "// include fmu header files, typedefs and macros\n";
	fmu_file << "#include \"fmuTemplate.h\"\n";
	fmu_file << "#include \"" << _topSubsystemName <<"_sl.h\"\n";
	fmu_file <<	"\n";
	fmu_file << _define;
	fmu_file <<	"\n";
	fmu_file << "static " << _topSubsystemName << "_context context;\n";
	fmu_file << "\n";
	fmu_file << "// called by fmiInstantiateModel\n";
	fmu_file << "// Set values for all variables that define a start value\n";
	fmu_file << "// Settings used unless changed by fmiSetX before fmiInitialize\n";
	fmu_file << "void setStartValues(ModelInstance *comp) {\n";
	fmu_file << _setStartValues <<"\n";
	fmu_file << "}\n";
	fmu_file << "\n";
	fmu_file << "// called by fmiInitialize() after setting eventInfo to defaults\n";
	fmu_file << "// Used to set the first time event, if any.\n";
	fmu_file << "void initialize(ModelInstance* comp, fmiEventInfo* eventInfo) {\n";
    fmu_file << "\teventInfo->upcomingTimeEvent   = fmiFalse;\n";
    fmu_file << "\teventInfo->nextEventTime       = 0;\n";
	fmu_file << "}\n";
	fmu_file << "// called by fmiGetReal, fmiGetContinuousStates and fmiGetDerivatives\n";
	fmu_file << "fmiReal getReal(ModelInstance* comp, fmiValueReference vr){\n";
    fmu_file << "\tswitch (vr) {\n";
	fmu_file << _getReal;
	fmu_file << "\t\tdefault: return 0.0;\n";
	fmu_file << "\t}\n";
	fmu_file << "}\n";
	fmu_file << "\n";
	fmu_file << "// called by fmiEventUpdate() after setting eventInfo to defaults\n";
	fmu_file << "void eventUpdate(ModelInstance* comp, fmiEventInfo* eventInfo) {\n";
	fmu_file << "} \n";
	fmu_file << "\n";
	fmu_file << "// include code that implements the FMI based on the above definitions\n";
	fmu_file << "#include \"fmuTemplate.c\"\n";

	fmu_file.close();
}