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 Spotchem™EL SE-1520 import schema #19

Merged
merged 20 commits into from
Nov 22, 2024
Merged

Add Spotchem™EL SE-1520 import schema #19

merged 20 commits into from
Nov 22, 2024

Conversation

ramonski
Copy link
Contributor

@ramonski ramonski commented Nov 7, 2024

Description of the issue/feature this PR addresses

This PR implements an instrument interface for the Spotchem™EL SE-1520

☝️ NOTE: This instrument does not implement the ASTM protocol and sends only a single message, e.g.:

\x0224/10/29 13:08 ID# 1DC042FP [B. Plasma] Na 131 mmol/L K 9.7 mmol/L Cl 96 mmol/L \x03

Therefore, we introduced in this PR the possibility to hook into the protocol data handler with an adapter:

    def handle_data(self, data):
        """Process incoming data
        """
        # lookup custom multi-adapter to handle the data
        adapter = adapter_registry.queryMultiAdapter((self, data), IDataHandler)
        if adapter and adapter.can_handle():
            return adapter.handle_data()

        response = None
        if data.startswith(ENQ):
            response = self.on_enq(data)
        elif data.startswith(ACK):
            response = self.on_ack(data)
        elif data.startswith(NAK):
            response = self.on_nak(data)
        elif data.startswith(EOT):
            response = self.on_eot(data)
        elif data.startswith(STX):
            response = self.on_message(data)
        else:
            response = self.default_handler(data)
        return response

This makes it possible to create a valid ASTM message for the message schema lookup and data provision to SENAITE.

Current behavior before PR

Spotchem™EL SE-1520 Instrument not supported

Desired behavior after PR is merged

Spotchem™EL SE-1520 Instrument is supported

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@ramonski ramonski changed the title Implemented Spotchem™EL SE-1520 Add Spotchem™EL SE-1520 import schema Nov 11, 2024
@ramonski ramonski requested a review from xispa November 11, 2024 06:49
@ramonski ramonski added the enhancement New feature or request label Nov 11, 2024
@xispa xispa merged commit 6b9dba9 into master Nov 22, 2024
2 checks passed
@xispa xispa deleted the spotchem-se-1520 branch November 22, 2024 12:54
Copy link
Member

@xispa xispa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!. I stumbled upon same problem recently with Abbott Cell-dyn Emerald 22 AL. You can connect the instrument through TCP/IP, but data sent does not adhere to ASTM E1394-97. Excerpt from the manual:

The Host Interface for the CELL-DYN Emerald 22 AL System is a specific format designed to transfer data to an external system. The system does not use the ASTM or CLIS (LIS-x) standards for communications with a host system. The format is text-oriented and is compatible with CSV format used by various Microsoft Office applications1

So I will open a PR soon with a custom IDataHandler adapter for this other instrument!

Footnotes

  1. Abbott - Afinion 2 User Manual, rev.2, 2023.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants