mriusero commited on
Commit
a555792
·
1 Parent(s): 1ee80e7

feat: tools count

Browse files
Files changed (2) hide show
  1. src/production/flow.py +3 -3
  2. src/ui/dashboard.py +5 -4
src/production/flow.py CHANGED
@@ -6,6 +6,8 @@ from datetime import datetime, timedelta
6
 
7
  from .downtime import machine_errors
8
 
 
 
9
  async def generate_data(state):
10
  """
11
  Generate synthetic production data for a manufacturing process.
@@ -16,8 +18,6 @@ async def generate_data(state):
16
  non_compliance_rates = {
17
  1: 0.05,
18
  2: 0.10,
19
- 3: 0.03,
20
- 4: 0.07
21
  }
22
 
23
  if 'raw_df' not in state['data']:
@@ -56,7 +56,7 @@ async def generate_data(state):
56
  else:
57
  position = np.random.normal(loc=0.4, scale=0.03)
58
  orientation = np.random.normal(loc=0.4, scale=0.06)
59
- tool_id = (part_id % 4) + 1
60
 
61
  if random.random() < non_compliance_rates[tool_id]:
62
  position = np.random.normal(loc=0.4, scale=0.2)
 
6
 
7
  from .downtime import machine_errors
8
 
9
+ TOOLS_COUNT = 2
10
+
11
  async def generate_data(state):
12
  """
13
  Generate synthetic production data for a manufacturing process.
 
18
  non_compliance_rates = {
19
  1: 0.05,
20
  2: 0.10,
 
 
21
  }
22
 
23
  if 'raw_df' not in state['data']:
 
56
  else:
57
  position = np.random.normal(loc=0.4, scale=0.03)
58
  orientation = np.random.normal(loc=0.4, scale=0.06)
59
+ tool_id = (part_id % TOOLS_COUNT) + 1
60
 
61
  if random.random() < non_compliance_rates[tool_id]:
62
  position = np.random.normal(loc=0.4, scale=0.2)
src/ui/dashboard.py CHANGED
@@ -9,6 +9,7 @@ from src.production.metrics.machine import machine_metrics, fetch_issues
9
  from src.ui.graphs.tools_graphs import ToolMetricsDisplay
10
 
11
  MAX_ROWS = 1000
 
12
 
13
  def hash_dataframe(df):
14
  """Computes a simple hash to detect changes in the DataFrame."""
@@ -28,7 +29,7 @@ async def dataflow(state):
28
 
29
  raw_data = state['data'].get('raw_df', pd.DataFrame())
30
  if raw_data.empty:
31
- return [pd.DataFrame()] * 4
32
 
33
  if len(raw_data) > MAX_ROWS:
34
  raw_data = raw_data.tail(MAX_ROWS)
@@ -37,7 +38,7 @@ async def dataflow(state):
37
  if state.get('last_hash') == current_hash:
38
  return [
39
  pd.DataFrame(state['data']['tools'].get(f'tool_{i}', pd.DataFrame()))
40
- for i in range(1, 5)
41
  ]
42
  state['last_hash'] = current_hash
43
 
@@ -54,7 +55,7 @@ async def dataflow(state):
54
 
55
  return [
56
  pd.DataFrame(state['data']['tools'].get(f'tool_{i}', pd.DataFrame()))
57
- for i in range(1, 5)
58
  ]
59
 
60
  def update_display_and_plots(df, display):
@@ -71,7 +72,7 @@ def update_display_and_plots(df, display):
71
  display.control_graph(df),
72
  ]
73
 
74
- def init_displays_and_blocks(n=4):
75
  """
76
  Initializes the graphical objects (ToolMetricsDisplay) and their associated blocks.
77
  """
 
9
  from src.ui.graphs.tools_graphs import ToolMetricsDisplay
10
 
11
  MAX_ROWS = 1000
12
+ TOOLS_COUNT = 2
13
 
14
  def hash_dataframe(df):
15
  """Computes a simple hash to detect changes in the DataFrame."""
 
29
 
30
  raw_data = state['data'].get('raw_df', pd.DataFrame())
31
  if raw_data.empty:
32
+ return [pd.DataFrame()] * TOOLS_COUNT
33
 
34
  if len(raw_data) > MAX_ROWS:
35
  raw_data = raw_data.tail(MAX_ROWS)
 
38
  if state.get('last_hash') == current_hash:
39
  return [
40
  pd.DataFrame(state['data']['tools'].get(f'tool_{i}', pd.DataFrame()))
41
+ for i in range(1, TOOLS_COUNT+1)
42
  ]
43
  state['last_hash'] = current_hash
44
 
 
55
 
56
  return [
57
  pd.DataFrame(state['data']['tools'].get(f'tool_{i}', pd.DataFrame()))
58
+ for i in range(1, TOOLS_COUNT+1)
59
  ]
60
 
61
  def update_display_and_plots(df, display):
 
72
  display.control_graph(df),
73
  ]
74
 
75
+ def init_displays_and_blocks(n=TOOLS_COUNT):
76
  """
77
  Initializes the graphical objects (ToolMetricsDisplay) and their associated blocks.
78
  """