changeset 59:f955e83da499

developed indicators in interactions
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 29 Oct 2010 01:55:00 -0400
parents 40e1508380ed
children 1d36a676c745
files python/event.py
diffstat 1 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/python/event.py	Fri Oct 29 01:54:11 2010 -0400
+++ b/python/event.py	Fri Oct 29 01:55:00 2010 -0400
@@ -3,24 +3,39 @@
 Interactions, pedestrian crossing...'''
 
 #import utils;
+import moving
 
 __metaclass__ = type
 
-class Interaction(STObject):
+class Interaction(moving.STObject):
     '''Class for an interaction between two road users 
     or a road user and an obstacle
     
     link to the moving objects
     '''
 
-    def __init__(self, num = None, timeInterval = None, roaduserNum1 = None, roaduserNum2 = None, movingObject1 = None, movingObject2 = None):
-        STObject.__init__(self, num, timeInterval)
+    categories = {'headon': 0,
+                  'rearend': 1,
+                  'side': 2,
+                  'parallel': 3}
+
+    def __init__(self, num = None, timeInterval = None, roaduserNum1 = None, roaduserNum2 = None, movingObject1 = None, movingObject2 = None, categoryNum = None):
+        moving.STObject.__init__(self, num, timeInterval)
         self.roaduserNum1 = roaduserNum1
         self.roaduserNum2 = roaduserNum2
         self.movingObject1 = movingObject1
         self.movingObject2 = movingObject2
+        self.categoryNum = categoryNum
 
-class Crossing(STObject):
+    def getIndicator(self, indicatorName):
+        if hasattr(self, 'indicators'):
+            for i in self.indicators:
+                if i.name == indicatorName:
+                    return i
+        else:
+            return None
+
+class Crossing(moving.STObject):
     '''Class for the event of a street crossing
 
     TODO: detecter passage sur la chaussee
@@ -30,9 +45,8 @@
     carac interaction'''
     
     def __init__(self, roaduserNum = None, num = None, timeInterval = None):
+        moving.STObject.__init__(self, num, timeInterval)
         self.roaduserNum = roaduserNum
-        self.num = num
-        self.timeInterval = timeInterval