@seedtactics/insight-client 16.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/README.md +37 -0
  2. package/dist/cell-status/buffers.d.ts +36 -0
  3. package/dist/cell-status/buffers.js +127 -0
  4. package/dist/cell-status/current-status.d.ts +30 -0
  5. package/dist/cell-status/current-status.js +200 -0
  6. package/dist/cell-status/estimated-cycle-times.d.ts +41 -0
  7. package/dist/cell-status/estimated-cycle-times.js +257 -0
  8. package/dist/cell-status/inspections.d.ts +55 -0
  9. package/dist/cell-status/inspections.js +213 -0
  10. package/dist/cell-status/loading.d.ts +26 -0
  11. package/dist/cell-status/loading.js +112 -0
  12. package/dist/cell-status/material-details.d.ts +116 -0
  13. package/dist/cell-status/material-details.js +422 -0
  14. package/dist/cell-status/material-summary.d.ts +52 -0
  15. package/dist/cell-status/material-summary.js +312 -0
  16. package/dist/cell-status/names.d.ts +19 -0
  17. package/dist/cell-status/names.js +134 -0
  18. package/dist/cell-status/pallet-cycles.d.ts +24 -0
  19. package/dist/cell-status/pallet-cycles.js +78 -0
  20. package/dist/cell-status/rebookings.d.ts +30 -0
  21. package/dist/cell-status/rebookings.js +139 -0
  22. package/dist/cell-status/scheduled-jobs.d.ts +18 -0
  23. package/dist/cell-status/scheduled-jobs.js +94 -0
  24. package/dist/cell-status/sim-day-usage.d.ts +14 -0
  25. package/dist/cell-status/sim-day-usage.js +54 -0
  26. package/dist/cell-status/sim-production.d.ts +22 -0
  27. package/dist/cell-status/sim-production.js +91 -0
  28. package/dist/cell-status/sim-station-use.d.ts +25 -0
  29. package/dist/cell-status/sim-station-use.js +71 -0
  30. package/dist/cell-status/station-cycles.d.ts +34 -0
  31. package/dist/cell-status/station-cycles.js +145 -0
  32. package/dist/cell-status/tool-replacements.d.ts +44 -0
  33. package/dist/cell-status/tool-replacements.js +155 -0
  34. package/dist/cell-status/tool-usage.d.ts +25 -0
  35. package/dist/cell-status/tool-usage.js +95 -0
  36. package/dist/components/App.d.ts +15 -0
  37. package/dist/components/App.js +549 -0
  38. package/dist/components/AxisAndGrid.d.ts +51 -0
  39. package/dist/components/AxisAndGrid.js +47 -0
  40. package/dist/components/BarcodeScanning.d.ts +6 -0
  41. package/dist/components/BarcodeScanning.js +150 -0
  42. package/dist/components/ChartTooltip.d.ts +28 -0
  43. package/dist/components/ChartTooltip.js +95 -0
  44. package/dist/components/ChooseMode.d.ts +18 -0
  45. package/dist/components/ChooseMode.js +136 -0
  46. package/dist/components/ChooseOperator.d.ts +1 -0
  47. package/dist/components/ChooseOperator.js +93 -0
  48. package/dist/components/ErrorsAndLoading.d.ts +9 -0
  49. package/dist/components/ErrorsAndLoading.js +55 -0
  50. package/dist/components/LoadingIcon.d.ts +1 -0
  51. package/dist/components/LoadingIcon.js +48 -0
  52. package/dist/components/LogEntry.d.ts +16 -0
  53. package/dist/components/LogEntry.js +365 -0
  54. package/dist/components/ManualSerialEntry.d.ts +5 -0
  55. package/dist/components/ManualSerialEntry.js +91 -0
  56. package/dist/components/MonthSelect.d.ts +6 -0
  57. package/dist/components/MonthSelect.js +67 -0
  58. package/dist/components/Navigation.d.ts +23 -0
  59. package/dist/components/Navigation.js +120 -0
  60. package/dist/components/VerboseLogging.d.ts +1 -0
  61. package/dist/components/VerboseLogging.js +47 -0
  62. package/dist/components/analysis/AnalysisSelectToolbar.d.ts +1 -0
  63. package/dist/components/analysis/AnalysisSelectToolbar.js +55 -0
  64. package/dist/components/analysis/BufferChart.d.ts +1 -0
  65. package/dist/components/analysis/BufferChart.js +139 -0
  66. package/dist/components/analysis/CostPerPiece.d.ts +2 -0
  67. package/dist/components/analysis/CostPerPiece.js +175 -0
  68. package/dist/components/analysis/CycleChart.d.ts +42 -0
  69. package/dist/components/analysis/CycleChart.js +281 -0
  70. package/dist/components/analysis/DataTable.d.ts +83 -0
  71. package/dist/components/analysis/DataTable.js +215 -0
  72. package/dist/components/analysis/EfficiencyPage.d.ts +2 -0
  73. package/dist/components/analysis/EfficiencyPage.js +138 -0
  74. package/dist/components/analysis/HeatChart.d.ts +22 -0
  75. package/dist/components/analysis/HeatChart.js +161 -0
  76. package/dist/components/analysis/InspectionDataTable.d.ts +10 -0
  77. package/dist/components/analysis/InspectionDataTable.js +148 -0
  78. package/dist/components/analysis/InspectionSankey.d.ts +12 -0
  79. package/dist/components/analysis/InspectionSankey.js +140 -0
  80. package/dist/components/analysis/PalletCycleCards.d.ts +1 -0
  81. package/dist/components/analysis/PalletCycleCards.js +137 -0
  82. package/dist/components/analysis/PartCycleCards.d.ts +2 -0
  83. package/dist/components/analysis/PartCycleCards.js +331 -0
  84. package/dist/components/analysis/QualityPage.d.ts +1 -0
  85. package/dist/components/analysis/QualityPage.js +49 -0
  86. package/dist/components/analysis/ScheduleHistory.d.ts +3 -0
  87. package/dist/components/analysis/ScheduleHistory.js +108 -0
  88. package/dist/components/analysis/StationDataTable.d.ts +25 -0
  89. package/dist/components/analysis/StationDataTable.js +246 -0
  90. package/dist/components/analysis/ToolReplacements.d.ts +1 -0
  91. package/dist/components/analysis/ToolReplacements.js +370 -0
  92. package/dist/components/operations/AllMaterial.d.ts +5 -0
  93. package/dist/components/operations/AllMaterial.js +267 -0
  94. package/dist/components/operations/ChartRangeEdit.d.ts +4 -0
  95. package/dist/components/operations/ChartRangeEdit.js +148 -0
  96. package/dist/components/operations/CloseoutReport.d.ts +2 -0
  97. package/dist/components/operations/CloseoutReport.js +172 -0
  98. package/dist/components/operations/CompletedParts.d.ts +2 -0
  99. package/dist/components/operations/CompletedParts.js +286 -0
  100. package/dist/components/operations/CurrentWorkorders.d.ts +3 -0
  101. package/dist/components/operations/CurrentWorkorders.js +368 -0
  102. package/dist/components/operations/Dashboard.d.ts +2 -0
  103. package/dist/components/operations/Dashboard.js +90 -0
  104. package/dist/components/operations/OEEChart.d.ts +10 -0
  105. package/dist/components/operations/OEEChart.js +173 -0
  106. package/dist/components/operations/Outliers.d.ts +4 -0
  107. package/dist/components/operations/Outliers.js +69 -0
  108. package/dist/components/operations/ProgramHighlight.d.ts +1 -0
  109. package/dist/components/operations/ProgramHighlight.js +9 -0
  110. package/dist/components/operations/Programs.d.ts +5 -0
  111. package/dist/components/operations/Programs.js +363 -0
  112. package/dist/components/operations/Rebookings.d.ts +1 -0
  113. package/dist/components/operations/Rebookings.js +213 -0
  114. package/dist/components/operations/RecentCycleChart.d.ts +4 -0
  115. package/dist/components/operations/RecentCycleChart.js +240 -0
  116. package/dist/components/operations/RecentProduction.d.ts +2 -0
  117. package/dist/components/operations/RecentProduction.js +213 -0
  118. package/dist/components/operations/RecentSchedules.d.ts +12 -0
  119. package/dist/components/operations/RecentSchedules.js +180 -0
  120. package/dist/components/operations/RecentStationCycles.d.ts +4 -0
  121. package/dist/components/operations/RecentStationCycles.js +159 -0
  122. package/dist/components/operations/ShiftSettings.d.ts +6 -0
  123. package/dist/components/operations/ShiftSettings.js +134 -0
  124. package/dist/components/operations/SimDayUsage.d.ts +1 -0
  125. package/dist/components/operations/SimDayUsage.js +133 -0
  126. package/dist/components/operations/ToolReport.d.ts +3 -0
  127. package/dist/components/operations/ToolReport.js +233 -0
  128. package/dist/components/operations/WorkorderGantt.d.ts +1 -0
  129. package/dist/components/operations/WorkorderGantt.js +124 -0
  130. package/dist/components/quality/QualityMaterial.d.ts +2 -0
  131. package/dist/components/quality/QualityMaterial.js +169 -0
  132. package/dist/components/quality/QualityPaths.d.ts +1 -0
  133. package/dist/components/quality/QualityPaths.js +53 -0
  134. package/dist/components/quality/RecentFailedInspections.d.ts +1 -0
  135. package/dist/components/quality/RecentFailedInspections.js +123 -0
  136. package/dist/components/routes.d.ts +170 -0
  137. package/dist/components/routes.js +301 -0
  138. package/dist/components/station-monitor/BulkRawMaterial.d.ts +11 -0
  139. package/dist/components/station-monitor/BulkRawMaterial.js +251 -0
  140. package/dist/components/station-monitor/Closeout.d.ts +5 -0
  141. package/dist/components/station-monitor/Closeout.js +162 -0
  142. package/dist/components/station-monitor/CustomStationMonitorDialog.d.ts +1 -0
  143. package/dist/components/station-monitor/CustomStationMonitorDialog.js +55 -0
  144. package/dist/components/station-monitor/Inspection.d.ts +8 -0
  145. package/dist/components/station-monitor/Inspection.js +164 -0
  146. package/dist/components/station-monitor/InvalidateCycle.d.ts +33 -0
  147. package/dist/components/station-monitor/InvalidateCycle.js +262 -0
  148. package/dist/components/station-monitor/JobDetails.d.ts +7 -0
  149. package/dist/components/station-monitor/JobDetails.js +108 -0
  150. package/dist/components/station-monitor/LoadStation.d.ts +10 -0
  151. package/dist/components/station-monitor/LoadStation.js +450 -0
  152. package/dist/components/station-monitor/Material.d.ts +77 -0
  153. package/dist/components/station-monitor/Material.js +489 -0
  154. package/dist/components/station-monitor/MoveMaterialArrows.d.ts +11 -0
  155. package/dist/components/station-monitor/MoveMaterialArrows.js +118 -0
  156. package/dist/components/station-monitor/PrintedLabel.d.ts +29 -0
  157. package/dist/components/station-monitor/PrintedLabel.js +166 -0
  158. package/dist/components/station-monitor/QuarantineButton.d.ts +4 -0
  159. package/dist/components/station-monitor/QuarantineButton.js +184 -0
  160. package/dist/components/station-monitor/Queues.d.ts +23 -0
  161. package/dist/components/station-monitor/Queues.js +312 -0
  162. package/dist/components/station-monitor/QueuesAddMaterial.d.ts +30 -0
  163. package/dist/components/station-monitor/QueuesAddMaterial.js +248 -0
  164. package/dist/components/station-monitor/SelectInspType.d.ts +2 -0
  165. package/dist/components/station-monitor/SelectInspType.js +99 -0
  166. package/dist/components/station-monitor/SelectWorkorder.d.ts +4 -0
  167. package/dist/components/station-monitor/SelectWorkorder.js +100 -0
  168. package/dist/components/station-monitor/StationToolbar.d.ts +3 -0
  169. package/dist/components/station-monitor/StationToolbar.js +168 -0
  170. package/dist/components/station-monitor/SystemOverview.d.ts +46 -0
  171. package/dist/components/station-monitor/SystemOverview.js +439 -0
  172. package/dist/components/station-monitor/Whiteboard.d.ts +10 -0
  173. package/dist/components/station-monitor/Whiteboard.js +67 -0
  174. package/dist/data/all-material-bins.d.ts +45 -0
  175. package/dist/data/all-material-bins.js +224 -0
  176. package/dist/data/chart-times.d.ts +20 -0
  177. package/dist/data/chart-times.js +99 -0
  178. package/dist/data/cost-per-piece.d.ts +32 -0
  179. package/dist/data/cost-per-piece.js +183 -0
  180. package/dist/data/current-cycles.d.ts +13 -0
  181. package/dist/data/current-cycles.js +144 -0
  182. package/dist/data/inspection-sankey.d.ts +15 -0
  183. package/dist/data/inspection-sankey.js +147 -0
  184. package/dist/data/move-arrows.d.ts +48 -0
  185. package/dist/data/move-arrows.js +217 -0
  186. package/dist/data/operators.d.ts +2 -0
  187. package/dist/data/operators.js +44 -0
  188. package/dist/data/part-summary.d.ts +17 -0
  189. package/dist/data/part-summary.js +107 -0
  190. package/dist/data/path-lookup.d.ts +13 -0
  191. package/dist/data/path-lookup.js +107 -0
  192. package/dist/data/queue-material.d.ts +46 -0
  193. package/dist/data/queue-material.js +256 -0
  194. package/dist/data/results.bufferchart.d.ts +10 -0
  195. package/dist/data/results.bufferchart.js +90 -0
  196. package/dist/data/results.completed-parts.d.ts +26 -0
  197. package/dist/data/results.completed-parts.js +181 -0
  198. package/dist/data/results.cycles.d.ts +86 -0
  199. package/dist/data/results.cycles.js +454 -0
  200. package/dist/data/results.inspection.d.ts +36 -0
  201. package/dist/data/results.inspection.js +188 -0
  202. package/dist/data/results.oee.d.ts +40 -0
  203. package/dist/data/results.oee.js +330 -0
  204. package/dist/data/results.schedules.d.ts +23 -0
  205. package/dist/data/results.schedules.js +157 -0
  206. package/dist/data/tools-programs.d.ts +78 -0
  207. package/dist/data/tools-programs.js +376 -0
  208. package/dist/index.d.ts +1 -0
  209. package/dist/index.js +60 -0
  210. package/dist/network/api.d.ts +1390 -0
  211. package/dist/network/api.js +4971 -0
  212. package/dist/network/backend-mock.d.ts +11 -0
  213. package/dist/network/backend-mock.js +512 -0
  214. package/dist/network/backend.d.ts +57 -0
  215. package/dist/network/backend.js +77 -0
  216. package/dist/network/load-specific-month.d.ts +13 -0
  217. package/dist/network/load-specific-month.js +77 -0
  218. package/dist/network/server-settings.d.ts +12 -0
  219. package/dist/network/server-settings.js +92 -0
  220. package/dist/network/websocket.d.ts +4 -0
  221. package/dist/network/websocket.js +165 -0
  222. package/dist/renderer.d.ts +8 -0
  223. package/dist/renderer.js +55 -0
  224. package/dist/seedtactics-logo.d.ts +2 -0
  225. package/dist/seedtactics-logo.js +4 -0
  226. package/dist/util/chart-colors.d.ts +1 -0
  227. package/dist/util/chart-colors.js +116 -0
  228. package/dist/util/chart-helpers.d.ts +3 -0
  229. package/dist/util/chart-helpers.js +51 -0
  230. package/dist/util/parseISODuration.d.ts +4 -0
  231. package/dist/util/parseISODuration.js +40 -0
  232. package/docs/client-efficiency.md +355 -0
  233. package/docs/client-engineering.md +54 -0
  234. package/docs/client-launch.md +55 -0
  235. package/docs/client-operations.md +88 -0
  236. package/docs/client-quality.md +74 -0
  237. package/docs/client-sales.md +61 -0
  238. package/docs/client-scanners.md +41 -0
  239. package/docs/client-station-monitor.md +149 -0
  240. package/docs/client-tools-programs.md +74 -0
  241. package/docs/improve-fms.md +141 -0
  242. package/docs/makino.md +40 -0
  243. package/docs/material-quarantine.md +82 -0
  244. package/docs/material-tracking.md +236 -0
  245. package/docs/mazak.md +115 -0
  246. package/docs/niigata.md +228 -0
  247. package/docs/operator-procedures.md +106 -0
  248. package/docs/part-instructions.md +63 -0
  249. package/docs/screenshots/insight-all-material.png +0 -0
  250. package/docs/screenshots/insight-analysis-pallets.png +0 -0
  251. package/docs/screenshots/insight-analysis-part-completed.png +0 -0
  252. package/docs/screenshots/insight-analysis-sankey.png +0 -0
  253. package/docs/screenshots/insight-analysis-station-oee.png +0 -0
  254. package/docs/screenshots/insight-buffer-occupancy.png +0 -0
  255. package/docs/screenshots/insight-choose-analysis-month.png +0 -0
  256. package/docs/screenshots/insight-closeout.png +0 -0
  257. package/docs/screenshots/insight-cost-percentages.png +0 -0
  258. package/docs/screenshots/insight-dashboard.png +0 -0
  259. package/docs/screenshots/insight-event-custom-view.jpg +0 -0
  260. package/docs/screenshots/insight-event-viewer.jpg +0 -0
  261. package/docs/screenshots/insight-inspection.png +0 -0
  262. package/docs/screenshots/insight-load-station-details.png +0 -0
  263. package/docs/screenshots/insight-load-station.png +0 -0
  264. package/docs/screenshots/insight-loadcycle-graph.png +0 -0
  265. package/docs/screenshots/insight-loadstation-small.jpg +0 -0
  266. package/docs/screenshots/insight-machinecycle-graph.png +0 -0
  267. package/docs/screenshots/insight-machinecycle-table.png +0 -0
  268. package/docs/screenshots/insight-machinecycles.png +0 -0
  269. package/docs/screenshots/insight-machinehours.png +0 -0
  270. package/docs/screenshots/insight-machineoutliers.png +0 -0
  271. package/docs/screenshots/insight-monthly-schedules.png +0 -0
  272. package/docs/screenshots/insight-operations-material.png +0 -0
  273. package/docs/screenshots/insight-operations-overview.png +0 -0
  274. package/docs/screenshots/insight-operations-reports.png +0 -0
  275. package/docs/screenshots/insight-part-cost.png +0 -0
  276. package/docs/screenshots/insight-program-report.png +0 -0
  277. package/docs/screenshots/insight-quality-material-details.png +0 -0
  278. package/docs/screenshots/insight-quality-material.png +0 -0
  279. package/docs/screenshots/insight-quality-quarantine.png +0 -0
  280. package/docs/screenshots/insight-quality-sankey.png +0 -0
  281. package/docs/screenshots/insight-quality-similar-paths.png +0 -0
  282. package/docs/screenshots/insight-queue-details.png +0 -0
  283. package/docs/screenshots/insight-queues-jobs-table.png +0 -0
  284. package/docs/screenshots/insight-queues.png +0 -0
  285. package/docs/screenshots/insight-sim-day-usage.png +0 -0
  286. package/docs/screenshots/insight-station-system-overview-buttons.png +0 -0
  287. package/docs/screenshots/insight-station-system-overview.png +0 -0
  288. package/docs/screenshots/insight-system-overview.png +0 -0
  289. package/docs/screenshots/insight-tool-replacements.png +0 -0
  290. package/docs/screenshots/insight-tool-report.png +0 -0
  291. package/docs/screenshots/insight-toolbar-btns.png +0 -0
  292. package/docs/screenshots/insight-workorder-gantt.png +0 -0
  293. package/docs/screenshots/insight-workorders.png +0 -0
  294. package/docs/security.md +131 -0
  295. package/docs/server-config.md +56 -0
  296. package/docs/server-errors.md +44 -0
  297. package/package.json +90 -0
  298. package/src/index.ts +65 -0
