|
From: <koc...@us...> - 2009-09-08 14:35:24
|
Revision: 284
http://scstudio.svn.sourceforge.net/scstudio/?rev=284&view=rev
Author: kocianon
Date: 2009-09-08 14:35:12 +0000 (Tue, 08 Sep 2009)
Log Message:
-----------
fixing constrain_check, segmentation fault - missing TimeRelationRefNode duplicator
Modified Paths:
--------------
trunk/CMakeLists.txt
trunk/src/check/time/CMakeLists.txt
trunk/src/check/time/constrain_check.cpp
trunk/src/check/time/constrain_check.h
trunk/tests/CMakeLists.txt
Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt 2009-09-08 14:26:13 UTC (rev 283)
+++ trunk/CMakeLists.txt 2009-09-08 14:35:12 UTC (rev 284)
@@ -37,5 +37,6 @@
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)
+
# $Id$
Modified: trunk/src/check/time/CMakeLists.txt
===================================================================
--- trunk/src/check/time/CMakeLists.txt 2009-09-08 14:26:13 UTC (rev 283)
+++ trunk/src/check/time/CMakeLists.txt 2009-09-08 14:35:12 UTC (rev 284)
@@ -1,4 +1,7 @@
+ADD_DEFINITIONS("-g -Wall -pedantic -ansi")
+
ADD_LIBRARY(sctime SHARED
+ export.h
time_consistency.cpp
time_consistency.h
bmsc_tightening.h
@@ -6,6 +9,9 @@
hmsc_all_paths.h
hmsc_tighten.h
hmsc_tighten.cpp
+ time_pseudocode.h
+ constrain_check.h
+ constrain_check.cpp
)
TARGET_LINK_LIBRARIES(sctime
Modified: trunk/src/check/time/constrain_check.cpp
===================================================================
--- trunk/src/check/time/constrain_check.cpp 2009-09-08 14:26:13 UTC (rev 283)
+++ trunk/src/check/time/constrain_check.cpp 2009-09-08 14:35:12 UTC (rev 284)
@@ -1,8 +1,18 @@
-#include "hmsc_constrain_check.h"
+#include "constrain_check.h"
+#include "data/dfs_bmsc_graph_traverser.h"
+HMscTimeConstrainCheckerPtr HMscTimeConstrainChecker::m_instance;
+
+HMscTimeConstrainChecker::HMscTimeConstrainChecker(
+ const std::string& top,
+ const std::string& bottom):
+ m_top_constrains(top),m_bottom_constrains(bottom)
+{}
+
+
void HMscTimeConstrainChecker::check_active_set(
- ReferenceNode* n
- , TimeRelationRefNodePtrSet constrain_set
+ ReferenceNode* n,
+ TimeRelationRefNodePtrSet constrain_set
)
{
TimeRelationRefNodePtrSet::iterator it;
@@ -11,21 +21,21 @@
{
TimeRelationRefNodePtr constrain = *it;
- TimeRelationRefNodePtrSet::iterator found_constain;
+ TimeRelationRefNodePtrSet::iterator found_constrain;
- found_constrain=active_constrain.find(constrain);
-
- if(found_constrain==active_constrains.end())
+ found_constrain=m_active_constrains.find(constrain);
+
+ if(found_constrain==m_active_constrains.end())
{
if(constrain->get_ref_node_b()==n)
- throw ConstrainException();
+ throw constrain.get();
- active_constrains.insert(constrain);
+ m_active_constrains.insert(constrain);
}
else
{
if(constrain->get_ref_node_b()==n)
- active_constrains.erase(found_constrain);
+ m_active_constrains.erase(found_constrain);
}
@@ -39,19 +49,19 @@
//TOP
constrain_set = n->get_time_relation_top();
- add_active_constains_top(n);
+ add_active_constrains_top(n);
check_active_set(n,constrain_set);
//BOTTOM
constrain_set = n->get_time_relation_bottom();
- add_active_constains_bottom(n);
+ add_active_constrains_bottom(n);
check_active_set(n,constrain_set);
if(dynamic_cast<EndNode*>(n))
- if(active_constains.size()!=0)
- throw ConstrainException();
+ if(m_active_constrains.size()!=0)
+ throw m_active_constrains;
}
void HMscTimeConstrainChecker::on_gray_node_found(ReferenceNode* n)
@@ -59,12 +69,12 @@
TimeRelationRefNodePtrSet constrains_set;
constrains_set = get_active_constrains_top(n);
- if(constrains_set!=active_constrains)
- throw ConstrainsExcetion();
+ if(constrains_set!=m_active_constrains)
+ throw constrains_set;
constrains_set = get_active_constrains_bottom(n);
- if(constrains_set!=active_constrains)
- throw ConstrainsExcetion();
+ if(constrains_set!=m_active_constrains)
+ throw constrains_set;
}
void HMscTimeConstrainChecker::on_black_node_found(ReferenceNode* n)
@@ -72,11 +82,47 @@
TimeRelationRefNodePtrSet constrains_set;
constrains_set = get_active_constrains_top(n);
- if(constrains_set!=active_constrains)
- throw ConstrainsExcetion();
+ if(constrains_set!=m_active_constrains)
+ throw constrains_set;
constrains_set = get_active_constrains_bottom(n);
- if(constrains_set!=active_constrains)
- throw ConstrainsExcetion();
+ if(constrains_set!=m_active_constrains)
+ throw constrains_set;
+}
+
+HMscPtr HMscTimeConstrainChecker::check(HMscPtr hmsc, ChannelMapperPtr chm)
+{
+ HMscPtr p;
+ DFSBMscGraphTraverser traverser;
+ traverser.add_white_node_found_listener(this);
+ traverser.add_gray_node_found_listener(this);
+ traverser.add_black_node_found_listener(this);
+ try
+ {
+ traverser.traverse(hmsc);
+ }
+ catch (TimeRelationRefNode* relation)
+ {
+ p = process_path(traverser.get_reached_elements());
+ mark_time_relation(relation);
+ traverser.cleanup_traversing_attributes();
+ }
+ catch (TimeRelationRefNodePtrSet relations)
+ {
+ p = process_path(traverser.get_reached_elements());
+ mark_time_relation(relations);
+ traverser.cleanup_traversing_attributes();
+ }
+
+ return p;
+
}
+
+Checker::PreconditionList HMscTimeConstrainChecker::get_preconditions(MscPtr msc) const
+{
+ Checker::PreconditionList result;
+ // no preconditions
+ return result;
+}
+
Modified: trunk/src/check/time/constrain_check.h
===================================================================
--- trunk/src/check/time/constrain_check.h 2009-09-08 14:26:13 UTC (rev 283)
+++ trunk/src/check/time/constrain_check.h 2009-09-08 14:35:12 UTC (rev 284)
@@ -11,9 +11,9 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * Copyright (c) 2008 Jindra Babica <ba...@ma...>
*
- * $Id: deadlock_checker.h 243 2009-05-03 19:05:14Z gotthardp $
+ *
+ *
*/
#include <string>
@@ -21,15 +21,15 @@
#include <set>
#include <exception>
+#include "check/time/export.h"
#include "data/checker.h"
#include "data/msc.h"
-#include "data/dfs_bmsc_graph_traverser.h"
-#include "data/dfsb_hmsc_traverser.h"
+#include "check/pseudocode/msc_duplicators.h"
class HMscTimeConstrainChecker;
typedef boost::shared_ptr<HMscTimeConstrainChecker> HMscTimeConstrainCheckerPtr;
-
+/*
class ConstrainException:public std::exception
{
@@ -39,9 +39,10 @@
return "Inconsistent constrain path found";
}
};
+*/
-class SCTIME_EXPORT HMscTimeConstrainChecker
- : public Checker
+class SCTIME_EXPORT HMscTimeConstrainChecker:
+ public Checker
, public HMscChecker
, public WhiteRefNodeFoundListener
, public GrayRefNodeFoundListener
@@ -50,27 +51,25 @@
private:
std::string m_top_constrains;
std::string m_bottom_constrains;
- std::stack<ReferenceNode*> to_be_clean;
+ std::stack<MscElement*> to_be_clean;
// active constrains on the path
- std::set<TimeRelationRefNode> m_active_constrains;
+ std::set<TimeRelationRefNodePtr> m_active_constrains;
+ HMscPathDuplicator m_duplicator;
//////////// attribute handler
// ADD
- add_active_constrains(
- ReferenceNode* n
- , std::string w
- )
+ void add_active_constrains(MscElement* n, std::string w)
{
n->set_attribute<TimeRelationRefNodePtrSet>(w,m_active_constrains);
to_be_clean.push(n);
}
- add_active_constrains_top(ReferenceNode* n)
+ void add_active_constrains_top(MscElement* n)
{
add_active_constrains(n,m_top_constrains);
}
- add_active_constrains_bottom(ReferenceNode* n)
+ void add_active_constrains_bottom(MscElement* n)
{
add_active_constrains(n,m_bottom_constrains);
}
@@ -81,10 +80,11 @@
, std::string w
)
{
- if(!n->is_attribute_set<TimeRelationRefNodePtrSet>(w))
- return NULL;
+ TimeRelationRefNodePtrSet empty;
+ if(!(n->is_attribute_set(w)))
+ return empty;
else
- return n->get_attribute<TimeRelationRefNodePtrSet>(w,NULL);
+ return n->get_attribute<TimeRelationRefNodePtrSet>(w,empty);
}
TimeRelationRefNodePtrSet get_active_constrains_top(ReferenceNode * n)
@@ -105,19 +105,18 @@
/**
* Common instance.
*/
- static HMscTimeConstrainPtr m_instance;
+ static HMscTimeConstrainCheckerPtr m_instance;
HMscPtr create_counter_example(const MscElementPListList& path);
public:
- HMscTimeConstrainChecker()
- {
- m_top_constrains = "top_active_constrains";
- m_bottom_constrains = "bottom_active_constrains";
- }
+ HMscTimeConstrainChecker(
+ const std::string& top="top constrain set",
+ const std::string& bottom="bottom constrain set"
+ );
- ~HMscTimeContrainChecker()
+ ~HMscTimeConstrainChecker()
{
cleanup_attributes();
}
@@ -131,7 +130,7 @@
return L"Time constrain checker";
}
- PreconditionList get_preconditions(MscPtr msc) const;
+ virtual Checker::PreconditionList get_preconditions(MscPtr msc) const;
/**
* Checks whether hmsc satisfy deadlock free property.
@@ -144,6 +143,34 @@
void on_black_node_found(ReferenceNode*);
+ HMscPtr process_path(const MscElementPListList& path)
+ {
+ HMscPtr p;
+ p = m_duplicator.duplicate_path(path);
+
+ MscElementPListList::const_iterator h;
+ for(h=path.begin();h!=path.end();h++)
+ {
+ MscElement* last = (*h).back();
+ m_duplicator.get_copy(last)->set_marked(true);
+ }
+
+ return p;
+
+ }
+
+ void mark_time_relation(const TimeRelationRefNodePtrSet& relations)
+ {
+ TimeRelationRefNodePtrSet::iterator it;
+ for(it=relations.begin();it!=relations.end();it++)
+ mark_time_relation(it->get());
+ }
+
+ void mark_time_relation(TimeRelationRefNode* relation)
+ {
+ m_duplicator.get_copy(relation)->set_marked(true);
+ }
+
/**
* Cleans up no more needed attributes.
*/
@@ -152,9 +179,9 @@
{
while(!to_be_clean.empty())
{
- ReferenceNode* n = to_be_clean.top();
- n->remove_attribute(m_top_constrains);
- n->remove_attribute(m_bottom_constrains);
+ MscElement* n = to_be_clean.top();
+ n->remove_attribute<TimeRelationRefNodePtrSet>(m_top_constrains);
+ n->remove_attribute<TimeRelationRefNodePtrSet>(m_bottom_constrains);
to_be_clean.pop();
}
}
@@ -175,4 +202,3 @@
}
};
-// $Id: deadlock_checker.h 243 2009-05-03 19:05:14Z gotthardp $
Modified: trunk/tests/CMakeLists.txt
===================================================================
--- trunk/tests/CMakeLists.txt 2009-09-08 14:26:13 UTC (rev 283)
+++ trunk/tests/CMakeLists.txt 2009-09-08 14:35:12 UTC (rev 284)
@@ -1,5 +1,7 @@
ENABLE_TESTING()
+ADD_DEFINITIONS("-g -Wall -pedantic -ansi")
+
ADD_EXECUTABLE(universal_boundedness_checker_test
universal_boundedness_checker_test.cpp
)
@@ -186,7 +188,16 @@
scpseudocode
)
+ADD_EXECUTABLE(constrain_check_test
+ constrain_check_test.cpp
+)
+TARGET_LINK_LIBRARIES(constrain_check_test
+ scmsc
+ sctime
+ scpseudocode
+)
+
#
#ADD_EXECUTABLE(max_tightener_test
# max_tightener_test.cpp
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|