@@ -40,7 +40,7 class Controller(): | |||||
40 |
|
40 | |||
41 | def addReadBranch(self, dpath, dataformat, readMode, startDate='', endDate='', startTime='', endTime=''): |
|
41 | def addReadBranch(self, dpath, dataformat, readMode, startDate='', endDate='', startTime='', endTime=''): | |
42 |
|
42 | |||
43 | id = len(self.readBranchObjList) + 1 |
|
43 | id = self.getNewId() | |
44 |
|
44 | |||
45 | readBranchObj = ReadBranch() |
|
45 | readBranchObj = ReadBranch() | |
46 | readBranchObj.setup(id, dpath, dataformat, readMode, startDate, endDate, startTime, endTime) |
|
46 | readBranchObj.setup(id, dpath, dataformat, readMode, startDate, endDate, startTime, endTime) | |
@@ -51,7 +51,7 class Controller(): | |||||
51 |
|
51 | |||
52 | def addProcBranch(self, name): |
|
52 | def addProcBranch(self, name): | |
53 |
|
53 | |||
54 | id = len(self.procBranchObjList) + 1 |
|
54 | id = self.getNewId() | |
55 |
|
55 | |||
56 | procBranchObj = ProcBranch() |
|
56 | procBranchObj = ProcBranch() | |
57 | procBranchObj.setup(id, name) |
|
57 | procBranchObj.setup(id, name) | |
@@ -60,6 +60,11 class Controller(): | |||||
60 |
|
60 | |||
61 | return procBranchObj |
|
61 | return procBranchObj | |
62 |
|
62 | |||
|
63 | def getNewId(self): | |||
|
64 | ||||
|
65 | id = int(self.id)*10 + len(self.readBranchObjList) + len(self.procBranchObjList) + 1 | |||
|
66 | return id | |||
|
67 | ||||
63 | def makeXml(self): |
|
68 | def makeXml(self): | |
64 |
|
69 | |||
65 | projectElement = Element('Controller') |
|
70 | projectElement = Element('Controller') | |
@@ -156,7 +161,7 class ReadBranch(): | |||||
156 |
|
161 | |||
157 | def addParameter(self, name, value): |
|
162 | def addParameter(self, name, value): | |
158 |
|
163 | |||
159 | id = len(self.parmObjList) + 1 |
|
164 | id = int(self.id)*10 + len(self.parmObjList) + 1 | |
160 |
|
165 | |||
161 | parmObj = ParameterConf() |
|
166 | parmObj = ParameterConf() | |
162 | parmObj.setup(id, name, value) |
|
167 | parmObj.setup(id, name, value) | |
@@ -219,12 +224,12 class ProcBranch(): | |||||
219 |
|
224 | |||
220 | self.upObjList = [] |
|
225 | self.upObjList = [] | |
221 |
|
226 | |||
222 | def addUP(self, name, type): |
|
227 | def addUP(self, name, type, inputId): | |
223 |
|
228 | |||
224 | id = len(self.upObjList) + 1 |
|
229 | id = int(self.id)*10 + len(self.upObjList) + 1 | |
225 |
|
230 | |||
226 | upObj = UPConf() |
|
231 | upObj = UPConf() | |
227 | upObj.setup(id, name, type) |
|
232 | upObj.setup(id, name, type, inputId) | |
228 |
|
233 | |||
229 | self.upObjList.append(upObj) |
|
234 | self.upObjList.append(upObj) | |
230 |
|
235 | |||
@@ -273,7 +278,7 class UPConf(): | |||||
273 | def __init__(self): |
|
278 | def __init__(self): | |
274 | pass |
|
279 | pass | |
275 |
|
280 | |||
276 |
def setup(self, id, name, type, inputId |
|
281 | def setup(self, id, name, type, inputId): | |
277 |
|
282 | |||
278 | self.id = id |
|
283 | self.id = id | |
279 | self.name = name |
|
284 | self.name = name | |
@@ -284,7 +289,7 class UPConf(): | |||||
284 |
|
289 | |||
285 | def addOperation(self, name, priority, type='self'): |
|
290 | def addOperation(self, name, priority, type='self'): | |
286 |
|
291 | |||
287 | id = len(self.opObjList) + 1 |
|
292 | id = int(self.id)*10 + len(self.opObjList) + 1 | |
288 |
|
293 | |||
289 | opObj = OperationConf() |
|
294 | opObj = OperationConf() | |
290 | opObj.setup(id, name, priority, type) |
|
295 | opObj.setup(id, name, priority, type) | |
@@ -357,7 +362,7 class OperationConf(): | |||||
357 |
|
362 | |||
358 | def addParameter(self, name, value): |
|
363 | def addParameter(self, name, value): | |
359 |
|
364 | |||
360 | id = len(self.parmObjList) + 1 |
|
365 | id = int(self.id)*10 + len(self.parmObjList) + 1 | |
361 |
|
366 | |||
362 | parmObj = ParameterConf() |
|
367 | parmObj = ParameterConf() | |
363 | parmObj.setup(id, name, value) |
|
368 | parmObj.setup(id, name, value) | |
@@ -451,13 +456,13 if __name__ == '__main__': | |||||
451 | procBranchObj = projectObj.addProcBranch(name='Branch1') |
|
456 | procBranchObj = projectObj.addProcBranch(name='Branch1') | |
452 |
|
457 | |||
453 | procBranchObj1 = projectObj.addProcBranch(name='Branch2') |
|
458 | procBranchObj1 = projectObj.addProcBranch(name='Branch2') | |
454 | upObj1 = procBranchObj.addUP(name='UP1', type='Voltage') |
|
459 | ||
455 |
upObj |
|
460 | upObj1 = procBranchObj.addUP(name='UP1', type='Voltage', inputId=readBranchObj.id) | |
|
461 | upObj2 = procBranchObj.addUP(name='UP2', type='Voltage', inputId=upObj1.id) | |||
456 |
|
462 | |||
457 | opObj11 = upObj1.addOperation(name='removeDC', priority=1) |
|
463 | opObj11 = upObj1.addOperation(name='removeDC', priority=1) | |
458 | opObj11.addParameter(name='type', value='1') |
|
464 | opObj11.addParameter(name='type', value='1') | |
459 |
|
465 | |||
460 |
|
||||
461 | opObj12 = upObj1.addOperation(name='decoder', priority=2) |
|
466 | opObj12 = upObj1.addOperation(name='decoder', priority=2) | |
462 | opObj12.addParameter(name='ncode', value='2') |
|
467 | opObj12.addParameter(name='ncode', value='2') | |
463 | opObj12.addParameter(name='nbauds', value='8') |
|
468 | opObj12.addParameter(name='nbauds', value='8') |
General Comments 0
You need to be logged in to leave comments.
Login now