Browse Source

log fixes

Marcel Zickler 3 years ago
parent
commit
55aee7ee9d

+ 85 - 18
Assets/Plotting/.idea/workspace.xml

@@ -2,25 +2,11 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="ee646045-196c-400d-a2b8-69533432d097" name="Default Changelist" comment="">
-      <change afterPath="$PROJECT_DIR$/Pipfile.lock" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../.idea/.idea.VRCyling/.idea/contentModel.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../.idea/.idea.VRCyling/.idea/contentModel.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../.idea/.idea.VRCyling/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../.idea/.idea.VRCyling/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../Assembly-CSharp-Editor.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/../../Assembly-CSharp-Editor.csproj" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../Assembly-CSharp.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/../../Assembly-CSharp.csproj" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../Logs.meta" beforeDir="false" afterPath="$PROJECT_DIR$/../Logs.meta" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/Pipfile.lock.meta" beforeDir="false" afterPath="$PROJECT_DIR$/Pipfile.lock.meta" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../Scripts/Tracking/FrontWheelTracker.cs" beforeDir="false" afterPath="$PROJECT_DIR$/../Scripts/Tracking/FrontWheelTracker.cs" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../Packages/packages-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/../../Packages/packages-lock.json" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../SteamVR.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/../../SteamVR.csproj" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../SteamVR_Editor.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/../../SteamVR_Editor.csproj" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../SteamVR_Input_Editor.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/../../SteamVR_Input_Editor.csproj" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../SteamVR_Windows_EditorHelper.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/../../SteamVR_Windows_EditorHelper.csproj" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../obj/Debug/Assembly-CSharp.csprojAssemblyReference.cache" beforeDir="false" afterPath="$PROJECT_DIR$/../../obj/Debug/Assembly-CSharp.csprojAssemblyReference.cache" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../obj/Debug/SteamVR_Windows_EditorHelper.csprojAssemblyReference.cache" beforeDir="false" afterPath="$PROJECT_DIR$/../../obj/Debug/SteamVR_Windows_EditorHelper.csprojAssemblyReference.cache" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../unityProject.vrmanifest" beforeDir="false" afterPath="$PROJECT_DIR$/../../unityProject.vrmanifest" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/data.py" beforeDir="false" afterPath="$PROJECT_DIR$/data.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/tools.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools.py" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../Scripts/Logging/FileLogger.cs" beforeDir="false" afterPath="$PROJECT_DIR$/../Scripts/Logging/FileLogger.cs" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -30,6 +16,7 @@
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
   </component>
+  <component name="JupyterTrust" id="70c77ed9-2d23-4b9b-8ca9-8dec3d4c8737" />
   <component name="ProjectId" id="1mguoWNWhOw6YE469c1MmJba58G" />
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
   <component name="ProjectViewState">
@@ -40,6 +27,41 @@
     <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
     <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
     <property name="WebServerToolWindowFactoryState" value="false" />
+    <property name="node.js.detected.package.eslint" value="true" />
+    <property name="node.js.detected.package.tslint" value="true" />
+    <property name="node.js.path.for.package.eslint" value="project" />
+    <property name="node.js.path.for.package.tslint" value="project" />
+    <property name="node.js.selected.package.eslint" value="(autodetect)" />
+    <property name="node.js.selected.package.tslint" value="(autodetect)" />
+  </component>
+  <component name="RunManager">
+    <configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
+      <module name="Plotting" />
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <envs>
+        <env name="PYTHONUNBUFFERED" value="1" />
+      </envs>
+      <option name="SDK_HOME" value="" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+      <option name="IS_MODULE_SDK" value="true" />
+      <option name="ADD_CONTENT_ROOTS" value="true" />
+      <option name="ADD_SOURCE_ROOTS" value="true" />
+      <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
+      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
+      <option name="PARAMETERS" value="" />
+      <option name="SHOW_COMMAND_LINE" value="false" />
+      <option name="EMULATE_TERMINAL" value="false" />
+      <option name="MODULE_MODE" value="false" />
+      <option name="REDIRECT_INPUT" value="false" />
+      <option name="INPUT_FILE" value="" />
+      <method v="2" />
+    </configuration>
+    <recent_temporary>
+      <list>
+        <item itemvalue="Python.main" />
+      </list>
+    </recent_temporary>
   </component>
   <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
   <component name="TaskManager">
@@ -51,10 +73,55 @@
       <updated>1609927731811</updated>
       <workItem from="1609927755546" duration="570000" />
       <workItem from="1609929396953" duration="1851000" />
+      <workItem from="1610104231320" duration="1600000" />
     </task>
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
     <option name="version" value="3" />
   </component>
