From e491cdb48129752324c4e3764f99bd9203c56dec Mon Sep 17 00:00:00 2001
From: lgq <1015864684@qq.com>
Date: 星期二, 31 三月 2026 09:48:44 +0800
Subject: [PATCH] 1.新增VF205门禁机代码

---
 vf205_access/dxmodules/dxGpioKey.js |   84 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/vf205_access/dxmodules/dxGpioKey.js b/vf205_access/dxmodules/dxGpioKey.js
new file mode 100644
index 0000000..44237b8
--- /dev/null
+++ b/vf205_access/dxmodules/dxGpioKey.js
@@ -0,0 +1,84 @@
+//build 20240524
+//鎺ュ彈 gpio 鐨勮緭鍏�
+//渚濊禆缁勪欢: dxLogger,dxDriver,dxEventBus
+import { gpioKeyClass } from './libvbar-m-dxkey.so'
+import bus from './dxEventBus.js'
+import * as os from "os";
+const gpioKeyObj = new gpioKeyClass();
+const gpioKey = {}
+
+/**
+ * gpioKey 鍒濆鍖�
+ * @returns true:鎴愬姛,false:澶辫触
+ */
+gpioKey.init = function () {
+	const res = gpioKeyObj.init()
+	if (res) {
+		gpioKeyObj.registerCb("gpioKeyCb")
+	}
+	return res
+}
+
+/**
+ * gpioKey 鍙栨秷鍒濆鍖�
+ * @returns true:鎴愬姛,false:澶辫触
+ */
+gpioKey.deinit = function () {
+	gpioKeyObj.unRegisterCb("gpioKeyCb")
+	return gpioKeyObj.deinit()
+}
+
+/**
+ * 鍒ゆ柇gpioKey娑堟伅闃熷垪鏄惁涓虹┖
+ * @returns true:鎴愬姛,false:澶辫触
+ */
+gpioKey.msgIsEmpty = function () {
+	return gpioKeyObj.msgIsEmpty()
+}
+
+/**
+ * 浠巊pioKey娑堟伅闃熷垪涓鍙栨暟鎹�
+ * @returns json娑堟伅瀵硅薄锛屾牸寮忥細{"code":30,"type":1,"value":1}
+ */
+gpioKey.msgReceive = function () {
+	let msg = gpioKeyObj.msgReceive()
+	return JSON.parse(msg);
+}
+
+gpioKey.RECEIVE_MSG = '__gpioKey__MsgReceive'
+
+/**
+ * 绠�鍖杇piokey缁勪欢鐨勪娇鐢紝鏃犻渶杞鍘昏幏鍙栨暟鎹紝鏁版嵁浼氶�氳繃eventbus鍙戦�佸嚭鍘�
+ * run 鍙細鎵ц涓�娆�
+ * 濡傛灉闇�瑕佸疄鏃惰幏鍙栨暟鎹紝鍙互璁㈤槄 eventbus鐨勪簨浠讹紝浜嬩欢鐨則opic鏄疓PIO_KEY锛屼簨浠剁殑鍐呭鏄被浼納"code":30,"type":1,"value":1}
+ * 鍏朵腑code鏄痝pio鐨勬爣璇嗭紝琛ㄧず鏄偅涓猤pio鏈夎緭鍏ワ紝value鍊煎彧鑳芥槸0锛�1閫氬父琛ㄧず浣庣數骞冲拰楂樼數骞�
+ * type鏄簨浠剁被鍨嬶紝閬靛惊Linux鐨勬爣鍑嗚緭鍏ヨ瀹�,浠ヤ笅鍒楀嚭甯哥敤鍑犱釜锛�
+	(0x01):鎸夐敭浜嬩欢锛屽寘鎷墍鏈夌殑閿洏鍜屾寜閽簨浠躲�備緥濡傦紝褰撴寜涓嬫垨閲婃斁閿洏涓婄殑涓�涓敭鏃讹紝灏嗘姤鍛婃绫讳簨浠躲��
+	(0x05):寮�鍏充簨浠讹紝渚嬪绗旇鏈數鑴戠洊鐨勫紑鍏冲彲浠ユ姤鍛婂紑鍚堢姸鎬併��
+	(Ox11):LED浜嬩欢锛岀敤浜庢帶鍒惰澶囦笂鐨凩ED鎸囩ず鐏紝
+	(Ox12):澹伴煶浜嬩欢锛岀敤浜庢帶鍒惰澶囦笂鐨勫0闊宠緭鍑猴紝
+	(0x16):鐢垫簮浜嬩欢锛屽彲浠ョ敤浜庢姤鍛婄數婧愭寜閽簨浠舵垨鐢垫睜鐢甸噺浣�
+ * 
+ */
+gpioKey.run = function () {
+	bus.newWorker("__gpiokey", '/app/code/dxmodules/gpioKeyWorker.js')
+}
+
+/**
+ * 濡傛灉gpioKey鍗曠嫭涓�涓嚎绋嬶紝鍙互鐩存帴浣跨敤run鍑芥暟锛屼細鑷姩鍚姩涓�涓嚎绋嬶紝
+ * 濡傛灉鎯冲姞鍏ュ埌鍏朵粬宸叉湁鐨勭嚎绋嬶紝鍙互浣跨敤浠ヤ笅灏佽鐨勫嚱鏁�
+ */
+gpioKey.worker = {
+	//鍦╳hile寰幆鍓�
+	beforeLoop: function () {
+		gpioKey.init()
+	},
+	//鍦╳hile寰幆閲�
+	loop: function () {
+		if (!gpioKey.msgIsEmpty()) {
+			let res = gpioKey.msgReceive();
+			bus.fire(gpioKey.RECEIVE_MSG, res)
+		}
+	}
+}
+export default gpioKey;

--
Gitblit v1.9.3