@@ -0,0 +1,376 @@
1
+ /* Copyright (c) 2022, John Lenz
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above
12
+ copyright notice, this list of conditions and the following
13
+ disclaimer in the documentation and/or other materials provided
14
+ with the distribution.
15
+
16
+ * Neither the name of John Lenz, Black Maple Software, SeedTactics,
17
+ nor the names of other contributors may be used to endorse or
18
+ promote products derived from this software without specific
19
+ prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+ import { ActionType, } from "../network/api.js";
34
+ import { durationToMinutes } from "../util/parseISODuration.js";
35
+ import { MachineBackend } from "../network/backend.js";
36
+ import { currentStatus } from "../cell-status/current-status.js";
37
+ import copy from "copy-to-clipboard";
38
+ import { last30ToolUse } from "../cell-status/tool-usage.js";
39
+ import { last30EstimatedCycleTimes, PartAndStationOperation, } from "../cell-status/estimated-cycle-times.js";
40
+ import { stat_name_and_num } from "../cell-status/station-cycles.js";
41
+ import { LazySeq, HashMap, hashValues, OrderedSet } from "@seedtactics/immutable-collections";
42
+ import { atom, useStore } from "jotai";
43
+ import { useCallback } from "react";
44
+ import { last30Jobs } from "../cell-status/scheduled-jobs.js";
45
+ function averageToolUse(usage, sort) {
46
+ return usage.mapValues((cycles) => {
47
+ const tools = LazySeq.of(cycles.recentCycles)
48
+ .flatMap((c) => c.tools)
49
+ .filter((c) => !c.toolChangedDuringMiddleOfCycle)
50
+ .groupBy((t) => t.toolName)
51
+ .map(([toolName, usageInCycles]) => ({
52
+ toolName: toolName,
53
+ cycleUsageMinutes: LazySeq.of(usageInCycles).sumBy((c) => c.cycleUsageMinutes) / usageInCycles.length,
54
+ cycleUsageCnt: LazySeq.of(usageInCycles).sumBy((c) => c.cycleUsageCnt) / usageInCycles.length,
55
+ toolChangedDuringMiddleOfCycle: false,
56
+ }))
57
+ .toMutableArray();
58
+ if (sort) {
59
+ tools.sort((a, b) => a.toolName.localeCompare(b.toolName));
60
+ }
61
+ return { tools };
62
+ });
63
+ }
64
+ class StationOperation {
65
+ constructor(statGroup, operation) {
66
+ this.statGroup = statGroup;
67
+ this.operation = operation;
68
+ }
69
+ compare(other) {
70
+ const c = this.statGroup.localeCompare(other.statGroup);
71
+ if (c !== 0)
72
+ return c;
73
+ return this.operation.localeCompare(other.operation);
74
+ }
75
+ hash() {
76
+ return hashValues(this.statGroup, this.operation);
77
+ }
78
+ toString() {
79
+ return `{statGroup: ${this.statGroup}, operation: ${this.operation}}`;
80
+ }
81
+ }
82
+ function estimateToolMinutesPerCount(parts, machineName) {
83
+ let use = 0;
84
+ let numParts = 0;
85
+ // weighted average of (u.scheduledUseMinutes / u.scheduledUseCnt) by quantity
86
+ for (const u of LazySeq.of(parts).filter((p) => p.machines.has(machineName) ?? false)) {
87
+ use += u.quantity * (u.scheduledUseMinutes / u.scheduledUseCnt);
88
+ numParts += u.quantity;
89
+ }
90
+ return numParts === 0 ? 0 : use / numParts;
91
+ }
92
+ export function calcToolReport(currentSt, toolsInMach, usage) {
93
+ let partPlannedQtys = HashMap.empty();
94
+ for (const [uniq, job] of LazySeq.ofObject(currentSt.jobs)) {
95
+ const planQty = job.cycles ?? 0;
96
+ for (let procIdx = 0; procIdx < job.procsAndPaths.length; procIdx++) {
97
+ let completed = 0;
98
+ let programsToAfterInProc = HashMap.empty();
99
+ for (let pathIdx = 0; pathIdx < job.procsAndPaths[procIdx].paths.length; pathIdx++) {
100
+ completed += job.completed?.[procIdx]?.[pathIdx] ?? 0;
101
+ const path = job.procsAndPaths[procIdx].paths[pathIdx];
102
+ for (let stopIdx = 0; stopIdx < path.stops.length; stopIdx += 1) {
103
+ const stop = path.stops[stopIdx];
104
+ const inProcAfter = LazySeq.of(currentSt.material)
105
+ .filter((m) => m.jobUnique === uniq &&
106
+ m.process == procIdx + 1 &&
107
+ m.path === pathIdx + 1 &&
108
+ (m.action.type === ActionType.UnloadToCompletedMaterial ||
109
+ m.action.type === ActionType.UnloadToInProcess ||
110
+ (m.lastCompletedMachiningRouteStopIndex !== undefined &&
111
+ m.lastCompletedMachiningRouteStopIndex > stopIdx)))
112
+ .length();
113
+ if (stop.program !== undefined && stop.program !== "") {
114
+ programsToAfterInProc = programsToAfterInProc.modify(new StationOperation(stop.stationGroup, stop.program), (old) => (old ?? 0) + inProcAfter);
115
+ }
116
+ }
117
+ }
118
+ for (const [op, afterInProc] of programsToAfterInProc) {
119
+ partPlannedQtys = partPlannedQtys.modify(new PartAndStationOperation(job.partName, op.statGroup, op.operation), (old) => (old ?? 0) + planQty - completed - afterInProc);
120
+ }
121
+ }
122
+ }
123
+ const parts = LazySeq.of(averageToolUse(usage, false))
124
+ .flatMap(([partAndProg, tools]) => {
125
+ const qty = window.bmsToolReportOverridePartQuantity ?? partPlannedQtys.get(partAndProg);
126
+ if (qty !== undefined && qty > 0) {
127
+ return tools.tools.map((tool) => {
128
+ return {
129
+ toolName: tool.toolName,
130
+ part: {
131
+ partAndProg,
132
+ quantity: qty,
133
+ scheduledUseMinutes: tool.cycleUsageMinutes,
134
+ // if no counts, just estimate as 1
135
+ scheduledUseCnt: tool.cycleUsageCnt === 0 ? 1 : tool.cycleUsageCnt,
136
+ machines: usage.get(partAndProg)?.machines ?? OrderedSet.empty(),
137
+ },
138
+ };
139
+ });
140
+ }
141
+ else {
142
+ return [];
143
+ }
144
+ })
145
+ .sortBy((p) => p.part.partAndProg.part, (p) => p.part.partAndProg.operation)
146
+ .toLookup((t) => t.toolName, (t) => t.part);
147
+ return LazySeq.of(toolsInMach)
148
+ .orderedGroupBy((t) => t.toolName)
149
+ .map(([toolName, tools]) => {
150
+ let estimatedToolCounts = false;
151
+ const toolsInMachine = LazySeq.of(tools)
152
+ .sortBy((t) => t.machineGroupName, (t) => t.machineNum, (t) => t.pocket)
153
+ .map((m) => {
154
+ const currentUseMinutes = m.currentUse !== null && m.currentUse !== undefined && m.currentUse !== ""
155
+ ? durationToMinutes(m.currentUse)
156
+ : null;
157
+ const lifetimeMinutes = m.totalLifeTime !== null && m.totalLifeTime !== undefined && m.totalLifeTime !== ""
158
+ ? durationToMinutes(m.totalLifeTime)
159
+ : null;
160
+ const machineName = stat_name_and_num(m.machineGroupName, m.machineNum);
161
+ let currentUseCnt = m.currentUseCount ?? null;
162
+ let lifetimeCnt = m.totalLifeCount ?? null;
163
+ if (currentUseCnt === null && lifetimeCnt === null) {
164
+ // If both are not defined, then estimate
165
+ const estUse = estimateToolMinutesPerCount(parts.get(toolName) ?? [], machineName);
166
+ if (estUse > 0) {
167
+ estimatedToolCounts = true;
168
+ // unit analysis: mins / (mins / cnt) = cnt
169
+ currentUseCnt = currentUseMinutes !== null ? currentUseMinutes / estUse : null;
170
+ lifetimeCnt = lifetimeMinutes !== null ? lifetimeMinutes / estUse : null;
171
+ }
172
+ }
173
+ return {
174
+ machineName,
175
+ pocket: m.pocket,
176
+ serial: m.serial,
177
+ currentUseMinutes,
178
+ lifetimeMinutes,
179
+ remainingMinutes: currentUseMinutes !== null && lifetimeMinutes !== null
180
+ ? Math.max(0, lifetimeMinutes - currentUseMinutes)
181
+ : null,
182
+ currentUseCnt: currentUseCnt ?? null,
183
+ lifetimeCnt: lifetimeCnt ?? null,
184
+ remainingCnt: currentUseCnt !== null && lifetimeCnt !== null
185
+ ? Math.max(0, lifetimeCnt - currentUseCnt)
186
+ : null,
187
+ };
188
+ })
189
+ .toRArray();
190
+ return {
191
+ toolName,
192
+ machines: toolsInMachine,
193
+ parts: parts.get(toolName) ?? [],
194
+ estimatedToolCounts,
195
+ };
196
+ })
197
+ .toRArray();
198
+ }
199
+ const toolsInMachine = atom(null);
200
+ export const toolReportRefreshTime = atom((get) => get(toolsInMachine)?.time ?? null, async (_, set, time) => {
201
+ set(toolsInMachine, {
202
+ tools: await MachineBackend.getToolsInMachines(),
203
+ time,
204
+ });
205
+ });
206
+ export const machinesWithTools = atom((get) => {
207
+ const toolsInMach = get(toolsInMachine);
208
+ if (toolsInMach === null)
209
+ return [];
210
+ const names = new Set();
211
+ for (const t of toolsInMach.tools) {
212
+ names.add(stat_name_and_num(t.machineGroupName, t.machineNum));
213
+ }
214
+ return Array.from(names).sort((a, b) => a.localeCompare(b));
215
+ });
216
+ export const currentToolReport = atom((get) => {
217
+ const toolsInMach = get(toolsInMachine);
218
+ if (toolsInMach === null)
219
+ return null;
220
+ const currentSt = get(currentStatus);
221
+ const usage = get(last30ToolUse);
222
+ return calcToolReport(currentSt, toolsInMach.tools, usage);
223
+ });
224
+ export const toolReportHasSerial = atom((get) => {
225
+ const report = get(currentToolReport);
226
+ if (!report)
227
+ return false;
228
+ return LazySeq.of(report)
229
+ .flatMap((r) => r.machines)
230
+ .some((t) => t.serial != null && t.serial !== "");
231
+ });
232
+ export const toolReportEstimatedToolCounts = atom((get) => {
233
+ const report = get(currentToolReport);
234
+ if (!report)
235
+ return false;
236
+ return LazySeq.of(report).some((r) => r.estimatedToolCounts);
237
+ });
238
+ function buildToolReportHTML(tools) {
239
+ const showTime = LazySeq.of(tools)
240
+ .flatMap((r) => r.machines)
241
+ .some((t) => t.currentUseMinutes != null);
242
+ const showCnts = LazySeq.of(tools)
243
+ .flatMap((r) => r.machines)
244
+ .some((t) => t.currentUseCnt != null);
245
+ let table = "<table>\n<thead><tr>";
246
+ table += "<th>Tool</th><th>Machine</th><th>Pocket</th>";
247
+ if (showTime) {
248
+ table +=
249
+ "<th>Scheduled Use (min)</th><th>Current Use (min)</th><th>Lifetime (min)</th><th>Remaining Life (min)</th>";
250
+ }
251
+ if (showCnts) {
252
+ table +=
253
+ "<th>Scheduled Use (cnt)</th><th>Current Use (cnt)</th><th>Lifetime (cnt)</th><th>Remaining Life (cnt)</th>";
254
+ }
255
+ table += "</tr></thead>\n<tbody>\n";
256
+ for (const tool of tools) {
257
+ for (const mach of tool.machines) {
258
+ table += `<tr><td>${tool.toolName}</td><td>${mach.machineName}</td><td>${mach.pocket}</td>`;
259
+ if (showTime) {
260
+ const schUse = LazySeq.of(tool.parts).sumBy((p) => p.scheduledUseMinutes * p.quantity);
261
+ table += "<td>" + schUse.toFixed(1) + "</td>";
262
+ table += "<td>" + (mach.currentUseMinutes ? mach.currentUseMinutes.toFixed(1) : "") + "</td>";
263
+ table += "<td>" + (mach.lifetimeMinutes ? mach.lifetimeMinutes.toFixed(1) : "") + "</td>";
264
+ table += "<td>" + (mach.remainingMinutes ? mach.remainingMinutes.toFixed(1) : "") + "</td>";
265
+ }
266
+ if (showCnts) {
267
+ const schUse = LazySeq.of(tool.parts).sumBy((p) => p.scheduledUseCnt * p.quantity);
268
+ table += "<td>" + schUse.toFixed(1) + "</td>";
269
+ table += "<td>" + (mach.currentUseCnt ? mach.currentUseCnt.toFixed(1) : "") + "</td>";
270
+ table += "<td>" + (mach.lifetimeCnt ? mach.lifetimeCnt.toFixed(1) : "") + "</td>";
271
+ table += "<td>" + (mach.remainingCnt ? mach.remainingCnt.toFixed(1) : "") + "</td>";
272
+ }
273
+ table += "</tr>\n";
274
+ }
275
+ }
276
+ table += "</tbody></table>";
277
+ return table;
278
+ }
279
+ export function useCopyToolReportToClipboard() {
280
+ const store = useStore();
281
+ return useCallback(() => {
282
+ const tools = store.get(currentToolReport);
283
+ if (!tools)
284
+ return;
285
+ copy(buildToolReportHTML(tools));
286
+ }, [store]);
287
+ }
288
+ export function calcProgramReport(usage, cycleTimes, jobs, progsInCellCtrl, progsToShow) {
289
+ const tools = averageToolUse(usage, true);
290
+ const progToPart = usage.keysToLazySeq().toRMap((op) => [op.operation, op], (_, x) => x);
291
+ let allPrograms = LazySeq.of(progsInCellCtrl);
292
+ if (progsToShow != null) {
293
+ allPrograms = allPrograms.filter((p) => progsToShow.has(p.programName));
294
+ }
295
+ const plannedTimes = jobs
296
+ ?.valuesToLazySeq()
297
+ .flatMap((j) => LazySeq.of(j.procsAndPaths)
298
+ .flatMap((p) => p.paths)
299
+ .flatMap((path) => LazySeq.of(path.stops).collect((stop) => {
300
+ const mins = durationToMinutes(stop.expectedCycleTime);
301
+ if (stop.program && mins > 0) {
302
+ return {
303
+ program: stop.program,
304
+ plannedMins: mins / path.partsPerPallet,
305
+ start: j.routeStartUTC,
306
+ };
307
+ }
308
+ else {
309
+ return null;
310
+ }
311
+ })))
312
+ .toOrderedMap((p) => [p.program, p], (v1, v2) => (v1.start > v2.start ? v1 : v2));
313
+ const programs = allPrograms
314
+ .map((prog) => {
315
+ const part = progToPart.get(prog.programName);
316
+ return {
317
+ programName: prog.programName,
318
+ cellControllerProgramName: prog.cellControllerProgramName,
319
+ comment: prog.comment ?? null,
320
+ revision: prog.revision ?? null,
321
+ partName: part?.part ?? null,
322
+ statisticalCycleTime: part ? (cycleTimes.get(part) ?? null) : null,
323
+ toolUse: part ? (tools.get(part) ?? null) : null,
324
+ plannedMins: plannedTimes?.get(prog.programName)?.plannedMins ?? null,
325
+ };
326
+ })
327
+ .toRArray();
328
+ return {
329
+ time: new Date(),
330
+ programs,
331
+ hasRevisions: programs.some((p) => p.revision !== null),
332
+ cellNameDifferentFromProgName: programs.some((p) => p.cellControllerProgramName !== p.programName),
333
+ };
334
+ }
335
+ export const programFilter = atom("AllPrograms");
336
+ const programsInCellCtrl = atom(null);
337
+ export const programReportRefreshTime = atom((get) => get(programsInCellCtrl)?.time ?? null, async (_, set, time) => {
338
+ set(programsInCellCtrl, {
339
+ progs: await MachineBackend.getProgramsInCellController(),
340
+ time,
341
+ });
342
+ });
343
+ export const currentProgramReport = atom((get) => {
344
+ const time = get(programReportRefreshTime);
345
+ if (time === null)
346
+ return null;
347
+ const filter = get(programFilter);
348
+ let progsToShow = null;
349
+ if (filter === "ActivePrograms") {
350
+ const status = get(currentStatus);
351
+ progsToShow = new Set(LazySeq.ofObject(status.jobs)
352
+ .flatMap(([, job]) => job.procsAndPaths)
353
+ .flatMap((p) => p.paths)
354
+ .flatMap((p) => p.stops)
355
+ .filter((s) => s.program !== null && s.program !== undefined && s.program !== "")
356
+ .map((s) => s.program ?? ""));
357
+ }
358
+ const progsInCell = get(programsInCellCtrl);
359
+ if (progsInCell === null)
360
+ return null;
361
+ return calcProgramReport(get(last30ToolUse), get(last30EstimatedCycleTimes), get(last30Jobs), progsInCell.progs, progsToShow);
362
+ });
363
+ export const programToShowContent = atom(null);
364
+ export const programContent = atom(async (get) => {
365
+ const prog = get(programToShowContent);
366
+ if (prog === null) {
367
+ return "";
368
+ }
369
+ else if (prog.revision === null) {
370
+ return await MachineBackend.getLatestProgramRevisionContent(prog.programName);
371
+ }
372
+ else {
373
+ return await MachineBackend.getProgramRevisionContent(prog.programName, prog.revision);
374
+ }
375
+ });
376
+ export const programToShowHistory = atom(null);
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
1
+ /* Copyright (c) 2019, John Lenz
2
+
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ * Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above
12
+ copyright notice, this list of conditions and the following
13
+ disclaimer in the documentation and/or other materials provided
14
+ with the distribution.
15
+
16
+ * Neither the name of John Lenz, Black Maple Software, SeedTactics,
17
+ nor the names of other contributors may be used to endorse or
18
+ promote products derived from this software without specific
19
+ prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+ import { render } from "./renderer.js";
34
+ import { registerNetworkBackend } from "./network/backend.js";
35
+ import { fmsInformation, loadInfo } from "./network/server-settings.js";
36
+ import { ApiException } from "./network/api.js";
37
+ import { createStore } from "jotai";
38
+ async function main() {
39
+ registerNetworkBackend();
40
+ const store = createStore();
41
+ store.set(fmsInformation, await loadInfo());
42
+ render(null, document.getElementById("root"), store);
43
+ }
44
+ main().catch((e) => {
45
+ console.log(e);
46
+ let msg = "Error loading Insight";
47
+ if (e instanceof ApiException) {
48
+ msg = "Error loading Insight: " + e.message + " " + e.response;
49
+ }
50
+ const p = document.createElement("p");
51
+ p.textContent = msg;
52
+ (document.getElementById("loading") ?? document.body).appendChild(p);
53
+ });
54
+ if ("serviceWorker" in navigator) {
55
+ void navigator.serviceWorker.getRegistrations().then((registrations) => {
56
+ for (const reg of registrations) {
57
+ void reg.unregister();
58
+ }
59
+ });
60
+ }