Skip to content

Commit

Permalink
Merge pull request #752 from entrylabs/develop-hw
Browse files Browse the repository at this point in the history
version up 1.9.56
  • Loading branch information
Tnks2U authored Jul 23, 2024
2 parents 1cbdb5c + 414b900 commit 551009e
Show file tree
Hide file tree
Showing 9 changed files with 706 additions and 42 deletions.
547 changes: 547 additions & 0 deletions app/modules/Telliot_Base.js

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions app/modules/telliot_lite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const {
TelliotBase,
Loglevel,
TelliotEvent
} = require('./Telliot_Base');

class TelliotLite extends TelliotBase {
constructor () {
super();
}

// ��Ʈ�� �������� ����Ǿ����� ȣ���
init(handler, config) {
super.init(handler, config);
}

// ���� ����õ�(handshake) ���� �Ŀ� ȣ���
setSerialPort(sp) {
super.setSerialPort(sp);
}

// ���� ����õ��� ����̽��� ���� ������. checkInitialData �� ����Ǿ��ִٸ� �ʼ�
requestInitialData() {
return super.requestInitialData();
}

// ���� ����õ����� ����̽��� �����͸� �޾�, ���ϴ� �����Ͱ� �´��� �Ǵ��ϴ� ����
// requestInitialData �� ����Ǿ��ִٸ� �ʼ�
checkInitialData(data, config) {
return super.checkInitialData(data, config);
}

// �ش� �Լ��� �����ϸ�, ����̽����� �����͸� �޾ƿ� �� validate �� ��ģ��. ������ �״�� ó���������� �����Ѵ�.
validateLocalData(data) {
return super.validateLocalData(data);
}

// ����̽����� �����͸� �޾ƿ� ��, �������� �����͸� ������ ���� ȣ��Ǵ� ����. handler �� �����ϴ� ������ ���� ���� �� �ִ�.
// handler.write(key, value) �� ������ ���� Entry.hw.portData ���� �޾ƺ� �� �ִ�.
requestRemoteData(handler) {
super.requestRemoteData(handler);
}

// ��Ʈ�� ���������� �� �����͸� ó���Ѵ�. handler.read �� �������� �����͸� �о�� �� �ִ�.
// handler �� ���� Entry.hw.sendQueue �� ������ ���� ����.
handleRemoteData(handler) {
super.handleRemoteData(handler);
}

// ����̽��� �����͸� ������ ����. control: slave �� ��� duration �ֱ⿡ ���� ����̽��� �����͸� ������.
// return ������ ���۸� ��ȯ�ϸ� ����̽��� �����͸� ������, �Ƶ��̳��� ��� ���Ž� �ڵ带 ������ �ִ�.
requestLocalData() {
return super.requestLocalData();
}

// ����̽����� �� �����͸� ó���ϴ� ����. ���⼭�� ó���� �����Ͱ� ���� ��ŵ�Ͽ���.
handleLocalData(data) {
super.handleLocalData(data);
}

// Ŀ���Ͱ� ���������� �� ȣ��Ǵ� ����, ��ĵ ���� Ȥ�� ����̽� ���� ������ ȣ��ȴ�.
disconnect(connector) {
super.disconnect(connector);
}

// ��Ʈ�� ���������� ���� ������ �������� �� �߻��ϴ� ����.
reset() {
super.reset();
}
}

