Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2019-1-OpenSourceSW
/
Probability Death
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
DESKTOP-PC6TBNS\강환석씨
2018-12-09 21:29:49 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0c58aa0236ce1913ff01de36d6d1550c3b8fa11e
0c58aa02
1 parent
dd143390
no meaning commit
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
45 deletions
lib/example_result.json
lib/socketio.js
routes/index.js
views/index.ejs
lib/example_result.json
View file @
0c58aa0
...
...
@@ -148,7 +148,8 @@
"requestUrl"
:
"/weather/index/th?appKey=c13b1a68-ef31-4131-a1b7-4069c263f82d&version=1&lat=37.239795&lon=127.083240"
,
"message"
:
"성공"
}
}{
}
{
"weather"
:
{
"wIndex"
:
{
"heatIndex"
:
[
...
...
lib/socketio.js
View file @
0c58aa0
...
...
@@ -98,8 +98,5 @@ module.exports = (server, app) => {
clearInterval
(
API_CALL
);
//연결 종료시 해제
})
})
}
...
...
routes/index.js
View file @
0c58aa0
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
var
db
=
require
(
'../lib/db'
);
require
(
'date-utils'
);
var
newDate
=
new
Date
();
/* GET home page. */
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
...
...
@@ -14,52 +11,38 @@ router.get('/', function(req, res, next) {
var
wsArr
=
new
Array
();
// 풍속
var
rainArr
=
new
Array
();
// 강우량
var
probArr
=
new
Array
();
// 사망 확률
var
dataLen
=
0
;
// 데이터 개수
var
empty
=
0
;
// 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음
var
sql
=
""
;
// 쿼리
var
index
;
// 이전 10분간 데이터 찾기
sql
=
"SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')"
;
db
.
query
(
sql
,
function
(
err
,
rows
,
fields
){
if
(
err
)
{
console
.
log
(
err
);
}
else
{
if
(
rows
.
length
==
0
)
{
empty
=
1
;
}
else
{
dataLen
=
rows
.
length
;
for
(
index
=
0
;
index
<
rows
.
length
;
index
++
){
var
temp
=
rows
[
index
].
time
.
getMinutesBetween
(
newDate
);
if
(
temp
==
index
){
probArr
.
push
(
rows
[
index
].
prob
);
time
.
push
(
rows
[
index
].
time
);
ptArr
.
push
(
rows
[
index
].
temperature
);
wsArr
.
push
(
rows
[
index
].
wind
);
rainArr
.
push
(
rows
[
index
].
rain
);
}
else
{
sql
=
"SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')"
;
db
.
query
(
sql
,
function
(
err
,
rows
,
fields
){
if
(
err
)
{
console
.
log
(
err
);
}
else
{
if
(
rows
.
length
!=
10
)
{
empty
=
1
;
break
;
}
else
{
probArr
.
push
(
rows
[
0
].
prob
);
time
.
push
(
rows
[
0
].
time
);
ptArr
.
push
(
rows
[
0
].
temperature
);
wsArr
.
push
(
rows
[
0
].
wind
);
rainArr
.
push
(
rows
[
0
].
rain
);
}
res
.
render
(
'index'
,
{
empty
,
time
,
ptArr
,
wsArr
,
rainArr
,
probArr
});
}
if
(
empty
==
1
&&
probArr
.
length
!=
0
)
empty
=
0
;
}
res
.
render
(
'index'
,
{
empty
,
time
,
ptArr
,
wsArr
,
rainArr
,
probArr
,
dataLen
});
}
})
})
});
module
.
exports
=
router
;
...
...
views/index.ejs
View file @
0c58aa0
...
...
@@ -38,7 +38,14 @@
></div>
</div>
</div>
<script
src=
"/socket.io/socket.io.js"
></script>
<script>
var
socket
=
io
.
connect
(
'/'
);
socket
.
emit
(
"connection"
);
socket
.
on
(
"weatherInfo_minutely_send_to_cliend"
,(
info
)
=>
{
//서버에서 client에게 메세지 전송
console
.
log
(
info
);
});
</script>
<!-- 첫번째 그래프 -->
<script
type=
"text/javascript"
>
Highcharts
.
chart
(
"container1"
,
{
...
...
Please
register
or
login
to post a comment