+  <component name="WindowStateProjectService">
+    <state width="1877" height="396" key="GridCell.Tab.0.bottom" timestamp="1610106612109">
+      <screen x="0" y="0" width="1920" height="1160" />
+    </state>
+    <state width="1877" height="396" key="GridCell.Tab.0.bottom/1920.0.1920.1160/0.0.1920.1160@0.0.1920.1160" timestamp="1610106612109" />
+    <state width="1877" height="396" key="GridCell.Tab.0.center" timestamp="1610106612109">
+      <screen x="0" y="0" width="1920" height="1160" />
+    </state>
+    <state width="1877" height="396" key="GridCell.Tab.0.center/1920.0.1920.1160/0.0.1920.1160@0.0.1920.1160" timestamp="1610106612109" />
+    <state width="1877" height="396" key="GridCell.Tab.0.left" timestamp="1610106612109">
+      <screen x="0" y="0" width="1920" height="1160" />
+    </state>
+    <state width="1877" height="396" key="GridCell.Tab.0.left/1920.0.1920.1160/0.0.1920.1160@0.0.1920.1160" timestamp="1610106612109" />
+    <state width="1877" height="396" key="GridCell.Tab.0.right" timestamp="1610106612109">
+      <screen x="0" y="0" width="1920" height="1160" />
+    </state>
+    <state width="1877" height="396" key="GridCell.Tab.0.right/1920.0.1920.1160/0.0.1920.1160@0.0.1920.1160" timestamp="1610106612109" />
+    <state width="970" height="590" key="XDebugger.FullValuePopup" timestamp="1610106286803">
+      <screen x="0" y="0" width="1920" height="1160" />
+    </state>
+    <state width="970" height="590" key="XDebugger.FullValuePopup/1920.0.1920.1160/0.0.1920.1160@0.0.1920.1160" timestamp="1610106286803" />
+  </component>
+  <component name="XDebuggerManager">
+    <breakpoint-manager>
+      <breakpoints>
+        <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
+          <url>file://$PROJECT_DIR$/tools.py</url>
+          <line>15</line>
+          <option name="timeStamp" value="2" />
+        </line-breakpoint>
+      </breakpoints>
+    </breakpoint-manager>
+    <watches-manager>
+      <configuration name="PythonConfigurationType">
+        <watch expression="df.index" language="Python" />
+        <watch expression="df[c]" language="Python" />
+        <watch expression="df[c][math.isNan(df[c])]" language="Python" />
+        <watch expression="df[c].index" language="Python" />
+      </configuration>
+    </watches-manager>
+  </component>
+  <component name="com.intellij.coverage.CoverageDataManagerImpl">
+    <SUITE FILE_PATH="coverage/Plotting$main.coverage" NAME="main Coverage Results" MODIFIED="1610106180565" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
+  </component>
 </project>

+ 4 - 7
Assets/Plotting/data.py

@@ -10,20 +10,17 @@ class Data:
     def __init__(self, base_path):
         self.base_path = base_path
         self.df: Optional[pd.DataFrame] = None
-        self.current_folder_name = ''
         self.current_file_name = ''
 
-    def read_folder(self, path):
-        self.current_folder_name = path
-        if path is None:
-            return []
-        return [file for file in os.listdir(f'{self.base_path}/{path}') if file.endswith('.tsv')]
+    def read_folder(self):
+        l = [file for file in os.listdir(f'{self.base_path}') if file.endswith('.tsv')]
+        return sorted(l, reverse=True)
 
     def read_data(self, file_name):
         if file_name is None:
             return None
         self.current_file_name = file_name
-        self.df = pd.read_csv(f'{self.base_path}/{self.current_folder_name}/{file_name}', index_col=0, sep='\t')
+        self.df = pd.read_csv(f'{self.base_path}/{file_name}', index_col=0, sep='\t')
 
     def read_data_old(self, path):
         if path is None:

+ 7 - 30
Assets/Plotting/main.py

