22import logging
33from typing import Union , TextIO , TYPE_CHECKING
44
5- from ..sdo import SdoClient
6- from ..nmt import NmtMaster
7- from ..emcy import EmcyConsumer
8- from ..pdo import TPDO , RPDO , PDO
9- from ..objectdictionary import Record , Array , Variable , List
10- from .base import BaseNode
11-
12- import canopen
13-
14- from canopen import objectdictionary
5+ from canopen .sdo import SdoClient , SdoCommunicationError , SdoAbortedError
6+ from canopen .nmt import NmtMaster
7+ from canopen .emcy import EmcyConsumer
8+ from canopen .pdo import TPDO , RPDO , PDO
9+ from canopen .objectdictionary import ODRecord , ODArray , ODVariable , ObjectDictionary
10+ from canopen .node .base import BaseNode
1511
1612if TYPE_CHECKING :
17- from . .network import Network
13+ from canopen .network import Network
1814
1915logger = logging .getLogger (__name__ )
2016
@@ -35,7 +31,7 @@ class RemoteNode(BaseNode):
3531 def __init__ (
3632 self ,
3733 node_id : int ,
38- object_dictionary : Union [objectdictionary . ObjectDictionary , str , TextIO ],
34+ object_dictionary : Union [ObjectDictionary , str , TextIO ],
3935 load_od : bool = False ,
4036 ):
4137 super (RemoteNode , self ).__init__ (node_id , object_dictionary )
@@ -160,9 +156,9 @@ def __load_configuration_helper(self, index, subindex, name, value):
160156 index = index ,
161157 name = name ,
162158 value = value )))
163- except canopen . SdoCommunicationError as e :
159+ except SdoCommunicationError as e :
164160 logger .warning (str (e ))
165- except canopen . SdoAbortedError as e :
161+ except SdoAbortedError as e :
166162 # WORKAROUND for broken implementations: the SDO is set but the error
167163 # "Attempt to write a read-only object" is raised any way.
168164 if e .code != 0x06010002 :
@@ -174,10 +170,10 @@ def __load_configuration_helper(self, index, subindex, name, value):
174170 def load_configuration (self ):
175171 ''' Load the configuration of the node from the object dictionary.'''
176172 for obj in self .object_dictionary .values ():
177- if isinstance (obj , Record ) or isinstance (obj , Array ):
173+ if isinstance (obj , ODRecord ) or isinstance (obj , ODArray ):
178174 for subobj in obj .values ():
179- if isinstance (subobj , Variable ) and subobj .writable and (subobj .value is not None ):
175+ if isinstance (subobj , ODVariable ) and subobj .writable and (subobj .value is not None ):
180176 self .__load_configuration_helper (subobj .index , subobj .subindex , subobj .name , subobj .value )
181- elif isinstance (obj , Variable ) and obj .writable and (obj .value is not None ):
177+ elif isinstance (obj , ODVariable ) and obj .writable and (obj .value is not None ):
182178 self .__load_configuration_helper (obj .index , None , obj .name , obj .value )
183179 self .pdo .read () # reads the new configuration from the driver
0 commit comments