Consolidate PC machinetypeid: all PCs use 33, pctypeid determines type

- Simplified GetMachineTypeIdFromPCType() to always return 33 (PC)
- PC type differentiation now handled entirely by pctypeid
- Updated savedevice.asp: 28 -> 33
- Updated savedevice_direct.asp: 36 -> 33, added pctypeid
- Removed redundant machinetypeid mapping logic (36-43)
- All 317 existing PCs already use machinetypeid=33

Schema simplified:
  machinetypeid=33 (PC) + pctypeid determines specific type
  pctypeid: 1=Standard, 2=Engineer, 3=Shopfloor, 5=CMM, etc.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-09 07:53:27 -05:00
parent adeff46d80
commit 53fd7e2214
3 changed files with 17 additions and 49 deletions

53
api.asp
View File

@@ -833,20 +833,19 @@ Function InsertOrUpdatePC(conn, hostname, serialnumber, manufacturer, model, pcT
Dim pctypeId
pctypeId = GetPCTypeIdFromPCType(pcType)
' Override types based on machinenumber pattern
' WJPRT* = Wax Trace PC (machinetypeid 42, pctypeid 6)
' Override pctypeid based on machinenumber pattern
' WJPRT* = Wax Trace PC (pctypeid 6)
If machinenumber <> "" Then
If UCase(Left(machinenumber, 5)) = "WJPRT" Then
machineTypeId = 42 ' PC - Wax Trace
pctypeId = 6 ' Wax / Trace
LogToFile "Detected WJPRT pattern in machinenumber, setting machineTypeId to 42, pctypeid to 6"
LogToFile "Detected WJPRT pattern in machinenumber, setting pctypeid to 6 (Wax/Trace)"
End If
End If
' Ensure all IDs are numeric (fallback to safe defaults if empty)
If Not IsNumeric(vendorId) Or vendorId = "" Then vendorId = 0
If Not IsNumeric(modelId) Or modelId = "" Then modelId = 1 ' TBD model
If Not IsNumeric(machineTypeId) Or machineTypeId = "" Then machineTypeId = 36 ' PC - Standard
If Not IsNumeric(machineTypeId) Or machineTypeId = "" Then machineTypeId = 33 ' PC
If Not IsNumeric(pctypeId) Or pctypeId = "" Then pctypeId = 1 ' Standard
LogToFile "Vendor ID: " & vendorId & ", Model ID: " & modelId & ", Machine Type ID: " & machineTypeId & ", PC Type ID: " & pctypeId
@@ -1627,8 +1626,9 @@ End Function
' ============================================================================
' LEGACY FUNCTION REMOVED: GetOrCreatePCType
' This function was replaced by GetMachineTypeIdFromPCType which maps
' PC type strings directly to machinetypeid (33=Standard, 34=Engineer, 35=Shopfloor)
' All PCs now use machinetypeid=33, with pctypeid determining the specific type
' GetMachineTypeIdFromPCType returns 33 for all PCs
' GetPCTypeIdFromPCType maps pcType string to pctypeid (1=Standard, 2=Engineer, etc.)
' Removed: 2025-11-17 during Phase 2 migration from pc/pctype to machines/machinetypes
' ============================================================================
@@ -1853,41 +1853,10 @@ Function GetOrCreateAppVersion(conn, appId, appVersion)
End Function
Function GetMachineTypeIdFromPCType(pcTypeString)
On Error Resume Next
' Direct mapping from pcType parameter to machinetypeid (Phase 2 schema)
' Phase 2 PC Machine Types:
' 36=PC - Standard, 37=PC - Shopfloor, 38=PC - Engineer
' 41=PC - CMM, 42=PC - Wax Trace, 43=PC - Measuring Tool
Dim pcTypeClean
pcTypeClean = Trim(UCase(pcTypeString))
Select Case pcTypeClean
Case "ENGINEER", "ENGINEERING"
GetMachineTypeIdFromPCType = 38 ' PC - Engineer
Case "SHOPFLOOR", "SHOP FLOOR"
GetMachineTypeIdFromPCType = 37 ' PC - Shopfloor
Case "CMM"
GetMachineTypeIdFromPCType = 41 ' PC - CMM (runs PC-DMIS, goCMM, DODA)
Case "WAX TRACE", "WAXTRACE", "WAX"
GetMachineTypeIdFromPCType = 42 ' PC - Wax Trace (runs Formtracepak, FormStatusMonitor)
Case "KEYENCE"
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool - Keyence (runs Keyence VR Series)
Case "EAS1000", "GENSPECT"
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool - EAS1000/Genspect (runs GageCal, NI Software)
Case "PART MARKER", "PARTMARKER"
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool - Part Marker (0615 machines)
Case "MEASURING", "MEASURING TOOL"
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool (generic)
Case "STANDARD", ""
GetMachineTypeIdFromPCType = 36 ' PC - Standard
Case Else
LogToFile "Unknown pcType '" & pcTypeString & "', defaulting to PC - Standard (36)"
GetMachineTypeIdFromPCType = 36 ' Default to PC - Standard
End Select
LogToFile "Mapped pcType '" & pcTypeString & "' to machinetypeid: " & GetMachineTypeIdFromPCType
' All PCs use machinetypeid = 33 (PC)
' The specific PC type is determined by pctypeid, not machinetypeid
GetMachineTypeIdFromPCType = 33
LogToFile "All PCs use machinetypeid 33, pcType '" & pcTypeString & "' -> pctypeid handles type"
End Function
Function GetPCTypeIdFromPCType(pcTypeString)