@@ -31,23 +31,13 @@ app.layout = html.Div(
                      html.Div(className='four columns div-user-controls',
                               children=[
                                   html.H2('VR Cycling - Visualize Logs'),
-                                  html.H3('Pick a log folder.'),
-                                  html.Div(
-                                      className='div-for-dropdown',
-                                      children=[
-                                          dcc.Dropdown(id='select-log', options=get_options(log_files),
-                                                       multi=False, value=None,
-                                                       style={'backgroundColor': '#1E1E1E'},
-                                                       )
-                                      ],
-                                      style={'color': '#F1F1F1'}),
-
                                   html.Div(
                                       className='div-for-dropdown-group',
                                       children=[
                                           html.H3('First plot:'),
                                           dcc.Dropdown(id='select-file-1',
                                                        multi=False,
+                                                       options=get_options(d1.read_folder()),
                                                        style={'backgroundColor': '#1E1E1E'}
                                                        ),
                                           html.H3('Pick one or more data items.'),
@@ -64,6 +54,7 @@ app.layout = html.Div(
                                           html.H3('Second plot:'),
                                           dcc.Dropdown(id='select-file-2',
                                                        multi=False,
+                                                       options=get_options(d1.read_folder()),
                                                        style={'backgroundColor': '#1E1E1E'}
                                                        ),
                                           html.H3('Pick one or more data items.'),
@@ -79,11 +70,11 @@ app.layout = html.Div(
                                   dcc.Graph(id='data-plot-1', config={'displayModeBar': False}, animate=True),
                                   html.Div(style={'height': '12px'}),
                                   dcc.Graph(id='data-plot-2', config={'displayModeBar': False}, animate=True),
-                                  #dcc.Interval(
+                                  # dcc.Interval(
                                   #    id='interval-component',
                                   #    interval=1 * 1000,  # in milliseconds
                                   #    n_intervals=0
-                                  #)
+                                  # )
                               ])
                  ])
     ]
@@ -91,20 +82,6 @@ app.layout = html.Div(
 )
 
 
-@app.callback(Output('select-file-1', 'options'),
-              [Input('select-log', 'value')])
-def update_file_options_1(selected_folder):
-    files = d1.read_folder(selected_folder)
-    return get_options(files)
-
-
-@app.callback(Output('select-file-2', 'options'),
-              [Input('select-log', 'value')])
-def update_file_options_2(selected_folder):
-    files = d2.read_folder(selected_folder)
-    return get_options(files)
-
-
 @app.callback(Output('select-data-1', 'options'),
               [Input('select-file-1', 'value')])
 def update_file_selection_1(selected_file):
@@ -122,15 +99,15 @@ def update_file_selection_2(selected_file):
 @app.callback(Output('data-plot-1', 'figure'),
               [Input('select-data-1', 'value')])
 def update_plot_1(selected_data_columns):
-    #print(f'Interval {n}')
+    # print(f'Interval {n}')
     return generate_figure(selected_data_columns, d1.df,
-                           f'Log Data - {d1.current_folder_name} - {d1.current_file_name}')
+                           f'Log Data - {d1.current_file_name}')
 
 
 @app.callback(Output('data-plot-2', 'figure'), [Input('select-data-2', 'value')])
 def update_plot_1(selected_data_columns):
     return generate_figure(selected_data_columns, d2.df,
-                           f'Log Data - {d2.current_folder_name} - {d2.current_file_name}')
+                           f'Log Data - {d2.current_file_name}')
 
 
 if __name__ == '__main__':

+ 5 - 2
Assets/Plotting/tools.py

@@ -1,4 +1,6 @@
 import plotly.graph_objects as go
+import math
+import pandas as pd
 
 def get_options(options_list):
     dict_list = []
@@ -12,8 +14,9 @@ def generate_figure(cols, df, title):
     # STEP 2
     # Draw and append traces for each stock
     for c in cols if cols is not None else []:
-        trace.append(go.Scatter(x=df.index,
-                                y=df[c],
+        s = df[c].dropna()
+        trace.append(go.Scatter(x=s.index,
+                                y=s,
                                 mode='lines',
                                 opacity=0.7,
                                 name=c,

+ 9 - 6
Assets/Scripts/Logging/FileLogger.cs

@@ -72,8 +72,8 @@ namespace Logging
                 var begin = keys.Length > 0 ? keys.First() : -1;
                 var end = keys.Length > 0 ? keys.Last() : -1;
 
-                if (minBegin == -1 || begin < minBegin) minBegin = begin;
-                if (minEnd == -1 || end < minEnd) minEnd = end;
+                if (minBegin == -1 || begin >= 0 && begin < minBegin) minBegin = begin;
+                if (minEnd == -1 || end >= 0 && end < minEnd) minEnd = end;
             }
 
             Debug.Log($"\t{minBegin} - {minEnd}");
@@ -91,7 +91,7 @@ namespace Logging
                 {
                     foreach (var waitingTs in waiting.Keys)
                     {
-                        if (waitingTs >= minBegin && waitingTs <= minEnd)
+                        if (waitingTs <= minEnd)
                         {
                             allTimestamps.Add(waitingTs);
                         }
@@ -157,9 +157,9 @@ namespace Logging
                     }
                     else
                     {
-                        //var lastAvailableKey =
-                        l.BufferLines.Keys.Where(k => k < timestamp).DefaultIfEmpty(-1).LastOrDefault();
-                        /*linePart = lastAvailableKey >= 0
+                        /*var lastAvailableKey =
+                            l.BufferLines.Keys.Where(k => k < timestamp).DefaultIfEmpty(-1).LastOrDefault();
+                        linePart = lastAvailableKey >= 0
                             ? l.BufferLines[lastAvailableKey]
                             : new string[l.HeaderNames.ToArray().Length];*/
                         linePart = new string[l.HeaderNames.ToArray().Length];
@@ -203,6 +203,9 @@ namespace Logging
                 writer.Dispose();
             }
 
+            Debug.Log("----Disposing FileLogger----");
+            Debug.Log($"\tLeft keys: {waitingBuffers}");
+
             logables.Clear();
         }
     }