593 @return: a modified copy of the given CanFestival network editor model |
593 @return: a modified copy of the given CanFestival network editor model |
594 """ |
594 """ |
595 |
595 |
596 dcfgenerator = ConciseDCFGenerator(nodelist, nodename) |
596 dcfgenerator = ConciseDCFGenerator(nodelist, nodename) |
597 dcfgenerator.GenerateDCF(locations, current_location, sync_TPDOs) |
597 dcfgenerator.GenerateDCF(locations, current_location, sync_TPDOs) |
598 return dcfgenerator.GetMasterNode(), dcfgenerator.GetPointedVariables() |
598 masternode,pointers = dcfgenerator.GetMasterNode(), dcfgenerator.GetPointedVariables() |
|
599 # allow access to local OD from Master PLC |
|
600 pointers.update(LocalODPointers(locations, current_location, masternode)) |
|
601 return masternode,pointers |
599 |
602 |
600 def LocalODPointers(locations, current_location, slave): |
603 def LocalODPointers(locations, current_location, slave): |
601 IECLocations = {} |
604 IECLocations = {} |
602 pointers = {} |
605 pointers = {} |
603 for location in locations: |
606 for location in locations: |
691 {"IEC_TYPE":"INT","NAME":"__QW0_1_64_25617_2","DIR":"Q","SIZE":"W","LOC":(0,1,64,25617,1)}, |
694 {"IEC_TYPE":"INT","NAME":"__QW0_1_64_25617_2","DIR":"Q","SIZE":"W","LOC":(0,1,64,25617,1)}, |
692 {"IEC_TYPE":"BYTE","NAME":"__IB0_1_64_24578_1","DIR":"I","SIZE":"B","LOC":(0,1,64,24578,1)}, |
695 {"IEC_TYPE":"BYTE","NAME":"__IB0_1_64_24578_1","DIR":"I","SIZE":"B","LOC":(0,1,64,24578,1)}, |
693 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_1","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,1)}, |
696 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_1","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,1)}, |
694 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_2","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,2)}, |
697 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_2","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,2)}, |
695 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_3","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,3)}, |
698 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_3","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,3)}, |
696 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_4","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,4)}] |
699 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_4","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,4)}, |
|
700 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_4096_0","DIR":"I","SIZE":"D","LOC":(0,1,4096,0)}] |
697 |
701 |
698 # Generate MasterNode configuration |
702 # Generate MasterNode configuration |
699 try: |
703 try: |
700 masternode = GenerateConciseDCF(locations, (0, 1), nodelist, True, "TestNode") |
704 masternode, pointedvariables = GenerateConciseDCF(locations, (0, 1), nodelist, True, "TestNode") |
701 except ValueError, message: |
705 except ValueError, message: |
702 print "%s\nTest Failed!"%message |
706 print "%s\nTest Failed!"%message |
703 sys.exit() |
707 sys.exit() |
704 |
708 |
|
709 import pprint |
705 # Get Text corresponding to MasterNode |
710 # Get Text corresponding to MasterNode |
706 result = masternode.PrintString() |
711 result_node = masternode.PrintString() |
|
712 result_vars = pprint.pformat(pointedvariables) |
|
713 result = result_node + "\n********POINTERS*********\n" + result_vars + "\n" |
707 |
714 |
708 # If reset has been choosen |
715 # If reset has been choosen |
709 if reset: |
716 if reset: |
710 # Write Text into reference result file |
717 # Write Text into reference result file |
711 file = open("test_config/result.txt", "w") |
718 testfile = open("test_config/result.txt", "w") |
712 file.write(result) |
719 testfile.write(result) |
713 file.close() |
720 testfile.close() |
714 |
721 |
715 print "Reset Successful!" |
722 print "Reset Successful!" |
716 else: |
723 else: |
717 import os |
724 import os |
718 |
725 |
719 file = open("test_config/result_tmp.txt", "w") |
726 testfile = open("test_config/result_tmp.txt", "w") |
720 file.write(result) |
727 testfile.write(result) |
721 file.close() |
728 testfile.close() |
722 |
729 |
723 os.system("diff test_config/result.txt test_config/result_tmp.txt") |
730 os.system("diff test_config/result.txt test_config/result_tmp.txt") |
724 os.remove("test_config/result_tmp.txt") |
731 os.remove("test_config/result_tmp.txt") |