pyScienceMode package

Submodules

pyScienceMode.channel module

pyScienceMode.acks module

pyScienceMode.acks.continue_basic_training_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

pyScienceMode.acks.get_mode_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Rehastim

Return type:

Returns the string corresponding to the information contain in the ‘getModeAck’ packet.

pyScienceMode.acks.get_motomed_mode_ack(packet: (<class 'list'>, <class 'str'>)) str[source]
Parameters:

packet ((list, str)) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘InitPhaseTrainingAck’ packet.

pyScienceMode.acks.init_phase_training_ack(packet: bytes) str[source]

This function processes a packet received from the Motomed and returns a string corresponding to the information contained in the ‘InitPhaseTrainingAck’ packet

Parameters:

packet (bytes) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘InitPhaseTrainingAck’ packet.

pyScienceMode.acks.init_stimulation_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Rehastim

Return type:

Returns the string corresponding to the information contain in the ‘InitChannelListModeAck’ packet.

pyScienceMode.acks.motomed_error_ack(packet: int) str[source]

This function processes a packet received from the Motomed and returns a string corresponding to the error code :param packet: Packet received from the Motomed :type packet: int

Return type:

Returns the string corresponding to the information contain in the ‘MotomedError’ packet.

pyScienceMode.acks.motomed_error_values(error_code: int)[source]

Handles the Motomed errors

Parameters:

error_code (int) – Motomed code error

Return type:

Returns the string corresponding to the information contain in the ‘MotomedError’ packet.

pyScienceMode.acks.pause_basic_training_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

pyScienceMode.acks.pause_phase_ack(packet: bytes) str[source]

This function processes a packet received from the Motomed and returns a string :param packet: Packet received from the Motomed :type packet: bytes

Returns:

  • Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

  • Else, returns the error message corresponding to the error code

pyScienceMode.acks.rehastim_error(error_code: int) str[source]

Handles the Rehastim2 errors

Parameters:

error_code (int) – Rehastim2 code error

Return type:

Returns the string corresponding to the information contain in the ‘StimulationError’ packet.

pyScienceMode.acks.set_gear_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

pyScienceMode.acks.set_rotation_direction_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

pyScienceMode.acks.set_speed_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

pyScienceMode.acks.start_basic_training_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

pyScienceMode.acks.start_phase_ack(packet: bytes) str[source]

This function processes a packet received from the Motomed and returns a string :param packet: Packet received from the Motomed :type packet: bytes

Returns:

  • Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

  • Else, returns the error message corresponding to the error code

pyScienceMode.acks.start_stimulation_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Rehastim

Return type:

Returns the string corresponding to the information contain in the ‘StartChannelListModeAck’ packet.

pyScienceMode.acks.stimulation_error(error_code: int) str[source]
Parameters:

error_code (int) – Rehastim2 code error

Return type:

Returns the string corresponding to the information contain in the ‘StimulationError’ packet.

pyScienceMode.acks.stop_basic_training_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

pyScienceMode.acks.stop_phase_training_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Motomed

Return type:

Returns the string corresponding to the information contain in the ‘StartPhaseAck’ packet.

pyScienceMode.acks.stop_stimulation_ack(packet: bytes) str[source]
Parameters:

packet (bytes) – Packet received from the Rehastim

Return type:

Returns the string corresponding to the information contain in the ‘StopChannelListModeAck’ packet.

pyScienceMode.enums module

class pyScienceMode.enums.Device(value)[source]

Bases: Enum

An enumeration.

Rehastim2 = 'Rehastim2'
Rehastimp24 = 'RehastimP24'
class pyScienceMode.enums.ErrorCode(value)[source]

Bases: Enum

An enumeration.

CurrentLevelNotInitialized = 7
ElectrodeError = 10
InvalidCommandError = 11
NoError = 0
ParameterError = 2
ProtocolError = 3
TimeoutError = 5
TransferError = 1
class pyScienceMode.enums.HighVoltage(value)[source]

Bases: Enum

An enumeration.

High_Voltage_120V = 5
High_Voltage_150V = 6
High_Voltage_30V = 2
High_Voltage_60V = 3
High_Voltage_90V = 4
Voltage_Default = 0
Voltage_Off = 1
class pyScienceMode.enums.Modes(value)[source]

Bases: Enum

An enumeration.

DOUBLET = 1
NONE = 3
SINGLE = 0
TRIPLET = 2
class pyScienceMode.enums.Rehastim2Commands(value)[source]

Bases: Enum

An enumeration.

