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

WLM control by task handler #27

Merged
merged 12 commits into from
Nov 20, 2024
Merged

Conversation

BECATRUE
Copy link
Member

This resolves #6.

I couldn't test these features since it needs a WLM device, so please check the codes carefully.

@BECATRUE BECATRUE added the enhancement New feature or request label Nov 19, 2024
@BECATRUE BECATRUE added this to the v1.0.0 milestone Nov 19, 2024
@BECATRUE BECATRUE requested a review from kangz12345 November 19, 2024 02:53
@BECATRUE BECATRUE self-assigned this Nov 19, 2024
wlm_server/task/measure.py Outdated Show resolved Hide resolved
wlm_server/task/handler.py Outdated Show resolved Hide resolved
self._message_queue: MessageQueue = settings.MESSAGE_QUEUE
self._measure_queue: MeasureQueue = MeasureQueue()
self._channel_to_period: dict[int, timedelta] = {}
self._open_connection()

def _open_connection(self):
Copy link
Member

Choose a reason for hiding this comment

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

This method may cause several errors, e.g., there is no Config, failed to open WLM.
In fact, regarding WLM, it is always possible to fail the API call as the USB connection goes wrong sometimes.
I think we should carefully handle such error cases.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe modeling this handler as an FSM would be helpful..?

Copy link
Member Author

Choose a reason for hiding this comment

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

Umm.. Indeed, I didn't consider any error on purpose.
To send the occurred error info to the request handler, we need to implement more APIs, hence I'd like to handle this after implementing main features.

What do you think about this? @kangz12345

Copy link
Member

Choose a reason for hiding this comment

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

Alright then, for now the structure might vary in the future, so let's handle the errors later.

wlm_server/task/handler.py Show resolved Hide resolved
self._wlm.close()

def _start_channel_measurement(self, channel: int):
setting = Setting.objects.filter(channel__name=channel).order_by('-created_at').first()
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep this in mind: the filtering might cost quite a lot in the future.
For now I think it would be fine.

wlm_server/task/handler.py Show resolved Hide resolved
wlm_server/task/handler.py Show resolved Hide resolved
wlm_server/task/handler.py Outdated Show resolved Hide resolved
Co-authored-by: Jiyong Kang <[email protected]>

See also: #6
@BECATRUE BECATRUE requested a review from kangz12345 November 20, 2024 09:03
Copy link
Member

@kangz12345 kangz12345 left a comment

Choose a reason for hiding this comment

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

LGTM

@BECATRUE BECATRUE merged commit 9437393 into develop Nov 20, 2024
3 checks passed
@BECATRUE BECATRUE deleted the BECATRUE/6/wlm-control-task-handler branch November 20, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WLM control by task handler
2 participants