Skip to content

Commit 064acb5

Browse files
committed
[fix] #104 Throw up error if API String doesn't match any enum option
1 parent 36c0b58 commit 064acb5

22 files changed

Lines changed: 31 additions & 7 deletions

CSM API String Arguments Support.vipb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2023-08-12 17:59:50" Modified_Date="2026-01-03 17:00:06" Creator="yaoli" Comments="" ID="89262b944ee0dbf464e6c83e9e444921">
1+
<VI_Package_Builder_Settings Version="2020.1" Created_Date="2023-08-12 17:59:50" Modified_Date="2026-01-06 11:25:07" Creator="yaoli" Comments="" ID="7b06187f899619e91a19f0980decfd12">
22
<Library_General_Settings>
33
<Package_File_Name>NEVSTOP_lib_CSM_API_String_Arguments_Support</Package_File_Name>
44
<Library_Version>2025.11.0.1</Library_Version>
@@ -55,7 +55,8 @@ More information for the supported datatype format, please visit: https://github
5555
<Release_Notes>[feature] #95 support lvlibp
5656
[fix] #98 Do not check (), to avoid bugs
5757
[fix] #100 for enum type, empty string should be converted to the reference enum value.
58-
[fix] #102 for cluster type, all elements will be used in no-tag mode in ��Data To API String Arguments.vi��</Release_Notes>
58+
[fix] #102 for cluster type, all elements will be used in no-tag mode in ��Data To API String Arguments.vi��
59+
[fix] #104 Throw up error if API String does'nt match any enum option</Release_Notes>
5960
</Description>
6061
<Destinations>
6162
<Toolkit_VIs>

README(zh-cn).md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ _**转换规则2:包含索引编号时**_
214214
- 字符串 "5" 将转换为 Enum(5 - BBBB),数字值为 1
215215
- 字符串 "9 - CCCC" 将转换为 Enum(9 - CCCC),数字值为 2
216216

217+
> [!NOTE]
218+
> - String matching is case-insensitive.
219+
> - String matching performs regular expression matching starting from the first element in the enum list until the first match is found. Therefore, partial writing is supported.
220+
> For example: 0x00 -- Spring | 0x01 -- Summer | 0x02 -- Autumn | 0x03 -- Winter
221+
> The input string "aut" will match to "Autumn".
222+
217223
### 数组(Array)
218224

