added file writing flush callto clean up file writing and prevent file overflow for new experiments
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cmake.sourceDirectory": "/Users/flyingtopher/Desktop/Code Citadel/School/2. Research/Fork Clone/XPlaneConnectCSP/C"
|
||||
}
|
||||
@@ -6,8 +6,6 @@ import math
|
||||
from geographiclib.geodesic import Geodesic as geo
|
||||
from rich import print
|
||||
|
||||
|
||||
|
||||
# Initialize XPlaneConnect client
|
||||
class scaleFactor():
|
||||
SCALEYOKEPULL = 10
|
||||
|
||||
@@ -216,6 +216,7 @@ def log(cogModel, file,timeElapsed):
|
||||
mainString[len(mainString)-1] = "\n"
|
||||
finalString = "".join(mainString)
|
||||
file.write(finalString)
|
||||
file.flush()
|
||||
# file.write(str(timeElapsed) + "," + str(data[0][0]) + "," + str(data[1][0]) + "," + str(data[2][0]) + "," + str(data[3][0]) +"\n")
|
||||
|
||||
|
||||
@@ -322,7 +323,7 @@ def setUp():
|
||||
def cleanUp(count,title):
|
||||
now = datetime.datetime
|
||||
# shutil.copy("/Users/flyingtopher/X-Plane 11/Data.txt", "/Users/flyingtopher/Desktop/Test Destination/" + title + "_"+ count + "_" + str(now.now()) + "_" + ".txt")
|
||||
shutil.copy("/Users/flyingtopher/X-Plane 11/Data.txt", "/Users/flyingtopher/Desktop/Test Destination/Current Experiment/" + title + "_"+ str(count) + "_" + ".txt")
|
||||
shutil.copy("/Users/flyingtopher/X-Plane 11/Data.txt", "/Users/flyingtopher/Desktop/Test Destination/Current Experiment/" + str(count)+ "_" + title + ".txt")
|
||||
print("CLEAN UP: Data File Deleted and Reset")
|
||||
specialPrint("Data File Ready",False,messageType.REGULAR)
|
||||
|
||||
@@ -358,6 +359,8 @@ def ex():
|
||||
experimentCount = int(startAt)
|
||||
header = "Cycle Time,Latitude, Longitude, Altitude, Pitch, Roll\n"
|
||||
file2 = open("/Users/flyingtopher/Desktop/Test Destination/Current Experiment/CurrentExperimentList.txt", 'w')
|
||||
file2.write(str(title) + "\n")
|
||||
startTime = time.time()
|
||||
"""
|
||||
Experiment Loop
|
||||
"""
|
||||
@@ -366,12 +369,16 @@ def ex():
|
||||
file = open("/Users/flyingtopher/X-Plane 11/Data.txt", 'a')
|
||||
file.write(str(header)) #Write Header to File$
|
||||
currentConditions = experimentConditionMatrix[experimentCount]
|
||||
file2.write(str(experimentCount) +" // " + str(currentConditions) + "\n")
|
||||
file2.write(str(experimentCount) +" // " + str(currentConditions))
|
||||
file2.flush()
|
||||
exitExperimentLoop = runExperiment(title,currentConditions,allowPrinting,isNewExperiment,experimentCount,file)
|
||||
if(exitExperimentLoop):
|
||||
break
|
||||
cleanUp(experimentCount,title)
|
||||
experimentCount+=1
|
||||
endTime = time.time()
|
||||
elapsed = endTime-startTime
|
||||
file2.write(" " + str(elapsed) + "\n")
|
||||
# pag.alert(text="Experiment " + str(experimentCount+1) + " complete. Starting new Experiment", title="EXPERIMENT STATUS UPDATE")
|
||||
"""
|
||||
End of Experiments
|
||||
|
||||
Reference in New Issue
Block a user