maodevice.scpi module¶
-
class
maodevice.scpi.
ScpiCommonCommands
(com)[source]¶ Bases:
maodevice.core.BaseDeviceHandler
IEEE-488.2 common commands.
This class is for handling IEEE-488.2 common commands.
- Attribute:
- SCPI_DICT (dict): Dictionary of IEEE-488.2 common commands.
-
SCPI_DICT
= {'*CLS': 'clear_status', '*ESE': 'standard_event_status_enable', '*ESE?': 'standard_event_status_enable_query', '*ESR?': 'standard_event_status_register_query', '*IDN?': 'identification_query', '*LRN?': 'learn_device_setup_query', '*OPC': 'operation_complete', '*OPC?': 'operation_complete_query', '*PSC': 'power_on_status_clear', '*PSC?': 'power_on_status_clear_query', '*RCL': 'recall', '*RST': 'reset', '*SAV': 'save', '*SRE': 'service_request_enable', '*SRE?': 'service_request_enable_query', '*STB?': 'read_status_byte_query', '*TRG': 'trigger', '*TST?': 'self_test', '*WAI': 'wait_to_continue'}¶
-
clear_status
()[source]¶ CLS: Clear Status
This commands clear the status byte, the data questionable event register, the standard event status register, the standard operation status register, and any other registers that are summarized in the byte.
Parameters: None – Returns: None
-
identification_query
()[source]¶ IDN? Idntification query
This query outputs an identifying string to the GPIB. The response for the signal generator will be a storing that shows the actual model number, serial number and firmware revision will be substituted.
Parameters: None – Returns: String that identify the device. Return type: ret (bytes)
-
learn_device_setup_query
()[source]¶ LRN? Learn Device Setup query
This query returns instrument settings by binary block data (same as Save/Recall state file contents) with “SYSTem:SET” prefix. The returned data is the same as the contents of state file which can be saved by the SCPI.MMEMory.STORe.STATe. Therefore, the returned data contents is changed according to the setting of SCPI.MMEMory.STORe.STYPe.
Parameters: None – Returns: Instruments settings by binary block data Return type: ret (bytes)
-
operation_complete
()[source]¶ OPC: Operation Complete
This command sets bit 0 in the standard event status register when all pending operations have finished.
Parameters: None – Returns: None
-
operation_complete_query
()[source]¶ OPC?: Operation Complete query
This queries bit 0 in the standard event status register. The signal generator will return an ASCII “1” when all pending operations have finished.
Parameters: None – Returns: ASCII “1”. Return type: ret (bytes)
-
power_on_status_clear
(status)[source]¶ PSC: Power on Status Clear
This command turns on / off clearing of the specific enable register at power on.
Parameters: status (int) – 1 is on, 0 is off. Returns: None
-
power_on_status_clear_query
()[source]¶ PSC?: Power on Status Clear query
This command queries the power on status clear setting.
Parameters: None – Returns: On (1) or Off (0). Return type: ret (bytes)
-
read_status_byte_query
()[source]¶ STB?: Read Status Byte query
This queries the status byte. This is a non-destructive read.
Parameters: None – Returns: Status byte register bits to be turned on. Return type: ret (bytes)
-
recall
(mem_loc)[source]¶ RCL: Recall
This command recall the complete instrument setting from memory.
Parameters: mem_loc (int) – Memory location. Allowed values are 0, 1, 2, 3 or 4. Returns: None
-
reset
()[source]¶ RST: Reset
This command resets the instrument to a factory pre-defined condition.
Parameters: None – Returns: None
-
save
(mem_loc)[source]¶ SAV: Save
This command save the complete instrument setting to memory.
Parameters: mem_loc (int) – Memory location. Allowed values are 0, 1, 2, 3 or 4. Returns: None
-
self_test
()[source]¶ TST?: Self-Test query
This query returns the result of the power-up selftest.
Parameters: None – Returns: 0 (Passed) or 1 (Failed). Return type: ret (int)
-
service_request_enable
(bit)[source]¶ SRE: Service Request Enable
This command sets the value of the service request enable register.
Note
The status byte register is described below. - 0 (1): Unused - 1 (2): Unused - 2 (4): Error Queue - 3 (8): Questionable Data Register - 4 (16): Output Buffer - 5 (32): Standard Event Register - 6 (64): Status Byte Register - 7 (128): Unused
Parameters: bit (int) – Standard event register bits to be turned on.
-
service_request_enable_query
()[source]¶ SRE?: Service Request Enable query
This queries the value of the service request enable register.
Parameters: None – Returns: Status byte register. Return type: ret (bytes)
-
standard_event_status_enable
(bit)[source]¶ ESE: Standard Event Status Enable
This command sets the standard event status enable register.
Note
The standard event register is described below. - 0 (1): Operation Complete - 1 (2): Unused - 2 (4): Query Error - 3 (8): Device Error - 4 (16): Execution Error - 5 (32): Command Error - 6 (64): Unused - 7 (128): Power On
Parameters: bit (int) – Standard event register bits to be turned on. Returns: None Example
Bit 4 and bit 5 of the enable register are on:
>>> standard_event_status_enable(24) # 0b11000, 0x18
-
standard_event_status_enable_query
()[source]¶ ESE?: Standard Event Status Enable query
This queries the status of standard event status enable register. This is a destructive read.
Parameters: None – Returns: Standard event status enable register. Return type: ret (bytes)
-
standard_event_status_register_query
()[source]¶ ESR?: Standard Event Status Register query
This queries the value of the standard event status register.
Parameters: None – Returns: Standard event status register. Return type: ret (bytes)
-
class
maodevice.scpi.
ScpiHandler
(com)[source]¶ Bases:
maodevice.core.BaseDeviceHandler
Handle IEEE-488.2 common commands.
Note
If you limit IEEE-488.2 common commands, write it as follows before instantiation. When you use only CLS and RST,:
>>> enable_cmds = ["*CLS", "*RST"]
Parameters: com (maodevice.communicator) – Communicator instance to control the device. - Attribute:
- enable_cmds (
list
ofstr
): - IEEE-488.2 common commands to use.
- enable_cmds (
-
enable_cmds
= ['*CLS', '*ESE', '*OPC', '*PSC', '*RCL', '*RST', '*SAV', '*SRE', '*TRG', '*WAI', '*ESE?', '*ESR?', '*IDN?', '*LRN?', '*OPC?', '*PSC?', '*SRE?', '*STB?', '*TST?']¶