//------------------------------------------------------------------------------ bool GroundStation::SetStringParameter(const Integer id, const std::string & value, const Integer index) { if (index < 0) { AssetException ex; ex.SetDetails("The index %d is out-of-range for field \"%s\"", index, GetParameterText(id).c_str()); throw ex; } switch (id) { case ADD_HARDWARE: // made changes by Tuan Nguyen // Only add the hardware if it is not in the list already if (find(hardwareNames.begin(), hardwareNames.end(), value) == hardwareNames.end()) { //hardwareNames[index] = value; // This line causes system collapse due to index beyond array's size hardwareNames.push_back(value); } return true; default: break; // intentional drop through } return GroundstationInterface::SetStringParameter(id, value, index); }
//------------------------------------------------------------------------------ bool CalculatedPoint::SetStringParameter(const Integer id, const std::string &value, const Integer index) { #ifdef DEBUG_CP_SET_STRING MessageInterface::ShowMessage( "Entering CalculatedPoint::SetString with id = %d (%s), index = %d, and value = %s\n", id, GetParameterText(id).c_str(), index, value.c_str()); #endif if (id == BODY_NAMES) { if (isBuiltIn) { std::string errmsg = "The value of \""; errmsg += value + "\" for field \"BodyNames\" on built-in CalculatedPoint \"";; errmsg += instanceName + "\" is not an allowed value.\n"; errmsg += "The allowed values are: [None].\n"; throw SolarSystemException(errmsg); } if (index == (Integer) bodyNames.size()) { return ValidateBodyName(value, true, true); } // replace current name else { return ValidateBodyName(value, true, false, index); } } return SpacePoint::SetStringParameter(id, value, index); }
//------------------------------------------------------------------------------ std::string GroundStation::GetStringParameter(const Integer id, const Integer index) const { // MessageInterface::PopupMessage(Gmat::WARNING_, "GroundStation::GetStringParameter(id, index)"); if (index < 0) { AssetException ex; ex.SetDetails("The index %d is out-of-range for field \"%s\"", index, GetParameterText(id).c_str()); throw ex; } // made changes by Tuan Nguyen switch (id) { case ADD_HARDWARE: { if ((0 <= index)&&(index < (Integer)hardwareNames.size())) return hardwareNames[index]; else return ""; } default: break; // intentional drop through } return GroundstationInterface::GetStringParameter(id, index); }
//------------------------------------------------------------------------------ bool DataInterface::SetStringParameter(const Integer id, const std::string& value) { if (id == FORMAT) { if (find(supportedFormats.begin(), supportedFormats.end(), value) != supportedFormats.end()) { readerFormat = value; return true; } else { std::string theList; for (UnsignedInt i = 0; i < supportedFormats.size(); ++i) { if (i > 0) theList += ", "; theList += supportedFormats[i]; } InterfaceException ex(""); ex.SetDetails(errorMessageFormat.c_str(), value.c_str(), GetParameterText(id).c_str(), theList.c_str()); throw ex; } } return Interface::SetStringParameter(id, value); }
//------------------------------------------------------------------------------ bool CalculatedPoint::TakeRequiredAction(const Integer id) { #ifdef DEBUG_CP_ACTION MessageInterface::ShowMessage( "Entering CP::TakeRequiredAction with id = %d (%s)\n", id, (GetParameterText(id)).c_str()); #endif if (id == BODY_NAMES) return TakeAction("ClearBodies"); return SpacePoint::TakeRequiredAction(id); }
//------------------------------------------------------------------------------ bool CalculatedPoint::SetStringParameter(const Integer id, const std::string &value) { #ifdef DEBUG_CP_SET_STRING MessageInterface::ShowMessage("Entering CalculatedPoint::SetString with id = %d (%s), value = %s\n", id, GetParameterText(id).c_str(), value.c_str()); #endif if (id == BODY_NAMES) { if (isBuiltIn) { std::string errmsg = "The value of \""; errmsg += value + "\" for field \"BodyNames\" on built-in CalculatedPoint \"";; errmsg += instanceName + "\" is not an allowed value.\n"; errmsg += "The allowed values are: [None].\n"; throw SolarSystemException(errmsg); } std::string value1 = GmatStringUtil::Trim(value); // If there are names inside a brace-enclosed list, reset the // entire array of names to that list if (GmatStringUtil::IsEnclosedWithBraces(value1)) { // bodyNames.clear(); TakeAction("ClearBodies"); StringArray nameList = GmatStringUtil::ToStringArray(value1); for (unsigned int ii = 0; ii < nameList.size(); ii++) { ValidateBodyName(nameList.at(ii), true, true); } } else { ValidateBodyName(value, true, true); } #ifdef DEBUG_CP_SET_STRING MessageInterface::ShowMessage("Exiting CalculatedPoint::SetString: BodyNames are: \n"); for (unsigned int ii = 0; ii < bodyNames.size(); ii++) MessageInterface::ShowMessage(" %d %s\n", (Integer) ii, (bodyNames.at(ii)).c_str()); #endif return true; } return SpacePoint::SetStringParameter(id, value); }
/** * Retrieve the value for a Real parameter. * * @param <id> The integer ID for the parameter. * * @return The parameter's value. */ Real Formation::GetRealParameter(const Integer id) const { #ifdef DEBUG_GET_REAL MessageInterface::ShowMessage( "In Formation::GetReal, asking for parameter %d, whose string is \"%s\"\n", id, (GetParameterText(id)).c_str()); //for (Integer i=0; i<6;i++) // MessageInterface::ShowMessage(" state(%d) = %.12f\n", // i, state[i]); //MessageInterface::ShowMessage(" and stateType = %s\n", // stateType.c_str()); #endif if (id >= FORMATION_CARTESIAN_STATE ) return state[id - FORMATION_CARTESIAN_STATE]; return FormationInterface::GetRealParameter(id); }
Real BodyFixedPoint::SetRealParameter(const Integer id, const Real value) { if (id == EPOCH_PARAM) // from SpacePoint { A1Mjd a1(value); GetMJ2000State(a1); return lastStateTime.Get(); } #ifdef DEBUG_BODYFIXED_SET_REAL MessageInterface::ShowMessage("Entering BFP::SetRealParameter with id = %d (%s) and value = %12.10f\n", id, (GetParameterText(id)).c_str(), value); // MessageInterface::ShowMessage("stateType = %s and horizon = %s\n", // stateType.c_str(), horizon.c_str()); #endif if (((id == LOCATION_1) || (id == LOCATION_2)) && stateType == "Spherical") { // if Spherical statetype, then check if Latitude/Longitude are in the correct range if (id == LOCATION_1) // latitude { if ((value >= -90.0) && (value <= 90)) location[id-LOCATION_1] = value * GmatMathConstants::RAD_PER_DEG; else { AssetException aException(""); aException.SetDetails(errorMessageFormat.c_str(), GmatStringUtil::ToString(value, 16).c_str(), GetStringParameter(id-LOCATION_1+LOCATION_LABEL_1).c_str(), "Real Number >= -90.0 and <= 90.0"); throw aException; } } else // longitude (0-360) location[id-LOCATION_1] = (GmatMathUtil::Mod(value,360)) * GmatMathConstants::RAD_PER_DEG; return location[id-LOCATION_1]; } else if ((id >= LOCATION_1) && (id <= LOCATION_3)) // not Spherical { location[id-LOCATION_1] = value; return location[id-LOCATION_1]; } return SpacePoint::SetRealParameter(id, value); }
//------------------------------------------------------------------------------ // bool SetStringParameter(const Integer id, const std::string &value) //------------------------------------------------------------------------------ bool GroundTrackPlot::SetStringParameter(const Integer id, const std::string &value) { #if DBGLVL_PARAM_STRING MessageInterface::ShowMessage ("GroundTrackPlot::SetStringParameter() this=<%p>'%s', id=%d<%s>, value='%s'\n", this, instanceName.c_str(), id, GetParameterText(id).c_str(), value.c_str()); #endif switch (id) { case COORD_SYSTEM: // script do not specify view coordinate system, so do nothing here // we want to create local body fixed coord system instead in Initialize() break; case CENTRAL_BODY: if (centralBodyName != value) { centralBodyName = value; // Since ground track data uses body fixed coordinates, name it here mViewCoordSysName = value + "Fixed"; // Get default texture map file for the new body FileManager *fm = FileManager::Instance(); std::string mapFile = GmatStringUtil::ToUpper(centralBodyName) + "_TEXTURE_FILE"; textureMapFileName = fm->GetFullPathname(mapFile); #if DBGLVL_PARAM_STRING MessageInterface::ShowMessage (" this = <%p>, textureMapFile changed to '%s'\n", this, textureMapFileName.c_str()); #endif } return true; case TEXTURE_MAP: textureMapFileName = value; return true; case SHOW_FOOT_PRINTS: { bool itemFound = false; int index = -1; for (int i = 0; i < FootPrintOptionCount; i++) { if (value == FOOT_PRINT_OPTION_TEXT[i]) { itemFound = true; index = i; break; } } if (itemFound) { footPrints = value; footPrintOption = (FootPrintOption)index; #if DBGLVL_PARAM_STRING MessageInterface::ShowMessage(" footPrintOption = %d\n", footPrintOption); #endif return true; } else { SubscriberException se; std::string options; for (int i = 0; i < FootPrintOptionCount - 1; i++) options = options + FOOT_PRINT_OPTION_TEXT[i] + " ,"; options = options + FOOT_PRINT_OPTION_TEXT[FootPrintOptionCount - 1]; se.SetDetails(errorMessageFormat.c_str(), value.c_str(), GetParameterText(id).c_str(), options.c_str()); throw se; } } default: ; // Intentional drop through so all paths return a value } return OrbitPlot::SetStringParameter(id, value); }