Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Config Files #6

Closed
bellh14 opened this issue Oct 3, 2023 · 1 comment
Closed

Add Config Files #6

bellh14 opened this issue Oct 3, 2023 · 1 comment
Assignees
Labels
Hard Hard to implement High Priority High Priority

Comments

@bellh14
Copy link
Member

bellh14 commented Oct 3, 2023

Config File to Initialize the Sensors

  • Create a JSON file that can stores which sensors are on the car, which ports they are connected to, and what those sensors represent
  • Create a parser class that parses this data
  • Once the refactors are done, the parse should have methods to return a useable version of the data to initialize the sensors

JSON File

Up to interpretation on how to implement the JSON data, but it needs to be easily parseable and logical to add to it.

Possible option:

Sensors {
     Linpots: {
         inputs: [
             {
                 name: "Front Right",
                 port: "AIN1",
            },
            {
                 name: "Front Left",
                 port: "AIN2",
            },
        ],
    },
    Switch: {
        inputs: [
             {
                 name: "Saving Switch",
                 port: "AIN0",
            },
        ],
    },

  Accelerometers: {
          inputs: [
               {
                   name: "Acc1",
                   ports: [
                          "AIN10",
                           "AIN11",
                           "AIN12",
                        ],
              },
          ],
      },
}

Do not worry about the specific port numbers and names as these might change.

Parser Class

  • Should initialize off of the name of the config file. self.config_data = load_json(self.file_name). (note load json is probably a different method name)
  • Have a method for parsing each sensor, so
def read_linpot_config(self) -> [[]]: 
  return [[name, port], [name, port], [name, port], [name, port]]

This is just a possible option you are free to implement it as you see fit. The only requirements here are that it is logical and easy to use.

What the data goes to.

#  General Form for 1 Linpot
# Will need to call this for each list in the return list
self.linpot_df.loc[index, name] = ljm.eReadName(
                            self.handle, port)
# Current
self.linpot_df.loc[index, "Front Right"] = ljm.eReadName(
                            self.handle, "AIN1")

Questions

If you have any questions message Noel or I.

@bellh14 bellh14 added High Priority High Priority Hard Hard to implement labels Oct 3, 2023
@GHAFHA GHAFHA moved this to Todo in LabJackCanBus Oct 3, 2023
@GHAFHA GHAFHA moved this from Todo to In Progress in LabJackCanBus Oct 4, 2023
@Squidtoon99 Squidtoon99 self-assigned this Oct 6, 2023
@GHAFHA GHAFHA assigned SRanganath97 and unassigned Squidtoon99 Oct 6, 2023
@Squidtoon99
Copy link
Contributor

Squidtoon99 commented Oct 9, 2023

BTW: This class should be atomic (or really well designed) otherwise there will be a risk of corrupting config data with access from different threads.

@bellh14 bellh14 closed this as completed Oct 9, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in LabJackCanBus Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hard Hard to implement High Priority High Priority
Projects
Status: Done
Development

No branches or pull requests

3 participants