Updated config_utils so that command line tests work.
authoretisserant
Mon, 19 Jan 2009 10:08:45 +0100
changeset 307 b80d3a84b8bf
parent 306 d73d30b1095f
child 308 d7b0b2d8854c
Updated config_utils so that command line tests work.
plugins/canfestival/canfestival.py
plugins/canfestival/config_utils.py
plugins/canfestival/test_config/result.txt
--- a/plugins/canfestival/canfestival.py	Mon Jan 19 08:40:09 2009 +0100
+++ b/plugins/canfestival/canfestival.py	Mon Jan 19 10:08:45 2009 +0100
@@ -234,8 +234,6 @@
         Gen_OD_path = os.path.join(buildpath, "OD_%s.c"%prefix )
         # Create a new copy of the model with DCF loaded with PDO mappings for desired location
         master, pointers = config_utils.GenerateConciseDCF(locations, current_location, self, self.CanFestivalNode.getSync_TPDOs(),"OD_%s"%prefix)
-        # allow access to local OD from Master PLC
-        pointers.update(config_utils.LocalODPointers(locations, current_location, master))
         # Do generate C file.
         res = gen_cfile.GenerateFile(Gen_OD_path, master, pointers)
         if res :
--- a/plugins/canfestival/config_utils.py	Mon Jan 19 08:40:09 2009 +0100
+++ b/plugins/canfestival/config_utils.py	Mon Jan 19 10:08:45 2009 +0100
@@ -595,7 +595,10 @@
     
     dcfgenerator = ConciseDCFGenerator(nodelist, nodename)
     dcfgenerator.GenerateDCF(locations, current_location, sync_TPDOs)
-    return dcfgenerator.GetMasterNode(), dcfgenerator.GetPointedVariables()
+    masternode,pointers = dcfgenerator.GetMasterNode(), dcfgenerator.GetPointedVariables()
+    # allow access to local OD from Master PLC
+    pointers.update(LocalODPointers(locations, current_location, masternode))
+    return masternode,pointers
 
 def LocalODPointers(locations, current_location, slave):
     IECLocations = {}
@@ -693,32 +696,36 @@
                  {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_1","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,1)},
                  {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_2","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,2)},
                  {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_3","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,3)},
-                 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_4","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,4)}]
+                 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_64_25638_4","DIR":"I","SIZE":"D","LOC":(0,1,64,25638,4)},
+                 {"IEC_TYPE":"UDINT","NAME":"__ID0_1_4096_0","DIR":"I","SIZE":"D","LOC":(0,1,4096,0)}]
     
     # Generate MasterNode configuration
     try:
-        masternode = GenerateConciseDCF(locations, (0, 1), nodelist, True, "TestNode")
+        masternode, pointedvariables = GenerateConciseDCF(locations, (0, 1), nodelist, True, "TestNode")
     except ValueError, message:
         print "%s\nTest Failed!"%message
         sys.exit()
     
+    import pprint
     # Get Text corresponding to MasterNode 
-    result = masternode.PrintString()
+    result_node = masternode.PrintString()
+    result_vars = pprint.pformat(pointedvariables)
+    result = result_node + "\n********POINTERS*********\n" + result_vars + "\n"
     
     # If reset has been choosen
     if reset:
         # Write Text into reference result file
-        file = open("test_config/result.txt", "w")
-        file.write(result)
-        file.close()
+        testfile = open("test_config/result.txt", "w")
+        testfile.write(result)
+        testfile.close()
         
         print "Reset Successful!"
     else:
         import os
         
-        file = open("test_config/result_tmp.txt", "w")
-        file.write(result)
-        file.close()
+        testfile = open("test_config/result_tmp.txt", "w")
+        testfile.write(result)
+        testfile.close()
         
         os.system("diff test_config/result.txt test_config/result_tmp.txt")
         os.remove("test_config/result_tmp.txt")
--- a/plugins/canfestival/test_config/result.txt	Mon Jan 19 08:40:09 2009 +0100
+++ b/plugins/canfestival/test_config/result.txt	Mon Jan 19 10:08:45 2009 +0100
@@ -230,16 +230,28 @@
 1F22 7E (Concise DCF for Node 126): 
 1F22 7F (Concise DCF for Node 127): 
 2000 (Read Inputs): 0
-2240 (__IB0_1_64):
+2240 (beremiz__IB0_1_64):
 2240 01 (24576_1): 0
 2240 02 (24578_1): 0
-2340 (__IW0_1_64):
+2340 (beremiz__IW0_1_64):
 2340 01 (25601_2): 0
 2340 02 (25601_3): 0
-2440 (__ID0_1_64):
+2440 (beremiz__ID0_1_64):
 2440 01 (25638_2): 0
 2440 02 (25638_3): 0
 2440 03 (25638_4): 0
 2440 04 (25638_1): 0
-4340 (__QW0_1_64):
+4340 (beremiz__QW0_1_64):
 4340 01 (25617_1): 0
+
+********POINTERS*********
+{(4096, 0): '__ID0_1_4096_0',
+ (8768, 1): '__IB0_1_64_24576_1',
+ (8768, 2): '__IB0_1_64_24578_1',
+ (9024, 1): '__IW0_1_64_25601_2',
+ (9024, 2): '__IW0_1_64_25601_3',
+ (9280, 1): '__ID0_1_64_25638_2',
+ (9280, 2): '__ID0_1_64_25638_3',
+ (9280, 3): '__ID0_1_64_25638_4',
+ (9280, 4): '__ID0_1_64_25638_1',
+ (17216, 1): '__QW0_1_64_25617_1'}