219225
逗号(,) 用于元素分隔,分号(;) 用于行分隔。方括号([]) 用作边界符号。对于非复杂的混合数据类型,方括号可以省略。

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
[![Installs](https://www.vipm.io/package/nevstop_lib_csm_api_string_arguments_support/badge.svg?metric=installs)](https://www.vipm.io/package/nevstop_lib_csm_api_string_arguments_support/)
66
[![Stars](https://www.vipm.io/package/nevstop_lib_csm_api_string_arguments_support/badge.svg?metric=stars)](https://www.vipm.io/package/nevstop_lib_csm_api_string_arguments_support/)
7+
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
78
[![GitHub Downloads](https://img.shields.io/github/downloads/NEVSTOP-LAB/CSM-API-String-Arguments-Support/total)](https://github.com/NEVSTOP-LAB/CSM-API-String-Arguments-Support/releases)
89

9-
This library enhances the API parameters for the Communicable State Machine (CSM) framework by enabling the inclusion of various data types in plain text format.
10+
This library enhances the API parameters for the Communicable State Machine (CSM) framework by enabling the inclusion of various data types in plain text format and is specially optimized for manual input experience.
1011

11-
The library also provides two additional templates that include "Data: Get Configuration", "Data: Set Configuration", and "Data: Get Internal Data" states. These templates serve as a starting point for building CSM modules with the ability to access data stored in the '>> internal data >>' shift register.
12+
The library also provides two additional templates that include "Data: Get Configuration" and "Data: Set Configuration" states. These templates serve as a starting point for building CSM modules with the ability to access data stored in the '>> internal data >>' shift register.
1213

1314
![example](.github/doc.png)
1415

@@ -218,6 +219,12 @@ Example: Enum = {1- AAA, 5 - BBBB, 9 - CCCC}
218219
- String "5" converts to Enum(5 - BBBB), IntegerValue = 1
219220
- String "9 - CCCC" converts to Enum(9 - CCCC), IntegerValue = 2
220221

222+
> [!NOTE]
223+
> - String matching is case-insensitive.
224+
> - String matching performs regex matching from the first element in the enum list until the first match is found. Therefore, partial writing is supported.
225+
> For example: 0x00 -- Spring | 0x01 -- Summer | 0x02 -- Autumn | 0x03 -- Winter
226+
> Input string "aut" will match to "Autumn".
227+
221228
### Array
222229

223230
Commas (',') are used as element separators, and semicolons (';') are used as row separators. Square brackets ('[' and ']') serve as boundary symbols but can be omitted for simple data types.
@@ -303,4 +310,4 @@ In Non-Tag mode, the input string consists only of data values separated by semi
303310
304311
### Other Data Types
305312

306-
Other data types are treated as variants and transformed using CSM-HexStr.
313+
Other data types are first converted to variants and then transformed using CSM-HexStr.

_test/benchmark of to 1d array.vi

48 Bytes
Binary file not shown.

addons/API-String-Arugments-Support/API String Arguments Support.lvlib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<Item Name="String To Indexed Enum_csm.vi" Type="VI" URL="../_Support/String To Indexed Enum_csm.vi"/>
5656
<Item Name="Indexed Enum to Numeric_csm.vim" Type="VI" URL="../_Support/Indexed Enum to Numeric_csm.vim"/>
5757
<Item Name="Numeric to Indexed Enum_csm.vim" Type="VI" URL="../_Support/Numeric to Indexed Enum_csm.vim"/>
58+
<Item Name="Search 1D String Array by Pattern.vi" Type="VI" URL="../_Support/Search 1D String Array by Pattern.vi"/>
5859
</Item>
5960
<Item Name="Configure" Type="Folder">
6061
<Item Name="API String - Add Boolean Strings.vi" Type="VI" URL="../API String - Add Boolean Strings.vi"/>
Binary file not shown.
Binary file not shown.
Binary file not shown.

testcases/testcase-Supported-Datatype/testcase-Supported-Datatype.lvclass

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<Property Name="NI.ClassItem.IsStaticMethod" Type="Bool">true</Property>
108108
<Property Name="NI.ClassItem.MethodScope" Type="UInt">1</Property>
109109
<Property Name="NI.ClassItem.Priority" Type="Int">1</Property>
110-
<Property Name="NI.ClassItem.State" Type="Int">1082130960</Property>
110+
<Property Name="NI.ClassItem.State" Type="Int">1342972432</Property>
111111
</Item>
112112
<Item Name="test - Cluster Changed Value as Arguments.vi" Type="VI" URL="../testcases/test - Cluster Changed Value as Arguments.vi">
113113
<Property Name="NI.ClassItem.ConnectorPane" Type="Bin">&amp;Q#!!!!!!!)!"1!&amp;!!!-!%!!!@````]!!!!"!!%!!!&amp;!!!!!#1!-1#%'=X2B&gt;(6T!!!,1!-!"'.P:'5!!""!-0````]'=W^V=G.F!!!71&amp;!!!Q!!!!%!!AFF=H*P=C"P&gt;81!"!!!!$R!=!!?!!!F)X2F=X2D98.F,6.V=("P=H2F:#V%982B&gt;(FQ:3ZM&gt;G.M98.T!!R5:8.U1W&amp;T:3"P&gt;81!!#"!5!!$!!!!!1!#%W6S=G^S)'FO)#BO&lt;S"F=H*P=CE!/E"Q!"Y!!#5D&gt;'6T&gt;'.B=W5N5X6Q='^S&gt;'6E,52B&gt;'&amp;U?8"F,GRW9WRB=X-!#V2F=X2$98.F)'FO!'%!]!!-!!-!"!!%!!5!"!!%!!1!"!!'!!1!"!!(!Q!!?!!!$1A!!!!!!!!!!!!!$1M!!!!!!!!!!!!!!!!!!!!!!!!+!!!!!!!!!!!!!!!3!!!.!!!!$!!!!!!!!!!!!!!"!!A!!!!!</Property>
@@ -242,7 +242,16 @@
242242
<Property Name="NI.ClassItem.IsStaticMethod" Type="Bool">true</Property>
243243
<Property Name="NI.ClassItem.MethodScope" Type="UInt">1</Property>
244244
<Property Name="NI.ClassItem.Priority" Type="Int">1</Property>
245-
<Property Name="NI.ClassItem.State" Type="Int">1107821074</Property>
245+
<Property Name="NI.ClassItem.State" Type="Int">1107821072</Property>
246+
</Item>
247+
<Item Name="test - #104.vi" Type="VI" URL="../testcases/test - #104.vi">
248+
<Property Name="NI.ClassItem.ConnectorPane" Type="Bin">&amp;Q#!!!!!!!)!"1!&amp;!!!-!%!!!@````]!!!!"!!%!!!&amp;!!!!!#1!-1#%'=X2B&gt;(6T!!!,1!-!"'.P:'5!!""!-0````]'=W^V=G.F!!!71&amp;!!!Q!!!!%!!AFF=H*P=C"P&gt;81!"!!!!$R!=!!?!!!F)X2F=X2D98.F,6.V=("P=H2F:#V%982B&gt;(FQ:3ZM&gt;G.M98.T!!R5:8.U1W&amp;T:3"P&gt;81!!#"!5!!$!!!!!1!#%W6S=G^S)'FO)#BO&lt;S"F=H*P=CE!/E"Q!"Y!!#5D&gt;'6T&gt;'.B=W5N5X6Q='^S&gt;'6E,52B&gt;'&amp;U?8"F,GRW9WRB=X-!#V2F=X2$98.F)'FO!'%!]!!-!!-!"!!%!!5!"!!%!!1!"!!'!!1!"!!(!Q!!?!!!$1A!!!!!!!!!!!!!$1M!!!!!!!!!!!!!!!!!!!!!!!!+!!!!!!!!!!!!!!!3!!!.!!!!$!!!!!!!!!!!!!!"!!A!!!!!</Property>
249+
<Property Name="NI.ClassItem.ExecutionSystem" Type="Int">-1</Property>
250+
<Property Name="NI.ClassItem.Flags" Type="Int">16777216</Property>
251+
<Property Name="NI.ClassItem.IsStaticMethod" Type="Bool">true</Property>
252+
<Property Name="NI.ClassItem.MethodScope" Type="UInt">1</Property>
253+
<Property Name="NI.ClassItem.Priority" Type="Int">1</Property>
254+
<Property Name="NI.ClassItem.State" Type="Int">1074278928</Property>
246255
</Item>
247256
</Item>
248257
<Item Name="setUp.vi" Type="VI" URL="../setUp.vi">
Binary file not shown.

0 commit comments

Comments
 (0)