23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
24 |
25 from minixsv import pyxsval |
25 from minixsv import pyxsval |
26 import cPickle |
26 import cPickle |
27 import os,sys,re |
27 import os,sys,re |
|
28 from datetime import * |
28 |
29 |
29 from plcopen import plcopen |
30 from plcopen import plcopen |
30 from plcopen.structures import * |
31 from plcopen.structures import * |
31 from graphics.GraphicCommons import * |
32 from graphics.GraphicCommons import * |
32 from PLCGenerator import * |
33 from PLCGenerator import * |
|
34 |
|
35 duration_model = re.compile("(?:([0-9]{1,2})h)?(?:([0-9]{1,2})m)?(?:([0-9]{1,2})s)?(?:([0-9]{1,3})ms)?") |
33 |
36 |
34 [ITEM_UNEDITABLE, ITEM_PROJECT, ITEM_POU, ITEM_CLASS, ITEM_VARIABLE, |
37 [ITEM_UNEDITABLE, ITEM_PROJECT, ITEM_POU, ITEM_CLASS, ITEM_VARIABLE, |
35 ITEM_TRANSITION, ITEM_ACTION, ITEM_CONFIGURATION, ITEM_RESOURCE] = range(9) |
38 ITEM_TRANSITION, ITEM_ACTION, ITEM_CONFIGURATION, ITEM_RESOURCE] = range(9) |
36 |
39 |
37 """ |
40 """ |
1774 for task in tasks: |
1777 for task in tasks: |
1775 new_task = plcopen.resource_task() |
1778 new_task = plcopen.resource_task() |
1776 new_task.setName(task["Name"]) |
1779 new_task.setName(task["Name"]) |
1777 if task["Single"] != "": |
1780 if task["Single"] != "": |
1778 new_task.setSingle(task["Single"]) |
1781 new_task.setSingle(task["Single"]) |
1779 if task["Interval"] != "": |
1782 result = duration_model.match(task["Interval"]).groups() |
1780 new_task.setInterval(task["Interval"]) |
1783 if reduce(lambda x, y: x or y != None, result): |
|
1784 values = [] |
|
1785 for value in result: |
|
1786 if value != None: |
|
1787 values.append(int(value)) |
|
1788 else: |
|
1789 values.append(0) |
|
1790 values[3] = values[3] * 1000 |
|
1791 new_task.setInterval(time(*values)) |
1781 new_task.priority.setValue(int(task["Priority"])) |
1792 new_task.priority.setValue(int(task["Priority"])) |
1782 if task["Name"] != "": |
1793 if task["Name"] != "": |
1783 task_list[task["Name"]] = new_task |
1794 task_list[task["Name"]] = new_task |
1784 resource.appendTask(new_task) |
1795 resource.appendTask(new_task) |
1785 for instance in instances: |
1796 for instance in instances: |
1805 new_task["Single"] = single |
1816 new_task["Single"] = single |
1806 else: |
1817 else: |
1807 new_task["Single"] = "" |
1818 new_task["Single"] = "" |
1808 interval = task.getInterval() |
1819 interval = task.getInterval() |
1809 if interval: |
1820 if interval: |
1810 new_task["Interval"] = interval |
1821 text = "" |
|
1822 if interval.hour != 0: |
|
1823 text += "%dh"%interval.hour |
|
1824 if interval.minute != 0: |
|
1825 text += "%dm"%interval.minute |
|
1826 if interval.second != 0: |
|
1827 text += "%ds"%interval.second |
|
1828 if interval.microsecond != 0: |
|
1829 text += "%dms"%(interval.microsecond / 1000) |
|
1830 new_task["Interval"] = text |
1811 else: |
1831 else: |
1812 new_task["Interval"] = "" |
1832 new_task["Interval"] = "" |
1813 new_task["Priority"] = str(task.priority.getValue()) |
1833 new_task["Priority"] = str(task.priority.getValue()) |
1814 tasks_data.append(new_task) |
1834 tasks_data.append(new_task) |
1815 for instance in task.getPouInstance(): |
1835 for instance in task.getPouInstance(): |