summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-11-06 04:50:12 +0000
committerjkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-11-06 04:50:12 +0000
commit68a189404702e0148ecd1bca3e7a8dff990eb4de (patch)
tree95bf96c0a1fc5d6ac43d464a14849d8bbcb488cb
parent95cbd3a8b0e6ae42e8ba3ea05e470b578722b6c4 (diff)
downloadATCD-68a189404702e0148ecd1bca3e7a8dff990eb4de.tar.gz
Mon Nov 6 04:42:43 UTC 2006 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
-rw-r--r--ChangeLog15
-rw-r--r--SA_POP/SA_POP.mpc21
-rw-r--r--SA_POP/SA_POP_Types.h4
-rw-r--r--SA_POP/SA_WorkingPlan.cpp4
-rw-r--r--SA_POP/server/Driver.cpp384
-rw-r--r--SA_POP/server/Driver.h38
-rw-r--r--SA_POP/server/Driver.mpc17
-rw-r--r--SA_POP/server/server.cpp14
-rw-r--r--common/OpString.idl8
9 files changed, 467 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index ed80ef617d9..e4de556e2c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Mon Nov 6 04:42:43 UTC 2006 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
+
+ * common/OpString.idl:
+
+ * SA_POP/SA_POP.mpc:
+ * SA_POP/SA_POP_Types.h:
+ * SA_POP/SA_WorkingPlan.cpp:
+
+ * SA_POP/server/Driver.h:
+ * SA_POP/server/Driver.cpp:
+ * SA_POP/server/Driver.mpc:
+ * SA_POP/server/server.cpp:
+
+ Updated SA-POP driver/server to handle IDL goal structure.
+
Sat Nov 4 19:07:07 UTC 2006 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
* SA_POP/Driver.cpp:
diff --git a/SA_POP/SA_POP.mpc b/SA_POP/SA_POP.mpc
index 0f8690e0c47..116be7a2800 100644
--- a/SA_POP/SA_POP.mpc
+++ b/SA_POP/SA_POP.mpc
@@ -1,19 +1,11 @@
-project(SA_POP_Driver) : ciao_component_dnc, ciao_race_component, \
- taoexe, ciao_plan_generator, \
- ciao_config_handlers, xerces {
+project(SA_POP) : ciao_config_handlers, xerces {
- after += Interactive_Input_Adapter_stub OpString_stub XSC_Config_Handlers
- exename = driver
+ after += XSC_Config_Handlers
+ sharedname = SA_POP
- includes += $(CIAO_ROOT)/RACE/Input_Adapters/Interactive_Input_Adapter \
- $(CIAO_ROOT)/tools/Config_Handlers \
+ includes += $(CIAO_ROOT)/tools/Config_Handlers \
$(CIAO_ROOT)/RACE/SA_POP
- libs += Interactive_Input_Adapter_stub \
- Input_Adapter_stub \
- Plan_Analyzer_Interface_stub\
- OpString_stub
-
macros = SA_POP_HAS_ACE SA_POP_HAS_CIAO
@@ -21,8 +13,6 @@ project(SA_POP_Driver) : ciao_component_dnc, ciao_race_component, \
}
Header_Files {
- Converter.h
-
SA_POP_Types.h
SA_POP_Exceptions.h
@@ -59,9 +49,6 @@ project(SA_POP_Driver) : ciao_component_dnc, ciao_race_component, \
}
Source_Files {
- Converter.cpp
- Driver.cpp
-
SA_POP_Exceptions.cpp
SA_Builder.cpp
diff --git a/SA_POP/SA_POP_Types.h b/SA_POP/SA_POP_Types.h
index b215d9eb2e9..532efdcb5fa 100644
--- a/SA_POP/SA_POP_Types.h
+++ b/SA_POP/SA_POP_Types.h
@@ -441,10 +441,10 @@ namespace SA_POP {
// Start-by and end-by constraints on conditions, in relative time
// (relative to start of opstring to achieve this goal).
- TimeConstraintMap rel_time_constraints;
+ TimeConstraintMap rel_times;
// Start-by and end-by constraints on conditions, in clock time.
- TimeConstraintMap abs_time_constraints;
+ TimeConstraintMap abs_times;
// Expected time range for start of opstring (for achieving this goal)
// execution.
diff --git a/SA_POP/SA_WorkingPlan.cpp b/SA_POP/SA_WorkingPlan.cpp
index b0860dd1b66..3c009856b04 100644
--- a/SA_POP/SA_WorkingPlan.cpp
+++ b/SA_POP/SA_WorkingPlan.cpp
@@ -41,8 +41,8 @@ add_threats_cmd_ (0)
// Clear goal.
this->goal_.goal_id = "NULL";
this->goal_.name = "NULL";
- this->goal_.abs_time_constraints.clear ();
- this->goal_.rel_time_constraints.clear ();
+ this->goal_.abs_times.clear ();
+ this->goal_.rel_times.clear ();
this->goal_.goal_conds.clear ();
this->goal_.start_window = std::make_pair (0, 0);
diff --git a/SA_POP/server/Driver.cpp b/SA_POP/server/Driver.cpp
index 501924b9941..1492b272c5d 100644
--- a/SA_POP/server/Driver.cpp
+++ b/SA_POP/server/Driver.cpp
@@ -1,4 +1,15 @@
+#include <iostream>
+
#include "Driver.h"
+#include "ace/UUID.h"
+
+#include "SA_POP_Types.h"
+#include "SA_Builder.h"
+#include "TaskMapFileIn.h"
+#include "SANet/SANetFileIn.h"
+#include "Planner.h"
+#include "LogScreenOut.h"
+
namespace CIAO
{
@@ -9,16 +20,19 @@ namespace CIAO
{
Driver_i::Driver_i (CORBA::ORB_ptr orb)
: orb_ (CORBA::ORB::_duplicate (orb)),
- iia_name_ ("RACE::InteractiveInput")
+ iia_name_ ("RACE::InteractiveInput"),
+ planner_ (0),
+ screen_out_ (std::cout)
{
}
Driver_i::~Driver_i (void)
{
+ delete this->planner_;
}
int
- Driver_i::init (const char *RM_name)
+ Driver_i::init (const char *RM_name, const char *sanet_str, const char *taskmap_str)
{
try
{
@@ -47,6 +61,20 @@ namespace CIAO
// Now initialize the plan generator.
// this->plan_gen_.init (this->orb_, true, RM_name);
+
+ // Create SA-POP planner.
+ ::SA_POP::SA_Builder builder;
+ ::SANet::SANetFileIn sanet_in;
+ ::SA_POP::TaskMapFileIn tm_in;
+
+ sanet_in.build_net (sanet_str, &builder);
+ tm_in.build_task_map (taskmap_str, &builder);
+
+ this->planner_ = builder.get_planner ();
+
+ // Add screen output adapter to planner.
+ this->planner_->add_out_adapter (&(this->screen_out_));
+
return 0;
}
catch (CORBA::Exception &ex)
@@ -79,14 +107,40 @@ namespace CIAO
}
void
- Driver_i::deploy_goal (const ::CIAO::RACE::GoalStructure &)
+ Driver_i::deploy_goal (const ::CIAO::RACE::GoalStructure &goal_idl)
throw (::CORBA::SystemException)
{
+ try
+ {
+ // Convert goal.
+ ::SA_POP::Goal goal;
+ this->goal_from_idl (goal_idl, goal);
+
+ // Run planner (with a maximum of 100 steps of spreading activation).
+ this->planner_->plan (100, goal);
+
+ // Get and convert opstring.
+ ::SA_POP::Plan opstring = this->planner_->get_plan ();
+ ::CIAO::RACE::OperationalString opstring_idl;
+ this->opstring_to_idl (opstring, opstring_idl);
+ opstring_idl.goal = goal_idl;
+
+ // Convert opstring to deployment plan and deploy.
+ ::Deployment::DeploymentPlan deploy_plan;
+ if (this->opstring_to_dplan (opstring_idl, deploy_plan) == 0)
+ this->deploy_plan (deploy_plan);
+ else
+ throw "CIAO::RACE::Driver_i::deploy_goal(): Could not convert opstring to deployment plan.";
+ }
+ catch (...)
+ {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) Unknown exception\n"));
+ }
}
int
- Driver_i::convert (::CIAO::RACE::OperationalString &op_string,
- ::Deployment::DeploymentPlan &plan)
+ Driver_i::opstring_to_dplan (::CIAO::RACE::OperationalString &op_string,
+ ::Deployment::DeploymentPlan &plan)
{
// Populate the label, UUID, connections, and info property fields of
// the deployment plan.
@@ -139,6 +193,326 @@ namespace CIAO
return 0;
}
+ void Driver_i::opstring_to_idl (const ::SA_POP::Plan &opstring,
+ OperationalString &opstring_idl)
+ {
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get ID from Goal or Plan)
+ // Create and set the opstring_idl ID.
+ ACE_Utils::UUID uuid;
+ ACE_Utils::UUID_GENERATOR::instance ()->generateUUID (uuid);
+ opstring_idl.UUID = CORBA::string_dup (uuid.to_string()->c_str ());
+ //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Set opstring_idl name.
+ opstring_idl.name = CORBA::string_dup (opstring.name.c_str ());
+
+ // Set opstring_idl time windows.
+ opstring_idl.startWindow.earliest.sec = opstring.start_window.first;
+ opstring_idl.startWindow.earliest.usec = 0;
+ opstring_idl.startWindow.latest.sec = opstring.start_window.second;
+ opstring_idl.startWindow.latest.usec = 0;
+ opstring_idl.endWindow.earliest.sec = opstring.end_window.first;
+ opstring_idl.endWindow.earliest.usec = 0;
+ opstring_idl.endWindow.latest.sec = opstring.end_window.second;
+ opstring_idl.endWindow.latest.usec = 0;
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get from expected utility)
+// long priority;
+ // (Get from goal)
+// QoSSpecifications QoSRequirements;
+ // (???)
+// ::Deployment::Properties properties;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+
+ // Map from instance IDs to instance index.
+ typedef std::map <::SA_POP::TaskInstID, CORBA::ULong> InstToIndexMap;
+ InstToIndexMap inst_to_index;
+ inst_to_index.clear ();
+
+ // Add instances to opstring_idl.
+ for (::SA_POP::PlanInstSet::const_iterator inst_iter = opstring.task_insts.begin ();
+ inst_iter != opstring.task_insts.end (); inst_iter++)
+ {
+ ::SA_POP::PlanTaskInst inst = *inst_iter;
+
+ // Instance description to populate.
+ CIAO::RACE::InstanceDescription inst_desc;
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get instance ID from instance in opstring)
+ // Create and set task instance ID.
+ ACE_Utils::UUID inst_uuid;
+ ACE_Utils::UUID_GENERATOR::instance ()->generateUUID (inst_uuid);
+ inst_desc.UUID = CORBA::string_dup (inst_uuid.to_string()->c_str());
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get from repoman)
+// ::Deployment::Properties configProperty;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Set instance name, task ID, supported type ID, and suggested implementation ID.
+ inst_desc.name = CORBA::string_dup (inst.name.c_str());
+ inst_desc.taskId = CORBA::string_dup (::SA_POP::to_string (inst.task_id).c_str ());
+ inst_desc.taskTypeId = CORBA::string_dup (inst.type_id.c_str ());
+ inst_desc.suggestedImpl = CORBA::string_dup (inst.suggested_impl.c_str ());
+
+ // Set instance time windows.
+ inst_desc.startWindow.earliest.sec = inst.start_window.first;
+ inst_desc.startWindow.earliest.usec = 0;
+ inst_desc.startWindow.latest.sec = inst.start_window.second;
+ inst_desc.startWindow.latest.usec = 0;
+ inst_desc.endWindow.earliest.sec = inst.end_window.first;
+ inst_desc.endWindow.earliest.usec = 0;
+ inst_desc.endWindow.latest.sec = inst.end_window.second;
+ inst_desc.endWindow.latest.usec = 0;
+
+ // Add instance to opstring_idl and record index.
+ CORBA::ULong inst_len = opstring_idl.instances.length ();
+ opstring_idl.instances.length (inst_len + 1);
+ opstring_idl.instances[inst_len] = inst_desc;
+ inst_to_index.insert (std::make_pair (inst.inst_id, inst_len));
+ }
+
+ // Add opstring data links.
+ CORBA::ULong conns_index = 0;
+ for (::SA_POP::PlanConnSet::const_iterator conn_iter = opstring.connections.begin ();
+ conn_iter != opstring.connections.end (); conn_iter++)
+ {
+ ::SA_POP::PlanConnection conn = *conn_iter;
+
+ // Connection description to populate.
+ Deployment::PlanConnectionDescription conn_desc;
+
+ // Get opstring instance and port IDS for connection.
+ ::SA_POP::TaskInstID taskA = conn.first_task_inst;
+ ::SA_POP::TaskInstID taskB = conn.second_task_inst;
+ ::SA_POP::PortID taskAport = conn.first_port;
+ ::SA_POP::PortID taskBport = conn.second_port;
+
+ // Get deployment opstring instances (port IDs are the same).
+ InstToIndexMap::iterator taskA_iter = inst_to_index.find (taskA);
+ CORBA::ULong taskAinst = taskA_iter->second;
+ InstToIndexMap::iterator taskB_iter = inst_to_index.find (taskB);
+ CORBA::ULong taskBinst = taskB_iter->second;
+
+ // Create connection name.
+ std::string conn_name = "";
+ conn_name += ::SA_POP::to_string (static_cast<unsigned long>(taskAinst));
+ conn_name += "_";
+ conn_name += taskAport;
+ conn_name += "___";
+ conn_name += ::SA_POP::to_string (static_cast<unsigned long>(taskBinst));
+ conn_name += "_";
+ conn_name += taskBport;
+
+ // Create connection endpoints.
+ conn_desc.internalEndpoint.length (2);
+ conn_desc.internalEndpoint[0].instanceRef = taskAinst;
+ conn_desc.internalEndpoint[0].portName = CORBA::string_dup (taskAport.c_str ());
+ conn_desc.internalEndpoint[0].provider = 1;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get kind from data link in opstring)
+ conn_desc.internalEndpoint[0].kind = Deployment::EventEmitter;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ conn_desc.internalEndpoint[1].instanceRef = taskBinst;
+ conn_desc.internalEndpoint[1].portName = CORBA::string_dup (taskBport.c_str ());
+ conn_desc.internalEndpoint[1].provider = 0;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+ // (Get kind from data link in opstring)
+ conn_desc.internalEndpoint[1].kind = Deployment::EventConsumer;
+//****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP
+
+ // Set connection name.
+ conn_desc.name = CORBA::string_dup (conn_name.c_str ());
+
+ // Add data link to opstring_idl.
+ opstring_idl.dataLinks.length (conns_index + 1);
+ opstring_idl.dataLinks[conns_index] = conn_desc;
+
+ // Increment connection index.
+ conns_index++;
+ }
+
+ // Add scheduling links.
+ CORBA::ULong links_index = 0;
+ for (::SA_POP::SchedLinkSet::const_iterator sched_iter = opstring.sched_links.begin ();
+ sched_iter != opstring.sched_links.end (); sched_iter++)
+ {
+ ::SA_POP::SchedLink link = *sched_iter;
+
+ // Link to populate.
+ CIAO::RACE::OrderLinkDescription link_desc;
+
+ // Set link type.
+ link_desc.type = CIAO::RACE::SCHEDULING;
+
+ // Get opstring instance and port IDS for link.
+ ::SA_POP::TaskInstID taskA = link.first;
+ ::SA_POP::TaskInstID taskB = link.second;
+
+ // Get deployment opstring instances (port IDs are the same).
+ InstToIndexMap::iterator taskA_iter = inst_to_index.find (taskA);
+ CORBA::ULong taskAinst = taskA_iter->second;
+ InstToIndexMap::iterator taskB_iter = inst_to_index.find (taskB);
+ CORBA::ULong taskBinst = taskB_iter->second;
+
+ // Create link name.
+ std::string link_name = "";
+ link_name += ::SA_POP::to_string (static_cast<unsigned long>(taskAinst));
+ link_name += "___";
+ link_name += ::SA_POP::to_string (static_cast<unsigned long>(taskBinst));
+
+ // Create link endpoints.
+ link_desc.internalEndpoint.length (2);
+ link_desc.internalEndpoint[0].instanceRef = taskAinst;
+ link_desc.internalEndpoint[0].provider = 1;
+ link_desc.internalEndpoint[1].instanceRef = taskBinst;
+ link_desc.internalEndpoint[1].provider = 0;
+
+ // Set link name.
+ link_desc.name = CORBA::string_dup (link_name.c_str ());
+
+ // Add data link to opstring_idl.
+ opstring_idl.orderLinks.length (links_index + 1);
+ opstring_idl.orderLinks[links_index] = link_desc;
+
+ // Increment link index.
+ links_index++;
+ }
+
+ // Add threat links.
+ links_index = opstring_idl.orderLinks.length ();
+ for (::SA_POP::ThreatLinkSet::const_iterator threat_iter = opstring.threat_links.begin ();
+ threat_iter != opstring.threat_links.end (); threat_iter++)
+ {
+ ::SA_POP::ThreatLink link = *threat_iter;
+
+ // Link to populate.
+ CIAO::RACE::OrderLinkDescription link_desc;
+
+ // Set link type.
+ link_desc.type = CIAO::RACE::THREAT;
+
+ // Get opstring instance and port IDS for link.
+ ::SA_POP::TaskInstID taskA = link.first;
+ ::SA_POP::TaskInstID taskB = link.second;
+
+ // Get deployment opstring instances (port IDs are the same).
+ InstToIndexMap::iterator taskA_iter = inst_to_index.find (taskA);
+ CORBA::ULong taskAinst = taskA_iter->second;
+ InstToIndexMap::iterator taskB_iter = inst_to_index.find (taskB);
+ CORBA::ULong taskBinst = taskB_iter->second;
+
+ // Create link name.
+ std::string link_name = "";
+ link_name += ::SA_POP::to_string (static_cast<unsigned long>(taskAinst));
+ link_name += "___";
+ link_name += ::SA_POP::to_string (static_cast<unsigned long>(taskBinst));
+
+ // Create link endpoints.
+ link_desc.internalEndpoint.length (2);
+ link_desc.internalEndpoint[0].instanceRef = taskAinst;
+ link_desc.internalEndpoint[0].provider = 1;
+ link_desc.internalEndpoint[1].instanceRef = taskBinst;
+ link_desc.internalEndpoint[1].provider = 0;
+
+ // Set link name.
+ link_desc.name = CORBA::string_dup (link_name.c_str ());
+
+ // Add data link to opstring_idl.
+ opstring_idl.orderLinks.length (links_index + 1);
+ opstring_idl.orderLinks[links_index] = link_desc;
+
+ // Increment link index.
+ links_index++;
+ }
+
+ // Add causal links.
+ links_index = opstring_idl.orderLinks.length ();
+ for (::SA_POP::CLSet::const_iterator cl_iter = opstring.causal_links.begin ();
+ cl_iter != opstring.causal_links.end (); cl_iter++)
+ {
+ ::SA_POP::CausalLink link = *cl_iter;
+
+ // Link to populate.
+ CIAO::RACE::OrderLinkDescription link_desc;
+
+ // Set link type.
+ link_desc.type = CIAO::RACE::CAUSAL;
+
+ // Get opstring instance and port IDS for link.
+ ::SA_POP::TaskInstID taskA = link.first;
+ ::SA_POP::TaskInstID taskB = link.second;
+
+ // Get deployment opstring instances (port IDs are the same).
+ InstToIndexMap::iterator taskA_iter = inst_to_index.find (taskA);
+ CORBA::ULong taskAinst = taskA_iter->second;
+ InstToIndexMap::iterator taskB_iter = inst_to_index.find (taskB);
+ CORBA::ULong taskBinst = taskB_iter->second;
+
+ // Create link name.
+ std::string link_name = "";
+ link_name += ::SA_POP::to_string (static_cast<unsigned long>(taskAinst));
+ link_name += "___";
+ link_name += ::SA_POP::to_string (static_cast<unsigned long>(taskBinst));
+
+ // Create link endpoints.
+ link_desc.internalEndpoint.length (2);
+ link_desc.internalEndpoint[0].instanceRef = taskAinst;
+ link_desc.internalEndpoint[0].provider = 1;
+ link_desc.internalEndpoint[1].instanceRef = taskBinst;
+ link_desc.internalEndpoint[1].provider = 0;
+
+ // Set link name.
+ link_desc.name = CORBA::string_dup (link_name.c_str ());
+
+ // Add data link to opstring_idl.
+ opstring_idl.orderLinks.length (links_index + 1);
+ opstring_idl.orderLinks[links_index] = link_desc;
+
+ // Increment link index.
+ links_index++;
+ }
+ };
+
+ void Driver_i::goal_from_idl (const GoalStructure &goal_idl,
+ ::SA_POP::Goal &goal)
+ {
+ // Set ID and name.
+ goal.goal_id = CORBA::string_dup (goal_idl.UUID);
+ goal.name = CORBA::string_dup (goal_idl.name);
+
+ // Set start window.
+ goal.start_window = std::make_pair (goal_idl.startWindow.earliest.sec,
+ goal_idl.startWindow.latest.sec);
+
+ // Add goal conditions.
+ ::CIAO::RACE::GoalConditions conds = goal_idl.goalConds;
+ for (CORBA::ULong i (0); i < conds.length (); ++i) {
+ goal.goal_conds.insert (std::make_pair (conds[i].condID,
+ conds[i].utility));
+ }
+
+ // Add relative time constraints.
+ ::CIAO::RACE::TimeConstraints rel_times = goal_idl.relTimes;
+ for (CORBA::ULong i (0); i < rel_times.length (); ++i) {
+ goal.rel_times.insert (std::make_pair (rel_times[i].condID,
+ rel_times[i].constraint.sec));
+ }
+
+ // Add absolute time constraints.
+ ::CIAO::RACE::TimeConstraints abs_times = goal_idl.absTimes;
+ for (CORBA::ULong i (0); i < abs_times.length (); ++i) {
+ goal.abs_times.insert (std::make_pair (abs_times[i].condID,
+ abs_times[i].constraint.sec));
+ }
+
+ };
+
int
Driver_i::deploy_plan (::Deployment::DeploymentPlan &plan)
{
diff --git a/SA_POP/server/Driver.h b/SA_POP/server/Driver.h
index ad626a0d34d..9db618d4862 100644
--- a/SA_POP/server/Driver.h
+++ b/SA_POP/server/Driver.h
@@ -8,6 +8,11 @@
#include "orbsvcs/CosNamingC.h"
#include "RACE/common/OpStringC.h"
#include "Plan_Generator_Impl.h"
+
+#include "SA_POP_Types.h"
+#include "Planner.h"
+#include "LogScreenOut.h"
+
namespace CIAO
{
namespace RACE
@@ -27,19 +32,38 @@ namespace CIAO
virtual ~Driver_i (void);
virtual
- int init (const char *RM_name);
+ int init (const char *RM_name, const char *sanet_str, const char *taskmap_str);
virtual
void deploy_plan (const char * plan_uri)
throw (::CORBA::SystemException);
virtual
- void deploy_goal (const ::CIAO::RACE::GoalStructure & goal)
+ void deploy_goal (const ::CIAO::RACE::GoalStructure & goal_idl)
throw (::CORBA::SystemException);
protected:
- virtual int convert (::CIAO::RACE::OperationalString &op_string,
- ::Deployment::DeploymentPlan &plan);
+ virtual int opstring_to_dplan (::CIAO::RACE::OperationalString &op_string,
+ ::Deployment::DeploymentPlan &plan);
+
+ /// Convert SA-POP operational string to IDL operational string.
+ /**
+ * @param opstring SA-POP operational string to convert.
+ *
+ * @param opstring_idl Empty IDL operational string structure
+ * to be populated.
+ */
+ virtual void opstring_to_idl (const ::SA_POP::Plan &opstring,
+ OperationalString &opstring_idl);
+
+ /// Convert IDL goal to SA-POP goal.
+ /**
+ * @param goal_idl IDL goal to convert.
+ *
+ * @param goal Empty SA-POP goal structure to be populated.
+ */
+ virtual void goal_from_idl (const GoalStructure &goal_idl,
+ ::SA_POP::Goal &goal);
virtual int deploy_plan (::Deployment::DeploymentPlan &plan);
@@ -57,6 +81,12 @@ namespace CIAO
// Plan generator object.
::CIAO::Plan_Generator::Plan_Generator_i plan_gen_;
+
+ // Pointer to SA-POP planner.
+ ::SA_POP::Planner *planner_;
+
+ // Screen output adapter for SA-POP.
+ ::SA_POP::LogScreenOut screen_out_;
};
}
}
diff --git a/SA_POP/server/Driver.mpc b/SA_POP/server/Driver.mpc
index cda776c32d5..6b401738ece 100644
--- a/SA_POP/server/Driver.mpc
+++ b/SA_POP/server/Driver.mpc
@@ -45,14 +45,23 @@ project(Driver_svnt): taolib_with_idl, ciao_race_default {
}
}
-project(Server): ciao_component_dnc, ciao_race_component, taoexe, ciao_plan_generator {
+project(Server): ciao_component_dnc, ciao_race_component, ciao_config_handlers, taoexe, ciao_plan_generator {
exename = server
- after += Driver_svnt
+
+ after += Driver_svnt SA_POP
+
+ includes += $(CIAO_ROOT)/RACE/Input_Adapters/Interactive_Input_Adapter \
+ $(CIAO_ROOT)/tools/Config_Handlers \
+ $(CIAO_ROOT)/RACE/SA_POP
+
libs += OpString_stub \
Driver_stub \
Driver_svnt \
- Interactive_Input_Adapter_stub
+ Interactive_Input_Adapter_stub \
+ Input_Adapter_stub \
+ Plan_Analyzer_Interface_stub \
+ SA_POP
IDL_Files {
}
@@ -70,7 +79,9 @@ project(Server): ciao_component_dnc, ciao_race_component, taoexe, ciao_plan_gene
project(client): taoclient, ciao_race_component, ciao_component_dnc {
exename = client
+
after += Driver_stub
+
libs += Driver_stub
IDL_Files {
diff --git a/SA_POP/server/server.cpp b/SA_POP/server/server.cpp
index 18556df7b2e..317629c3c43 100644
--- a/SA_POP/server/server.cpp
+++ b/SA_POP/server/server.cpp
@@ -4,6 +4,8 @@
const char *ior_output_file = "server.ior";
const char *rm_name = "RM";
+const char *sanet_str = "";
+const char *taskmap_str = "";
int
parse_args (int argc, char *argv[])
@@ -22,12 +24,22 @@ parse_args (int argc, char *argv[])
rm_name = get_opts.opt_arg ();
break;
+ case 's':
+ sanet_str = get_opts.opt_arg ();
+ break;
+
+ case 't':
+ taskmap_str = get_opts.opt_arg ();
+ break;
+
case '?':
default:
ACE_ERROR_RETURN ((LM_ERROR,
"usage: %s "
"-o <iorfile> "
"-r <repoman name>"
+ "-s <task network filename>"
+ "-t <task map filename>"
"\n",
argv [0]),
-1);
@@ -66,7 +78,7 @@ main (int argc, char *argv[])
ACE_NEW_RETURN (driver_impl,
::CIAO::RACE::SA_POP::Driver_i (orb.in ()), 1);
- if (driver_impl->init (rm_name) != 0)
+ if (driver_impl->init (rm_name, sanet_str, taskmap_str) != 0)
{
return -1;
diff --git a/common/OpString.idl b/common/OpString.idl
index 89320eef097..c50ad20bc22 100644
--- a/common/OpString.idl
+++ b/common/OpString.idl
@@ -22,10 +22,10 @@ module CIAO
struct TimeWindow
{
// Beginning of time window.
- CIAO::RACE::TimeValue Earliest;
+ CIAO::RACE::TimeValue earliest;
// End of time window.
- CIAO::RACE::TimeValue Latest;
+ CIAO::RACE::TimeValue latest;
};
// A task instance in an opstring.
@@ -178,10 +178,10 @@ module CIAO
// Start-by and end-by constraints on conditions, in relative time
// (relative to start of opstring to achieve this goal).
- TimeConstraints relativeTimeConstraints;
+ TimeConstraints relTimes;
// Start-by and end-by constraints on conditions, in clock time.
- TimeConstraints absoluteTimeConstraintns;
+ TimeConstraints absTimes;
// QoS requirements.
QoSSpecifications QoSRequirements;