⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forma.java

📁 RFID读写器调用实例程序。RFID读写器是远望谷804系列。通过JNI调用远望谷API。 提供读
💻 JAVA
字号:
package hfut.wispy;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.grouplayout.GroupLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import hfut.wispy.LinkDll;
import hfut.wispy.ReportThread;

public class FormA {
	public static Text textA;
	static Button hcomButton;
	static Button powerButton;
	static Integer hCom = -1;
	static LinkDll objLinkDll = new LinkDll();
	public static void main(String[] args) {
		 
		System.out.println(System.getProperty("java.library.path"));
		final Display display = new Display();
		final Shell shell = new Shell();
		shell.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(final DisposeEvent arg0)
			{
				objLinkDll.XCClose();
			}
		});
		shell.setSize(511, 424);
		shell.setLayout(new FormLayout());
		shell.setText("RFIDReader Sample in JAVA");
		shell.open();

		Group group;

		Group group_1;
		{
			group = new Group(shell, SWT.NONE);
			final FormData fd_group = new FormData();
			fd_group.bottom = new FormAttachment(0, 334);
			fd_group.top = new FormAttachment(0, 9);
			fd_group.right = new FormAttachment(0, 334);
			fd_group.left = new FormAttachment(0, 9);
			group.setLayoutData(fd_group);

			{
				textA = new Text(group, SWT.MULTI|SWT.BORDER|SWT.V_SCROLL|SWT.H_SCROLL);
			}

			final GroupLayout groupLayout_1 = new GroupLayout(group);
			groupLayout_1.setHorizontalGroup(
				groupLayout_1.createParallelGroup(GroupLayout.TRAILING)
					.add(GroupLayout.LEADING, groupLayout_1.createSequentialGroup()
						.addContainerGap()
						.add(textA, GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
						.addContainerGap())
			);
			groupLayout_1.setVerticalGroup(
				groupLayout_1.createParallelGroup(GroupLayout.TRAILING)
					.add(GroupLayout.LEADING, groupLayout_1.createSequentialGroup()
						.add(textA, GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
						.addContainerGap())
			);
			group.setLayout(groupLayout_1);
		}

		{
			final Menu menu = new Menu(shell, SWT.BAR);
			shell.setMenuBar(menu);
		}
		{
			group_1 = new Group(shell, SWT.NONE);
			final FormData fd_group_1 = new FormData();
			fd_group_1.bottom = new FormAttachment(0, 334);
			fd_group_1.top = new FormAttachment(0, 9);
			fd_group_1.right = new FormAttachment(0, 499);
			fd_group_1.left = new FormAttachment(0, 350);
			group_1.setLayoutData(fd_group_1);
			
			{
				final Button xcopneButton = new Button(group_1, SWT.NONE);
				xcopneButton.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						hCom = objLinkDll.XCOpen("NotTRUE_lsCfgFile", "NotTRUE_lsCfgItem");
						hcomButton.setText("hCom = " + hCom);
					}
				});
				xcopneButton.setText("XCOpen");
				xcopneButton.setBounds(10, 22, 67, 26);
			}

			{
				final Button xcpoweronButton = new Button(group_1, SWT.NONE);
				xcpoweronButton.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						objLinkDll.XCPowerOn(1);
						powerButton.setText("PowerON");
					}
				});
				xcpoweronButton.setText("XCPowerON");
				xcpoweronButton.setBounds(10, 55, 81, 26);
			}

			{
				final Button xcreadtagonceButton = new Button(group_1, SWT.NONE);
				xcreadtagonceButton.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						objLinkDll.XCIdentify(1, (byte)0x01, (byte)0x02, (byte)0x00);
						textA.append(LinkDll.Bytes2HexString(objLinkDll.EPCCharArray));
						textA.append("\n");
					}
				});
				xcreadtagonceButton.setText("XCReadTagOnce");
				xcreadtagonceButton.setBounds(10, 90, 117, 26);
			}

			{
				final Button xcreadtagclcyeButton = new Button(group_1, SWT.NONE);
				xcreadtagclcyeButton.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						objLinkDll.XCIdentify(1, (byte)0x01, (byte)0x02, (byte)0x01);
						ReportThread reportThread = new ReportThread();
						reportThread.setPriority(Thread.MAX_PRIORITY);
						reportThread.start();
					}
				});
				xcreadtagclcyeButton.setText("XCReadTagClcye");
				xcreadtagclcyeButton.setBounds(10, 125, 117, 26);
			}

			{
				final Button xcpoweroffButton = new Button(group_1, SWT.NONE);
				xcpoweroffButton.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						objLinkDll.XCPowerOff(1);
						powerButton.setText("PowerOFF_OFF");
					}
				});
				xcpoweroffButton.setText("XCPowerOFF");
				xcpoweroffButton.setBounds(10, 160, 81, 26);
			}

			{
				final Button xccloseButton = new Button(group_1, SWT.NONE);
				xccloseButton.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						hCom = objLinkDll.XCClose();
						hcomButton.setText("hCom = " + hCom);
					}
				});
				xccloseButton.setText("XCClose");
				xccloseButton.setBounds(10, 195, 67, 26);
			}

			{
				final Button button = new Button(group_1, SWT.NONE);
				button.setText("button");
				button.setBounds(10, 294, 117, 26);
			}

			{
				hcomButton = new Button(group_1, SWT.NONE);
				hcomButton.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						Integer temp_hCom = objLinkDll.GethCom();
						String temp_hCom_Str = "hCom = " + temp_hCom.toString();
						hcomButton.setText(temp_hCom_Str);
					}
				});
				hcomButton.setText("hCom");
				hcomButton.setBounds(10, 230, 117, 26);
			}

			{
				powerButton = new Button(group_1, SWT.NONE);
				powerButton.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(final SelectionEvent arg0)
					{
						if(objLinkDll.GetPowerState() == 1)
							powerButton.setText("PowerON");
						else				
							powerButton.setText("PowerOFF_OFF");
					}
				});
				powerButton.setText("Power");
				powerButton.setBounds(10, 262, 117, 26);
			}

			{
				final Group group_2 = new Group(group_1, SWT.NONE);
				group_2.setBounds(5, 216, 139, 109);
			}
		}
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		shell.pack();
	}
	
	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -