You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the Network class contains too many methods (coroutines), which makes finding the right method for a certain task unnecessary cumbersome. Some methods also only make sense, if certain preconditions are true. For example, reading the acceleration range (read_acceleration_sensor_range_in_g) only makes sense for a sensor device, but not for an STU.
Implementation
One option might be to return different objects (that only provide certain functionality) via a context manager or method. These objects could then store a reference to a Network object as attribute that provides only basic functionality. For example, in the case of EEPROM access we could add a method that creates an EEPROM object, which then uses the Network object for sending and receiving the correct command.
Class Hierarchy
The class hierarchy could look something like this:
classDiagram
class Network {
-connect_sensor_device() : SensorNode
+connect_sth(identifier: [str, int, EUI])
+stu()
}
class Node {
+eeprom() : NodeEEPROM
+reset()
+get_name() : str
+set_name(name: str)
+get_state() : State
}
class SensorNode {
+eeprom() : SensorNodeEEPROM
}
class STU {
+eeprom() : STUEEPROM
}
class STH {
+eeprom() : STHEEPROM
}
class SMH {
+eeprom() : SMHEEPROM
}
Node <|-- SensorNode
Node <|-- STU
SensorNode <|-- STH
SensorNode <|-- SMH
NodeEEPROM <|-- SensorNodeEEPROM
NodeEEPROM <|-- STUEEPROM
SensorNodeEEPROM <|-- STHEEPROM
SensorNodeEEPROM <|-- SMHEEPROM
Description
Currently the
Network
class contains too many methods (coroutines), which makes finding the right method for a certain task unnecessary cumbersome. Some methods also only make sense, if certain preconditions are true. For example, reading the acceleration range (read_acceleration_sensor_range_in_g
) only makes sense for a sensor device, but not for an STU.Implementation
One option might be to return different objects (that only provide certain functionality) via a context manager or method. These objects could then store a reference to a
Network
object as attribute that provides only basic functionality. For example, in the case of EEPROM access we could add a method that creates an EEPROM object, which then uses theNetwork
object for sending and receiving the correct command.Class Hierarchy
The class hierarchy could look something like this:
Examples
Manually Clean Up Network Resources
Writing STU EEPROM Data
Reading STH EEPROM Data
Reading STH Streaming Data
Open Questions
connect_sensor_device
does not know, if device is STH or SMHconnect_sensor_device
(e.g. attributedevice
: stores class of returned object (SMH
,STH
)connect_sth
,connect_smh
)Node
(mytoolit.can.node
) already existsNode
class to different namespace (e.g.mytoolit.can.identifier
)NodeIdentifier
,NodeID
)Device
as name for new classNode
e.g.SensorNode
(in tests)The text was updated successfully, but these errors were encountered: