composite_type.py
Go to the documentation of this file.
1 # -*- Python -*-
2 # -*- coding: utf-8 -*-
3 
4 '''rtsprofile
5 
6 Copyright (C) 2009-2010
7  Geoffrey Biggs
8  RT-Synthesis Research Group
9  Intelligent Systems Research Institute,
10  National Institute of Advanced Industrial Science and Technology (AIST),
11  Japan
12  All rights reserved.
13 Licensed under the Eclipse Public License -v 1.0 (EPL)
14 http://www.opensource.org/licenses/eclipse-1.0.txt
15 
16 File: composite_type.py
17 
18 Enumeration for composite types.
19 
20 This module stores the possible types of component composition.
21 
22 Valid types are:
23 NONE: The component is not in a composite component.
24 ALLSHARED: Composition sharing all attributes. All attributes (execution
25  context and status) are shared amongst all components in the composition.
26  This is the strongest type of composition.
27 ECSHARED: Only the execution context is shared amongst components in the
28  composition.
29 NONSHARED: Nothing is shared amongst components in the composition. This is the
30  weakest type of composition.
31 
32 '''
33 
34 __version__ = '$Revision: $'
35 # $Source$
36 
37 
38 from rtsprofile.exceptions import InvalidCompositeTypeError
39 
40 NONE = 'None'
41 PERIODIC_EC_SHARED = 'PeriodicECShared'
42 PERIODIC_STATE_SHARED = 'PeriodicStateShared'
43 GROUPING = 'Grouping'
44 FSM_EC_SHARED = 'FsmECSHared'
45 FSM_STATE_SHARED = 'FsmStateShared'
46 
47 
48 # Use this to match the correct type when specifying data correctness
49 const_type = str
50 
51 
52 def from_string(type_string):
53  '''Returns the correct constant for a given string.
54 
55  @raises InvalidCompositeTypeError
56 
57  '''
58  if type_string == NONE:
59  return NONE
60  elif type_string == PERIODIC_EC_SHARED:
61  return PERIODC_EC_SHARED
62  elif type_string == PERIODIC_STATE_SHARED:
63  return PERIODIC_STATE_SHARED
64  elif type_string == GROUPING:
65  return GROUPING
66  elif type_string == FSM_EC_SHARED:
67  return FSM_EC_SHARED
68  elif type_string == FSM_STATE_SHARED:
69  return FSM_STATE_SHARED
70  else:
71  raise InvalidCompositeTypeError(type_string)
72 
73 
74 def to_string(comp_type):
75  '''Returns the correct string for a given composite type.
76 
77  @raises InvalidCompositeTypeError
78 
79  '''
80  if comp_type == NONE:
81  return NONE
82  elif comp_type== PERIODIC_EC_SHARED:
83  return PERIODC_EC_SHARED
84  elif comp_type == PERIODIC_STATE_SHARED:
85  return PERIODIC_STATE_SHARED
86  elif comp_type == GROUPING:
87  return GROUPING
88  elif comp_type == FSM_EC_SHARED:
89  return FSM_EC_SHARED
90  elif comp_type == FSM_STATE_SHARED:
91  return FSM_STATE_SHARED
92  else:
93  raise InvalidCompositeTypeError(type_string)
94 
95 
96 # vim: tw=79
97 
def from_string(type_string)


rtsprofile
Author(s): Geoffrey Biggs
autogenerated on Fri Jun 7 2019 21:52:35