ENLIGHTEN
Cross-platform desktop GUI for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
enlighten.KnowItAll.Wrapper.Wrapper Class Reference

This class encapsulates ENLIGHTEN's interface to KnowItAll. More...

Public Member Functions

 __init__ (self, executable_pathname, library_pathname, log_level, log_queue)
 
 connect (self)
 Spawn the sub-process which actually communicates with our KIAConsole.exe via stdin/out in a background thread (so that KIAConsole processing delays, which can be considerable, do not affect the ENLIGHTEN GUI response time).
 
 continuous_poll (self, args)
 
 disconnect (self)
 Kill the subprocess by passing a "poison-pill" request downstream.
 
 get_response (self)
 Feature calls this to fetch the latest KIA response, if there is one.
 
 reset (self)
 
 send_request (self, x_axis, spectrum, max_results, min_score, measurement_id=None)
 enlighten.Controller calls this to identify the last-collected spectrum.
 
 verify_connection (self)
 check to confirm subprocess spawns okay, by checking for exactly one "True" object on the response pipeline
 

Public Attributes

int connection_status = Wrapper.CONNECTION_NOT_STARTED
 
 executable_pathname = executable_pathname
 
 library_pathname = library_pathname
 
 log_level = log_level
 
 log_queue = log_queue
 
 pipe_child = None
 
 pipe_parent = None
 
 poller = None
 
 q_child = Queue()
 
 q_parent = Queue()
 
 time_connection_started = None
 

Static Public Attributes

int CONNECTION_ERROR = 3
 
int CONNECTION_NOT_STARTED = 0
 
int CONNECTION_PENDING_VERIFICATION = 1
 
int CONNECTION_TIMEOUT_SEC = 15
 
int CONNECTION_VERIFIED = 2
 
int POLLER_WAIT_SEC = 1
 How long the subprocess should sleep before checking to see if a new request has been passed down the interprocess pipe.
 

Detailed Description

This class encapsulates ENLIGHTEN's interface to KnowItAll.

Design Considerations

This needs to be in a background thread, so we can process newly acquired spectra when there is no pending match in-progress. Therefore, we're borrowing some architecture from WasatchDeviceWrapper.

The subprocess will communicate with KIAConsole via the text protocol used by KIAConsole. The subprocess will communicate with the MainProcess.KnowItAllWrapper via picklable Python objects.

Currently no attempt has been made to integrate this into the RamanMatching class as an alternate matching engine, though it certainly should be. Right now I'm just providing a quick "proof-of-concept" integration to show that the executable and linked library and signature database can indeed be accessed from within ENLIGHTEN in timely fashion.

Multiprocessing Shenanigans

Note that multiprocessing.Process().start() explodes if the Wrapper contains callbacks to Controller. (Controller is a QThingy that can't be pickled.)

Todo

support authentication (look for "expected" within match results)

support good/bad (look for known-good and known-bad results, returning binary indicator)

Constructor & Destructor Documentation

◆ __init__()

enlighten.KnowItAll.Wrapper.Wrapper.__init__ ( self,
executable_pathname,
library_pathname,
log_level,
log_queue )

Member Function Documentation

◆ connect()

enlighten.KnowItAll.Wrapper.Wrapper.connect ( self)

Spawn the sub-process which actually communicates with our KIAConsole.exe via stdin/out in a background thread (so that KIAConsole processing delays, which can be considerable, do not affect the ENLIGHTEN GUI response time).

This is essentially a private method, as the initial connect is driven by the "enable" checkbox.

◆ continuous_poll()

enlighten.KnowItAll.Wrapper.Wrapper.continuous_poll ( self,
args )

◆ disconnect()

enlighten.KnowItAll.Wrapper.Wrapper.disconnect ( self)

Kill the subprocess by passing a "poison-pill" request downstream.

This is a public method, called by the Controller.

◆ get_response()

enlighten.KnowItAll.Wrapper.Wrapper.get_response ( self)

Feature calls this to fetch the latest KIA response, if there is one.

◆ reset()

enlighten.KnowItAll.Wrapper.Wrapper.reset ( self)

◆ send_request()

enlighten.KnowItAll.Wrapper.Wrapper.send_request ( self,
x_axis,
spectrum,
max_results,
min_score,
measurement_id = None )

enlighten.Controller calls this to identify the last-collected spectrum.

x should be in wavenumbers, since KIAConsole is hard-coded to use KIA's Raman module. This function packages the request into a request object and then sends to the subprocess for matching.

Only one request can be active at once, so if a pending request is already in-process, this request is rejected outright (not queued, as ENLIGHTEN can collect data far faster than KIA can process it).

Todo
address use-case of identifying loaded spectra, perhaps via a process(x, y) method

◆ verify_connection()

enlighten.KnowItAll.Wrapper.Wrapper.verify_connection ( self)

check to confirm subprocess spawns okay, by checking for exactly one "True" object on the response pipeline

Member Data Documentation

◆ CONNECTION_ERROR

int enlighten.KnowItAll.Wrapper.Wrapper.CONNECTION_ERROR = 3
static

◆ CONNECTION_NOT_STARTED

int enlighten.KnowItAll.Wrapper.Wrapper.CONNECTION_NOT_STARTED = 0
static

◆ CONNECTION_PENDING_VERIFICATION

int enlighten.KnowItAll.Wrapper.Wrapper.CONNECTION_PENDING_VERIFICATION = 1
static

◆ connection_status

int enlighten.KnowItAll.Wrapper.Wrapper.connection_status = Wrapper.CONNECTION_NOT_STARTED

◆ CONNECTION_TIMEOUT_SEC

int enlighten.KnowItAll.Wrapper.Wrapper.CONNECTION_TIMEOUT_SEC = 15
static

◆ CONNECTION_VERIFIED

int enlighten.KnowItAll.Wrapper.Wrapper.CONNECTION_VERIFIED = 2
static

◆ executable_pathname

enlighten.KnowItAll.Wrapper.Wrapper.executable_pathname = executable_pathname

◆ library_pathname

enlighten.KnowItAll.Wrapper.Wrapper.library_pathname = library_pathname

◆ log_level

enlighten.KnowItAll.Wrapper.Wrapper.log_level = log_level

◆ log_queue

enlighten.KnowItAll.Wrapper.Wrapper.log_queue = log_queue

◆ pipe_child

enlighten.KnowItAll.Wrapper.Wrapper.pipe_child = None

◆ pipe_parent

enlighten.KnowItAll.Wrapper.Wrapper.pipe_parent = None

◆ poller

enlighten.KnowItAll.Wrapper.Wrapper.poller = None

◆ POLLER_WAIT_SEC

int enlighten.KnowItAll.Wrapper.Wrapper.POLLER_WAIT_SEC = 1
static

How long the subprocess should sleep before checking to see if a new request has been passed down the interprocess pipe.

(Is there an event- oriented Python message queue?)

◆ q_child

enlighten.KnowItAll.Wrapper.Wrapper.q_child = Queue()

◆ q_parent

enlighten.KnowItAll.Wrapper.Wrapper.q_parent = Queue()

◆ time_connection_started

enlighten.KnowItAll.Wrapper.Wrapper.time_connection_started = None

The documentation for this class was generated from the following file: