367 config_infos = {"name" : config.getname(), "type": ITEM_CONFIGURATION, "values" : []} |
367 config_infos = {"name" : config.getname(), "type": ITEM_CONFIGURATION, "values" : []} |
368 for resource in config.getresource(): |
368 for resource in config.getresource(): |
369 resource_infos = {"name" : resource.getname(), "type": ITEM_RESOURCE, "values": []} |
369 resource_infos = {"name" : resource.getname(), "type": ITEM_RESOURCE, "values": []} |
370 for task in resource.gettask(): |
370 for task in resource.gettask(): |
371 for pou in task.getpouInstance(): |
371 for pou in task.getpouInstance(): |
372 instance_infos = self.GetPouTopology(pou.getname(), pou.gettype(), debug=debug) |
372 instance_infos = self.GetPouTopology(pou.getname(), pou.gettypeName(), debug=debug) |
373 if instance_infos is not None: |
373 if instance_infos is not None: |
374 resource_infos["values"].append(instance_infos) |
374 resource_infos["values"].append(instance_infos) |
375 for pou in resource.getpouInstance(): |
375 for pou in resource.getpouInstance(): |
376 instance_infos = self.GetPouTopology(pou.getname(), pou.gettype(), debug=debug) |
376 instance_infos = self.GetPouTopology(pou.getname(), pou.gettypeName(), debug=debug) |
377 if instance_infos is not None: |
377 if instance_infos is not None: |
378 resource_infos["values"].append(instance_infos) |
378 resource_infos["values"].append(instance_infos) |
379 for varlist in resource.getglobalVars(): |
379 for varlist in resource.getglobalVars(): |
380 for variable in varlist.getvariable(): |
380 for variable in varlist.getvariable(): |
381 vartype_content = variable.gettype().getcontent() |
381 vartype_content = variable.gettype().getcontent() |
2264 position = output_connector.GetRelPosition() |
2264 position = output_connector.GetRelPosition() |
2265 transition.addconnectionPointOut() |
2265 transition.addconnectionPointOut() |
2266 transition.connectionPointOut.setrelPositionXY(position.x, position.y) |
2266 transition.connectionPointOut.setrelPositionXY(position.x, position.y) |
2267 elif infos.get("type", None) == "connection" and param == "connection" and value: |
2267 elif infos.get("type", None) == "connection" and param == "connection" and value: |
2268 transition.setconditionContent("connection", None) |
2268 transition.setconditionContent("connection", None) |
2269 self.SetConnectionWires(transition, value) |
2269 self.SetConnectionWires(transition.condition.content["value"], value) |
2270 |
2270 |
2271 def AddEditedElementDivergence(self, tagname, id, type): |
2271 def AddEditedElementDivergence(self, tagname, id, type): |
2272 element = self.GetEditedElement(tagname) |
2272 element = self.GetEditedElement(tagname) |
2273 if element is not None: |
2273 if element is not None: |
2274 if type == SELECTION_DIVERGENCE: |
2274 if type == SELECTION_DIVERGENCE: |
2424 for task in tasks: |
2424 for task in tasks: |
2425 new_task = plcopen.resource_task() |
2425 new_task = plcopen.resource_task() |
2426 new_task.setname(task["Name"]) |
2426 new_task.setname(task["Name"]) |
2427 if task["Single"] != "": |
2427 if task["Single"] != "": |
2428 new_task.setsingle(task["Single"]) |
2428 new_task.setsingle(task["Single"]) |
2429 result = duration_model.match(task["Interval"]).groups() |
2429 ## result = duration_model.match(task["Interval"]).groups() |
2430 if reduce(lambda x, y: x or y != None, result): |
2430 ## if reduce(lambda x, y: x or y != None, result): |
2431 values = [] |
2431 ## values = [] |
2432 for value in result[:-1]: |
2432 ## for value in result[:-1]: |
2433 if value != None: |
2433 ## if value != None: |
2434 values.append(int(value)) |
2434 ## values.append(int(value)) |
2435 else: |
2435 ## else: |
2436 values.append(0) |
2436 ## values.append(0) |
2437 if result[-1] is not None: |
2437 ## if result[-1] is not None: |
2438 values.append(int(float(result[-1]) * 1000)) |
2438 ## values.append(int(float(result[-1]) * 1000)) |
2439 new_task.setinterval(datetime.time(*values)) |
2439 ## new_task.setinterval(datetime.time(*values)) |
|
2440 if task["Interval"] != "": |
|
2441 new_task.setinterval(task["Interval"]) |
2440 new_task.setpriority(int(task["Priority"])) |
2442 new_task.setpriority(int(task["Priority"])) |
2441 if task["Name"] != "": |
2443 if task["Name"] != "": |
2442 task_list[task["Name"]] = new_task |
2444 task_list[task["Name"]] = new_task |
2443 resource.appendtask(new_task) |
2445 resource.appendtask(new_task) |
2444 for instance in instances: |
2446 for instance in instances: |
2445 new_instance = plcopen.pouInstance() |
2447 new_instance = plcopen.pouInstance() |
2446 new_instance.setname(instance["Name"]) |
2448 new_instance.setname(instance["Name"]) |
2447 new_instance.settype(instance["Type"]) |
2449 new_instance.settypeName(instance["Type"]) |
2448 if instance["Task"] != "": |
2450 if instance["Task"] != "": |
2449 task_list[instance["Task"]].appendpouInstance(new_instance) |
2451 task_list[instance["Task"]].appendpouInstance(new_instance) |
2450 else: |
2452 else: |
2451 resource.appendpouInstance(new_instance) |
2453 resource.appendpouInstance(new_instance) |
2452 |
2454 |
2465 new_task["Single"] = single |
2467 new_task["Single"] = single |
2466 else: |
2468 else: |
2467 new_task["Single"] = "" |
2469 new_task["Single"] = "" |
2468 interval = task.getinterval() |
2470 interval = task.getinterval() |
2469 if interval: |
2471 if interval: |
2470 text = "" |
2472 ## text = "" |
2471 if interval.hour != 0: |
2473 ## if interval.hour != 0: |
2472 text += "%dh"%interval.hour |
2474 ## text += "%dh"%interval.hour |
2473 if interval.minute != 0: |
2475 ## if interval.minute != 0: |
2474 text += "%dm"%interval.minute |
2476 ## text += "%dm"%interval.minute |
2475 if interval.second != 0: |
2477 ## if interval.second != 0: |
2476 text += "%ds"%interval.second |
2478 ## text += "%ds"%interval.second |
2477 if interval.microsecond != 0: |
2479 ## if interval.microsecond != 0: |
2478 if interval.microsecond % 1000 != 0: |
2480 ## if interval.microsecond % 1000 != 0: |
2479 text += "%.3fms"%(float(interval.microsecond) / 1000) |
2481 ## text += "%.3fms"%(float(interval.microsecond) / 1000) |
2480 else: |
2482 ## else: |
2481 text += "%dms"%(interval.microsecond / 1000) |
2483 ## text += "%dms"%(interval.microsecond / 1000) |
2482 new_task["Interval"] = text |
2484 ## new_task["Interval"] = text |
|
2485 new_task["Interval"] = interval |
2483 else: |
2486 else: |
2484 new_task["Interval"] = "" |
2487 new_task["Interval"] = "" |
2485 new_task["Priority"] = str(task.getpriority()) |
2488 new_task["Priority"] = str(task.getpriority()) |
2486 tasks_data.append(new_task) |
2489 tasks_data.append(new_task) |
2487 for instance in task.getpouInstance(): |
2490 for instance in task.getpouInstance(): |
2488 new_instance = {} |
2491 new_instance = {} |
2489 new_instance["Name"] = instance.getname() |
2492 new_instance["Name"] = instance.getname() |
2490 new_instance["Type"] = instance.gettype() |
2493 new_instance["Type"] = instance.gettypeName() |
2491 new_instance["Task"] = task.getname() |
2494 new_instance["Task"] = task.getname() |
2492 instances_data.append(new_instance) |
2495 instances_data.append(new_instance) |
2493 for instance in instances: |
2496 for instance in instances: |
2494 new_instance = {} |
2497 new_instance = {} |
2495 new_instance["Name"] = instance.getname() |
2498 new_instance["Name"] = instance.getname() |
2496 new_instance["Type"] = instance.gettype() |
2499 new_instance["Type"] = instance.gettypeName() |
2497 new_instance["Task"] = "" |
2500 new_instance["Task"] = "" |
2498 instances_data.append(new_instance) |
2501 instances_data.append(new_instance) |
2499 return tasks_data, instances_data |
2502 return tasks_data, instances_data |
2500 |
2503 |
2501 def OpenXMLFile(self, filepath): |
2504 def OpenXMLFile(self, filepath): |