Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-05-09 01:06:44 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b92b2eaa6dd6994a7bab22903b4fd6322e72978d
b92b2eaa
1 parent
cc85fbbb
feat. Data Processing Logic
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
1 deletions
server/src/lib/DataProcess.js
server/src/lib/DataProcess.js
View file @
b92b2ea
exports
.
processing
=
async
(
data
)
=>
{
const
Bottle
=
require
(
'../models/bottle'
);
//Hub topic : bottle/bottleId
//Hub로부터 받은 message : 개폐여부/온도/습도/초음파센서
exports
.
factoring
=
(
topic
,
message
)
=>
{
const
bottleId
=
topic
.
split
(
'/'
)[
1
];
const
data
=
message
.
split
(
'/'
);
const
[
isOpen
,
temperature
,
humidity
,
balance
]
=
data
;
const
openDate
=
new
Date
();
return
{
bottleId
,
isOpen
,
openDate
,
temperature
,
humidity
,
balance
};
}
//bottleId가 포함된 data를 받아서 해당 약병의 data를 업데이트한다.
exports
.
bottleInfoUpdate
=
async
(
data
)
=>
{
const
{
bottleId
,
isOpen
,
openDate
,
temperature
,
humidity
,
balance
}
=
data
;
if
(
isOpen
===
'1'
)
{
await
Bottle
.
findOneAndUpdate
({
bottleId
},
{
recentOpen
:
openDate
},
{
new
:
true
});
}
await
Bottle
.
findByIdAndUpdate
({
bottleId
},
{
temperature
,
humidity
,
balance
},
{
new
:
true
});
}
//해당 MQTT Broker(client)에 bottleId의 정보에 관한 message를 발행한다.
exports
.
dataPublishg
=
(
client
,
bottleId
)
=>
{
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment