root/ossiedev/branches/jsnyder/trunk/tools/WaveDev/wavedev/ComponentClass.py @ 11083

Revision 11083, 6.1 KB (checked in by Snyder.Jason, 14 months ago)

changes related to alternate component implementations

  • Property svn:eol-style set to native
Line 
1## Copyright 2005, 2006, 2007 Virginia Polytechnic Institute and State University
2##
3## This file is part of the OSSIE Waveform Developer.
4##
5## OSSIE Waveform Developer is free software; you can redistribute it and/or modify
6## it under the terms of the GNU General Public License as published by
7## the Free Software Foundation; either version 2 of the License, or
8## (at your option) any later version.
9##
10## OSSIE Waveform Developer is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13## GNU General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License
16## along with OSSIE Waveform Developer; if not, write to the Free Software
17## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19import uuidgen
20
21# Component Class
22class Component:
23    def __init__(self, name="",AC=False,type="resource",description="",generate=True):
24        self.name = name        # this refers to the instance name
25        self.baseName = name    # this refers to the component that the instance is based on
26        self.connections = []
27        self.ports = []
28        self.mutable_params = []
29        self.device = None
30        self.node = None
31        self.uuid = uuidgen.uuidgen()
32        self.file_uuid = uuidgen.uuidgen()
33        self.ace = False
34        self.timing = False
35        self.AssemblyController = AC
36        self.type = type
37        self.generate = generate
38        self.xmlName = name     #if imported from component library - this may change
39        self.properties = []
40        self.description = description
41        self.implementations = []
42
43    def __getitem__(self,i):
44        return self.connections[i]
45
46    def setUUID(self):
47        self.uuid = uuidgen.uuidgen()
48
49    def changeName(self,newname):
50        self.name = newname
51        if self.generate == True:
52            self.baseName = newname
53            self.xmlName = newname
54           
55    def getImplementation(self, processorName):
56        for implementation in self.implementations:
57            if implementation.name == processorName:
58                return implementation
59        return None
60         
61
62
63class Node:
64    def __init__(self, name="", path="", description="", generate=True):
65        self.name = name
66        self.path = path
67        self.Devices = []
68        self.type = "node"
69        self.generate = generate
70        self.description = description
71        self.id = ""
72
73    def addDevice(self, in_dev=None):
74        if in_dev != None:
75            self.Devices.append(in_dev)
76
77
78class Port:
79    def __init__(self, name, interface, type="Uses",portType="data"):#,dataType="ShortSequence",interface_ns="standardInterfaces"):
80        self.name = name
81        self.interface = interface
82        self.portType = portType    #control or data
83        self.type = type            #Uses or Provides
84        self.u_cname = "dataOut_" + interface.name + "_i"
85        self.p_cname = "dataIn_" + interface.name + "_i"
86        if type == "Uses":
87            self.cname = self.u_cname
88        if type == "Provides":
89            self.cname = self.p_cname
90
91class Connection:
92    def __init__(self, LP, RP, RC):
93        self.localPort = LP
94        self.remotePort = RP
95        self.remoteComp = RC
96
97class Interface:
98    def __init__(self,name,nameSpace="standardInterfaces",operations=[],filename="",fullpath=""):
99        self.name = name
100        self.nameSpace = nameSpace
101        self.operations = []
102        self.filename = filename    #does not include the '.idl' suffix
103        self.fullpath = fullpath
104
105    def __eq__(self,other):
106        if isinstance(other, Interface):
107            return (other.nameSpace == self.nameSpace ) and (other.name == self.name)
108        else:
109            return False
110
111    def __ne__(self,other):
112        if isinstance(other, Interface):
113            return (other.nameSpace != self.nameSpace ) and (other.name != self.name)
114        else:
115            return True
116
117
118class Operation:
119    def __init__(self,name,returnType,params=[]):
120        self.name = name
121        self.returnType = returnType
122        self.cxxReturnType = ''
123        self.params = []
124
125class Param:
126    def __init__(self,name,dataType='',direction=''):
127        """
128        Exampleinterface complexShort {
129            void pushPacket(in PortTypes::ShortSequence I, in PortTypes::ShortSequence Q);
130        };
131        """
132
133        self.name = name            # The actual argument name: 'I'
134        self.dataType = dataType    # The type of the argument: 'PortTypes::ShortSequence'
135        self.cxxType = ""
136        self.direction = direction  # Flow of data: 'in'
137
138class Property:
139    def __init__(self,elementType,name,mode,description=''):
140        self.elementType = elementType
141        self.name = name
142        self.mode = mode
143        self.id = 'DCE:' + uuidgen.uuidgen()
144
145class SimpleProperty(Property):
146    def __init__(self,name,mode,type,description='',value=None,defaultValue=None,units=None,
147                range=(-1,-1),enum='',kind='configure',action=None):
148        Property.__init__(self,"Simple",name,mode,description)
149        self.type = type
150        self.description = description
151        self.value = value
152        self.defaultValue = defaultValue
153        self.units = units
154        self.range = range
155        self.enum = enum
156        self.kind = kind
157        self.action = action
158
159class SimpleSequenceProperty(Property):
160    def __init__(self,name,mode,type,description='',values=[],defaultValues=[],units=None,range=(-1,-1),kind='configure',action=None):
161        Property.__init__(self,"SimpleSequence",name,mode,description)
162        self.type = type
163        self.description = description
164        self.values = values
165        self.defaultValues = defaultValues
166        self.units = units
167        self.range = range
168        self.kind = kind
169        self.action = action
170       
171class Implementation:
172    def __init__(self, id, description='', propertyFile='', processor=''):
173        self.id = id
174        self.description = description
175        self.propertyFile = propertyFile
176        self.processor = processor
177        self.properties = []
178       
179   
180
181
Note: See TracBrowser for help on using the browser.