From aeb358487d6404732d7b814b000ace8f572596b6 Mon Sep 17 00:00:00 2001 From: jkinnebrew Date: Wed, 8 Nov 2006 00:39:52 +0000 Subject: --- ChangeLog | 9 +++++ SA_POP/server/Driver.cpp | 2 +- SA_POP/server/client.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++++---- SA_POP/server/client.h | 20 ++++++++++ SA_POP/server/server.cpp | 2 +- 5 files changed, 120 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc85497371c..271497c8e91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Nov 8 00:38:28 UTC 2006 John S. Kinnebrew + + * SA_POP/server/Driver.cpp: + * SA_POP/server/client.h: + * SA_POP/server/client.cpp: + * SA_POP/server/server.cpp: + + Client and server updates/debugging for ATC Demo + Tue Nov 7 19:50:13 UTC 2006 Nishanth Shankaran * SA_POP/SA_POP.mpc: diff --git a/SA_POP/server/Driver.cpp b/SA_POP/server/Driver.cpp index dabe111ed33..e06ed45f537 100644 --- a/SA_POP/server/Driver.cpp +++ b/SA_POP/server/Driver.cpp @@ -59,7 +59,7 @@ namespace CIAO ::CIAO::RACE::Interactive_Input_Adapter::_narrow (iia_tmp.in ()); // Now initialize the plan generator. - // this->plan_gen_.init (this->orb_, true, RM_name); + this->plan_gen_.init (this->orb_, true, RM_name); // Create SA-POP planner. ::SA_POP::SA_Builder builder; diff --git a/SA_POP/server/client.cpp b/SA_POP/server/client.cpp index 49eb6e1909e..a0907e1a880 100644 --- a/SA_POP/server/client.cpp +++ b/SA_POP/server/client.cpp @@ -1,6 +1,8 @@ +#include #include "client.h" #include "DriverC.h" #include "ace/Get_Opt.h" +#include "ace/UUID.h" const char *ior = "file://server.ior"; const char *plan = 0; @@ -40,9 +42,11 @@ parse_args (int argc, char *argv[]) else { - ACE_ERROR ((LM_ERROR, "URI of the deployment plan is necessary!\n")); - return -1; +// ACE_ERROR ((LM_ERROR, "URI of the deployment plan is necessary!\n")); +// return -1; } + + return 0; } int @@ -53,9 +57,7 @@ main (int argc, char *argv[]) CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, ""); if (parse_args (argc, argv) != 0) - { - return 1; - } + return 1; CORBA::Object_var tmp = orb->string_to_object(ior); @@ -66,12 +68,40 @@ main (int argc, char *argv[]) if (CORBA::is_nil (driver.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, - "Nil Driver reference <%s>\n", ior), 1); + "Nil Driver reference <%s>\n", ior), 1); } - driver->deploy_plan (plan); + if (plan != 0) { + driver->deploy_plan (plan); + } else { + // Get goal ID and utility. + ::SA_POP::CondID cond_id; + ::SA_POP::Utility util; + std::cout << "Goal condition ID: "; + std::cin >> cond_id; + std::cout << std::endl; + std::cout << "Goal utility: "; + std::cin >> util; + std::cout << std::endl; + + // Create goal map. + ::SA_POP::GoalMap goal_map; + goal_map.clear (); + goal_map.insert (std::make_pair (cond_id, util)); + + // Create goal option. + ::SA_POP::GoalOption goal_opt ( + "Plan and deploy opstring for user-specified goal.", + "Tear down deployed opstring for user-specified goal.", driver.in (), + goal_map); + + // Activate goal option. + std::cout << "Activating goal option to plan and deploy opstring." << std::endl; + goal_opt.do_action (); + } orb->destroy (); + } catch (CORBA::Exception &ex) { @@ -90,7 +120,7 @@ UIOption::UIOption (std::string descrip, std::string undo_descrip, undo_descrip_ (undo_descrip), is_invoked_ (false), is_active_ (true), - driver_ (driver) + driver_ (::CIAO::RACE::SA_POP::Driver::_duplicate (driver)) { // Nothing to do. }; @@ -142,6 +172,16 @@ GoalOption::GoalOption (std::string descrip, std::string undo_descrip, // Nothing to do. }; +// Constructor for a goal with only goal conditions. +GoalOption::GoalOption (std::string descrip, std::string undo_descrip, + ::CIAO::RACE::SA_POP::Driver_ptr driver, + ::SA_POP::GoalMap goal_conds) +: UIOption (descrip, undo_descrip, driver) +{ + // Create goal with specified goal conditions and default values for the rest. + this->create_def_goal (goal_conds); +}; + // Destructor. GoalOption::~GoalOption (void) { @@ -173,6 +213,47 @@ bool GoalOption::undo (void) return true; }; +// Create and set internal goal using specified goal conditions and defaults. +void GoalOption::create_def_goal (const ::SA_POP::GoalMap goal_conds) +{ + // Add goal conditions. + ::CORBA::ULong cond_index = 0; + for (::SA_POP::GoalMap::const_iterator cond_iter = goal_conds.begin (); + cond_iter != goal_conds.end (); cond_iter++) + { + // Goal condition to populate. + ::CIAO::RACE::GoalCondition cond_desc; + + // Set condition ID and utility. + cond_desc.condID = cond_iter->first; + cond_desc.utility = static_cast< ::CORBA::Long> (cond_iter->second); + + // Add goal condition to goal idl. + this->goal_.goalConds.length (cond_index + 1); + this->goal_.goalConds[cond_index] = cond_desc; + + // Increment link index. + cond_index++; + } + + // Create and set UUID. + ACE_Utils::UUID goal_uuid; + ACE_Utils::UUID_GENERATOR::instance ()->generateUUID (goal_uuid); + this->goal_.UUID = CORBA::string_dup (goal_uuid.to_string()->c_str()); + + // Provide default name. + this->goal_.name = "DefaultGoalName"; + + // Create default time. + ::CIAO::RACE::TimeValue def_time; + def_time.sec = 0; + def_time.usec = 0; + + // Set start window to [default, default]. + this->goal_.startWindow.earliest = def_time; + this->goal_.startWindow.latest = def_time; +}; + // Constructor. DeployOption::DeployOption (std::string descrip, std::string undo_descrip, ::CIAO::RACE::SA_POP::Driver_ptr driver, diff --git a/SA_POP/server/client.h b/SA_POP/server/client.h index 0277acadf5c..737770a18de 100644 --- a/SA_POP/server/client.h +++ b/SA_POP/server/client.h @@ -122,6 +122,20 @@ namespace SA_POP { ::CIAO::RACE::SA_POP::Driver_ptr driver, ::CIAO::RACE::GoalStructure goal); + /// Constructor for a goal with only goal conditions. + /** + * @param descrip Description of option for display in UI. + * + * @param undo_descrip Description of undo option for display in UI. + * + * @param driver Pointer to SA-POP driver to use during option invocation. + * + * @param goal_conds Map from goal conditions to utilities. + */ + GoalOption (std::string descrip, std::string undo_descrip, + ::CIAO::RACE::SA_POP::Driver_ptr driver, + ::SA_POP::GoalMap goal_conds); + /// Destructor. virtual ~GoalOption (void); @@ -142,6 +156,12 @@ namespace SA_POP { * @return True if undo succeeded; otherwise false. */ virtual bool undo (void); + + /// Create and set internal goal using specified goal conditions & defaults. + /** + * @param goal_conds Map from goal condition IDs to utilities. + */ + virtual void create_def_goal (const ::SA_POP::GoalMap goal_conds); }; /** diff --git a/SA_POP/server/server.cpp b/SA_POP/server/server.cpp index 317629c3c43..11bf581c2f4 100644 --- a/SA_POP/server/server.cpp +++ b/SA_POP/server/server.cpp @@ -10,7 +10,7 @@ const char *taskmap_str = ""; int parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "o:r:"); + ACE_Get_Opt get_opts (argc, argv, "o:r:s:t:"); int c; while ((c = get_opts ()) != -1) -- cgit v1.2.1