ActualValues = 60
ContinueBasicTraining = 84
ContinueBasicTrainingAck = 85
GetMotomedMode = 12
GetMotomedModeAck = 13
GetStimulationMode = 10
GetStimulationModeAck = 11
Init = 1
InitAck = 2
InitChannelListMode = 30
InitChannelListModeAck = 31
InitPhaseTraining = 50
InitPhaseTrainingAck = 51
MotomedCommandDone = 89
MotomedError = 90
PauseBasicTraining = 82
PauseBasicTrainingAck = 83
PausePhase = 54
PausePhaseAck = 55
PhaseResult = 58
SetGear = 74
SetGearAck = 75
SetKeyboardLock = 76
SetKeyboardLockAck = 77
SetRotationDirection = 70
SetRotationDirectionAck = 71
SetSpeed = 72
SetSpeedAck = 73
SinglePulse = 36
SinglePulseAck = 37
StartBasicTraining = 80
StartBasicTrainingAck = 81
StartChannelListMode = 32
StartChannelListModeAck = 33
StartPhase = 52
StartPhaseAck = 53
StimulationError = 38
StopBasicTraining = 86
StopBasicTrainingAck = 87
StopChannelListMode = 34
StopChannelListModeAck = 35
StopPhaseTraining = 56
StopPhaseTrainingAck = 57
UnknownCommand = 3
Watchdog = 4
class pyScienceMode.enums.RehastimP24Commands(value)[source]

Bases: Enum

An enumeration.

Smpt_Cmd_Bl_Init = (120,)
Smpt_Cmd_Bl_Init_Ack = (121,)
Smpt_Cmd_Bl_Update_Block = (124,)
Smpt_Cmd_Bl_Update_Block_Ack = (125,)
Smpt_Cmd_Bl_Update_Init = (122,)
Smpt_Cmd_Bl_Update_Init_Ack = (123,)
Smpt_Cmd_Bl_Update_Stop = (126,)
Smpt_Cmd_Bl_Update_Stop_Ack = (127,)
Smpt_Cmd_Dl_Get = 109
Smpt_Cmd_Dl_Get_Ack = 110
Smpt_Cmd_Dl_Init = 100
Smpt_Cmd_Dl_Init_Ack = 101
Smpt_Cmd_Dl_Power_Module = 111
Smpt_Cmd_Dl_Power_Module_Ack = 112
Smpt_Cmd_Dl_Send_File = 107
Smpt_Cmd_Dl_Send_File_Ack = 113
Smpt_Cmd_Dl_Send_Live_Data = 106
Smpt_Cmd_Dl_Send_MMI = 108
Smpt_Cmd_Dl_Start = 102
Smpt_Cmd_Dl_Start_Ack = 103
Smpt_Cmd_Dl_Stop = 104
Smpt_Cmd_Dl_Stop_Ack = 105
Smpt_Cmd_Dl_Sys = 114
Smpt_Cmd_Dl_Sys_Ack = 115
Smpt_Cmd_General_Error = 66
Smpt_Cmd_Get_Battery_Status = 54
Smpt_Cmd_Get_Battery_Status_Ack = 55
Smpt_Cmd_Get_Device_Id = 52
Smpt_Cmd_Get_Device_Id_Ack = 53
Smpt_Cmd_Get_Extended_Version = 68
Smpt_Cmd_Get_Extended_Version_Ack = 69
Smpt_Cmd_Get_Main_Status = 64
Smpt_Cmd_Get_Main_Status_Ack = 65
Smpt_Cmd_Get_Stim_Status = 62
Smpt_Cmd_Get_Stim_Status_Ack = 63
Smpt_Cmd_Get_Version_Main = 50
Smpt_Cmd_Get_Version_Main_Ack = 51
Smpt_Cmd_Get_Version_Stim = 60
Smpt_Cmd_Get_Version_Stim_Ack = 61
Smpt_Cmd_Ll_Channel_Config = 2
Smpt_Cmd_Ll_Channel_Config_Ack = 3
Smpt_Cmd_Ll_Emg_Switches = 18
Smpt_Cmd_Ll_Emg_Switches_Ack = 19
Smpt_Cmd_Ll_Init = 0
Smpt_Cmd_Ll_Init_Ack = 1
Smpt_Cmd_Ll_Stop = 4
Smpt_Cmd_Ll_Stop_Ack = 5
Smpt_Cmd_Ml_Get_Current_Data = 36
Smpt_Cmd_Ml_Get_Current_Data_Ack = 37
Smpt_Cmd_Ml_Init = 30
Smpt_Cmd_Ml_Init_Ack = 31
Smpt_Cmd_Ml_Stop = 34
Smpt_Cmd_Ml_Stop_Ack = 35
Smpt_Cmd_Ml_Update = 32
Smpt_Cmd_Ml_Update_Ack = 33
Smpt_Cmd_Reset = 58
Smpt_Cmd_Reset_Ack = 59
Smpt_Cmd_Set_Power = 56
Smpt_Cmd_Set_Power_Ack = 57
Smpt_Cmd_Sl_Debug_Message = (164,)
Smpt_Cmd_Sl_Set_Bluetooth = (168,)
Smpt_Cmd_Sl_Set_Bluetooth_Ack = (169,)
Smpt_Cmd_Sl_Set_Debug = (162,)
Smpt_Cmd_Sl_Set_Debug_Ack = (163,)
Smpt_Cmd_Sl_Set_Device_Id = (170,)
Smpt_Cmd_Sl_Set_Device_Id_Ack = (171,)
Smpt_Cmd_Sl_Set_Fuel_Gauge = (166,)
Smpt_Cmd_Sl_Set_Fuel_Gauge_Ack = (167,)
Smpt_Cmd_Sl_Test_Memory_Card = (160,)
Smpt_Cmd_Sl_Test_Memory_Card_Ack = (161,)
Smpt_Cmd_Unknown_Cmd = 67
class pyScienceMode.enums.StimStatus(value)[source]

