-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
140 changed files
with
15,002 additions
and
35 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
*~ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module.exports = { | ||
"env": { | ||
"commonjs": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"overrides": [ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"files": [ | ||
".eslintrc.{js,cjs}" | ||
], | ||
"parserOptions": { | ||
"sourceType": "script" | ||
} | ||
} | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": "latest" | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
4 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"double" | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 基於的映像檔 | ||
FROM node:current-alpine | ||
|
||
# 建立工作目錄 | ||
WORKDIR /usr/src/app | ||
|
||
# 時區 | ||
ENV TZ=Asia/Taipei | ||
RUN echo "${TZ}" > /etc/timezone | ||
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime | ||
|
||
# 安裝&更新所需的套件 | ||
RUN apk update \ | ||
apk upgrade --no-cache \ | ||
apk add --no-cache icu-data-full tzdata | ||
|
||
# 把目錄下的程式碼直接復制到容器中 | ||
COPY package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
|
||
# 指定使用的端口 | ||
EXPOSE 3095 | ||
EXPOSE 3094 | ||
|
||
# 容器啟動時 | ||
CMD [ "npm", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
CC1:=docker compose | ||
CC2:=npm | ||
IMAGE:=IoTGateway | ||
|
||
.PHONY: build-img build-apidoc up logs stop clean test-mqtt | ||
|
||
all: stop clean build-img | ||
|
||
build-img: | ||
@$(CC1) up --build -d | ||
|
||
build-apidoc: | ||
@$(CC2) run swagger-autogen | ||
|
||
test-mqtt: | ||
@$(CC2) run mqttTest-Sub | ||
|
||
up: | ||
@$(CC1) up -d | ||
|
||
logs: | ||
@$(CC1) logs --tail=100 -f | ||
|
||
stop: | ||
@$(CC1) stop | ||
|
||
clean: | ||
@$(CC1) down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
server: | ||
container_name: IoTGateway-cont | ||
restart: always # 跟系統服務一起重啟 | ||
network_mode: host # 網路: 使用實體機 | ||
# 編譯時的設置 | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 使用單線程部分 | ||
var service=require("./service.js"); | ||
var mqttPub=require("./rules/mqtt/Pubtopic.js"); | ||
|
||
function main(){ | ||
service; | ||
mqttPub; | ||
} | ||
|
||
/*主程式*/ | ||
try { | ||
main(); | ||
} catch(error) { | ||
console.log(`Error: ${error}`); | ||
throw error; | ||
}finally { | ||
main(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const moment = require("moment"); | ||
var ConfigParser = require("configparser"); | ||
const configZone = new ConfigParser(); | ||
|
||
/*時區設定*/ | ||
configZone.read("./modules/config/clockSet.cfg"); | ||
configZone.sections(); | ||
var locaLang=configZone.get("timezone","locaLang"); | ||
var localZone=configZone.get("timezone","localZone"); | ||
|
||
/*outpuut console Time*/ | ||
function consoleTime(){ | ||
var clock = new Date(); | ||
var nowTime = clock.toLocaleString(locaLang, {timeZone: localZone}); //時區 | ||
return nowTime; | ||
} | ||
|
||
/*SQL date&time*/ | ||
function SQLDate(){ | ||
var clock = new moment(); | ||
var dateFormat=configZone.get("formatStyle","dateFormat"); | ||
var Date=clock.format(dateFormat); | ||
return Date; | ||
} | ||
function SQLTime(){ | ||
var clock = new moment(); | ||
var timeFormat=configZone.get("formatStyle","timeFormat"); | ||
var Time=clock.format(timeFormat); | ||
return Time; | ||
} | ||
|
||
/* 將 ISO 8601 日期格式轉換為 "yyyy-mm-dd" 格式 */ | ||
function formatDateToYYYYMMDD(isoDateString) { | ||
const date = new Date(isoDateString); | ||
const year = date.getFullYear(); | ||
const month = String(date.getMonth() + 1).padStart(2, '0'); // Month is 0-based | ||
const day = String(date.getDate()).padStart(2, '0'); | ||
|
||
return `${year}-${month}-${day}`; | ||
} | ||
|
||
/*Yasterday a Date: 格式= 'YYYY-MM-DD'*/ | ||
function yasterDate(){ | ||
const today = new Date(); | ||
const yesterday = new Date(today); | ||
|
||
yesterday.setDate(today.getDate() - 1); | ||
const formattedYesterday = yesterday.toISOString().slice(0, 10); | ||
return formattedYesterday; | ||
} | ||
|
||
module.exports={ | ||
yasterDate:yasterDate, | ||
formatDateToYYYYMMDD:formatDateToYYYYMMDD, | ||
consoleTime:consoleTime, | ||
SQLDate:SQLDate, | ||
SQLTime:SQLTime | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[timezone] | ||
locaLang = zh-TW | ||
localZone = Asia/Taipei | ||
|
||
[formatStyle] | ||
timeFormat = HH:mm:ss | ||
dateFormat = YYYY-MM-DD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[POSTGRESQL] | ||
DBsource = localhost | ||
DBuser = postgres | ||
DBpassword = oitmis | ||
DBport = 5432 | ||
cnDatabase = sensordb | ||
|
||
[MQTT] | ||
source = localhost | ||
port = 3094 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Service] | ||
MQTT = 3094 | ||
HTTP = 3095 |
Oops, something went wrong.