//funciones temporales para simular la llegada de datos //cuando se definan sockets y extracción desde fichero entonces se separarán a su modulo void recibirEstaciones(std::set<Station>& estaciones){ //datos que se sacarán del fichero que llegue, esto es a fuego temporalmente estaciones.insert(Station("0x0000", "0x0010", 35.222, -13.332, -1)); estaciones.insert(Station("0x0001", "0x0011", 35.675, -10.322, -1)); estaciones.insert(Station("0x0002", "0x0012", 36.232, -7.543, -1)); estaciones.insert(Station("0x0003", "0x0013", 37.323, -5.887,-1)); }
Station Trajectory::removeLastState() { if(m_states_vec.empty()) return Station(); Station st = m_states_vec.back(); m_states_vec.pop_back(); return st; }
void WdgAddStation::OnSave() { QString Str = ui.leComment->text(); if(Str.capacity()<1) return; if(ui.sbFreq->value() > 100000 && ui.sbFreq->value() < 440000000) { emit Station(ui.leComment->text(), ui.sbFreq->value(), ui.comboBox->currentIndex()); close(); } }
Station PlanningProblem::SampleStateUniform() { Station sampled_station; for(int i=0; i < MAX_SAMPLING_TRY; ++i) { Vector3D rand_pos = actualBound->getUniformSample(); sampled_station.setPosition(rand_pos); if(CheckValidity(sampled_station)) return sampled_station; } return Station(); }
int main() { TransportationSystem ratt = TransportationSystem(); Station maria = Station("maria"); Station cluj = Station("cluj"); Station traian = Station("traian"); Station buzias = Station("buzias"); Station aem = Station("aem"); Segment aem_cluj = Segment(&aem, &cluj, 2); Segment aem_maria = Segment(&aem, &maria, 2); Segment maria_cluj = Segment(&maria, &cluj, 10); Segment maria_buzias = Segment(&maria, &buzias, 1); Segment cluj_buzias = Segment(&cluj, &buzias, 5); Segment cluj_traian = Segment(&cluj, &traian, 5); Segment traian_buzias = Segment(&traian, &buzias, 3); Metro tram8 = Metro("8"); tram8.addSegment(&maria_cluj); tram8.addSegment(&maria_buzias); tram8.addSegment(&cluj_buzias); tram8.addSegment(&cluj_traian); tram8.addSegment(&traian_buzias); tram8.addSegment(&aem_cluj); tram8.addSegment(&aem_maria); ratt.addMetro(&tram8); ratt.setRoutingStrategy("DIJSTRA"); ratt.findRoute(aem, traian); return 0; }
Station PlanningProblem::RRTExtend(const Station &start, const Station &target, float extension_len) { Vector3D diff_vec = target.getPosition() - start.getPosition(); diff_vec.normalize2D(); diff_vec *= extension_len; float start_angle = start.getPosition().Teta(); start_angle = continuousRadian(start_angle, diff_vec.to2D().arctan() - M_PI); float rotate_angle = (diff_vec.to2D().arctan() - start_angle) / 1.5; diff_vec.setTeta(rotate_angle); Station temp_station; temp_station.setPosition((diff_vec + start.getPosition()).standardizeTeta()); bool valid = CheckValidity(temp_station); if(valid) return temp_station; return Station(); }
void LineEditor::OnbtAddStationClick(wxCommandEvent& event) { Station::ID nextID = Stations::instance()->peekNextFreeID(); std::stringstream ss; ss << "Station " << nextID; wxString name = wxGetTextFromUser("Name for the new station:", "scheduler", ss.str(), this); if(!name.empty()) { //Station NewStation(std::string(name.c_str())); Station& station = Stations::instance()->addStation(Station(std::string(name.c_str()))); long itemIndex = lvStations->InsertItem(lvStations->GetItemCount(), station.getName()); lvStations->SetItemData(itemIndex, station.getID()); } else return; }
Station Trajectory::getLastStation() const { if(this->isEmpty()) return Station(); return getStation(this->length() - 1); }
Station Trajectory::getFirstStation() const { if(this->isEmpty()) return Station(); return getStation(0); }
// Create and initialize an array from data given in a text file. void Array::ImportFile(string filename, string comment_chars) { // Some local variables int max_params = 8; // This is the number of non-telescope parameters found in the array definition file. int n_params = 0; // the number of parameters read in from the file // Local varaibles for creating Station objects. string staname; int sta_index; double North; double East; double Up; double gain; double diameter; int coord_sys; bool xyz_coords = false; int line_number; // We permit shortcuts in the name of the arrays, this lets us do // $ oifits-sim -a CHARA // instead of // $ oifits-sim -a /home/.../etc/CHARA.txt // which I think is a nice feature. To do this, we first need to see if a file with the // name, filename, really exists. // TODO: Use a global variable, read in from a configuration file, to specify "../etc" below. if(!FileExists(filename)) { filename = "../etc/" + filename + ".txt"; } // stores non-blank, non-comment lines vector < string > lines = ReadFile(filename, comment_chars, "Cannot Open Array Definition File"); vector <string> results; for(line_number = 0; line_number < max_params; line_number++) { // Clear out the results, split the string and strip whitespace results.clear(); results = SplitString(lines[line_number], '='); StripWhitespace(results); if(results[0] == "name") { try { this->arrayname = string(results[1]); n_params += 1; cout << "Loading Array " << this->arrayname << endl; } catch(...) { throw std::runtime_error("Invalid array name"); } } if(results[0] == "lat") { try { this->latitude = atof(results[1].c_str()); // Convert to radians: this->latitude *= PI / 180; n_params += 1; } catch(...) { throw std::runtime_error("Invalid array latitude"); } } if(results[0] == "lon") { try { this->longitude = atof(results[1].c_str()); // Convert to radians: this->longitude *= PI / 180; n_params += 1; } catch(...) { throw std::runtime_error("Invalid array longitude"); } } if(results[0] == "alt") { try { this->altitude = atof(results[1].c_str()); n_params += 1; } catch(...) { throw std::runtime_error("Invalid array altitude"); } } if(results[0] == "coord") { try { coord_sys = atoi(results[1].c_str()); if(coord_sys == 0) { cout << "Array Coordinate system specified in XYZ." << endl; xyz_coords = true; } else cout << "Array Coordinate system specified in (North, East, Up)." << endl; n_params += 1; } catch(...) { throw std::runtime_error("Invalid Coordinate definition specification for telescope positions."); } } if(results[0] == "throughput") { try { this->throughput = atof(results[1].c_str()); n_params += 1; } catch(...) { throw std::runtime_error("Invalid array throughput"); } } if(results[0] == "wind_speed") { try { // Import the wind speed. In the input parameter file it is in m/s // all variables are stored in MKS units, so no conversion is necessary. this->wind_speed = atof(results[1].c_str()); n_params += 1; } catch(...) { throw std::runtime_error("Invalid array average wind speed"); } } if(results[0] == "r0") { try { this->r0 = atof(results[1].c_str()); n_params += 1; } catch(...) { throw std::runtime_error("Invalid average r0 for the array"); } } } // Do some quick error checking on the file format. First, make sure we've got all of the parameters: if(n_params != max_params) throw std::runtime_error("Parameters are missing from the array definition file."); // Now double-check that there are at least two telescopes in this array // This is represented by at least two lines remaining in the file. if(lines.size() - line_number < 2) throw std::runtime_error("At least two telescopes are required for an array! Check configuration file."); // Now iterate through the telescope definitions. There are four entries above // this point in the data file so we start at 4. for (unsigned int i = line_number; i < lines.size(); i++) { // First tokenize the line vector < string > tokens = Tokenize(lines[i]); // And now attempt to read in the line try { staname = tokens[0]; sta_index = atoi(tokens[1].c_str()); North = atof(tokens[2].c_str()); East = atof(tokens[3].c_str()); Up = atof(tokens[4].c_str()); gain = atof(tokens[5].c_str()); diameter = atof(tokens[6].c_str()); } catch(...) { throw std::runtime_error("Error in telecope definitions in array configuration file."); } // Push this station on to the list of stations for this array. this->stations.push_back( Station(this->latitude, staname, sta_index, xyz_coords, North, East, Up, gain, diameter) ); } // Compute a hash table for the stations: this->sta_hash = ComputeStationHash(stations); // Now compute all possible baselines from these stations. this->baselines = ComputeBaselines(stations); this->bl_hash = ComputeBaselineHash(this->baselines); this->triplets = ComputeTriplets(this, stations); this->tri_hash = ComputeTripletHash(this->triplets); this->quadruplets = ComputeQuadruplets(this, stations); this->quad_hash = ComputeQuadrupletHash(this->quadruplets); }