File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,17 @@ def import_eds(source, node_id):
36
36
od .node_id = int (eds .get ("DeviceComissioning" , "NodeID" ))
37
37
38
38
for section in eds .sections ():
39
+ # Match dummy definitions
40
+ match = re .match (r"^[Dd]ummy[Uu]sage$" , section )
41
+ if match is not None :
42
+ for i in range (1 , 8 ):
43
+ key = "Dummy%04d" % i
44
+ if eds .getint (section , key ) == 1 :
45
+ var = objectdictionary .Variable (key , i , 0 )
46
+ var .data_type = i
47
+ var .access_type = "const"
48
+ od .add_object (var )
49
+
39
50
# Match indexes
40
51
match = re .match (r"^[0-9A-Fa-f]{4}$" , section )
41
52
if match is not None :
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ LSS_SerialNumber=0
39
39
[DummyUsage]
40
40
Dummy0001=0
41
41
Dummy0002=0
42
- Dummy0003=0
42
+ Dummy0003=1
43
43
Dummy0004=0
44
44
Dummy0005=0
45
45
Dummy0006=0
Original file line number Diff line number Diff line change @@ -76,3 +76,17 @@ def test_compact_subobj_parameter_name_with_percent(self):
76
76
def test_sub_index_w_capital_s (self ):
77
77
name = self .od [0x3010 ][0 ].name
78
78
self .assertEqual (name , 'Temperature' )
79
+
80
+ def test_dummy_variable (self ):
81
+ var = self .od ['Dummy0003' ]
82
+ self .assertIsInstance (var , canopen .objectdictionary .Variable )
83
+ self .assertEqual (var .index , 0x0003 )
84
+ self .assertEqual (var .subindex , 0 )
85
+ self .assertEqual (var .name , 'Dummy0003' )
86
+ self .assertEqual (var .data_type , canopen .objectdictionary .INTEGER16 )
87
+ self .assertEqual (var .access_type , 'const' )
88
+ self .assertEqual (len (var ), 16 )
89
+
90
+ def test_dummy_variable_undefined (self ):
91
+ with self .assertRaises (KeyError ):
92
+ var_undef = self .od ['Dummy0001' ]
You can’t perform that action at this time.
0 commit comments