module.exports = new TelliotLite();
27 changes: 27 additions & 0 deletions app/modules/telliot_lite.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"id": "600101",
"name": {
"en": "GoldenKidsAICar",
"ko": "금쪽이 카"
},
"category": "board",
"platform": ["win32", "darwin"],
"icon": "telliot_lite.png",
"module": "telliot_lite.js",
"url": "https://www.iotedcorp.com/",
"email": "[email protected]",
"reconnect" : false,
"entry": {
"protocol": "json"
},
"select_com_port" : true,
"hardware": {
"type": "bluetooth",
"control": "slave",
"duration": 1000,
"vendor": "Microsoft",
"parity": "none",
"baudRate": 115200,
"firmwarecheck": false
}
}
Binary file added app/modules/telliot_lite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/server/win/server.exe
Binary file not shown.
86 changes: 49 additions & 37 deletions app/src/main/electron/serverProcessManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ServerProcessManager {
} catch (e) {
logger.error('Error occurred while spawn Server Process.', e);
throw new Error(
'Error occurred while spawn Server Process. make sure it exists same dir path',
'Error occurred while spawn Server Process. make sure it exists same dir path'
);
}
}
Expand All @@ -38,7 +38,7 @@ class ServerProcessManager {

open() {
this._receiveFromChildEventRegister();
this._sendToChild('open');
this._sendToChild('open', process.env.NODE_ENV);
// this.childProcess.open();
}

Expand All @@ -52,6 +52,14 @@ class ServerProcessManager {
this._sendToChild('addRoomId', roomId);
}

connectHardwareSuccess() {
this._sendToChild('connectHardwareSuccess');
}

connectHardwareFailed() {
this._sendToChild('connectHardwareFailed');
}

disconnectHardware() {
// this.childProcess.disconnectHardware();
this._sendToChild('disconnectHardware');
Expand All @@ -68,10 +76,11 @@ class ServerProcessManager {
* @private
*/
_sendToChild(methodName: string, message?: any) {
this._isProcessLive() && this.childProcess.send({
key: methodName,
value: message,
});
this._isProcessLive() &&
this.childProcess.send({
key: methodName,
value: message,
});
}

_receiveFromChildEventRegister() {
Expand All @@ -87,43 +96,46 @@ class ServerProcessManager {
// this.childProcess.on('close', () => {

// });
this.childProcess && this.childProcess.on('message', (message: { key: string; value: any; }) => {
const { key, value } = message;
switch (key) {
case 'cloudModeChanged': {
this.router.notifyCloudModeChanged(value);
break;
}
case 'runningModeChanged': {
this.router.notifyServerRunningModeChanged(value);
break;
}
case 'data': {
this.router.handleServerData(value);
break;
}
case 'connection': {
this.router.handleServerSocketConnected();
break;
}
case 'close': {
if (!this.currentRoomId || this.currentRoomId === value) {
this.router.handleServerSocketClosed();
this.childProcess &&
this.childProcess.on('message', (message: { key: string; value: any }) => {
const { key, value } = message;
switch (key) {
case 'cloudModeChanged': {
this.router.notifyCloudModeChanged(value);
break;
}
case 'runningModeChanged': {
this.router.notifyServerRunningModeChanged(value);
break;
}
case 'data': {
this.router.handleServerData(value);
break;
}
case 'connection': {
this.router.handleServerSocketConnected();
break;
}
case 'close': {
if (!this.currentRoomId || this.currentRoomId === value) {
this.router.handleServerSocketClosed();
}
break;
}
default: {
console.error('unhandled pkg server message', key, value);
}
}
break;
}
default: {
console.error('unhandled pkg server message', key, value);
}
}
});
});
}

_isProcessLive() {
return this.childProcess &&
return (
this.childProcess &&
!this.childProcess.killed &&
this.childProcess.connected &&
this.childProcess.channel;
this.childProcess.channel
);
}
}

Expand Down
12 changes: 9 additions & 3 deletions app/src/main/mainRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ interface IEntryServer {
setRouter: (router: MainRouter) => void;
open: () => void;
disconnectHardware: () => void;
connectHardwareSuccess: () => void;
connectHardwareFailed: () => void;
addRoomIdsOnSecondInstance: (roomId: string) => void;
send: (data: any) => void;
}
Expand Down Expand Up @@ -240,7 +242,7 @@ class MainRouter {
if (connector) {
logger.info(
`[Device Info] ${config.id} | ${
config?.name?.ko || config?.name?.en || 'noname'
config?.name?.ko || config?.name?.en || 'noname'
}`
);
this.connector = connector;
Expand All @@ -251,6 +253,7 @@ class MainRouter {
} catch (e) {
logger.error(`startScan Error, ${e.name} ${e.message}`);
this.sendState(HardwareStatement.scanFailed);
this.server.connectHardwareFailed();
}
}

Expand Down Expand Up @@ -317,6 +320,7 @@ class MainRouter {
logger.verbose('entryServer, connector connection');
this.handler = new DataHandler(this.config.id);
this._connectToServer();
this.server.connectHardwareSuccess();
this.connector.connect(); // router 설정 후 실제 기기와의 통신 시작
}
}
Expand Down Expand Up @@ -545,7 +549,7 @@ class MainRouter {
console.log(e);
return false;
}
})
});
ipcMain.on('getSharedObject', (e) => {
e.returnValue = global.sharedObject;
});
Expand All @@ -557,7 +561,9 @@ class MainRouter {
}
});
ipcMain.on('customButtonClicked', (e, key) => {
this.hwModule && this.hwModule.customButtonClicked && this.hwModule.customButtonClicked(key);
this.hwModule &&
this.hwModule.customButtonClicked &&
this.hwModule.customButtonClicked(key);
});
logger.verbose('EntryHW ipc event registered');
}
Expand Down
2 changes: 1 addition & 1 deletion build/entry-hw.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
!define PRODUCT_NAME "Entry_HW"
!define PROTOCOL_NAME "entryhw"
!define APP_NAME "Entry_HW.exe"
!define PRODUCT_VERSION "1.9.55"
!define PRODUCT_VERSION "1.9.56"
!define PRODUCT_PUBLISHER "EntryLabs"
!define PRODUCT_WEB_SITE "https://www.playentry.org/"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "entry-hw",
"version": "1.9.55",
"version": "1.9.56",
"description": "엔트리 하드웨어 연결 프로그램",
"author": "EntryLabs",
"main": "./app/src/index.bundle.js",
Expand Down

0 comments on commit 551009e

Please sign in to comment.