Skip to content

Commit 01b2e8c

Browse files
committed
Add typescript to project and prisma for db
1 parent a541415 commit 01b2e8c

25 files changed

+6245
-299
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This is a reworked version from the original, which was mainly written for test
44

55
## Status!
66
Very much still a work in progress :)
7+
Add TypeScript & Prisma to the project
78

89
## Variants
910
|Robot-T200|Robot-T201|Robot-T202|Robot-T203|
@@ -16,7 +17,6 @@ Very much still a work in progress :)
1617
* Robot-T420 QT application support
1718

1819
## Implementation Supported
19-
2020
* Packer Terminals
2121
* Pallet Scales
2222
* Scanner Stations

config/robots.json

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22

33
"robots" : [
4-
54
{
6-
"tagName" : "SOLAS Station 2",
7-
"macAddress" : "00:60:35:16:E4:06",
5+
"tagName" : "Raspberry PI Station",
6+
"macAddress" : "E4:5F:01:50:EC:E0",
87
"message" : "SOLAS Scale Ready!",
98
"type" : "AUTO",
109
"config" : {
@@ -13,7 +12,7 @@
1312
"highLimit" : "1100.0",
1413
"security" : "OPEN",
1514
"units" : "kg",
16-
"serverURL" : "http://192.168.1.194:8086/api/robots/scale"
15+
"serverURL" : "http://192.168.1.194:8080/api/robots/scale"
1716
},
1817
"labels" : [
1918
{"B1" : "RED APPLES x 1"},
@@ -25,20 +24,31 @@
2524
},
2625

2726
{
28-
"tagName" : "Label Print Station",
29-
"macAddress" : "00:60:35:24:42:85",
30-
"message" : "Label printer ready",
27+
"tagName" : "Label Print PC Station",
28+
"macAddress" : "74:D0:2B:C5:2A:04",
29+
"message" : "PC Scale ready!",
3130
"type" : "AUTO",
3231
"config" : {
33-
"type" : "DUALSCAN",
32+
"type" : "SCALE",
3433
"security" : "OPEN",
35-
"serverURL" : "http://192.168.1.194:8086/api/robots/label"
34+
"serverURL" : "http://192.168.1.194:8080/api/robots/scan"
3635
},
3736
"rpcList" : [
3837
{ "REM-PAL" : "Remove pallet" },
3938
{ "EMPTY-PAL" : "Empty pallet" },
4039
{ "DISC-PAL" : "Discard pallet" }
4140
]
41+
},
42+
{
43+
"tagName" : "Term Station",
44+
"macAddress" : "80:34:28:61:50:42",
45+
"message" : "Terminal Station Ready",
46+
"type" : "AUTO",
47+
"config" : {
48+
"type" : "TERMINAL",
49+
"security" : "OPEN",
50+
"serverURL" : "http://192.168.1.194:8080/api/robots/term"
51+
}
4252
}
4353

4454

config/server.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"server" : {
33
"ipAddress" : "192.168.1.194",
4-
"port" : 8086
4+
"port" : 8080,
5+
"latency" : {
6+
"max" : 1000,
7+
"min" : 100
8+
}
59
}
610
}

constants/ROBOT_APP_TYPES.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
const ROBOT_APP_TYPES = {
2+
APP_TYPE_DISABLED : 'DISABLED',
3+
APP_TYPE_REDIRECT : 'REDIRECT',
24
APP_TYPE_AUTO : 'AUTO',
3-
APP_TYPE_SCALE : 'SOLAS-SCALE',
4-
5+
APP_TYPE_TERMINAL : 'TERMINAL',
6+
APP_TYPE_SCALE : 'SCALE',
7+
APP_TYPE_SCANNER : 'SCANNER',
8+
APP_TYPE_BINTIP : 'BINTIP',
9+
APP_TYPE_FORKLIFT : 'FORKLIFT',
10+
APP_TYPE_DUALSCAN : 'DUALSCAN',
11+
APP_TYPE_LABELPRINT : 'LABELPRINT',
512
};
613

714
module.exports = ROBOT_APP_TYPES;

controllers/robotController.js

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11

22
const ROBOT_COMMANDS = require('../constants/ROBOT_COMMANDS');
33
const robotServiceProcessor = require('../service/robots/RobotService');
4+
const { logd } = require('../utils/logger');
45

5-
const handleResponse = (res, data) => res.status(200).send(data);
6+
const TAG = "RobotController";
7+
8+
const handleResponse = (res, data) => {
9+
res.status(200).send(data);
10+
}
611

712
const handleError = (res, err) => {
813
const status = err?.status ?? 500;
@@ -33,7 +38,8 @@ const robotCntrlError = (req, res, next) => {
3338

3439
try {
3540
const payload = req.body;
36-
robotServiceProcessor({requestReset : { MAC : '00:00:00:00:00:00' }}, res, next);
41+
const resMsg = robotServiceProcessor({requestReset : { MAC : '00:00:00:00:00:00' }}, res, next);
42+
handleResponse(res, resMsg);
3743
}
3844
catch(error) {
3945
// error occured while handling the message
@@ -48,6 +54,7 @@ const robotCntrlSetupPost = (req, res, next) => {
4854
const payload = req.body;
4955
const resMsg = robotServiceProcessor(payload);
5056
if(resMsg) {
57+
logd(TAG, "Setup Post", resMsg)
5158
handleResponse(res, resMsg);
5259
}
5360
else {
@@ -67,7 +74,21 @@ const robotCntrlSetupGet = (req, res, next) => {
6774
}
6875

6976
const robotCntrlScanPost = (req, res, next) => {
70-
res.json({});
77+
try {
78+
const payload = req.body;
79+
const resMsg = robotServiceProcessor(payload);
80+
if(resMsg) {
81+
handleResponse(res, resMsg);
82+
}
83+
else {
84+
// message not supported or not interpreted!
85+
next();
86+
}
87+
}
88+
catch(error) {
89+
// server error, error occured while handling the message
90+
handleError(res, error);
91+
}
7192
}
7293

7394
const robotCntrlScanGet = (req, res, next) => {
@@ -97,7 +118,21 @@ const robotCntrlLabelGet = (req, res, next) => {
97118
}
98119

99120
const robotCntrlTerminalPost = (req, res, next) => {
100-
res.json({});
121+
try {
122+
const payload = req.body;
123+
const resMsg = robotServiceProcessor(payload);
124+
if(resMsg) {
125+
handleResponse(res, resMsg);
126+
}
127+
else {
128+
// message not supported or not interpreted!
129+
next();
130+
}
131+
}
132+
catch(error) {
133+
// server error, error occured while handling the message
134+
handleError(res, error);
135+
}
101136
}
102137

103138
const robotCntrlTerminalGet = (req, res, next) => {
@@ -120,6 +155,24 @@ const robotCntrlForkliftPost = (req, res, next) => {
120155
res.json({});
121156
}
122157

158+
const robotCntrlBootUrl = (req, res, next) => {
159+
try {
160+
const payload = req.body;
161+
const resMsg = robotServiceProcessor(payload);
162+
if(resMsg) {
163+
handleResponse(res, resMsg);
164+
}
165+
else {
166+
// message not supported or not interpreted!
167+
next();
168+
}
169+
}
170+
catch(error) {
171+
// server error, error occured while handling the message
172+
handleError(res, error);
173+
}
174+
}
175+
123176

124177
module.exports = {
125178
robotCntrlPreProcess,
@@ -136,6 +189,7 @@ module.exports = {
136189
robotCntrlScaleGet,
137190
robotCntrlForkliftPost,
138191
robotCntrlForkliftSvrStatePost,
192+
robotCntrlBootUrl,
139193
robotCntrlError
140194
}
141195

logs/errLog.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)