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 18:03:36 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0757718350b9aedae87262f7699b40166beb2aba
07577183
1 parent
2b8f3aae
api calling and deathProb calculate complete
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
6 deletions
lib/socketio.js
lib/socketio.js
View file @
0757718
...
...
@@ -28,12 +28,13 @@ module.exports = (server, app) => {
}
io
.
on
(
'connection'
,
(
socket
)
=>
{
//웹 페이지 연결시 루프 동작
let
API_CALL
;
let
Current_Weather
;
let
Current_Weather
=
{}
;
let
Sensible_T
;
let
Heat_index
;
let
Discomport_index
;
let
Ultra_Violet_index
;
let
Heat_index
=
{};
let
Discomport_index
=
{};
let
Ultra_Violet_index
=
{};
let
sending_to_client_info
=
{};
socket
.
on
(
"connection"
,
()
=>
{
API_CALL
=
setInterval
(()
=>
{
...
...
@@ -42,8 +43,40 @@ module.exports = (server, app) => {
Heat_index
=
CALL
(
"index"
,
"heat"
);
//열지수
Discomport_index
=
CALL
(
"index"
,
"th"
);
//불쾌지수
Ultra_Violet_index
=
CALL
(
"index"
,
"uv"
);
//자외선지수
info
=
{
heat
:
Sensible_T
.
weather
.
wIndex
.
heatIndex
[
0
].
current
.
index
,
//열지수
sensible_temperature
:
Sensible_T
.
weather
.
wIndex
.
wctIndex
[
0
].
current
.
index
,
//체감온도
discomport
:
Discomport_index
.
weather
.
wIndex
.
thIndex
[
0
].
current
.
index
,
//불쾌지수
UV
:
Ultra_Violet_index
.
weather
.
wIndex
.
uvindex
[
0
].
day00
.
index
,
windspd
:
Current_Weather
.
weather
.
minutely
[
0
].
wind
.
wspd
,
sky
:
Current_Weather
.
weather
.
minutely
[
0
].
sky
.
code
,
rain
:
Current_Weather
.
weather
.
minutely
[
0
].
rain
.
last24hour
,
current_temperature
:
Current_Weather
.
weather
.
minutely
[
0
].
temperature
.
tc
,
lightning
:
Current_Weather
.
weather
.
minutely
[
0
].
lightning
,
warning
:
common
.
alertYn
,
typhoon
:
Current_Weather
.
common
.
stormYn
,
time
:
Current_Weather
.
weather
.
minutely
[
0
].
timeObservation
,
death_prob
:
0
}
info
.
death_prob
+=
info
.
sky
.
substr
(
5
)
*
1
//하늘 상태에 따라 확률 증가
if
(
info
.
lightning
===
1
)
//낙뢰시에 확률 증가
info
.
death_prob
+=
10
;
if
(
info
.
typhoon
===
"Y"
)
//태풍시에 확률 증가
info
.
death_prob
+=
10
;
if
(
info
.
warning
===
"Y"
)
// 특보 발령시 확률 증가
info
.
death_prob
+=
5
//죽을 확률 계산(내맘대로)
info
.
death_prob
=
(
(
info
.
heat
/
8
)
+
(
abs
(
info
.
sensible_temperature
-
15
)
/
2
)
+
(
info
.
discomport
/
10
)
+
(
info
.
UV
/
5
)
+
(
info
.
windspd
*
3
)
+
(
info
.
rain
/
10
)
+
(
abs
(
info
.
current_temperature
-
15
)
/
2
)
);
socket
.
emit
(
"weatherInfo_minutely_send_to_clien
d"
,
info
);
socket
.
emit
(
"weatherInfo_minutely_send_to_clien
t"
,
info
);
// 클라이언트에게 이벤트 발산
},
60
*
1000
);
//1분마다 호출
});
...
...
Please
register
or
login
to post a comment