Skip to content

Commit 752e513

Browse files
committed
Support for RFIDScanner Added
Support for RFIDScanner added. RFIDScanner added to list of supported device classes in startup GUI.
1 parent 0b8f59b commit 752e513

5 files changed

Lines changed: 550 additions & 6 deletions

File tree

src/SPF_Test/CommonController.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,10 +1065,17 @@ public String byteArrayToHexString(byte[] data, int limit, boolean separator, in
10651065

10661066
/**
10671067
* Converts hexadecimal string to byte array. Whitespace are allowed as byte separators and will be skipped.
1068+
* <br>Parameter strong specifies the behavior when data contains invalid characters:
1069+
* <ul>
1070+
* <li>If strong is true, this method returns null if data contains an invalid character.</li>
1071+
* <li>If strong is false, this method returns a byte array that represents the contents of the string
1072+
* up to the invalid character.</li>
1073+
* </ul>
10681074
* @param data Hexadecimal string.
1075+
* @param strong Specifies behavior in case of invalid string.
10691076
* @return The corresponding byte array.
10701077
*/
1071-
public byte[] hexStringToByteArray(String data) {
1078+
public byte[] hexStringToByteArray(String data, boolean strong) {
10721079
data = data.toUpperCase();
10731080
byte[] result = new byte[data.length()];
10741081
int i, j = 0;
@@ -1085,7 +1092,9 @@ public byte[] hexStringToByteArray(String data) {
10851092
if (v < 0) {
10861093
if (c <= 0x20) // whitespace: byte finished
10871094
break;
1088-
throw new Exception(""); // No hex digit, no whitespace: Break all loops
1095+
if (strong) // No hex digit, no whitespace: Break all loops
1096+
return null;
1097+
throw new Exception("");
10891098
}
10901099
b = (byte) (b * 0x10 + v);
10911100
}
@@ -1097,6 +1106,15 @@ public byte[] hexStringToByteArray(String data) {
10971106
return Arrays.copyOf(result, i);
10981107
}
10991108

1109+
/**
1110+
* Converts hexadecimal string to byte array. Whitespace are allowed as byte separators and will be skipped.
1111+
* @param data Hexadecimal string.
1112+
* @return The corresponding byte array.
1113+
*/
1114+
public byte[] hexStringToByteArray(String data) {
1115+
return hexStringToByteArray(data, false);
1116+
}
1117+
11001118
/**
11011119
* Converts byte array to ASCII string with backslash escape sequences: A single backslash will be replaced by
11021120
* two backslashes and byte values &lt; 0x20 and 0x7f will be replaced by one backslash, followed by the byte value
@@ -1319,8 +1337,6 @@ static int myOptionDialog(String message, String title, int optionType, int mess
13191337
Values ErrorCodeExtendedValueConverter = new IntValues();
13201338

13211339
String getLogString(ErrorEvent event) {
1322-
if (event instanceof JposErrorEvent)
1323-
return ((JposErrorEvent) event).toLogString();
13241340
String errorcodes = new ErrorLocusValues().getSymbol(event.getErrorLocus());
13251341
errorcodes += " - " + new ErrorCodeValues().getSymbol(event.getErrorCode());
13261342
if (event.getErrorCodeExtended() != 0) {

src/SPF_Test/DeviceControl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ static void loadDevices(String jposXml, Controller control) {
255255
} else if (category.equals("Scale")) {
256256
actdev.Control = new Scale();
257257
actdev.Gui = FXMLLoader.load(control.getClass().getResource("Scale.fxml"), new DeviceResources(actdev));
258+
} else if (category.equals("RFIDScanner")) {
259+
actdev.Control = new RFIDScanner();
260+
actdev.Gui = FXMLLoader.load(control.getClass().getResource("RFIDScanner.fxml"), new DeviceResources(actdev));
258261
} else if (category.equals("Scanner")) {
259262
actdev.Control = new Scanner();
260263
actdev.Gui = FXMLLoader.load(control.getClass().getResource("Scanner.fxml"), new DeviceResources(actdev));

src/SPF_Test/RFIDScanner.fxml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import java.lang.*?>
4+
<?import java.util.*?>
5+
<?import javafx.scene.*?>
6+
<?import javafx.scene.control.*?>
7+
<?import javafx.scene.layout.*?>
8+
9+
<!--
10+
~ Copyright 2023 Martin Conrad
11+
~ <p>
12+
~ Licensed under the Apache License, Version 2.0 (the "License");
13+
~ you may not use this file except in compliance with the License.
14+
~ You may obtain a copy of the License at
15+
~ <p>
16+
~ http://www.apache.org/licenses/LICENSE-2.0
17+
~ <p>
18+
~ Unless required by applicable law or agreed to in writing, software
19+
~ distributed under the License is distributed on an "AS IS" BASIS,
20+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
~ See the License for the specific language governing permissions and
22+
~ limitations under the License.
23+
~
24+
-->
25+
26+
<AnchorPane xmlns="http://javafx.com/javafx"
27+
xmlns:fx="http://javafx.com/fxml"
28+
fx:controller="SPF_Test.RFIDScannerController"
29+
prefHeight="540.0" prefWidth="980.0">
30+
<CheckBox fx:id="DeviceEnabled" text="DeviceEnabled" layoutY="5" onAction="#setDeviceEnabled"/>
31+
<CheckBox fx:id="FreezeEvents" text="FreezeEvents" layoutX="105" layoutY="5" onAction="#setFreezeEvents"/>
32+
<CheckBox fx:id="DataEventEnabled" text="DataEventEnabled" layoutX="200" layoutY="5" onAction="#setDataEventEnabled"/>
33+
<ComboBox fx:id="PowerNotify" prefWidth="145" layoutX="320" editable="true" onAction="#setPowerNotify"/>
34+
<Label text="PowerNotify" layoutX="470" layoutY="5"/>
35+
<CheckBox fx:id="AutoDisable" text="AutoDisable" layoutX="570" onAction="#setAutoDisable"/>
36+
<Label text="OutputID:" layoutX="720"/>
37+
<Label fx:id="OutputID" layoutX="770" prefWidth="50" textAlignment="RIGHT"/>
38+
<Label fx:id="DataCount" layoutX="830"/>
39+
<TableView fx:id="Properties" layoutX="570" layoutY="19" prefWidth="410" prefHeight="96"/>
40+
<Button text="Open" layoutY="35" onAction="#open" prefWidth="70"/>
41+
<Button text="Claim" layoutX="80" layoutY="35" onAction="#claim" prefWidth="70"/>
42+
<ComboBox fx:id="claim_timeout" prefWidth="70" layoutX="80" layoutY="60" promptText="timeout" editable="true"/>
43+
<Button text="Release" layoutX="160" layoutY="35" onAction="#release" prefWidth="70"/>
44+
<Button text="Close" layoutX="240" layoutY="35" onAction="#close" prefWidth="70"/>
45+
<Button text="CheckHealth" layoutX="320" layoutY="35" onAction="#checkHealth" prefWidth="90"/>
46+
<ComboBox fx:id="CH_level" prefWidth="90" layoutX="320" layoutY="60" promptText="level" editable="true"/>
47+
<Button text="DirectIO" layoutX="420" layoutY="35" onAction="#directIO" prefWidth="140"/>
48+
<TextField fx:id="DIO_command" prefWidth="70" layoutX="420" layoutY="60" promptText="command"/>
49+
<TextField fx:id="DIO_data" prefWidth="70" layoutX="490" layoutY="60" promptText="data"/>
50+
<TextField fx:id="DIO_obj" prefWidth="140" layoutX="420" layoutY="85" promptText="obj"/>
51+
<Button text="ClearInput" layoutX="0" layoutY="90" onAction="#clearInput" prefWidth="110"/>
52+
<Button text="ClearOutput" layoutX="120" layoutY="90" onAction="#clearOutput" prefWidth="110"/>
53+
<Button text="ClearInputProperties" layoutX="240" layoutY="90" onAction="#clearInputProperties" prefWidth="170"/>
54+
<Label fx:id="MethodActive" layoutY="530"/>
55+
<TabPane layoutY="116" prefWidth="695" prefHeight="424" tabClosingPolicy="UNAVAILABLE">
56+
<Tab text="Specific Properties And Methods">
57+
<AnchorPane prefHeight="409" prefWidth="695">
58+
<Label text="ReadTimerInterval: " layoutY="10"/>
59+
<TextField fx:id="ReadTimerInterval" prefWidth="70" layoutX="93" layoutY="5"/>
60+
<Label text="ProtocolMask: " layoutY="10" layoutX="170"/>
61+
<ComboBox fx:id="ProtocolMask" layoutX="240" layoutY="5" prefWidth="90" editable="true" onAction="#setProtocolMask"/>
62+
<ComboBox fx:id="MaskBit" layoutX="330" layoutY="5" prefWidth="150" promptText="Select Bit"/>
63+
<Button text="Add Bit" layoutX="480" layoutY="5" prefWidth="60" onAction="#addProtocolBit"/>
64+
<Button text="Clear Bit" layoutX="540" layoutY="5" prefWidth="60" onAction="#clearProtocolBit"/>
65+
<ComboBox fx:id="ProtocolMaskHelp" layoutY="5" layoutX="605" prefWidth="85" onAction="#protokolMaskHelp"/>
66+
<Label text="General Method Parameter 'timeout':" layoutY="40"/>
67+
<ComboBox fx:id="GMP_timeout" promptText="timeout" layoutY="35" layoutX="190" editable="true" prefWidth="90"/>
68+
<Label text="General Method Parameter 'password':" layoutY="80"/>
69+
<TextArea fx:id="GMP_password" promptText="password" layoutY="60" layoutX="190" prefWidth="150" styleClass="FixedFont" prefHeight="60"/>
70+
<Label text="General Method Parameter" layoutX="365" layoutY="70"/>
71+
<Label text="'tagID', 'filterID' or 'sourceID':" layoutX="365" layoutY="90"/>
72+
<TextArea fx:id="GMP_tagID" promptText="tagID, filterID or sourceID" layoutY="60" layoutX="510" prefWidth="180" styleClass="FixedFont" prefHeight="60"/>
73+
<Button text="StartReadTags" prefWidth="90" prefHeight="30" layoutY="125" onAction="#startReadTags"/>
74+
<Button text="ReadTags" prefWidth="90" prefHeight="30" layoutY="155" onAction="#readTags"/>
75+
<ComboBox fx:id="RT_cmd" promptText="cmd" layoutY="125" layoutX="90" prefWidth="100" prefHeight="60" editable="true"/>
76+
<TextArea fx:id="RT_filtermask" promptText="filtermask" layoutX="190" layoutY="125" prefWidth="150" styleClass="FixedFont" prefHeight="60"/>
77+
<TextField fx:id="RT_start" promptText="start" layoutX="340" layoutY="125" prefWidth="35" prefHeight="60"/>
78+
<TextField fx:id="RT_length" promptText="length" layoutX="375" layoutY="125" prefWidth="35" prefHeight="60"/>
79+
<Button text="StopReadTags" prefWidth="90" prefHeight="27" layoutX="430" layoutY="125" onAction="#stopReadTags"/>
80+
<Button text="LockTag" prefWidth="90" prefHeight="27" layoutX="430" layoutY="158" onAction="#lockTag"/>
81+
<Button text="DisableTag" prefWidth="90" prefHeight="27" layoutX="540" layoutY="158" onAction="#disableTag"/>
82+
<Button text="WriteTagData" onAction="#writeTagData" layoutY="190" prefWidth="90" prefHeight="60"/>
83+
<TextArea fx:id="WD_userdata" promptText="userdata" layoutX="90" layoutY="190" prefWidth="250" styleClass="FixedFont" prefHeight="60"/>
84+
<TextField fx:id="WD_start" promptText="start" layoutX="340" layoutY="190" prefWidth="35" prefHeight="60"/>
85+
<Button text="WriteTagID" onAction="#writeTagID" layoutY="190" layoutX="430" prefWidth="80" prefHeight="60"/>
86+
<TextArea fx:id="WI_destID" promptText="destID" layoutY="190" layoutX="510" prefWidth="180" styleClass="FixedFont" prefHeight="60"/>
87+
<Button text="FirstTag" onAction="#firstTag" layoutY="255" prefWidth="100"/>
88+
<Button text="NextTag" onAction="#nextTag" layoutX="110" layoutY="255" prefWidth="100"/>
89+
<Button text="PreviousTag" onAction="#previousTag" layoutX="220" layoutY="255" prefWidth="100"/>
90+
<Label text="TagCount: " layoutX="350" layoutY="260"/>
91+
<Label fx:id="TagCount" layoutX="405" layoutY="260"/>
92+
<Label text="CurrentTagProtocol: " layoutX="430" layoutY="260"/>
93+
<Label fx:id="CurrentTagProtocol" layoutX="530" layoutY="260"/>
94+
<Label text="CurrentTagID:" layoutY="310"/>
95+
<TextArea fx:id="CurrentTagID" layoutX="90" layoutY="290" prefWidth="150" prefHeight="60" editable="false" styleClass="FixedFont"/>
96+
<Label text="CurrentTagUserData:" layoutX="260" layoutY="310"/>
97+
<TextArea fx:id="CurrentTagUserData" layoutX="380" layoutY="290" prefWidth="310" prefHeight="60" editable="false" styleClass="FixedFont"/>
98+
</AnchorPane>
99+
</Tab>
100+
<Tab text="Maintenance Methods">
101+
<AnchorPane prefHeight="409" prefWidth="695">
102+
<Button onAction="#compareFirmwareVersion" layoutY="5" text="CompareFirmwareVersion" prefWidth="155"/>
103+
<TextField fx:id="CFV_firmwareFileName" layoutY="30" prefWidth="130" promptText="firmwareFileName"/>
104+
<Button styleClass="FileButton" onAction="#browseCFVName" layoutX="130" layoutY="30" text="" prefWidth="25"/>
105+
<TextField fx:id="CFV_result" layoutY="55" prefWidth="155" promptText="result" disable="true"/>
106+
<Button onAction="#updateFirmware" layoutX="165" layoutY="5" text="UpdateFirmware" prefWidth="155"/>
107+
<TextField fx:id="UF_firmwareFileName" layoutX="165" layoutY="30" prefWidth="130" promptText="firmwareFileName"/>
108+
<Button styleClass="FileButton" onAction="#browseUFName" layoutX="295" layoutY="30" text="" prefWidth="25"/>
109+
<Button onAction="#resetStatistics" layoutX="330" layoutY="5" text="ResetStatistics" prefWidth="110"/>
110+
<Button onAction="#retrieveStatistics" layoutX="450" layoutY="5" text="RetrieveStatistics" prefWidth="110"/>
111+
<Button onAction="#updateStatistics" layoutX="570" layoutY="5" text="UpdateStatistics" prefWidth="110"/>
112+
<TextArea fx:id="_statisticsBuffer" layoutX="330" layoutY="30" prefWidth="350" prefHeight="75" promptText="statisticsBuffer"/>
113+
</AnchorPane>
114+
</Tab>
115+
</TabPane>
116+
<Label text="Events" layoutY="121" layoutX="700" prefWidth="280" underline="true" alignment="CENTER"/>
117+
<TextArea fx:id="EventOutput" layoutX="700" layoutY="146" prefWidth="280" prefHeight="389"/>
118+
</AnchorPane>

0 commit comments

Comments
 (0)