|
From: <ma...@us...> - 2009-10-10 20:22:48
|
Revision: 415
http://scstudio.svn.sourceforge.net/scstudio/?rev=415&view=rev
Author: madzin
Date: 2009-10-10 20:22:38 +0000 (Sat, 10 Oct 2009)
Log Message:
-----------
Add multiple time intervals for one connection point
Modified Paths:
--------------
trunk/src/data/Z120/Context.cpp
trunk/src/data/Z120/Context.h
trunk/src/data/Z120/Context_Impl.h
trunk/src/data/Z120/Z120.g
trunk/tests/z120_test/CMakeLists.txt
Added Paths:
-----------
trunk/tests/z120_test/z120_time12.mpr
Modified: trunk/src/data/Z120/Context.cpp
===================================================================
--- trunk/src/data/Z120/Context.cpp 2009-10-10 15:00:30 UTC (rev 414)
+++ trunk/src/data/Z120/Context.cpp 2009-10-10 20:22:38 UTC (rev 415)
@@ -79,6 +79,10 @@
context->future_top_time_relations.clear();
context->not_connect = 0;
context->origin = false;
+
+ context->time_first = unknown;
+ context->time_second = unknown;
+ context->time_event = false;
}
/*
@@ -675,6 +679,11 @@
context->open_instance--;
}
+void set_time_event_fun(struct Context* context)
+{
+ context->time_event = true;
+}
+
void add_time_relation_event_fun(struct Context* context)
{
TimeRelationEventPtr relation;
@@ -721,7 +730,7 @@
void set_time_reference_event_fun(struct Context* context, char* name)
{
context->time_event_name = name;
- context->time_relation_type = unknown;
+ context->time_second = unknown;
}
void create_future_time_relations(struct Context* context)
@@ -1046,13 +1055,6 @@
}
}
-/*
- * Set time_relation_type to define where the time interval should be connected
- */
-void set_time_ref_relation_type_fun(struct Context* context, enum time_relation_kind time_relation_type)
-{
- context->time_relation_type = time_relation_type;
-}
/*
* Set time_ to define where the time interval should be connected
@@ -1088,19 +1090,23 @@
/*
* Set time interval between current node and another node.
- *
- * Kind defines where the time interval is defined on the current node
- * context->time_relation_type defines where the time interval is defined on the other node.
*/
-void add_time_relation_ref_fun(struct Context* context, enum time_relation_kind kind)
+void add_time_relation_ref_fun(struct Context* context)
{
- if(context->time_relation_type == unknown)
+ if(context->time_event)
{
+ add_time_relation_event_fun(context);
+ context->time_event = false;
+ return ;
+ }
+
+ if(context->time_second == unknown)
+ {
context->z->print_report(RS_WARNING, stringize() << "Warning 25: Time definition in " << TOWSTRING(context->element_name) << " has only one connection point");
- context->time_relation_type = kind;
+ context->time_second = context->time_first;
context->time_node_name = context->time_event_name;
}
-
+
TimeRelationRefNodePtr relation;
try
{
@@ -1135,14 +1141,16 @@
context->z->print_report(RS_ERROR, L"Warning 23: Time information can be defined only to a reference node\n");
return ;
}
-
- relation->glue_ref_nodes(kind == bottom, node.get(), context->time_relation_type == bottom, node2.get());
+/* check for z120_time08.mpr */
+//if(node2 == node) { std::cout << "connection points " << (context->time_first==bottom) << " " << (context->time_second==bottom) << std::endl;}
+/* */
+ relation->glue_ref_nodes(context->time_first == bottom, node.get(), context->time_second == bottom, node2.get());
}
else
{
- relation->glue_ref_node_a(kind == bottom, node.get());
+ relation->glue_ref_node_a(context->time_first == bottom, node.get());
- if(context->time_relation_type == top)
+ if(context->time_second == top)
{
std::map<std::string, std::set<TimeRelationRefNodePtr> >::iterator top_it;
top_it = context->future_top_time_relations.find(context->time_node_name);
@@ -1173,9 +1181,25 @@
}
}
- context->time_relation_type = unknown;
+ context->time_second = unknown;
}
+/*
+ * Set time_first to define where the time interval should be connected
+ */
+void set_first_time_rel_kind_fun(struct Context* context, enum time_relation_kind kind)
+{
+ context->time_first = kind;
+}
+
+/*
+ * Set time_second to define where the time interval should be connected
+ */
+void set_second_time_rel_kind_fun(struct Context* context, enum time_relation_kind time_relation_type)
+{
+ context->time_second = time_relation_type;
+}
+
#endif
// $Id$
Modified: trunk/src/data/Z120/Context.h
===================================================================
--- trunk/src/data/Z120/Context.h 2009-10-10 15:00:30 UTC (rev 414)
+++ trunk/src/data/Z120/Context.h 2009-10-10 20:22:38 UTC (rev 415)
@@ -89,6 +89,8 @@
void end_instance_fun(struct Context* context);
+void set_time_event_fun(struct Context* context);
+
void add_time_relation_event_fun(struct Context* context);
void set_time_reference_event_fun(struct Context* context, char* name);
@@ -120,14 +122,16 @@
void future_connection_fill_in_fun(struct Context* context);
-void set_time_ref_relation_type_fun(struct Context* context, enum time_relation_kind time_relation_type);
-
void set_time_reference_node_fun(struct Context* context, char* name);
void add_time_relation_ref_time_fun(struct Context* context);
-void add_time_relation_ref_fun(struct Context* context, enum time_relation_kind kind);
+void add_time_relation_ref_fun(struct Context* context);
+void set_first_time_rel_kind_fun(struct Context* context, enum time_relation_kind kind);
+
+void set_second_time_rel_kind_fun(struct Context* context, enum time_relation_kind kind);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/src/data/Z120/Context_Impl.h
===================================================================
--- trunk/src/data/Z120/Context_Impl.h 2009-10-10 15:00:30 UTC (rev 414)
+++ trunk/src/data/Z120/Context_Impl.h 2009-10-10 20:22:38 UTC (rev 415)
@@ -78,6 +78,7 @@
EventPtr current_event; //event which was currently created
std::string event_name; //name of event
std::string time_event_name; //name of event on which points a reference in the time relation
+ bool time_event;
int not_create_event; //flag for event in case msc has two labeled event with the same name
int no_message_label; //flag for message which does not have label
int open_instance; //counter of open instances
@@ -100,10 +101,12 @@
std::map<std::string, std::set<TimeRelationRefNodePtr> > future_bottom_time_relations;
enum hmsc_node_type node_type; //flag to recognize HMsc nodes (ConnectionNode, ReferenceNode, ConditionNode).
- enum time_relation_kind time_relation_type;
std::string time_node_name;
int not_connect;
+ enum time_relation_kind time_first;
+ enum time_relation_kind time_second;
+
~Context() {}
};
Modified: trunk/src/data/Z120/Z120.g
===================================================================
--- trunk/src/data/Z120/Z120.g 2009-10-10 15:00:30 UTC (rev 414)
+++ trunk/src/data/Z120/Z120.g 2009-10-10 20:22:38 UTC (rev 415)
@@ -413,10 +413,7 @@
{
add_relation_fun(context, after);
})? end
- ('time' time_dest_list end
- {
- add_time_relation_event_fun(context);
- })?
+ ( {set_time_event_fun(context);} 'time' time_dest_list end )?
{
set_not_create_event_fun(context);
@@ -429,14 +426,14 @@
time_dest_list:
(time_dest ('origin' { set_origin_fun(context); } )?)?
- time_interval (',' time_dest_list)?
+ time_interval { add_time_relation_ref_fun(context); } (',' time_dest_list)?
;
time_dest:
NAME {set_time_reference_event_fun(context, (char*) $NAME.text->chars);}
|
- ('top' { set_time_ref_relation_type_fun(context, top); }
- | 'bottom' { set_time_ref_relation_type_fun(context, bottom); })
+ ('top' { set_second_time_rel_kind_fun(context, top); }
+ | 'bottom' { set_second_time_rel_kind_fun(context, bottom); })
(reference_identification | NAME { set_time_reference_node_fun(context, (char*) $NAME.text->chars);} )
;
@@ -1111,8 +1108,16 @@
;
*/
+/* Where an interval label is used, the keyword int_boundary must appear in the programming
+representation, and must be absent in the graphical representation.
+*/
+
+//interval_label:
+// ('int_boundary')? NAME
+//;
+
interval_label:
- ('int_boundary')? NAME
+ ('int_boundary') NAME
;
singular_time:
@@ -1522,11 +1527,12 @@
condition_identification (shared)?
;
+//Peter's reguirements to allow multiple definition of top or bottom time information
timeable_node:
(hmsc_ref_expr_node { new_reference_node_fun(context); } | hmsc_expression)
('time' time_interval end { add_time_relation_ref_time_fun(context); })?
- ('top' time_dest_list end { add_time_relation_ref_fun(context, top); })?
- ('bottom' time_dest_list end { add_time_relation_ref_fun(context, bottom); })?
+ ( ('top'{ set_first_time_rel_kind_fun(context, top);} time_dest_list end) |
+ ('bottom' { set_first_time_rel_kind_fun(context, bottom);} time_dest_list end) )*
;
hmsc_ref_expr_node:
Modified: trunk/tests/z120_test/CMakeLists.txt
===================================================================
--- trunk/tests/z120_test/CMakeLists.txt 2009-10-10 15:00:30 UTC (rev 414)
+++ trunk/tests/z120_test/CMakeLists.txt 2009-10-10 20:22:38 UTC (rev 415)
@@ -98,6 +98,7 @@
ADD_Z120_TEST(z120_time09.mpr 1)
ADD_Z120_TEST(z120_time10.mpr 1)
ADD_Z120_TEST(z120_time11.mpr 1)
+ADD_Z120_TEST(z120_time12.mpr 1)
# $Id$
Added: trunk/tests/z120_test/z120_time12.mpr
===================================================================
--- trunk/tests/z120_test/z120_time12.mpr (rev 0)
+++ trunk/tests/z120_test/z120_time12.mpr 2009-10-10 20:22:38 UTC (rev 415)
@@ -0,0 +1,37 @@
+/* Basic time constraints in both MSC and HMSC
+ */
+mscdocument z120_time01;
+msc Main;
+initial connect L0;
+L0: connect L1, L2;
+L1: reference Subprocess connect L3, L4;
+L4: reference Fish connect L3;
+L2: reference Subprocess time [1,2);
+top bottom L1 (1,10), top L4 [2,4];
+connect L1;
+L3: final;
+endmsc;
+msc Subprocess;
+inst P1;
+inst P2;
+P1: instance;
+out NAME,0 to P2;
+label e0;
+out NAME,1 to P2;
+time e1 [7];
+label e1;
+in NAME,2 from P2;
+endinstance;
+P2: instance;
+concurrent;
+label e2;
+in NAME,0 from P1 before e3;
+time e4 [12];
+label e3;
+in NAME,1 from P1;
+endconcurrent;
+label e4;
+out NAME,2 to P1;
+endinstance;
+endmsc;
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|