|
From: <ma...@us...> - 2012-07-08 21:37:05
|
Revision: 1439
http://scstudio.svn.sourceforge.net/scstudio/?rev=1439&view=rev
Author: madzin
Date: 2012-07-08 21:36:59 +0000 (Sun, 08 Jul 2012)
Log Message:
-----------
Due to action and conditions were added to the internal structure. The import was extended to create these objects.
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/src/data/Z120/z120_save.cpp
trunk/tests/z120_test/CMakeLists.txt
Added Paths:
-----------
trunk/tests/z120_test/z120_test94.mpr
trunk/tests/z120_test/z120_test94.mpr.result
Modified: trunk/src/data/Z120/Context.cpp
===================================================================
--- trunk/src/data/Z120/Context.cpp 2012-06-27 11:49:42 UTC (rev 1438)
+++ trunk/src/data/Z120/Context.cpp 2012-07-08 21:36:59 UTC (rev 1439)
@@ -22,7 +22,7 @@
*/
/*
- * Maximal number of warning/error message is 33
+ * Maximal number of warning/error message is 34
*/
#ifndef __ParserStruct__
@@ -680,6 +680,135 @@
}
/*
+ * Add new local action
+ */
+void add_action_fun(struct Context* context, char* action_statement)
+{
+ std::string statement(action_statement);
+ InstancePtr instance;
+
+ std::map<std::string, InstancePtr>::iterator inst_it;
+ inst_it = context->instances.find(context->element_name);
+
+ if(inst_it == context->instances.end())
+ {
+ instance = new Instance(TOWSTRING(context->element_name));
+ context->instances.insert(std::make_pair(context->element_name, instance));
+ context->myBmsc->add_instance(instance);
+ context->open_instance++;
+ context->z->print_report(RS_WARNING,
+ stringize() << "Warning 23: Instance (" << TOWSTRING(context->element_name) << ") has not been started (e.g. " << TOWSTRING(context->element_name) << ": instance;)");
+ }
+ else
+ {
+ instance = inst_it->second;
+ }
+
+ if (instance->get_last() == NULL ||
+ context->coregion_area_finished.find(context->element_name) != context->coregion_area_finished.end())
+ {
+ StrictOrderAreaPtr strict(new StrictOrderArea());
+ instance->add_area(strict);
+ context->coregion_area_finished.erase(context->element_name);
+ }
+
+ std::map<std::string, EventPtr>::iterator event_it;
+ EventPtr event;
+
+ //if the event was created prematurely
+ if(context->event_name == "" ||
+ (event_it = context->future_events.find(context->event_name)) == context->future_events.end())
+ {
+ event = instance->get_last()->add_event();
+ }
+ else
+ {
+ event = event_it->second;
+ context->future_events.erase(event_it);
+ }
+
+ context->current_event = event;
+
+ LocalActionPtr action = new LocalAction(TOWSTRING(statement));
+ action->glue_event(event);
+
+ //if event is named, it adds event to named_events
+ if(context->event_name != "")
+ {
+ context->named_events.insert(std::make_pair(context->event_name, event));
+ }
+
+ create_future_time_relations(context);
+ context->event_name = "";
+}
+
+/*
+ * Add new condition
+ */
+void add_condition_fun(struct Context* context)
+{
+ InstancePtr instance;
+
+ std::map<std::string, InstancePtr>::iterator inst_it;
+ inst_it = context->instances.find(context->element_name);
+
+ if(inst_it == context->instances.end())
+ {
+ instance = new Instance(TOWSTRING(context->element_name));
+ context->instances.insert(std::make_pair(context->element_name, instance));
+ context->myBmsc->add_instance(instance);
+ context->open_instance++;
+ context->z->print_report(RS_WARNING,
+ stringize() << "Warning 23: Instance (" << TOWSTRING(context->element_name) << ") has not been started (e.g. " << TOWSTRING(context->element_name) << ": instance;)");
+ }
+ else
+ {
+ instance = inst_it->second;
+ }
+
+ if (instance->get_last() == NULL ||
+ context->coregion_area_finished.find(context->element_name) != context->coregion_area_finished.end())
+ {
+ StrictOrderAreaPtr strict(new StrictOrderArea());
+ instance->add_area(strict);
+ context->coregion_area_finished.erase(context->element_name);
+ }
+
+ std::map<std::string, EventPtr>::iterator event_it;
+ EventPtr event;
+
+ //if the event was created prematurely
+ if(context->event_name == "" ||
+ (event_it = context->future_events.find(context->event_name)) == context->future_events.end())
+ {
+ event = instance->get_last()->add_event();
+ }
+ else
+ {
+ event = event_it->second;
+ context->future_events.erase(event_it);
+ }
+
+ context->current_event = event;
+
+ if(context->condition_shared_inst.size() > 1)
+ context->z->print_report(RS_WARNING,
+ stringize() << "Warning 34: Condition across multiple instances is not supported yet.");
+
+ LocalConditionPtr local_condition = new LocalCondition(TOWSTRING(context->condition_name));
+ local_condition->glue_event(event);
+
+ //if event is named, it adds event to named_events
+ if(context->event_name != "")
+ {
+ context->named_events.insert(std::make_pair(context->event_name, event));
+ }
+
+ create_future_time_relations(context);
+ context->event_name = "";
+}
+
+/*
* Add name to order_events
*/
void add_order_event_fun(struct Context* context, char* name){
@@ -1153,6 +1282,21 @@
context->condition_name = "";
}
+void clear_shared_inst(struct Context* context)
+{
+ context->condition_shared_inst.clear();
+}
+
+void add_shared_inst(struct Context* context, char* inst)
+{
+ std::string instance(inst);
+
+ if(instance == "")
+ context->condition_shared_inst.push_back(context->element_name);
+ else
+ context->condition_shared_inst.push_back(instance);
+}
+
/*
* Set name of node
*/
Modified: trunk/src/data/Z120/Context.h
===================================================================
--- trunk/src/data/Z120/Context.h 2012-06-27 11:49:42 UTC (rev 1438)
+++ trunk/src/data/Z120/Context.h 2012-07-08 21:36:59 UTC (rev 1439)
@@ -81,6 +81,10 @@
void incomplete_message_fun(struct Context* context, char* msg_identifications, enum msg_kind kind);
+void add_action_fun(struct Context* context, char* action_statement);
+
+void add_condition_fun(struct Context* context);
+
void new_instance_fun(struct Context* context);
void start_coregion_fun(struct Context* context);
@@ -137,6 +141,10 @@
void clear_condition_name_fun(struct Context* context);
+void clear_shared_inst(struct Context* context);
+
+void add_shared_inst(struct Context* context, char* inst);
+
void set_node_name_fun(struct Context* context, char* name);
void add_connect_name_fun(struct Context* context, char* name);
Modified: trunk/src/data/Z120/Context_Impl.h
===================================================================
--- trunk/src/data/Z120/Context_Impl.h 2012-06-27 11:49:42 UTC (rev 1438)
+++ trunk/src/data/Z120/Context_Impl.h 2012-07-08 21:36:59 UTC (rev 1439)
@@ -122,6 +122,9 @@
std::string reference_name;
std::string condition_name;
+ std::vector<std::string> condition_shared_inst; // array of instances for which the condition is applied
+
+
HMscNodePtr current_node;
std::map<std::string, HMscNodePtr> hmsc_nodes; // map of hmsc nodes (key: name of node, value: smart pointer to node)
Modified: trunk/src/data/Z120/Z120.g
===================================================================
--- trunk/src/data/Z120/Z120.g 2012-06-27 11:49:42 UTC (rev 1438)
+++ trunk/src/data/Z120/Z120.g 2012-07-08 21:36:59 UTC (rev 1439)
@@ -799,6 +799,7 @@
shared_condition:
(shared)? condition_identification shared end
+ {add_condition_fun(context);}
;
condition_identification:
@@ -813,7 +814,7 @@
(condition_name_list { set_condition_name_fun(context, (char*) $condition_name_list.text->chars); }
| expr = ( '(' expression ')' ) { set_condition_name_fun(context, (char*) $expr.text->chars); }
)
-
+
| 'otherwise' { set_condition_name_fun(context, "otherwise"); }
// *** proprietary Z.120 extension
@@ -826,11 +827,15 @@
;
shared:
- 'shared' ((shared_instance_list)? | 'all')
+ { clear_shared_inst(context);}
+ { add_shared_inst(context, "");} //add current instance
+
+ 'shared' ((shared_instance_list)? | 'all' {add_shared_inst(context, "all");})
;
shared_instance_list:
- NAME (',' shared_instance_list)?
+ NAME {add_shared_inst(context, (char*) $NAME.text->chars);}
+ (',' shared_instance_list)?
;
condition:
@@ -872,6 +877,7 @@
action:
'action' action_statement
+ {add_action_fun(context, (char*) $action_statement.text->chars);}
;
/* if needed
Modified: trunk/src/data/Z120/z120_save.cpp
===================================================================
--- trunk/src/data/Z120/z120_save.cpp 2012-06-27 11:49:42 UTC (rev 1438)
+++ trunk/src/data/Z120/z120_save.cpp 2012-07-08 21:36:59 UTC (rev 1439)
@@ -384,7 +384,7 @@
LocalAction* act = dynamic_cast<LocalAction*>(incomplete_message.get());
LocalCondition* cond = dynamic_cast<LocalCondition*>(incomplete_message.get());
if(act != NULL)
- stream << "action " << VALID_NAME(act->get_label());
+ stream << "action '" << VALID_NAME(act->get_label()) << "'";
else if(cond != NULL)
stream << "condition " << VALID_NAME(cond->get_label()) << " shared";
else
Modified: trunk/tests/z120_test/CMakeLists.txt
===================================================================
--- trunk/tests/z120_test/CMakeLists.txt 2012-06-27 11:49:42 UTC (rev 1438)
+++ trunk/tests/z120_test/CMakeLists.txt 2012-07-08 21:36:59 UTC (rev 1439)
@@ -101,6 +101,7 @@
ADD_Z120_TEST(z120_test91.mpr 0)
ADD_Z120_TEST(z120_test92.mpr 1)
ADD_Z120_TEST(z120_test93.mpr 1)
+ADD_Z120_TEST(z120_test94.mpr 1)
ADD_Z120_TEST(z120_time01.mpr 1)
ADD_Z120_TEST(z120_time02.mpr 1)
Added: trunk/tests/z120_test/z120_test94.mpr
===================================================================
--- trunk/tests/z120_test/z120_test94.mpr (rev 0)
+++ trunk/tests/z120_test/z120_test94.mpr 2012-07-08 21:36:59 UTC (rev 1439)
@@ -0,0 +1,8 @@
+mscdocument Drawing1;
+msc Page_1;
+inst Instance1;
+Instance1: instance;
+action 'Action_test';
+condition Condition_test shared;
+endinstance;
+endmsc;
Added: trunk/tests/z120_test/z120_test94.mpr.result
===================================================================
--- trunk/tests/z120_test/z120_test94.mpr.result (rev 0)
+++ trunk/tests/z120_test/z120_test94.mpr.result 2012-07-08 21:36:59 UTC (rev 1439)
@@ -0,0 +1,10 @@
+OK: z120_test94 is correct, should be correct
+
+mscdocument z120_test94;
+msc Page_1;
+inst Instance1;
+Instance1: instance;
+action '_Action_test_';
+condition Condition_test shared;
+endinstance;
+endmsc;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|