-
Notifications
You must be signed in to change notification settings - Fork 6
Description
I'm working on expanding on the initial input (button pressed) to cover more inputs (e.g., ports). In doing this, I rethinking the 1 command per class route for a few reasons: 1) there is a lot of overhead (in lines of code needed to maintain the module/class structure and to override methods); 2) we're going to need a large number of commands to cover all of the functionality; and 3) batching of commands will be common (e.g., read all of the button states at once) requiring more classes to cover those options.
I'm thinking that we could get away with:
-
One class to handle each call (e.g., Command or Message). It would get set up to be either System or Direct, with or without a reply. It would be responsible for constructing the header and possibly handling the response. It would manage one or more sub commands (getting the bytes to send and assigning the appropriate parts of any response).
-
A subcommand class or hierarchy of classes. Each sub command needs:
- A subcommand type
- Some parameters (data type followed by data)
- Information for creating space for reply data (one or more type) so it can create indices for the replies and process them
I don't think we'll need one class per subcommand. It seems like it might be enough to pair up physical object with a class used for getting and setting its information (motor, port, button, ui), and perhaps some extra classes for more batch commands (reading all the ports at once, or starting two motors at the same time).
I think the subcommand should be responsible for querying the necessary information from the object (e.g., port id, layer, mode) and then assigning information returned (raw_value = X).
- The "Model" object in this case would be responsible for creating the command, holding values, and firing of any procedures based on changes detected.
Thoughts?