DESKTOP-PC6TBNS\강환석씨

api calling and deathProb calculate complete

...@@ -28,11 +28,12 @@ module.exports = (server, app) => { ...@@ -28,11 +28,12 @@ module.exports = (server, app) => {
28 } 28 }
29 io.on('connection', (socket) => { //웹 페이지 연결시 루프 동작 29 io.on('connection', (socket) => { //웹 페이지 연결시 루프 동작
30 let API_CALL; 30 let API_CALL;
31 - let Current_Weather; 31 + let Current_Weather ={};
32 let Sensible_T; 32 let Sensible_T;
33 - let Heat_index; 33 + let Heat_index={};
34 - let Discomport_index; 34 + let Discomport_index={};
35 - let Ultra_Violet_index; 35 + let Ultra_Violet_index={};
36 + let sending_to_client_info={};
36 37
37 socket.on("connection", () => { 38 socket.on("connection", () => {
38 API_CALL = setInterval(() => { 39 API_CALL = setInterval(() => {
...@@ -43,7 +44,39 @@ module.exports = (server, app) => { ...@@ -43,7 +44,39 @@ module.exports = (server, app) => {
43 Discomport_index = CALL("index","th"); //불쾌지수 44 Discomport_index = CALL("index","th"); //불쾌지수
44 Ultra_Violet_index = CALL("index","uv"); //자외선지수 45 Ultra_Violet_index = CALL("index","uv"); //자외선지수
45 46
46 - socket.emit("weatherInfo_minutely_send_to_cliend",info); 47 + info = {
48 + heat : Sensible_T.weather.wIndex.heatIndex[0].current.index, //열지수
49 + sensible_temperature : Sensible_T.weather.wIndex.wctIndex[0].current.index, //체감온도
50 + discomport : Discomport_index.weather.wIndex.thIndex[0].current.index, //불쾌지수
51 + UV : Ultra_Violet_index.weather.wIndex.uvindex[0].day00.index,
52 + windspd : Current_Weather.weather.minutely[0].wind.wspd,
53 + sky : Current_Weather.weather.minutely[0].sky.code,
54 + rain : Current_Weather.weather.minutely[0].rain.last24hour,
55 + current_temperature : Current_Weather.weather.minutely[0].temperature.tc,
56 + lightning : Current_Weather.weather.minutely[0].lightning,
57 + warning : common.alertYn,
58 + typhoon : Current_Weather.common.stormYn,
59 + time : Current_Weather.weather.minutely[0].timeObservation,
60 + death_prob:0
61 + }
62 +
63 + info.death_prob += info.sky.substr(5)*1 //하늘 상태에 따라 확률 증가
64 +
65 + if(info.lightning===1) //낙뢰시에 확률 증가
66 + info.death_prob += 10;
67 + if(info.typhoon === "Y") //태풍시에 확률 증가
68 + info.death_prob += 10;
69 + if(info.warning === "Y") // 특보 발령시 확률 증가
70 + info.death_prob += 5
71 +
72 + //죽을 확률 계산(내맘대로)
73 + info.death_prob =(
74 + (info.heat/8) + (abs(info.sensible_temperature-15)/2) + (info.discomport/10) + (info.UV/5)
75 + + (info.windspd*3) + (info.rain/10) + (abs(info.current_temperature-15)/2)
76 + );
77 +
78 +
79 + socket.emit("weatherInfo_minutely_send_to_client",info); // 클라이언트에게 이벤트 발산
47 }, 60 * 1000); //1분마다 호출 80 }, 60 * 1000); //1분마다 호출
48 }); 81 });
49 82
......