Go to the documentation of this file.00001
00002
00003
00004 '''rtsprofile
00005
00006 Copyright (C) 2009-2010
00007 Geoffrey Biggs
00008 RT-Synthesis Research Group
00009 Intelligent Systems Research Institute,
00010 National Institute of Advanced Industrial Science and Technology (AIST),
00011 Japan
00012 All rights reserved.
00013 Licensed under the Eclipse Public License -v 1.0 (EPL)
00014 http://www.opensource.org/licenses/eclipse-1.0.txt
00015
00016 File: composite_type.py
00017
00018 Enumeration for composite types.
00019
00020 This module stores the possible types of component composition.
00021
00022 Valid types are:
00023 NONE: The component is not in a composite component.
00024 ALLSHARED: Composition sharing all attributes. All attributes (execution
00025 context and status) are shared amongst all components in the composition.
00026 This is the strongest type of composition.
00027 ECSHARED: Only the execution context is shared amongst components in the
00028 composition.
00029 NONSHARED: Nothing is shared amongst components in the composition. This is the
00030 weakest type of composition.
00031
00032 '''
00033
00034 __version__ = '$Revision: $'
00035
00036
00037
00038 from rtsprofile.exceptions import InvalidCompositeTypeError
00039
00040 NONE = 'None'
00041 PERIODIC_EC_SHARED = 'PeriodicECShared'
00042 PERIODIC_STATE_SHARED = 'PeriodicStateShared'
00043 GROUPING = 'Grouping'
00044 FSM_EC_SHARED = 'FsmECSHared'
00045 FSM_STATE_SHARED = 'FsmStateShared'
00046
00047
00048
00049 const_type = str
00050
00051
00052 def from_string(type_string):
00053 '''Returns the correct constant for a given string.
00054
00055 @raises InvalidCompositeTypeError
00056
00057 '''
00058 if type_string == NONE:
00059 return NONE
00060 elif type_string == PERIODIC_EC_SHARED:
00061 return PERIODC_EC_SHARED
00062 elif type_string == PERIODIC_STATE_SHARED:
00063 return PERIODIC_STATE_SHARED
00064 elif type_string == GROUPING:
00065 return GROUPING
00066 elif type_string == FSM_EC_SHARED:
00067 return FSM_EC_SHARED
00068 elif type_string == FSM_STATE_SHARED:
00069 return FSM_STATE_SHARED
00070 else:
00071 raise InvalidCompositeTypeError(type_string)
00072
00073
00074 def to_string(comp_type):
00075 '''Returns the correct string for a given composite type.
00076
00077 @raises InvalidCompositeTypeError
00078
00079 '''
00080 if comp_type == NONE:
00081 return NONE
00082 elif comp_type== PERIODIC_EC_SHARED:
00083 return PERIODC_EC_SHARED
00084 elif comp_type == PERIODIC_STATE_SHARED:
00085 return PERIODIC_STATE_SHARED
00086 elif comp_type == GROUPING:
00087 return GROUPING
00088 elif comp_type == FSM_EC_SHARED:
00089 return FSM_EC_SHARED
00090 elif comp_type == FSM_STATE_SHARED:
00091 return FSM_STATE_SHARED
00092 else:
00093 raise InvalidCompositeTypeError(type_string)
00094
00095
00096
00097