Bases: Enum

An enumeration.

Low_Level_Initialized = 1
Mid_Level_Initialized = 2
Mid_Level_Running = 3
Uninitialized = 0

pyScienceMode.motomed_interface module

Motomed Interface class used to control and get data from Motomed while connected to the rehamove2. See ScienceMode2 - Description and protocol for more information.

pyScienceMode.rehastim2_interface module

pyScienceMode.rehastimP24_interface module

pyScienceMode.sciencemode module

pyScienceMode.utils module

pyScienceMode.utils.calc_electrode_number(list_channels: list, enable_low_frequency: bool = False) int[source]

When enable_low_frequency = False : Calculates the number corresponding to which electrode is activated. During the initialisation, the computer needs to tell the Rehastim which channel needs to be activated. It is done through the addition of 2 pow the number of the channel. For example if the channel 1 and 4 needs to be activated, electrode_number = 2**1 + 2**4

When enable_low_frequency = True : Calculates the number corresponding to which electrode has the low_frequency_factor enabled.

Parameters:
  • list_channels (list[Channel]) – Contains the channels that will be activated.

  • enable_low_frequency (bool) – Choose whether the number correspond to active channel (False) or correspond to channel with low frequency factor enabled (True).

Returns:

electrode_number – Electrode number calculated.

Return type:

int

pyScienceMode.utils.check_inter_pulse_interval(inter_pulse_interval: int | None = None)[source]

Checks if the “inter pulse interval” is within limits.

Parameters:

inter_pulse_interval (int, optional) – Inter pulse interval to check. If out of limits, raise a ValueError.

pyScienceMode.utils.check_list_channel_order(list_channels)[source]

Checks if the channels in the list_channels given are ordered.

Parameters:

list_channels (list[Channel]) – Contains the channels. Raises a RuntimeError if not ordered.

pyScienceMode.utils.check_low_frequency_factor(low_frequency_factor: int | None = None)[source]

Checks if the low frequency factor is within limits.

Parameters:

low_frequency_factor (int, optional) – Low frequency factor to check. If out of limits, raise a ValueError.

pyScienceMode.utils.check_stimulation_interval(stimulation_interval: int | None = None)[source]

Checks if the stimulation interval is within limits.

Parameters:

stimulation_interval (int) – Stimulation interval to check. If out of limits, raise a ValueError.

pyScienceMode.utils.check_unique_channel(list_channels: list | None = None) bool[source]

Checks if there is not 2 times the same channel in the list given.

Parameters:

list_channels (list[Channel], optional) – Contains a list of channel.

Return type:

True if all channels are unique, False and print a warning if not.

pyScienceMode.utils.generic_error_check(ack_object)[source]
pyScienceMode.utils.packet_construction(packet_count: int, packet_type: str, packet_data: list | None = None) bytes[source]

Constructs the packet which will be sent to the Rehastim.

Parameters:
  • packet_count (int) – Correspond to the number of packet sent to the Rehastim.

  • packet_type (str) – Correspond to the command that will be sent.

  • packet_data (list) – Contain the data of the packet.

Returns:

packet_construct – Packet constructed which will be sent.

Return type:

bytes

pyScienceMode.utils.signed_int(packet: bytes) int[source]

Converts a signed int from the packet received from the Rehastim.

Parameters:

packet (bytes) – Packet received from the Rehastim.

Returns:

signed_int – Signed int converted.

Return type:

int

Module contents