equal
deleted
inserted
replaced
31 from plcopen import plcopen |
31 from plcopen import plcopen |
32 from plcopen.structures import * |
32 from plcopen.structures import * |
33 from graphics.GraphicCommons import * |
33 from graphics.GraphicCommons import * |
34 from PLCGenerator import * |
34 from PLCGenerator import * |
35 |
35 |
36 duration_model = re.compile("(?:([0-9]{1,2})h)?(?:([0-9]{1,2})m)?(?:([0-9]{1,2})s)?(?:([0-9]{1,3})ms)?") |
36 duration_model = re.compile("(?:([0-9]{1,2})h)?(?:([0-9]{1,2})m(?!s))?(?:([0-9]{1,2})s)?(?:([0-9]{1,3}(?:.[0-9]*)?)ms)?") |
37 |
37 |
38 [ITEM_UNEDITABLE, ITEM_PROJECT, ITEM_POU, ITEM_CLASS, ITEM_VARIABLE, |
38 [ITEM_UNEDITABLE, ITEM_PROJECT, ITEM_POU, ITEM_CLASS, ITEM_VARIABLE, |
39 ITEM_TRANSITION, ITEM_ACTION, ITEM_CONFIGURATION, ITEM_RESOURCE] = range(9) |
39 ITEM_TRANSITION, ITEM_ACTION, ITEM_CONFIGURATION, ITEM_RESOURCE] = range(9) |
40 |
40 |
41 """ |
41 """ |
162 self.VerifyXML = False |
162 self.VerifyXML = False |
163 self.Project = None |
163 self.Project = None |
164 self.ProjectBuffer = None |
164 self.ProjectBuffer = None |
165 self.FilePath = "" |
165 self.FilePath = "" |
166 self.FileName = "" |
166 self.FileName = "" |
|
167 self.ProgramFilePath = "" |
167 self.ElementsOpened = [] |
168 self.ElementsOpened = [] |
168 self.CurrentElementEditing = None |
169 self.CurrentElementEditing = None |
169 self.RefreshPouUsingTree() |
170 self.RefreshPouUsingTree() |
170 self.RefreshBlockTypes() |
171 self.RefreshBlockTypes() |
171 |
172 |
219 return variables |
220 return variables |
220 |
221 |
221 # Return file path if project is an open file |
222 # Return file path if project is an open file |
222 def GetFilePath(self): |
223 def GetFilePath(self): |
223 return self.FilePath |
224 return self.FilePath |
|
225 |
|
226 # Return file path if project is an open file |
|
227 def GetProgramFilePath(self): |
|
228 return self.ProgramFilePath |
224 |
229 |
225 # Return file name and point out if file is up to date |
230 # Return file name and point out if file is up to date |
226 def GetFilename(self): |
231 def GetFilename(self): |
227 if self.ProjectBuffer.IsCurrentSaved(): |
232 if self.ProjectBuffer.IsCurrentSaved(): |
228 return self.FileName |
233 return self.FileName |
373 #try: |
378 #try: |
374 program = GenerateCurrentProgram(self.Project) |
379 program = GenerateCurrentProgram(self.Project) |
375 programfile = open(filepath, "w") |
380 programfile = open(filepath, "w") |
376 programfile.write(program) |
381 programfile.write(program) |
377 programfile.close() |
382 programfile.close() |
|
383 self.ProgramFilePath = filepath |
378 return True |
384 return True |
379 #except: |
385 #except: |
380 # pass |
386 # pass |
381 return False |
387 return False |
382 |
388 |
550 action = pou.getAction(pou_action) |
556 action = pou.getAction(pou_action) |
551 return action.getBodyType() |
557 return action.getBodyType() |
552 |
558 |
553 # Extract varlists from a list of vars |
559 # Extract varlists from a list of vars |
554 def ExtractVarLists(self, vars): |
560 def ExtractVarLists(self, vars): |
555 print "extract varlist" |
|
556 varlist_list = [] |
561 varlist_list = [] |
557 current_varlist = None |
562 current_varlist = None |
558 current_type = None |
563 current_type = None |
559 for var in vars: |
564 for var in vars: |
560 if current_type != (var["Class"], var["Retain"], var["Constant"], var["Location"] in ["", None]): |
565 if current_type != (var["Class"], var["Retain"], var["Constant"], var["Location"] in ["", None]): |
1788 if task["Single"] != "": |
1793 if task["Single"] != "": |
1789 new_task.setSingle(task["Single"]) |
1794 new_task.setSingle(task["Single"]) |
1790 result = duration_model.match(task["Interval"]).groups() |
1795 result = duration_model.match(task["Interval"]).groups() |
1791 if reduce(lambda x, y: x or y != None, result): |
1796 if reduce(lambda x, y: x or y != None, result): |
1792 values = [] |
1797 values = [] |
1793 for value in result: |
1798 for value in result[:-1]: |
1794 if value != None: |
1799 if value != None: |
1795 values.append(int(value)) |
1800 values.append(int(value)) |
1796 else: |
1801 else: |
1797 values.append(0) |
1802 values.append(0) |
1798 values[3] = values[3] * 1000 |
1803 values.append(int(float(result[-1]) * 1000)) |
1799 new_task.setInterval(time(*values)) |
1804 new_task.setInterval(time(*values)) |
1800 new_task.priority.setValue(int(task["Priority"])) |
1805 new_task.priority.setValue(int(task["Priority"])) |
1801 if task["Name"] != "": |
1806 if task["Name"] != "": |
1802 task_list[task["Name"]] = new_task |
1807 task_list[task["Name"]] = new_task |
1803 resource.appendTask(new_task) |
1808 resource.appendTask(new_task) |
1832 if interval.minute != 0: |
1837 if interval.minute != 0: |
1833 text += "%dm"%interval.minute |
1838 text += "%dm"%interval.minute |
1834 if interval.second != 0: |
1839 if interval.second != 0: |
1835 text += "%ds"%interval.second |
1840 text += "%ds"%interval.second |
1836 if interval.microsecond != 0: |
1841 if interval.microsecond != 0: |
1837 text += "%dms"%(interval.microsecond / 1000) |
1842 if interval.microsecond % 1000 != 0: |
|
1843 text += "%.3fms"%(float(interval.microsecond) / 1000) |
|
1844 else: |
|
1845 text += "%dms"%(interval.microsecond / 1000) |
1838 new_task["Interval"] = text |
1846 new_task["Interval"] = text |
1839 else: |
1847 else: |
1840 new_task["Interval"] = "" |
1848 new_task["Interval"] = "" |
1841 new_task["Priority"] = str(task.priority.getValue()) |
1849 new_task["Priority"] = str(task.priority.getValue()) |
1842 tasks_data.append(new_task) |
1850 tasks_data.append(new_task) |