3125 new_task = PLCOpenParser.CreateElement("task", "resource") |
3125 new_task = PLCOpenParser.CreateElement("task", "resource") |
3126 resource.appendtask(new_task) |
3126 resource.appendtask(new_task) |
3127 new_task.setname(task["Name"]) |
3127 new_task.setname(task["Name"]) |
3128 if task["Triggering"] == "Interrupt": |
3128 if task["Triggering"] == "Interrupt": |
3129 new_task.setsingle(task["Single"]) |
3129 new_task.setsingle(task["Single"]) |
3130 ## result = duration_model.match(task["Interval"]).groups() |
3130 # result = duration_model.match(task["Interval"]).groups() |
3131 ## if reduce(lambda x, y: x or y != None, result): |
3131 # if reduce(lambda x, y: x or y != None, result): |
3132 ## values = [] |
3132 # values = [] |
3133 ## for value in result[:-1]: |
3133 # for value in result[:-1]: |
3134 ## if value != None: |
3134 # if value != None: |
3135 ## values.append(int(value)) |
3135 # values.append(int(value)) |
3136 ## else: |
3136 # else: |
3137 ## values.append(0) |
3137 # values.append(0) |
3138 ## if result[-1] is not None: |
3138 # if result[-1] is not None: |
3139 ## values.append(int(float(result[-1]) * 1000)) |
3139 # values.append(int(float(result[-1]) * 1000)) |
3140 ## new_task.setinterval(datetime.time(*values)) |
3140 # new_task.setinterval(datetime.time(*values)) |
3141 if task["Triggering"] == "Cyclic": |
3141 if task["Triggering"] == "Cyclic": |
3142 new_task.setinterval(task["Interval"]) |
3142 new_task.setinterval(task["Interval"]) |
3143 new_task.setpriority(int(task["Priority"])) |
3143 new_task.setpriority(int(task["Priority"])) |
3144 if task["Name"] != "": |
3144 if task["Name"] != "": |
3145 task_list[task["Name"]] = new_task |
3145 task_list[task["Name"]] = new_task |
3169 new_task["Single"] = single |
3169 new_task["Single"] = single |
3170 else: |
3170 else: |
3171 new_task["Single"] = "" |
3171 new_task["Single"] = "" |
3172 interval = task.getinterval() |
3172 interval = task.getinterval() |
3173 if interval is not None: |
3173 if interval is not None: |
3174 ## text = "" |
3174 # text = "" |
3175 ## if interval.hour != 0: |
3175 # if interval.hour != 0: |
3176 ## text += "%dh"%interval.hour |
3176 # text += "%dh"%interval.hour |
3177 ## if interval.minute != 0: |
3177 # if interval.minute != 0: |
3178 ## text += "%dm"%interval.minute |
3178 # text += "%dm"%interval.minute |
3179 ## if interval.second != 0: |
3179 # if interval.second != 0: |
3180 ## text += "%ds"%interval.second |
3180 # text += "%ds"%interval.second |
3181 ## if interval.microsecond != 0: |
3181 # if interval.microsecond != 0: |
3182 ## if interval.microsecond % 1000 != 0: |
3182 # if interval.microsecond % 1000 != 0: |
3183 ## text += "%.3fms"%(float(interval.microsecond) / 1000) |
3183 # text += "%.3fms"%(float(interval.microsecond) / 1000) |
3184 ## else: |
3184 # else: |
3185 ## text += "%dms"%(interval.microsecond / 1000) |
3185 # text += "%dms"%(interval.microsecond / 1000) |
3186 ## new_task["Interval"] = text |
3186 # new_task["Interval"] = text |
3187 new_task["Interval"] = interval |
3187 new_task["Interval"] = interval |
3188 else: |
3188 else: |
3189 new_task["Interval"] = "" |
3189 new_task["Interval"] = "" |
3190 if single is not None and interval is None: |
3190 if single is not None and interval is None: |
3191 new_task["Triggering"] = "Interrupt" |
3191 new_task["Triggering"] = "Interrupt" |