1414import datetime
1515import sqlite3
1616
17- dt_now = datetime .datetime .now ()
18-
1917os .environ ["FLET_WS_MAX_MESSAGE_SIZE" ] = "16000000"
2018
2119async def main (page : Page ):
@@ -66,7 +64,7 @@ async def main(page: Page):
6664 ### Page System
6765 ################################
6866
69- page .title = "EBDAS - Ehime Baloon Data Analyze System"
67+ page .title = "EBDAS - Ehime Baloon Data Analysis System"
7068 body = []
7169 bodySide = []
7270 rtTab = []
@@ -92,7 +90,7 @@ async def rtRenderChange(e):
9290 if await page .client_storage .contains_key_async ("isRtRender" ) == True :
9391 rtRenderSwitch = ft .Switch (label = "リアルタイム描画" , on_change = rtRenderChange , value = await page .client_storage .get_async ("isRtRender" ))
9492 else :
95- rtRenderSwitch = ft .Switch (label = "リアルタイム描画" , on_change = rtRenderChange , value = True )
93+ rtRenderSwitch = ft .Switch (label = "リアルタイム描画" , on_change = rtRenderChange , value = False )
9694
9795 # ################################
9896 # ### autoscrollSwitch
@@ -417,6 +415,7 @@ async def addRealtimeData(resList, resListFloat):
417415 recordStartTime = resListFloat [0 ]
418416 recordRawData += "time[sec], temperature[degC], pressure[hPa], humidity[%], altitude[m], a0, a1, a2, a3\n "
419417 recordBaloonName = baloonSelecter .value
418+ dt_now = datetime .datetime .now ()
420419 recordDateTime = copy .deepcopy (dt_now .strftime ('%Y-%m-%d_%H-%M-%S' ))
421420 recordDataStatus = True
422421 recordList = copy .deepcopy (resList )
@@ -1352,6 +1351,35 @@ async def recordSave(e):
13521351 return ()
13531352 weightInput .border_color = None
13541353 await weightInput .update_async ()
1354+
1355+ if actualTemp .value == None or actualTemp .value == "" :
1356+ await openSnackbar ("実際の気温が未入力です。" )
1357+ # weightInput の border_color を red にする
1358+ actualTemp .border_color = "red"
1359+ await actualTemp .update_async ()
1360+ await actualTemp .focus_async ()
1361+ return ()
1362+ actualTemp .border_color = None
1363+ await actualTemp .update_async ()
1364+ if actualHumidity .value == None or actualHumidity .value == "" :
1365+ await openSnackbar ("実際の湿度が未入力です。" )
1366+ # weightInput の border_color を red にする
1367+ actualHumidity .border_color = "red"
1368+ await actualHumidity .update_async ()
1369+ await actualHumidity .focus_async ()
1370+ return ()
1371+ actualHumidity .border_color = None
1372+ await actualHumidity .update_async ()
1373+ if actualAirTime .value == None or actualAirTime .value == "" :
1374+ await openSnackbar ("実際の湿度が未入力です。" )
1375+ # weightInput の border_color を red にする
1376+ actualAirTime .border_color = "red"
1377+ await actualAirTime .update_async ()
1378+ await actualAirTime .focus_async ()
1379+ return ()
1380+ actualAirTime .border_color = None
1381+ await actualAirTime .update_async ()
1382+
13551383 fName = "EBDAS_" + recordDateTime + "_" + baloonSelecter .value + ".csv"
13561384 fDir = await page .client_storage .get_async ("directory_path" )+ "/" + baloonSelecter .value
13571385 airTime = "{:.3f}" .format (float (recordTime )- float (takeoffTime ))
@@ -1362,7 +1390,26 @@ async def recordSave(e):
13621390 conn = sqlite3 .connect (dbname )
13631391 cur = conn .cursor ()
13641392 takeoffIndex = r_time_str .index ("0.00" )
1365- cur .execute (f'INSERT INTO data(baloon, weight, datetime, recordTime, chargeTime, airTime, temperature_ave, pressure_init, humidity_init, altitude_max, a_ave_init, a0_max, a1_max, a2_max, a3_max, rawdata, recordLocation, a0_location, a1_location, a2_location, a3_location, recordNote) values("{ baloonSelecter .value } ", { weightInput .value } , "{ recordDateTime } ", { recordTime } , { takeoffTime } , { airTime } , { "{:.2f}" .format (sum (r_temp )/ len (r_temp ))} , { "{:.1f}" .format (r_pressure [takeoffIndex ])} , { "{:.1f}" .format (r_humidity [takeoffIndex ])} , { "{:.1f}" .format (max (r_altitude [takeoffIndex :]))} , { "{:.2f}" .format (sum ([r_a0 [takeoffIndex ]+ r_a1 [takeoffIndex ]+ r_a2 [takeoffIndex ]+ r_a3 [takeoffIndex ]])/ 4 )} , { "{:.1f}" .format (max (r_a0 [takeoffIndex :]))} , { "{:.1f}" .format (max (r_a1 [takeoffIndex :]))} , { "{:.1f}" .format (max (r_a2 [takeoffIndex :]))} , { "{:.1f}" .format (max (r_a3 [takeoffIndex :]))} , "{ recordRawData } ", "{ recordLocation .value } ", "{ sensorLocationA0 .value } ", "{ sensorLocationA1 .value } ", "{ sensorLocationA2 .value } ", "{ sensorLocationA3 .value } ", "{ recordNote .value } ")' )
1393+
1394+ if actualAirTime .value != None and actualAirTime .value != "" :
1395+ acAirTime = actualAirTime .value
1396+ else :
1397+ acAirTime = "NULL"
1398+
1399+ if actualTemp .value != None and actualTemp .value != "" :
1400+ acTemp = actualTemp .value
1401+ else :
1402+ acTemp = "NULL"
1403+
1404+ if actualHumidity .value != None and actualHumidity .value != "" :
1405+ acHumidity = actualHumidity .value
1406+ else :
1407+ acHumidity = "NULL"
1408+
1409+ if recordNote == "" or recordNote == None :
1410+ cur .execute (f'INSERT INTO data(baloon, weight, datetime, recordTime, chargeTime, airTime, temperature_ave, pressure_init, humidity_init, altitude_max, a_ave_init, a0_max, a1_max, a2_max, a3_max, rawdata, recordLocation, a0_location, a1_location, a2_location, a3_location, actualAirTime) values("{ baloonSelecter .value } ", { weightInput .value } , "{ recordDateTime } ", { recordTime } , { takeoffTime } , { airTime } , { acTemp } , { "{:.1f}" .format (r_pressure [takeoffIndex ])} , { acHumidity } , { "{:.1f}" .format (max (r_altitude [takeoffIndex :]))} , { "{:.2f}" .format (sum ([r_a0 [takeoffIndex ]+ r_a1 [takeoffIndex ]+ r_a2 [takeoffIndex ]+ r_a3 [takeoffIndex ]])/ 4 )} , { "{:.1f}" .format (max (r_a0 [takeoffIndex :]))} , { "{:.1f}" .format (max (r_a1 [takeoffIndex :]))} , { "{:.1f}" .format (max (r_a2 [takeoffIndex :]))} , { "{:.1f}" .format (max (r_a3 [takeoffIndex :]))} , "{ recordRawData } ", "{ recordLocation .value } ", "{ sensorLocationA0 .value } ", "{ sensorLocationA1 .value } ", "{ sensorLocationA2 .value } ", "{ sensorLocationA3 .value } ", { acAirTime } )' )
1411+ else :
1412+ cur .execute (f'INSERT INTO data(baloon, weight, datetime, recordTime, chargeTime, airTime, temperature_ave, pressure_init, humidity_init, altitude_max, a_ave_init, a0_max, a1_max, a2_max, a3_max, rawdata, recordLocation, a0_location, a1_location, a2_location, a3_location, recordNote, actualAirTime) values("{ baloonSelecter .value } ", { weightInput .value } , "{ recordDateTime } ", { recordTime } , { takeoffTime } , { airTime } , { acTemp } , { "{:.1f}" .format (r_pressure [takeoffIndex ])} , { acHumidity } , { "{:.1f}" .format (max (r_altitude [takeoffIndex :]))} , { "{:.2f}" .format (sum ([r_a0 [takeoffIndex ]+ r_a1 [takeoffIndex ]+ r_a2 [takeoffIndex ]+ r_a3 [takeoffIndex ]])/ 4 )} , { "{:.1f}" .format (max (r_a0 [takeoffIndex :]))} , { "{:.1f}" .format (max (r_a1 [takeoffIndex :]))} , { "{:.1f}" .format (max (r_a2 [takeoffIndex :]))} , { "{:.1f}" .format (max (r_a3 [takeoffIndex :]))} , "{ recordRawData } ", "{ recordLocation .value } ", "{ sensorLocationA0 .value } ", "{ sensorLocationA1 .value } ", "{ sensorLocationA2 .value } ", "{ sensorLocationA3 .value } ", "{ recordNote .value } ", "{ acAirTime } ")' )
13661413 conn .commit ()
13671414 cur .close ()
13681415 conn .close ()
@@ -1387,8 +1434,7 @@ async def recordSave(e):
13871434 await recordDeleteTitle .update_async ()
13881435 await recordDeleteText .update_async ()
13891436 await recordDeleteIcon .update_async ()
1390-
1391-
1437+
13921438 recordSaveTitle = ft .Text (value = "保存" , size = 20 )
13931439 recordSaveText = ft .Text (value = "保存対象?" )
13941440 recordSaveIcon = ft .Icon (name = ft .icons .SAVE )
@@ -1720,8 +1766,11 @@ async def setRecordLocation(e):
17201766 body .append (rtBottomMenu2 )
17211767
17221768 # 記録メモText Fieldを追加
1723- recordNote = ft .TextField (label = "記録メモ" , multiline = True ,min_lines = 2 ,max_lines = 2 , value = await page .client_storage .get_async ("recordNote" ))
1724- body .append (recordNote )
1769+ recordNote = ft .TextField (label = "記録メモ" , multiline = True ,min_lines = 2 ,max_lines = 2 , value = await page .client_storage .get_async ("recordNote" ), width = 550 )
1770+ actualTemp = ft .TextField (label = "気温" , width = 100 , suffix_text = "℃" )
1771+ actualHumidity = ft .TextField (label = "湿度" , width = 100 , suffix_text = "%" )
1772+ actualAirTime = ft .TextField (label = "実際滞空時間" , width = 100 , suffix_text = "sec" )
1773+ body .append (ft .Row ([recordNote ,actualTemp , actualHumidity ,actualAirTime ], spacing = 5 ))
17251774
17261775 # weightForm=ft.Row(
17271776 # spacing=5,
@@ -1808,8 +1857,8 @@ async def button_clicked(time):
18081857
18091858
18101859
1811- # body.append(ft.Row([rtAutoScSwitch, ft.Text("動作が重くなります! 記録は滞空中のみしてください 。")], spacing=12))
1812- body .append (ft .Row ([ft .Text ("記録は滞空中のみしてください 。正確な記録のために、接続前にリアルタイム描画をオフにしてください。" )], spacing = 12 ))
1860+ # body.append(ft.Row([rtAutoScSwitch, ft.Text("動作が重くなります! 記録は充填+滞空中のみしてください 。")], spacing=12))
1861+ body .append (ft .Row ([ft .Text ("記録は充填+滞空中のみしてください 。正確な記録のために、接続前にリアルタイム描画をオフにしてください。" )], spacing = 12 ))
18131862
18141863
18151864 await page .add_async (menubaritem )
@@ -1950,11 +1999,6 @@ def d(m):
19501999 # ),
19512000 # ),
19522001 # ft.Tab(
1953- # text="計算機",
1954- # icon=ft.icons.CALCULATE_ROUNDED,
1955- # content=ft.Text("この機能はまだ実装されていません。"),
1956- # ),
1957- # ft.Tab(
19582002 # text="チェックリスト",
19592003 # icon=ft.icons.CHECK_BOX_ROUNDED,
19602004 # content=ft.Text("この機能はまだ実装されていません。"),
0 commit comments