Setup.SetupAllDevices package
Submodules
Setup.SetupAllDevices.Setup_PodDevices module
- class Setup.SetupAllDevices.Setup_PodDevices.SetupAll(saveFileDict: dict[str, str] | None = None, podParametersDict: dict[str, dict[int, Morelia.Parameters.ParamsBasic.Params] | None] | None = None)
Bases:
object
Setup_PodDevices allows a user to set up and stream from any number of POD devices. The streamed data is saved to a file.
REQUIRES FIRMWARE 1.0.2 OR HIGHER.
- _Setup_PodDevices
Dictionary containing the Setup_Interface subclasses for each POD device.
- Type:
dict[str,dict[int,Params_Interface]
- _options
Dictionary listing the different options for the user to complete.
- Type:
dict[int,str]
- GetOptions() dict[int, str]
Gets the dictionary of setup options.
- Returns:
Dictionary listing the different options for the user to complete (_options).
- Return type:
dict[int,str]
- GetPODparametersInit() str
Sets up each POD device type. Used in initialization. :returns: String representing a dictionary of all POD devices initialization. The keys are the device name and the entries are the initialization dictionaries. :rtype: str
- GetSaveFileNames() dict[str]
Gets a dictionary of the save files names for all connected POD devices.
- Returns:
Dictionary of the save file name and path for all devices.
- Return type:
dict[str]
- Run() None
Prints the options and askes the user what to do. Loops until ‘Quit” is chosen.
- SetupPODparameters(podParametersDict: dict[str, dict[int, Morelia.Parameters.ParamsBasic.Params] | None]) None
Sets up each POD device type. Used in initialization.
- Parameters:
podParametersDict (dict[str,dict[int,Params_Interface] | None]) – Dictionary of all POD devices initialization. The keys are the device name and the entries are the initialization dictionaries.
- SetupSaveFile(saveFileDict: dict[str, str] | None = None) None
Gets the path/file name from the user and stores it. Used in initialization.
- Parameters:
saveFile (dict[str,str|None] | None, optional) – String of the save file, which includes the directory path, filename, and file extension. Defaults to None.
- _AskOption() int
Asks user which option to do.
- Returns:
Integer number representing an option key.
- Return type:
int
- _AskToStopStream() None
Asks user to press enter to stop streaming. The program will then prompt all POD devices to end stream.
- static _AskUserForDevices()
Asks the user what POD devices they want to use.
- _CheckForValidParams(podParametersDict: dict[str, None | dict]) bool
Checks if the parameters are correctly formatted.
- Parameters:
podParametersDict (dict[str,None | dict]) – Dictionary with keys as the device names and values as None or the respective parameter dictionary.
- Raises:
Exception – Parameters must be dictionary type.
Exception – Parameters dictionary is empty.
Exception – Invalid device name in paramater dictionary.
- Returns:
True if the parameters are correctly formatted.
- Return type:
bool
- _ConnectNewDevice() None
Asks the user for the POD device type, then it sets up that device.
- _DoOption(choice: int) None
Performs the methods associated with the user selected option.
- Parameters:
choice (int) – Integer number representing an option key.
- _EditCheckConnect() None
Displays the POD devices parameters, asks the user to edit the device, and then reconnects the device for each POD device type.
- _EditSaveFilePath() None
Asks the user for the POD device type, then asks the user for a new file name and path, then sets the value to the POD devices.
- _GetChosenDeviceType(question: str) str
Asks the user which type of POD device they want.
- Parameters:
question (str) – Question to ask the user.
- Returns:
String of the user input (may be invalid POD device type).
- Return type:
str
- _GetParams(podParametersDict: None | dict[str, None]) dict[str, dict | None]
If no parameters are give, this asks user which types of POD devices they want to use. Then it checks if the parameters are valid.
- Parameters:
podParametersDict (None | dict[str,None]) – Dictionary of all POD devices initialization. The keys are the device name and the entries are the initialization dictionaries.
- Returns:
Dictionary whose keys are the POD device name, and value the setup dictionary.
- Return type:
dict[str,dict|None]
- _PrintInitCode() None
Prints code that can be used to initialize and run SetupPodDevices with the current parameters.
- _PrintOptions() None
Prints options available for user.
- _Reconnect() bool
Reconnects all POD devices.
- Returns:
Bool that is true if all devices were successfully connected. False otherwise.
- Return type:
bool
- _RemoveDevice() None
Displays the POD devices parameters, asks the user which device ro remove, and then deletes that POD device.
- _Set_Setup_PodDevices(podParametersDict: dict[str, dict | None]) None
Sets the _Setup_PodDevices varaible to have keys as the POD device name and values as the setup class.
- Parameters:
podParametersDict (dict[str,dict | None]) – Dictionary with keys as the device names and values as None or the respective parameter dictionary.
- _ShowCurrentSettings() None
Displays the POD device settings for all devices, and then prints the save file name.
- _Stream() float
Streams data from all POD devices and prints the execution time.
- Returns:
Float of the execution time in seconds.
- Return type:
float
- _StreamAllDevices() None
Streams data from all the devices. User is asked to click enter to stop streaming. Data is saved to file. Uses threading.
- static _TimeFunc(func: function) float
Runs a function and gets the calculated execultion time.
- Parameters:
func (function) – Function/method name.
- Returns:
Float of the execution time in seconds rounded to 3 decimal places.
- Return type:
float