@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,312 @@
1
+ /* Copyright (c) 2021, 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 { LogType } from "../network/api.js";
34
+ import { addDays } from "date-fns";
35
+ import { HashMap, LazySeq, HashSet } from "@seedtactics/immutable-collections";
36
+ import { atom } from "jotai";
37
+ const last30MaterialSummaryRW = atom({
38
+ matsById: HashMap.empty(),
39
+ matIdsForJob: HashMap.empty(),
40
+ });
41
+ export const last30MaterialSummary = last30MaterialSummaryRW;
42
+ const specificMonthMaterialSummaryRW = atom({
43
+ matsById: HashMap.empty(),
44
+ matIdsForJob: HashMap.empty(),
45
+ });
46
+ export const specificMonthMaterialSummary = specificMonthMaterialSummaryRW;
47
+ export function inproc_mat_to_summary(mat) {
48
+ return {
49
+ materialID: mat.materialID,
50
+ jobUnique: mat.jobUnique,
51
+ partName: mat.partName,
52
+ startedProcess1: mat.process > 0,
53
+ serial: mat.serial,
54
+ workorderId: mat.workorderId,
55
+ signaledInspections: mat.signaledInspections,
56
+ quarantineAfterUnload: mat.quarantineAfterUnload,
57
+ };
58
+ }
59
+ function process_event(st, e) {
60
+ let mats = st.matsById;
61
+ let jobs = st.matIdsForJob;
62
+ if (e.startofcycle || e.material.length === 0) {
63
+ return st;
64
+ }
65
+ for (const logMat of e.material) {
66
+ if (logMat.uniq && logMat.uniq !== "") {
67
+ const forJob = jobs.get(logMat.uniq);
68
+ if (forJob === undefined) {
69
+ jobs = jobs.set(logMat.uniq, HashSet.empty().add(logMat.id));
70
+ }
71
+ else {
72
+ if (!forJob.has(logMat.id)) {
73
+ jobs = jobs.set(logMat.uniq, forJob.add(logMat.id));
74
+ }
75
+ }
76
+ }
77
+ const oldMat = mats.get(logMat.id);
78
+ let mat;
79
+ if (oldMat !== undefined) {
80
+ mat = { ...oldMat, last_event: e.endUTC };
81
+ }
82
+ else {
83
+ mat = {
84
+ materialID: logMat.id,
85
+ jobUnique: logMat.uniq,
86
+ partName: logMat.part,
87
+ last_event: e.endUTC,
88
+ startedProcess1: false,
89
+ numProcesses: logMat.numproc,
90
+ unloaded_processes: {},
91
+ signaledInspections: [],
92
+ quarantineAfterUnload: null,
93
+ completedInspections: {},
94
+ };
95
+ }
96
+ switch (e.type) {
97
+ case LogType.PartMark:
98
+ mat = { ...mat, serial: e.result };
99
+ break;
100
+ case LogType.OrderAssignment:
101
+ mat = { ...mat, workorderId: e.result };
102
+ break;
103
+ case LogType.Inspection:
104
+ if (e.result.toLowerCase() === "true" || e.result === "1") {
105
+ const inspType = (e.details || {}).InspectionType;
106
+ if (inspType) {
107
+ mat = {
108
+ ...mat,
109
+ signaledInspections: [...mat.signaledInspections, inspType],
110
+ };
111
+ }
112
+ }
113
+ break;
114
+ case LogType.InspectionForce:
115
+ if (e.result.toLowerCase() === "true" || e.result === "1") {
116
+ const inspType = e.program;
117
+ mat = {
118
+ ...mat,
119
+ signaledInspections: [...mat.signaledInspections, inspType],
120
+ };
121
+ }
122
+ break;
123
+ case LogType.InspectionResult: {
124
+ const success = e.result.toLowerCase() == "true" || e.result === "1";
125
+ mat = {
126
+ ...mat,
127
+ completedInspections: {
128
+ ...mat.completedInspections,
129
+ [e.program]: { time: e.endUTC, success },
130
+ },
131
+ completed_inspect_time: e.endUTC,
132
+ };
133
+ break;
134
+ }
135
+ case LogType.LoadUnloadCycle:
136
+ if (e.result === "UNLOAD") {
137
+ mat = {
138
+ ...mat,
139
+ unloaded_processes: { ...mat.unloaded_processes, [logMat.proc]: e.endUTC },
140
+ quarantineAfterUnload: false,
141
+ currently_quarantined: false, // a load cycle disables quarantine
142
+ };
143
+ if (logMat.proc === logMat.numproc) {
144
+ mat = {
145
+ ...mat,
146
+ last_unload_time: e.endUTC,
147
+ completed_last_proc_machining: true,
148
+ };
149
+ }
150
+ else {
151
+ mat = {
152
+ ...mat,
153
+ last_unload_time: e.endUTC,
154
+ };
155
+ }
156
+ }
157
+ else if (e.result === "LOAD") {
158
+ mat = {
159
+ ...mat,
160
+ startedProcess1: true,
161
+ quarantineAfterUnload: false,
162
+ currently_quarantined: false, // a load cycle disables quarantine
163
+ };
164
+ }
165
+ break;
166
+ case LogType.MachineCycle:
167
+ // a machine cycle disables quarantine
168
+ if (mat.currently_quarantined) {
169
+ mat = { ...mat, currently_quarantined: false };
170
+ }
171
+ break;
172
+ case LogType.AddToQueue:
173
+ if (e.program === "Quarantine") {
174
+ mat = { ...mat, currently_quarantined: true };
175
+ }
176
+ break;
177
+ case LogType.CloseOut:
178
+ mat = { ...mat, closeout_completed: e.endUTC, closeout_failed: e.result === "Failed" };
179
+ break;
180
+ case LogType.SignalQuarantine:
181
+ mat = { ...mat, quarantineAfterUnload: true };
182
+ }
183
+ mats = mats.set(logMat.id, mat);
184
+ }
185
+ return { matsById: mats, matIdsForJob: jobs };
186
+ }
187
+ function filter_old(expire, { matIdsForJob, matsById }) {
188
+ const matsToRemove = matsById
189
+ .valuesToLazySeq()
190
+ .filter((e) => e.last_event < expire)
191
+ .toRSet((e) => e.materialID);
192
+ if (matsToRemove.size > 0) {
193
+ matIdsForJob = matIdsForJob.collectValues((ids) => {
194
+ const newIds = LazySeq.of(matsToRemove).fold(ids, (i, c) => i.delete(c));
195
+ if (newIds.size > 0) {
196
+ return newIds;
197
+ }
198
+ else {
199
+ return null;
200
+ }
201
+ });
202
+ }
203
+ matsById = matsById.filter((e) => e.last_event >= expire);
204
+ return { matIdsForJob, matsById };
205
+ }
206
+ function process_swap(swap, st) {
207
+ let jobs = st.matIdsForJob;
208
+ const oldMatFromState = st.matsById.get(swap.oldMaterialID) ?? null;
209
+ const newMatFromState = st.matsById.get(swap.newMaterialID) ?? null;
210
+ if (oldMatFromState === null)
211
+ return st;
212
+ let oldMat = oldMatFromState;
213
+ let newMat;
214
+ if (newMatFromState === null) {
215
+ newMat = {
216
+ materialID: swap.newMaterialID,
217
+ jobUnique: oldMat.jobUnique,
218
+ partName: oldMat.partName,
219
+ last_event: oldMat.last_event,
220
+ numProcesses: oldMat.numProcesses,
221
+ startedProcess1: true,
222
+ unloaded_processes: {},
223
+ signaledInspections: [],
224
+ quarantineAfterUnload: null,
225
+ completedInspections: {},
226
+ };
227
+ }
228
+ else {
229
+ newMat = newMatFromState;
230
+ }
231
+ if (oldMat.jobUnique && oldMat.jobUnique !== "" && (!newMat.jobUnique || newMat.jobUnique === "")) {
232
+ // Swap newMat from raw material
233
+ const forJob = jobs.get(oldMat.jobUnique);
234
+ if (forJob !== undefined) {
235
+ jobs = jobs.set(oldMat.jobUnique, forJob.delete(oldMat.materialID).add(newMat.materialID));
236
+ }
237
+ newMat = { ...newMat, jobUnique: oldMat.jobUnique };
238
+ oldMat = { ...oldMat, jobUnique: "" };
239
+ }
240
+ const oldMatUnloads = oldMat.unloaded_processes;
241
+ oldMat = { ...oldMat, unloaded_processes: newMat.unloaded_processes };
242
+ newMat = { ...newMat, unloaded_processes: oldMatUnloads };
243
+ for (const evt of swap.editedEvents) {
244
+ const newMatFromEvt = evt.material.find((m) => m.id === swap.newMaterialID);
245
+ if (newMatFromEvt) {
246
+ newMat = {
247
+ ...newMat,
248
+ serial: newMatFromEvt.serial ?? newMat.serial,
249
+ workorderId: newMatFromEvt.workorder ?? newMat.workorderId,
250
+ };
251
+ }
252
+ switch (evt.type) {
253
+ case LogType.Inspection:
254
+ case LogType.InspectionForce: {
255
+ const inspType = evt.program;
256
+ let inspect;
257
+ if (evt.result.toLowerCase() === "true" || evt.result === "1") {
258
+ inspect = true;
259
+ }
260
+ else {
261
+ inspect = false;
262
+ }
263
+ if (inspect) {
264
+ // remove from oldMat, add to newMat
265
+ oldMat = {
266
+ ...oldMat,
267
+ signaledInspections: LazySeq.of(oldMat.signaledInspections)
268
+ .filter((i) => i !== inspType)
269
+ .toRArray(),
270
+ };
271
+ newMat = {
272
+ ...newMat,
273
+ signaledInspections: LazySeq.of([...newMat.signaledInspections, inspType])
274
+ .distinct()
275
+ .toSortedArray((x) => x),
276
+ };
277
+ }
278
+ }
279
+ }
280
+ }
281
+ return {
282
+ matsById: st.matsById.set(oldMat.materialID, oldMat).set(newMat.materialID, newMat),
283
+ matIdsForJob: jobs,
284
+ };
285
+ }
286
+ export const setLast30MatSummary = atom(null, (_, set, log) => {
287
+ set(last30MaterialSummaryRW, (st) => log.reduce(process_event, st));
288
+ });
289
+ export const updateLast30MatSummary = atom(null, (_, set, { evt, now, expire }) => {
290
+ if (evt.logEntry) {
291
+ const log = evt.logEntry;
292
+ set(last30MaterialSummaryRW, (st) => {
293
+ const newSt = process_event(st, log);
294
+ if (newSt === st || !expire) {
295
+ return st;
296
+ }
297
+ else {
298
+ return filter_old(addDays(now, -30), newSt);
299
+ }
300
+ });
301
+ }
302
+ else if (evt.editMaterialInLog) {
303
+ const edit = evt.editMaterialInLog;
304
+ set(last30MaterialSummaryRW, (st) => process_swap(edit, st));
305
+ }
306
+ });
307
+ export const setSpecificMonthMatSummary = atom(null, (_, set, log) => {
308
+ set(specificMonthMaterialSummaryRW, log.reduce(process_event, {
309
+ matsById: HashMap.empty(),
310
+ matIdsForJob: HashMap.empty(),
311
+ }));
312
+ });
@@ -0,0 +1,19 @@
1
+ import { Atom } from "jotai";
2
+ import { ICurrentStatus, IHistoricData, ILogEntry } from "../network/api.js";
3
+ import type { ServerEventAndTime } from "./loading.js";
4
+ export declare const rawMaterialQueues: Atom<ReadonlySet<string>>;
5
+ export declare const inProcessQueues: Atom<ReadonlySet<string>>;
6
+ export declare const castingNames: Atom<ReadonlySet<string>>;
7
+ export declare const last30InspectionTypes: Atom<ReadonlySet<string>>;
8
+ export declare const updateNames: import("jotai").WritableAtom<null, [ServerEventAndTime], void> & {
9
+ init: null;
10
+ };
11
+ export declare const setNamesFromLast30Jobs: import("jotai").WritableAtom<null, [history: Readonly<IHistoricData>], void> & {
12
+ init: null;
13
+ };
14
+ export declare const setNamesFromLast30Evts: import("jotai").WritableAtom<null, [logs: readonly Readonly<ILogEntry>[]], void> & {
15
+ init: null;
16
+ };
17
+ export declare const setNamesFromCurrentStatus: import("jotai").WritableAtom<null, [st: Readonly<ICurrentStatus>], void> & {
18
+ init: null;
19
+ };
@@ -0,0 +1,134 @@
1
+ /* Copyright (c) 2021, 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 { atom } from "jotai";
34
+ import { LogType, QueueRole } from "../network/api.js";
35
+ import { LazySeq } from "@seedtactics/immutable-collections";
36
+ const rawMaterialQueuesRW = atom(new Set());
37
+ export const rawMaterialQueues = rawMaterialQueuesRW;
38
+ const inProcQueuesRW = atom(new Set());
39
+ export const inProcessQueues = inProcQueuesRW;
40
+ const castingNamesRW = atom(new Set());
41
+ export const castingNames = castingNamesRW;
42
+ const inspectionTypesRW = atom(new Set());
43
+ export const last30InspectionTypes = inspectionTypesRW;
44
+ export const updateNames = atom(null, (get, set, { evt }) => {
45
+ if (evt.newJobs) {
46
+ onNewJobs(set, evt.newJobs.jobs);
47
+ }
48
+ else if (evt.logEntry) {
49
+ onLog(set, [evt.logEntry]);
50
+ }
51
+ else if (evt.newCurrentStatus) {
52
+ onCurrentStatus(get, set, evt.newCurrentStatus);
53
+ }
54
+ });
55
+ export const setNamesFromLast30Jobs = atom(null, (_, set, history) => {
56
+ onNewJobs(set, Object.values(history.jobs));
57
+ });
58
+ export const setNamesFromLast30Evts = atom(null, (_, set, logs) => onLog(set, logs));
59
+ export const setNamesFromCurrentStatus = atom(null, onCurrentStatus);
60
+ function onNewJobs(set, newJobs) {
61
+ set(castingNamesRW, (names) => {
62
+ const newC = new Set();
63
+ for (const j of newJobs) {
64
+ for (const path of j.procsAndPaths[0].paths) {
65
+ if (path.casting && path.casting !== "" && !names.has(path.casting)) {
66
+ newC.add(path.casting);
67
+ }
68
+ }
69
+ }
70
+ if (newC.size === 0) {
71
+ return names;
72
+ }
73
+ else {
74
+ return new Set([...names, ...newC]);
75
+ }
76
+ });
77
+ }
78
+ function onCurrentStatus(get, set, st) {
79
+ onNewJobs(set, Object.values(st.jobs));
80
+ const rawMatQueues = get(rawMaterialQueuesRW);
81
+ const inProc = get(inProcQueuesRW);
82
+ const newRawQ = new Set();
83
+ const newInProcQ = new Set();
84
+ for (const [queue, info] of LazySeq.ofObject(st.queues)) {
85
+ if (info.role === QueueRole.RawMaterial) {
86
+ if (!rawMatQueues.has(queue)) {
87
+ newRawQ.add(queue);
88
+ }
89
+ }
90
+ else if (info.role === QueueRole.InProcessTransfer) {
91
+ if (!inProc.has(queue)) {
92
+ newInProcQ.add(queue);
93
+ }
94
+ }
95
+ }
96
+ if (newRawQ.size > 0) {
97
+ set(rawMaterialQueuesRW, new Set([...rawMatQueues, ...newRawQ]));
98
+ }
99
+ if (newInProcQ.size > 0) {
100
+ set(inProcQueuesRW, new Set([...inProc, ...newInProcQ]));
101
+ }
102
+ }
103
+ function onLog(set, evts) {
104
+ set(inspectionTypesRW, (inspTypes) => {
105
+ const newC = new Set();
106
+ for (const evt of evts) {
107
+ switch (evt.type) {
108
+ case LogType.Inspection:
109
+ {
110
+ const inspType = (evt.details || {}).InspectionType;
111
+ if (inspType && !inspTypes.has(inspType)) {
112
+ newC.add(inspType);
113
+ }
114
+ }
115
+ break;
116
+ case LogType.InspectionForce:
117
+ case LogType.InspectionResult:
118
+ {
119
+ const inspType = evt.program;
120
+ if (!inspTypes.has(inspType)) {
121
+ newC.add(inspType);
122
+ }
123
+ }
124
+ break;
125
+ }
126
+ }
127
+ if (newC.size === 0) {
128
+ return inspTypes;
129
+ }
130
+ else {
131
+ return new Set([...inspTypes, ...newC]);
132
+ }
133
+ });
134
+ }
@@ -0,0 +1,24 @@
1
+ import { ILogEntry, ILogMaterial } from "../network/api.js";
2
+ import { HashMap } from "@seedtactics/immutable-collections";
3
+ import type { ServerEventAndTime } from "./loading.js";
4
+ import { Atom } from "jotai";
5
+ export interface PalletCycleData {
6
+ readonly cntr: number;
7
+ readonly x: Date;
8
+ readonly y: number;
9
+ readonly active: number;
10
+ readonly mats: ReadonlyArray<Readonly<ILogMaterial>>;
11
+ }
12
+ export type PalletCyclesByCntr = HashMap<number, PalletCycleData>;
13
+ export type PalletCyclesByPallet = HashMap<number, PalletCyclesByCntr>;
14
+ export declare const last30PalletCycles: Atom<PalletCyclesByPallet>;
15
+ export declare const specificMonthPalletCycles: Atom<PalletCyclesByPallet>;
16
+ export declare const setLast30PalletCycles: import("jotai").WritableAtom<null, [log: readonly Readonly<ILogEntry>[]], void> & {
17
+ init: null;
18
+ };
19
+ export declare const updateLast30PalletCycles: import("jotai").WritableAtom<null, [ServerEventAndTime], void> & {
20
+ init: null;
21
+ };
22
+ export declare const setSpecificMonthPalletCycles: import("jotai").WritableAtom<null, [log: readonly Readonly<ILogEntry>[]], void> & {
23
+ init: null;
24
+ };
@@ -0,0 +1,78 @@
1
+ /* Copyright (c) 2021, 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 { addDays } from "date-fns";
34
+ import { LogType } from "../network/api.js";
35
+ import { LazySeq, HashMap } from "@seedtactics/immutable-collections";
36
+ import { durationToMinutes } from "../util/parseISODuration.js";
37
+ import { atom } from "jotai";
38
+ const last30PalletCyclesRW = atom(HashMap.empty());
39
+ export const last30PalletCycles = last30PalletCyclesRW;
40
+ const specificMonthPalletCyclesRW = atom(HashMap.empty());
41
+ export const specificMonthPalletCycles = specificMonthPalletCyclesRW;
42
+ function logToPalletCycle(c) {
43
+ return {
44
+ cntr: c.counter,
45
+ x: c.endUTC,
46
+ y: durationToMinutes(c.elapsed),
47
+ active: durationToMinutes(c.active),
48
+ mats: c.material,
49
+ };
50
+ }
51
+ export const setLast30PalletCycles = atom(null, (_, set, log) => {
52
+ set(last30PalletCyclesRW, (oldCycles) => oldCycles.union(LazySeq.of(log)
53
+ .filter((c) => !c.startofcycle && c.type === LogType.PalletCycle && c.pal !== 0)
54
+ .toLookupMap((c) => c.pal, (c) => c.counter, logToPalletCycle), (e1, e2) => e1.union(e2)));
55
+ });
56
+ export const updateLast30PalletCycles = atom(null, (_, set, { evt, now, expire }) => {
57
+ if (evt.logEntry &&
58
+ !evt.logEntry.startofcycle &&
59
+ evt.logEntry.type === LogType.PalletCycle &&
60
+ evt.logEntry.pal !== 0) {
61
+ const log = evt.logEntry;
62
+ set(last30PalletCyclesRW, (oldCycles) => {
63
+ if (expire) {
64
+ const thirtyDaysAgo = addDays(now, -30);
65
+ oldCycles = oldCycles.collectValues((es) => {
66
+ const newEs = es.filter((e) => e.x >= thirtyDaysAgo);
67
+ return newEs.size > 0 ? newEs : null;
68
+ });
69
+ }
70
+ return oldCycles.modify(log.pal, (old) => (old ?? HashMap.empty()).set(log.counter, logToPalletCycle(log)));
71
+ });
72
+ }
73
+ });
74
+ export const setSpecificMonthPalletCycles = atom(null, (_, set, log) => {
75
+ set(specificMonthPalletCyclesRW, LazySeq.of(log)
76
+ .filter((c) => !c.startofcycle && c.type === LogType.PalletCycle && c.pal !== 0)
77
+ .toLookupMap((c) => c.pal, (c) => c.counter, logToPalletCycle));
78
+ });
@@ -0,0 +1,30 @@
1
+ import { Atom } from "jotai";
2
+ import { ServerEventAndTime } from "./loading";
3
+ import { ILogEntry, IRebooking, IRecentHistoricData } from "../network/api";
4
+ import { OrderedMap } from "@seedtactics/immutable-collections";
5
+ export declare const last30Rebookings: Atom<OrderedMap<string, Readonly<IRebooking>>>;
6
+ export declare const canceledRebookings: Atom<OrderedMap<string, Date>>;
7
+ type ScheduledBooking = {
8
+ readonly scheduledTime: Date;
9
+ readonly jobUnique: string;
10
+ };
11
+ export declare const last30ScheduledBookings: Atom<OrderedMap<string, ScheduledBooking>>;
12
+ export declare const setLast30Rebookings: import("jotai").WritableAtom<null, [log: readonly Readonly<ILogEntry>[]], void> & {
13
+ init: null;
14
+ };
15
+ export declare const setLast30RebookingJobs: import("jotai").WritableAtom<null, [historic: Readonly<IRecentHistoricData>], void> & {
16
+ init: null;
17
+ };
18
+ export declare const updateLast30Rebookings: import("jotai").WritableAtom<null, [ServerEventAndTime], void> & {
19
+ init: null;
20
+ };
21
+ export declare function useCancelRebooking(): [(bookingId: string) => Promise<void>, boolean];
22
+ export type NewRebooking = {
23
+ readonly part: string;
24
+ readonly qty?: number;
25
+ readonly workorder?: string | null;
26
+ readonly priority?: number | null;
27
+ readonly notes?: string;
28
+ };
29
+ export declare function useNewRebooking(): [(n: NewRebooking) => Promise<void>, boolean];
30
+ export {};