From 96fa6263a84f36b2c43dd02e004712ed849d7cd0 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Wed, 17 Jun 2026 12:39:12 +0800 Subject: [PATCH] doc: add some infos - add some infos in doc - add count limit prompt in query step --- README.md | 11 +++++- legacy/README.md | 50 ++++++++++++++++++++++++++-- legacy/pyproject.toml | 2 +- legacy/src/lcr_connector/__init__.py | 32 +++++++++++++++++- 4 files changed, 90 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 52c1d94..9b4dadf 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ # LCR Connector -TODO +Get the resistor, capacitor, or inductor circuit which has the closest value for your given value within at most 3 devices. + +# Todos + +- [x] Refactor the legacy version. +- [ ] Add A-Star resolver in legacy version to replace LUT resolver. +- [ ] Use Rust to fully rewrite the legacy version as a library. +- [ ] Use Rust to create a CLI based on the library created at previous step. +- [ ] Utilize FLTK to create a GUI in desktop operating system. +- [ ] Utilize Flutter to create a GUI in mobile operating system. diff --git a/legacy/README.md b/legacy/README.md index cd94f01..3b7adf4 100644 --- a/legacy/README.md +++ b/legacy/README.md @@ -1,5 +1,51 @@ # LCR Connector (Legacy) -在3个元器件内,使用给定元器件数值列表快速找到目标数值元器件的最好拼接方式,支持电阻,电容,电感 +Get the resistor, capacitor, or inductor circuit which has the closest value for your given value within at most 3 devices. -执行`uv run lcr-connector --help`来查阅参数手册。 +This is the legacy version of LCR Connector, although this is also refactored from true legacy version in modern Python. + +## Usage + +- Execute `uv sync` to configure the environment. +- Execute `uv run lcr-connector --help` for the usage of LCR Connector. +- After launch LCR Connector, you can see the help message in interactive console, or type `help` to see the help message. + +Additionaly, for using LCR Connector, you need 3 list files holding all possible device standard values which are available in your laboratory. +Each of them represents a type of device respectively, resistor, capacitor, or inductor. +These list files are basically like this: + +``` +100 +220 +270 +390 +470 +680 +1k +1.2k +1.5k +2.2k +3.3k +4.7k +6.8k +10k +47k +100k +1M +``` + +Supported units are: + +- n: Nano +- p: Pico +- u: Micro +- m: Milli +- k: Kilo +- M: Mega +- G: Giga + +There is no physical unit for the values in the list files. + +Unit is optional. If you don't specify a unit, the value is considered as a plain floating value. + +Unit is **case sensitive** to distinguish between milli and mega (e.g. 1m is milli, 1M is mega). diff --git a/legacy/pyproject.toml b/legacy/pyproject.toml index ec1e27c..c7b7fc1 100644 --- a/legacy/pyproject.toml +++ b/legacy/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "lcr-connector" version = "1.0.0" -description = "Use as much 3 devices to reach target value for resistor, capacitor and inductor." +description = "Get the resistor, capacitor, or inductor circuit which has the closest value for your given value within at most 3 devices." readme = "README.md" authors = [ { name = "yyc12345", email = "yyc12321@outlook.com" } diff --git a/legacy/src/lcr_connector/__init__.py b/legacy/src/lcr_connector/__init__.py index afa8cd3..368caf3 100644 --- a/legacy/src/lcr_connector/__init__.py +++ b/legacy/src/lcr_connector/__init__.py @@ -149,8 +149,13 @@ class App: App.QuerySortPriority ).to_response_priority() + print("How may result are you expected?") + count_limit = self.__accept_count_value() + # build request and ask resolver - request = Request(device_kind, target_value, tolerance, response_priority, 100) + request = Request( + device_kind, target_value, tolerance, response_priority, count_limit + ) response = self.__resolver.resolve(request) # use page viewer to show result @@ -217,10 +222,33 @@ class App: except ValueError: print("Unknown command, please try again.") + def __accept_count_value(self) -> int: + MAX_COUNT: int = 50 + + while True: + self.__show_prompt_arrow() + words = input() + if words == "": + continue + + try: + value = int(words) + except ValueError: + print("Wrong value, please try again.") + continue + + if value > MAX_COUNT or value <= 0: + print("Wrong value, please try again.") + else: + return value + def __accept_device_value(self) -> float: while True: self.__show_prompt_arrow() words = input() + if words == "": + continue + value = self.__parse_human_readable_value(words) if value is None: print("Wrong value, please try again.") @@ -231,6 +259,8 @@ class App: while True: self.__show_prompt_arrow() words = input() + if words == "": + continue if words.endswith("%"): value = self.__parse_plain_float(