<%@ Language=VBScript %> <% Option Explicit Response.Expires = -1 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", "private, no-cache, must-revalidate" '============================================================================= ' FILE: displayudc.asp ' PURPOSE: UDC (Universal Data Collector) Management Dashboard ' SECURITY: Parameterized queries, HTML encoding, input validation ' CREATED: 2025-12-12 '============================================================================= Dim theme, strSQL, rs, objConn %> UDC Dashboard - ShopDB <% theme = Request.Cookies("theme") If theme = "" Then theme = "bg-theme1" ' Get filter parameters Dim filterMachine, filterBadge, filterPart, filterStart, filterEnd, periodFilter, filterBU filterMachine = Trim(Request.QueryString("machine") & "") filterBadge = Trim(Request.QueryString("badge") & "") filterPart = Trim(Request.QueryString("part") & "") filterStart = Trim(Request.QueryString("startdate") & "") filterEnd = Trim(Request.QueryString("enddate") & "") periodFilter = Trim(Request.QueryString("period") & "") filterBU = Trim(Request.QueryString("bu") & "") ' Tab persistence Dim activeTab activeTab = Trim(Request.QueryString("tab") & "") If activeTab = "" Then activeTab = "dashboard" ' Shift-span filter for manual response times Dim excludeShiftSpan, shiftFilter excludeShiftSpan = (Request.QueryString("excludeshift") = "1") shiftFilter = "" If excludeShiftSpan Then shiftFilter = " AND mr.responseseconds < 1800" End If ' Default date range: last 30 days If filterStart = "" Then filterStart = Year(DateAdd("d", -30, Date())) & "-" & Right("0" & Month(DateAdd("d", -30, Date())), 2) & "-" & Right("0" & Day(DateAdd("d", -30, Date())), 2) If filterEnd = "" Then filterEnd = Year(Date()) & "-" & Right("0" & Month(Date()), 2) & "-" & Right("0" & Day(Date()), 2) ' Period shortcuts Dim periodLabel, tempDate If periodFilter = "today" Then filterStart = Year(Date()) & "-" & Right("0" & Month(Date()), 2) & "-" & Right("0" & Day(Date()), 2) filterEnd = filterStart periodLabel = "Today" ElseIf periodFilter = "yesterday" Then tempDate = DateAdd("d", -1, Date()) filterStart = Year(tempDate) & "-" & Right("0" & Month(tempDate), 2) & "-" & Right("0" & Day(tempDate), 2) filterEnd = filterStart periodLabel = "Yesterday" ElseIf periodFilter = "7days" Then tempDate = DateAdd("d", -6, Date()) filterStart = Year(tempDate) & "-" & Right("0" & Month(tempDate), 2) & "-" & Right("0" & Day(tempDate), 2) filterEnd = Year(Date()) & "-" & Right("0" & Month(Date()), 2) & "-" & Right("0" & Day(Date()), 2) periodLabel = "Last 7 Days" ElseIf periodFilter = "14days" Then tempDate = DateAdd("d", -13, Date()) filterStart = Year(tempDate) & "-" & Right("0" & Month(tempDate), 2) & "-" & Right("0" & Day(tempDate), 2) filterEnd = Year(Date()) & "-" & Right("0" & Month(Date()), 2) & "-" & Right("0" & Day(Date()), 2) periodLabel = "Last 14 Days" ElseIf periodFilter = "30days" Then tempDate = DateAdd("d", -29, Date()) filterStart = Year(tempDate) & "-" & Right("0" & Month(tempDate), 2) & "-" & Right("0" & Day(tempDate), 2) filterEnd = Year(Date()) & "-" & Right("0" & Month(Date()), 2) & "-" & Right("0" & Day(Date()), 2) periodLabel = "Last 30 Days" ElseIf periodFilter = "90days" Then tempDate = DateAdd("d", -89, Date()) filterStart = Year(tempDate) & "-" & Right("0" & Month(tempDate), 2) & "-" & Right("0" & Day(tempDate), 2) filterEnd = Year(Date()) & "-" & Right("0" & Month(Date()), 2) & "-" & Right("0" & Day(Date()), 2) periodLabel = "Last 90 Days" ElseIf periodFilter = "week" Then tempDate = DateAdd("d", -7, Date()) filterStart = Year(tempDate) & "-" & Right("0" & Month(tempDate), 2) & "-" & Right("0" & Day(tempDate), 2) filterEnd = Year(Date()) & "-" & Right("0" & Month(Date()), 2) & "-" & Right("0" & Day(Date()), 2) periodLabel = "This Week" ElseIf periodFilter = "month" Then tempDate = DateAdd("d", -30, Date()) filterStart = Year(tempDate) & "-" & Right("0" & Month(tempDate), 2) & "-" & Right("0" & Day(tempDate), 2) filterEnd = Year(Date()) & "-" & Right("0" & Month(Date()), 2) & "-" & Right("0" & Day(Date()), 2) periodLabel = "This Month" Else periodLabel = "Custom Range" End If %>
Link Copied! This link will show the search term and highlight the result
UDC Performance Dashboard
>
Clear
<% ' Build WHERE clause for filters Dim whereClause whereClause = " WHERE p.programstart >= '" & Replace(filterStart, "'", "''") & "' " & _ " AND p.programstart <= '" & Replace(filterEnd, "'", "''") & " 23:59:59'" If filterMachine <> "" Then whereClause = whereClause & " AND s.machinenumber = '" & Replace(filterMachine, "'", "''") & "'" End If If filterBU <> "" Then whereClause = whereClause & " AND s.machinenumber IN (SELECT machinenumber FROM machines WHERE businessunitid = " & CLng(filterBU) & ")" End If If filterBadge <> "" Then whereClause = whereClause & " AND p.badgenumber = '" & Replace(filterBadge, "'", "''") & "'" End If If filterPart <> "" Then whereClause = whereClause & " AND p.partnumber LIKE '%" & Replace(filterPart, "'", "''") & "%'" End If ' Get summary statistics Dim rsSummary, totalParts, totalOOT, partsWithOOT, avgCycleTime, avgManualTime, ootRate, strSQL2, ootCardClass strSQL2 = "SELECT COUNT(*) as totalparts, " & _ "SUM(ootcount) as totaloot, " & _ "SUM(CASE WHEN ootcount > 0 THEN 1 ELSE 0 END) as partswithoot, " & _ "AVG(cycletime) as avgcycle, " & _ "SUM(manualcount) as totalmanual " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & whereClause Set rsSummary = objConn.Execute(strSQL2) If Not rsSummary.EOF Then If IsNull(rsSummary("totalparts")) Then totalParts = 0 Else totalParts = CLng(rsSummary("totalparts")) If IsNull(rsSummary("totaloot")) Then totalOOT = 0 Else totalOOT = CLng(rsSummary("totaloot")) If IsNull(rsSummary("partswithoot")) Then partsWithOOT = 0 Else partsWithOOT = CLng(rsSummary("partswithoot")) If Not IsNull(rsSummary("avgcycle")) Then avgCycleTime = FormatNumber(CDbl(rsSummary("avgcycle")) / 60, 1) Else avgCycleTime = "0" End If If totalParts > 0 Then ootRate = FormatNumber(CDbl(partsWithOOT) / CDbl(totalParts) * 100, 1) Else ootRate = "0" End If Else totalParts = 0 totalOOT = 0 partsWithOOT = 0 avgCycleTime = "0" ootRate = "0" End If rsSummary.Close Set rsSummary = Nothing ' Get avg manual response time Dim rsManual, avgManualResp strSQL2 = "SELECT AVG(mr.responseseconds) as avgresponse " & _ "FROM udcmanualrequests mr " & _ "JOIN udcparts p ON mr.partrunid = p.partrunid " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & whereClause & shiftFilter Set rsManual = objConn.Execute(strSQL2) If Not rsManual.EOF And Not IsNull(rsManual("avgresponse")) Then avgManualResp = FormatNumber(CDbl(rsManual("avgresponse")), 0) Else avgManualResp = "0" End If rsManual.Close Set rsManual = Nothing %>

<%=totalParts%>

Total Parts Produced

<%=avgCycleTime%>m

Avg Cycle Time
<% If CDbl(ootRate) > 5 Then ootCardClass = "bg-danger" ElseIf CDbl(ootRate) > 0 Then ootCardClass = "bg-warning" Else ootCardClass = "bg-success" End If %>

<%=ootRate%>%

Parts with OOT (<%=partsWithOOT%> of <%=totalParts%>)

<%=avgManualResp%>s

Avg Manual Response
<% ' ============================================================================ ' DASHBOARD CHARTS DATA QUERIES ' ============================================================================ ' Chart 1: Production Trend (daily parts for date range) Dim rsProductionTrend, prodLabels, prodData, prodDate prodLabels = "" prodData = "" strSQL2 = "SELECT DATE_FORMAT(DATE(p.programstart), '%m/%d') as day_label, COUNT(*) as parts " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " GROUP BY DATE(p.programstart) ORDER BY DATE(p.programstart) ASC" Set rsProductionTrend = objConn.Execute(strSQL2) Do While Not rsProductionTrend.EOF prodDate = rsProductionTrend("day_label") & "" If prodLabels <> "" Then prodLabels = prodLabels & "," If prodData <> "" Then prodData = prodData & "," prodLabels = prodLabels & """" & prodDate & """" prodData = prodData & rsProductionTrend("parts") rsProductionTrend.MoveNext Loop rsProductionTrend.Close Set rsProductionTrend = Nothing If prodLabels = "" Then prodLabels = """No Data""" If prodData = "" Then prodData = "0" ' Chart 2: OOT Rate Trend (daily OOT rate for date range) Dim rsOOTTrend, ootLabels, ootRateData, ootCountData, ootDay, dayRate ootLabels = "" ootRateData = "" ootCountData = "" strSQL2 = "SELECT DATE_FORMAT(DATE(p.programstart), '%m/%d') as day_label, " & _ "SUM(p.ootcount) as oot_count, COUNT(*) as total_parts, " & _ "ROUND(SUM(p.ootcount)*100.0/COUNT(*), 1) as oot_rate " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " GROUP BY DATE(p.programstart) ORDER BY DATE(p.programstart) ASC" Set rsOOTTrend = objConn.Execute(strSQL2) Do While Not rsOOTTrend.EOF ootDay = rsOOTTrend("day_label") & "" If ootLabels <> "" Then ootLabels = ootLabels & "," If ootRateData <> "" Then ootRateData = ootRateData & "," If ootCountData <> "" Then ootCountData = ootCountData & "," ootLabels = ootLabels & """" & ootDay & """" If IsNull(rsOOTTrend("oot_rate")) Then dayRate = "0" Else dayRate = rsOOTTrend("oot_rate") & "" End If ootRateData = ootRateData & dayRate ootCountData = ootCountData & (rsOOTTrend("oot_count") & "0") rsOOTTrend.MoveNext Loop rsOOTTrend.Close Set rsOOTTrend = Nothing If ootLabels = "" Then ootLabels = """No Data""" If ootRateData = "" Then ootRateData = "0" If ootCountData = "" Then ootCountData = "0" ' Chart 3: Machine Utilization (top 10 by runtime hours) Dim rsMachineUtil, machLabels, machData, machHours machLabels = "" machData = "" strSQL2 = "SELECT s.machinenumber, ROUND(SUM(p.cycletime)/3600, 1) as runtime_hours " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " AND p.cycletime IS NOT NULL AND p.cycletime > 0 " & _ "GROUP BY s.machinenumber ORDER BY runtime_hours DESC LIMIT 10" Set rsMachineUtil = objConn.Execute(strSQL2) Do While Not rsMachineUtil.EOF If machLabels <> "" Then machLabels = machLabels & "," If machData <> "" Then machData = machData & "," machLabels = machLabels & """" & (rsMachineUtil("machinenumber") & "") & """" If IsNull(rsMachineUtil("runtime_hours")) Then machHours = "0" Else machHours = rsMachineUtil("runtime_hours") & "" End If machData = machData & machHours rsMachineUtil.MoveNext Loop rsMachineUtil.Close Set rsMachineUtil = Nothing If machLabels = "" Then machLabels = """No Data""" If machData = "" Then machData = "0" ' Chart 4: Top Operators (top 10 by parts produced) Dim rsTopOps, opLabels, opData opLabels = "" opData = "" strSQL2 = "SELECT p.badgenumber, COUNT(*) as parts_count " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " AND p.badgenumber IS NOT NULL AND p.badgenumber != '' " & _ "GROUP BY p.badgenumber ORDER BY parts_count DESC LIMIT 10" Set rsTopOps = objConn.Execute(strSQL2) Do While Not rsTopOps.EOF If opLabels <> "" Then opLabels = opLabels & "," If opData <> "" Then opData = opData & "," opLabels = opLabels & """" & (rsTopOps("badgenumber") & "") & """" opData = opData & rsTopOps("parts_count") rsTopOps.MoveNext Loop rsTopOps.Close Set rsTopOps = Nothing If opLabels = "" Then opLabels = """No Data""" If opData = "" Then opData = "0" ' ============================================================================ ' HISTORICAL TRENDS DATA (from summary tables - survives 90-day purge) ' ============================================================================ ' Monthly measurement trends (last 12 months) Dim rsMonthlyMeas, monthlyLabels, monthlyMeasData, monthlyOOTData, monthlyOOTRate monthlyLabels = "" monthlyMeasData = "" monthlyOOTData = "" monthlyOOTRate = "" strSQL2 = "SELECT yearmonth, SUM(measurement_count) as total_meas, SUM(oot_count) as total_oot, " & _ "ROUND(SUM(oot_count)*100.0/NULLIF(SUM(measurement_count),0), 2) as oot_rate " & _ "FROM vwudcmeasurements_monthly " If filterMachine <> "" Then strSQL2 = strSQL2 & "WHERE machinenumber = '" & Replace(filterMachine, "'", "''") & "' " End If strSQL2 = strSQL2 & "GROUP BY yearmonth ORDER BY yearmonth DESC LIMIT 12" Set rsMonthlyMeas = objConn.Execute(strSQL2) Dim monthlyArr(11,3), monthlyIdx monthlyIdx = 0 Do While Not rsMonthlyMeas.EOF And monthlyIdx < 12 monthlyArr(monthlyIdx, 0) = rsMonthlyMeas("yearmonth") & "" monthlyArr(monthlyIdx, 1) = rsMonthlyMeas("total_meas") & "" monthlyArr(monthlyIdx, 2) = rsMonthlyMeas("total_oot") & "" If IsNull(rsMonthlyMeas("oot_rate")) Then monthlyArr(monthlyIdx, 3) = "0" Else monthlyArr(monthlyIdx, 3) = rsMonthlyMeas("oot_rate") & "" End If monthlyIdx = monthlyIdx + 1 rsMonthlyMeas.MoveNext Loop rsMonthlyMeas.Close Set rsMonthlyMeas = Nothing ' Reverse order for chronological display Dim mi For mi = monthlyIdx - 1 To 0 Step -1 If monthlyLabels <> "" Then monthlyLabels = monthlyLabels & "," If monthlyMeasData <> "" Then monthlyMeasData = monthlyMeasData & "," If monthlyOOTData <> "" Then monthlyOOTData = monthlyOOTData & "," If monthlyOOTRate <> "" Then monthlyOOTRate = monthlyOOTRate & "," monthlyLabels = monthlyLabels & """" & monthlyArr(mi, 0) & """" monthlyMeasData = monthlyMeasData & monthlyArr(mi, 1) monthlyOOTData = monthlyOOTData & monthlyArr(mi, 2) monthlyOOTRate = monthlyOOTRate & monthlyArr(mi, 3) Next If monthlyLabels = "" Then monthlyLabels = """No Data""" If monthlyMeasData = "" Then monthlyMeasData = "0" If monthlyOOTData = "" Then monthlyOOTData = "0" If monthlyOOTRate = "" Then monthlyOOTRate = "0" ' Machine comparison from summaries (total measurements by machine, all time) Dim rsMachHist, machHistLabels, machHistMeas, machHistOOT machHistLabels = "" machHistMeas = "" machHistOOT = "" strSQL2 = "SELECT machinenumber, SUM(measurement_count) as total_meas, SUM(oot_count) as total_oot " & _ "FROM udcmeasurements_daily GROUP BY machinenumber ORDER BY total_meas DESC LIMIT 15" Set rsMachHist = objConn.Execute(strSQL2) Do While Not rsMachHist.EOF If machHistLabels <> "" Then machHistLabels = machHistLabels & "," If machHistMeas <> "" Then machHistMeas = machHistMeas & "," If machHistOOT <> "" Then machHistOOT = machHistOOT & "," machHistLabels = machHistLabels & """" & (rsMachHist("machinenumber") & "") & """" machHistMeas = machHistMeas & (rsMachHist("total_meas") & "") machHistOOT = machHistOOT & (rsMachHist("total_oot") & "") rsMachHist.MoveNext Loop rsMachHist.Close Set rsMachHist = Nothing If machHistLabels = "" Then machHistLabels = """No Data""" If machHistMeas = "" Then machHistMeas = "0" If machHistOOT = "" Then machHistOOT = "0" ' Weekly trends for the last 26 weeks Dim rsWeeklyTrend, weeklyLabels, weeklyMeasData, weeklyOOTRate weeklyLabels = "" weeklyMeasData = "" weeklyOOTRate = "" strSQL2 = "SELECT week_start, SUM(measurement_count) as total_meas, " & _ "ROUND(SUM(oot_count)*100.0/NULLIF(SUM(measurement_count),0), 2) as oot_rate " & _ "FROM vwudcmeasurements_weekly " If filterMachine <> "" Then strSQL2 = strSQL2 & "WHERE machinenumber = '" & Replace(filterMachine, "'", "''") & "' " End If strSQL2 = strSQL2 & "GROUP BY yearweek, week_start ORDER BY week_start DESC LIMIT 26" Set rsWeeklyTrend = objConn.Execute(strSQL2) Dim weeklyArr(25,2), weeklyIdx weeklyIdx = 0 Do While Not rsWeeklyTrend.EOF And weeklyIdx < 26 weeklyArr(weeklyIdx, 0) = Month(rsWeeklyTrend("week_start")) & "/" & Day(rsWeeklyTrend("week_start")) weeklyArr(weeklyIdx, 1) = rsWeeklyTrend("total_meas") & "" If IsNull(rsWeeklyTrend("oot_rate")) Then weeklyArr(weeklyIdx, 2) = "0" Else weeklyArr(weeklyIdx, 2) = rsWeeklyTrend("oot_rate") & "" End If weeklyIdx = weeklyIdx + 1 rsWeeklyTrend.MoveNext Loop rsWeeklyTrend.Close Set rsWeeklyTrend = Nothing ' Reverse for chronological Dim wi For wi = weeklyIdx - 1 To 0 Step -1 If weeklyLabels <> "" Then weeklyLabels = weeklyLabels & "," If weeklyMeasData <> "" Then weeklyMeasData = weeklyMeasData & "," If weeklyOOTRate <> "" Then weeklyOOTRate = weeklyOOTRate & "," weeklyLabels = weeklyLabels & """" & weeklyArr(wi, 0) & """" weeklyMeasData = weeklyMeasData & weeklyArr(wi, 1) weeklyOOTRate = weeklyOOTRate & weeklyArr(wi, 2) Next If weeklyLabels = "" Then weeklyLabels = """No Data""" If weeklyMeasData = "" Then weeklyMeasData = "0" If weeklyOOTRate = "" Then weeklyOOTRate = "0" ' Monthly parts production trends (from udcpartsdaily) Dim rsMonthlyParts, monthlyPartsLabels, monthlyPartsData monthlyPartsLabels = "" monthlyPartsData = "" strSQL2 = "SELECT yearmonth, SUM(partscount) as total_parts " & _ "FROM vwudcparts_monthly " If filterMachine <> "" Then strSQL2 = strSQL2 & "WHERE machinenumber = '" & Replace(filterMachine, "'", "''") & "' " End If strSQL2 = strSQL2 & "GROUP BY yearmonth ORDER BY yearmonth DESC LIMIT 12" Set rsMonthlyParts = objConn.Execute(strSQL2) Dim partsArr(11,1), partsIdx partsIdx = 0 Do While Not rsMonthlyParts.EOF And partsIdx < 12 partsArr(partsIdx, 0) = rsMonthlyParts("yearmonth") & "" partsArr(partsIdx, 1) = rsMonthlyParts("total_parts") & "" partsIdx = partsIdx + 1 rsMonthlyParts.MoveNext Loop rsMonthlyParts.Close Set rsMonthlyParts = Nothing Dim pi For pi = partsIdx - 1 To 0 Step -1 If monthlyPartsLabels <> "" Then monthlyPartsLabels = monthlyPartsLabels & "," If monthlyPartsData <> "" Then monthlyPartsData = monthlyPartsData & "," monthlyPartsLabels = monthlyPartsLabels & """" & partsArr(pi, 0) & """" monthlyPartsData = monthlyPartsData & partsArr(pi, 1) Next If monthlyPartsLabels = "" Then monthlyPartsLabels = """No Data""" If monthlyPartsData = "" Then monthlyPartsData = "0" ' Monthly response time trends (from udcmanualrequestsdaily) Dim rsMonthlyResp, monthlyRespLabels, monthlyRespData monthlyRespLabels = "" monthlyRespData = "" strSQL2 = "SELECT yearmonth, ROUND(AVG(avgresponseseconds), 1) as avg_resp " & _ "FROM vwudcmanualrequests_monthly " If filterMachine <> "" Then strSQL2 = strSQL2 & "WHERE machinenumber = '" & Replace(filterMachine, "'", "''") & "' " End If strSQL2 = strSQL2 & "GROUP BY yearmonth ORDER BY yearmonth DESC LIMIT 12" Set rsMonthlyResp = objConn.Execute(strSQL2) Dim respArr(11,1), respIdx respIdx = 0 Do While Not rsMonthlyResp.EOF And respIdx < 12 respArr(respIdx, 0) = rsMonthlyResp("yearmonth") & "" If IsNull(rsMonthlyResp("avg_resp")) Then respArr(respIdx, 1) = "0" Else respArr(respIdx, 1) = rsMonthlyResp("avg_resp") & "" End If respIdx = respIdx + 1 rsMonthlyResp.MoveNext Loop rsMonthlyResp.Close Set rsMonthlyResp = Nothing Dim ri For ri = respIdx - 1 To 0 Step -1 If monthlyRespLabels <> "" Then monthlyRespLabels = monthlyRespLabels & "," If monthlyRespData <> "" Then monthlyRespData = monthlyRespData & "," monthlyRespLabels = monthlyRespLabels & """" & respArr(ri, 0) & """" monthlyRespData = monthlyRespData & respArr(ri, 1) Next If monthlyRespLabels = "" Then monthlyRespLabels = """No Data""" If monthlyRespData = "" Then monthlyRespData = "0" ' Monthly violations trends (CLM specific) Dim rsMonthlyViol, monthlyViolLabels, monthlyViolData monthlyViolLabels = "" monthlyViolData = "" strSQL2 = "SELECT yearmonth, SUM(violationcount) as total_violations " & _ "FROM vwudcviolations_monthly " If filterMachine <> "" Then strSQL2 = strSQL2 & "WHERE machinenumber = '" & Replace(filterMachine, "'", "''") & "' " End If strSQL2 = strSQL2 & "GROUP BY yearmonth ORDER BY yearmonth DESC LIMIT 12" Set rsMonthlyViol = objConn.Execute(strSQL2) Dim violArr(11,1), violIdx violIdx = 0 Do While Not rsMonthlyViol.EOF And violIdx < 12 violArr(violIdx, 0) = rsMonthlyViol("yearmonth") & "" If IsNull(rsMonthlyViol("total_violations")) Then violArr(violIdx, 1) = "0" Else violArr(violIdx, 1) = rsMonthlyViol("total_violations") & "" End If violIdx = violIdx + 1 rsMonthlyViol.MoveNext Loop rsMonthlyViol.Close Set rsMonthlyViol = Nothing Dim vi For vi = violIdx - 1 To 0 Step -1 If monthlyViolLabels <> "" Then monthlyViolLabels = monthlyViolLabels & "," If monthlyViolData <> "" Then monthlyViolData = monthlyViolData & "," monthlyViolLabels = monthlyViolLabels & """" & violArr(vi, 0) & """" monthlyViolData = monthlyViolData & violArr(vi, 1) Next If monthlyViolLabels = "" Then monthlyViolLabels = """No Data""" If monthlyViolData = "" Then monthlyViolData = "0" ' Monthly changeover time trends Dim rsMonthlyChg, monthlyChgLabels, monthlyChgData monthlyChgLabels = "" monthlyChgData = "" strSQL2 = "SELECT yearmonth, ROUND(AVG(avgchangeover)/60, 1) as avg_changeover_min " & _ "FROM vwudcchangeover_monthly " If filterMachine <> "" Then strSQL2 = strSQL2 & "WHERE machinenumber = '" & Replace(filterMachine, "'", "''") & "' " End If strSQL2 = strSQL2 & "GROUP BY yearmonth ORDER BY yearmonth DESC LIMIT 12" Set rsMonthlyChg = objConn.Execute(strSQL2) Dim chgArr(11,1), chgIdx chgIdx = 0 Do While Not rsMonthlyChg.EOF And chgIdx < 12 chgArr(chgIdx, 0) = rsMonthlyChg("yearmonth") & "" If IsNull(rsMonthlyChg("avg_changeover_min")) Then chgArr(chgIdx, 1) = "0" Else chgArr(chgIdx, 1) = rsMonthlyChg("avg_changeover_min") & "" End If chgIdx = chgIdx + 1 rsMonthlyChg.MoveNext Loop rsMonthlyChg.Close Set rsMonthlyChg = Nothing Dim ci For ci = chgIdx - 1 To 0 Step -1 If monthlyChgLabels <> "" Then monthlyChgLabels = monthlyChgLabels & "," If monthlyChgData <> "" Then monthlyChgData = monthlyChgData & "," monthlyChgLabels = monthlyChgLabels & """" & chgArr(ci, 0) & """" monthlyChgData = monthlyChgData & chgArr(ci, 1) Next If monthlyChgLabels = "" Then monthlyChgLabels = """No Data""" If monthlyChgData = "" Then monthlyChgData = "0" ' Violations by machine (top 10) Dim rsViolByMachine, violMachLabels, violMachData violMachLabels = "" violMachData = "" strSQL2 = "SELECT machinenumber, SUM(violationcount) as total_violations " & _ "FROM vwudcviolations_monthly " & _ "GROUP BY machinenumber ORDER BY total_violations DESC LIMIT 10" Set rsViolByMachine = objConn.Execute(strSQL2) Do While Not rsViolByMachine.EOF If violMachLabels <> "" Then violMachLabels = violMachLabels & "," If violMachData <> "" Then violMachData = violMachData & "," violMachLabels = violMachLabels & """" & rsViolByMachine("machinenumber") & """" violMachData = violMachData & rsViolByMachine("total_violations") rsViolByMachine.MoveNext Loop rsViolByMachine.Close Set rsViolByMachine = Nothing If violMachLabels = "" Then violMachLabels = """No Data""" If violMachData = "" Then violMachData = "0" %>
" id="dashboard">
UDC Performance Dashboard
Production Trend
OOT Rate Trend
Machine Utilization (Hours)
Top Operators (Parts)
" id="liveactivity">
Active Machines Live

Machines currently running jobs. Data refreshes when page loads.

<% ' Get active sessions with optional machine/BU filter Dim rsActive, activeCount, activeWhereClause activeWhereClause = "" If filterMachine <> "" Then activeWhereClause = " WHERE a.machinenumber = '" & Replace(filterMachine, "'", "''") & "'" ElseIf filterBU <> "" Then activeWhereClause = " WHERE a.machinenumber IN (SELECT machinenumber FROM machines WHERE businessunitid = " & CLng(filterBU) & ")" End If strSQL2 = "SELECT a.machinenumber, a.partnumber, a.badgenumber, a.partsrun, a.lastupdate, a.sessionstart, " & _ "TIMESTAMPDIFF(MINUTE, a.sessionstart, NOW()) as runtime_minutes " & _ "FROM udcactivesessions a" & activeWhereClause & " ORDER BY a.lastupdate DESC" Set rsActive = objConn.Execute(strSQL2) activeCount = 0 If rsActive.EOF Then %>
No active jobs detected
<% Else %>
<% Dim runtimeMinutes, runtimeDisplay Do While Not rsActive.EOF activeCount = activeCount + 1 runtimeMinutes = rsActive("runtime_minutes") If IsNull(runtimeMinutes) Or runtimeMinutes = "" Then runtimeDisplay = "-" ElseIf CLng(runtimeMinutes) >= 60 Then runtimeDisplay = Int(CLng(runtimeMinutes) / 60) & "h " & (CLng(runtimeMinutes) Mod 60) & "m" Else runtimeDisplay = CLng(runtimeMinutes) & "m" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsActive.MoveNext Loop %>
Machine Part Number Operator Badge Parts Run Runtime Session Start Last Activity
" & Server.HTMLEncode(rsActive("machinenumber") & "") & "" & Server.HTMLEncode(rsActive("partnumber") & "") & "" & Server.HTMLEncode(rsActive("badgenumber") & "") & "" & rsActive("partsrun") & "" & runtimeDisplay & "" & Server.HTMLEncode(rsActive("sessionstart") & "") & "" & Server.HTMLEncode(rsActive("lastupdate") & "") & "

<%=activeCount%> machine(s) currently active

<% End If rsActive.Close Set rsActive = Nothing %>
" id="operators">
Operator Performance Leaderboard
<% ' Get operator stats Dim rsOperators, opCycle, opManual, opRowNum, opRowStyle strSQL2 = "SELECT p.badgenumber, COUNT(*) as partsrun, " & _ "AVG(p.cycletime) as avgcycle, " & _ "MAX(p.programend) as lastactive, " & _ "(SELECT AVG(mr.responseseconds) FROM udcmanualrequests mr " & _ " JOIN udcparts p2 ON mr.partrunid = p2.partrunid WHERE p2.badgenumber = p.badgenumber) as avgmanual " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " AND p.badgenumber IS NOT NULL AND p.badgenumber != '' " & _ "GROUP BY p.badgenumber ORDER BY partsrun DESC, p.badgenumber ASC" Set rsOperators = objConn.Execute(strSQL2) opRowNum = 0 If rsOperators.EOF Then Response.Write("") Else Do While Not rsOperators.EOF opRowNum = opRowNum + 1 If Not IsNull(rsOperators("avgcycle")) Then opCycle = FormatNumber(CDbl(rsOperators("avgcycle")) / 60, 1) Else opCycle = "-" End If If Not IsNull(rsOperators("avgmanual")) Then opManual = FormatNumber(CDbl(rsOperators("avgmanual")), 0) Else opManual = "-" End If ' Highlight top 3 performers opRowStyle = "" If opRowNum = 1 Then opRowStyle = "background-color:#28a745; color:#fff;" ElseIf opRowNum = 2 Then opRowStyle = "background-color:#20c997; color:#fff;" ElseIf opRowNum = 3 Then opRowStyle = "background-color:#17a2b8; color:#fff;" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsOperators.MoveNext Loop End If rsOperators.Close Set rsOperators = Nothing %>
Badge # Parts Run Avg Cycle (min) Avg Manual Response (sec) Last Active
No operator data found
" & Server.HTMLEncode(rsOperators("badgenumber") & "") & "" & rsOperators("partsrun") & "" & opCycle & "" & opManual & "" & Server.HTMLEncode(rsOperators("lastactive") & "") & "
" id="machines">
Machine Performance Comparison
<% ' Get machine stats Dim rsMachStats, machCycle, machChange, machOOTRate, machOOTBadge, machPartsWithOOT strSQL2 = "SELECT s.machinenumber, COUNT(*) as partsrun, " & _ "AVG(p.cycletime) as avgcycle, " & _ "AVG(p.changeover) as avgchangeover, " & _ "SUM(CASE WHEN p.ootcount > 0 THEN 1 ELSE 0 END) as partswithoot, " & _ "MAX(p.programend) as lastrun " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " GROUP BY s.machinenumber ORDER BY partsrun DESC, s.machinenumber ASC" Set rsMachStats = objConn.Execute(strSQL2) If rsMachStats.EOF Then Response.Write("") Else Do While Not rsMachStats.EOF If Not IsNull(rsMachStats("avgcycle")) Then machCycle = FormatNumber(CDbl(rsMachStats("avgcycle")) / 60, 1) Else machCycle = "-" End If If Not IsNull(rsMachStats("avgchangeover")) Then machChange = FormatNumber(CDbl(rsMachStats("avgchangeover")) / 60, 1) Else machChange = "-" End If machPartsWithOOT = CLng("0" & rsMachStats("partswithoot")) If CLng("0" & rsMachStats("partsrun")) > 0 Then machOOTRate = FormatNumber(CDbl(machPartsWithOOT) / CDbl(rsMachStats("partsrun")) * 100, 2) Else machOOTRate = "0" End If If CDbl(machOOTRate) > 5 Then machOOTBadge = "" & machOOTRate & "%" ElseIf CDbl(machOOTRate) > 0 Then machOOTBadge = "" & machOOTRate & "%" Else machOOTBadge = "" & machOOTRate & "%" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsMachStats.MoveNext Loop End If rsMachStats.Close Set rsMachStats = Nothing %>
Machine # Parts Run Avg Cycle (min) Avg Changeover (min) Parts with OOT OOT Rate Last Run
No machine data found
" & Server.HTMLEncode(rsMachStats("machinenumber") & "") & "" & rsMachStats("partsrun") & "" & machCycle & "" & machChange & "" & machPartsWithOOT & "" & machOOTBadge & "" & Server.HTMLEncode(rsMachStats("lastrun") & "") & "
" id="parts">
Part Number Analysis
<% ' Get part stats Dim rsPartStats, partCycle, partOOTRate, partOOTBadge, partPartsWithOOT strSQL2 = "SELECT p.partnumber, COUNT(*) as cnt, " & _ "AVG(p.cycletime) as avgcycle, " & _ "SUM(CASE WHEN p.ootcount > 0 THEN 1 ELSE 0 END) as partswithoot " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " AND p.partnumber IS NOT NULL AND p.partnumber != '' " & _ "GROUP BY p.partnumber ORDER BY partswithoot DESC, cnt DESC, p.partnumber ASC LIMIT 50" Set rsPartStats = objConn.Execute(strSQL2) If rsPartStats.EOF Then Response.Write("") Else Do While Not rsPartStats.EOF If Not IsNull(rsPartStats("avgcycle")) Then partCycle = FormatNumber(CDbl(rsPartStats("avgcycle")) / 60, 1) Else partCycle = "-" End If partPartsWithOOT = CLng("0" & rsPartStats("partswithoot")) If CLng("0" & rsPartStats("cnt")) > 0 Then partOOTRate = FormatNumber(CDbl(partPartsWithOOT) / CDbl(rsPartStats("cnt")) * 100, 2) Else partOOTRate = "0" End If If CDbl(partOOTRate) > 5 Then partOOTBadge = "" & partOOTRate & "%" ElseIf CDbl(partOOTRate) > 0 Then partOOTBadge = "" & partOOTRate & "%" Else partOOTBadge = "0%" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsPartStats.MoveNext Loop End If rsPartStats.Close Set rsPartStats = Nothing %>
Part # Count Avg Cycle (min) Parts with OOT OOT Rate
No part data found
" & Server.HTMLEncode(rsPartStats("partnumber") & "") & "" & rsPartStats("cnt") & "" & partCycle & "" & partPartsWithOOT & "" & partOOTBadge & "
" id="quality">
Out-of-Tolerance Analysis
OOT by Machine
<% ' Get OOT by Machine Dim rsOOTMach, maxOOT, ootMachRate, barWidth, ootMachParts maxOOT = 1 strSQL2 = "SELECT s.machinenumber, SUM(CASE WHEN p.ootcount > 0 THEN 1 ELSE 0 END) as partswithoot, COUNT(*) as partsrun " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " GROUP BY s.machinenumber ORDER BY partswithoot DESC, s.machinenumber ASC LIMIT 10" Set rsOOTMach = objConn.Execute(strSQL2) If rsOOTMach.EOF Then Response.Write("") Else ' Find max for bar scaling Do While Not rsOOTMach.EOF If CLng("0" & rsOOTMach("partswithoot")) > maxOOT Then maxOOT = CLng("0" & rsOOTMach("partswithoot")) rsOOTMach.MoveNext Loop rsOOTMach.Close Set rsOOTMach = objConn.Execute(strSQL2) Do While Not rsOOTMach.EOF ootMachParts = CLng("0" & rsOOTMach("partswithoot")) If CLng("0" & rsOOTMach("partsrun")) > 0 Then ootMachRate = FormatNumber(CDbl(ootMachParts) / CDbl(rsOOTMach("partsrun")) * 100, 2) Else ootMachRate = "0" End If barWidth = Int((ootMachParts / maxOOT) * 100) Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsOOTMach.MoveNext Loop End If rsOOTMach.Close Set rsOOTMach = Nothing %>
Machine Parts with OOT Parts Run OOT Rate Bar
No OOT data found
" & Server.HTMLEncode(rsOOTMach("machinenumber") & "") & "" & ootMachParts & "" & rsOOTMach("partsrun") & "" & ootMachRate & "%
Recent OOT Measurements
<% ' Get recent OOT measurements Dim rsOOT strSQL2 = "SELECT m.eventtime, s.machinenumber, p.partnumber, m.dimid, m.description, " & _ "m.minval, m.actualval, m.maxval " & _ "FROM udcmeasurements m " & _ "JOIN udcparts p ON m.partrunid = p.partrunid " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " AND m.oot = 1 " & _ "ORDER BY m.eventtime DESC LIMIT 50" Set rsOOT = objConn.Execute(strSQL2) If rsOOT.EOF Then Response.Write("") Else Do While Not rsOOT.EOF Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsOOT.MoveNext Loop End If rsOOT.Close Set rsOOT = Nothing %>
Time Machine Part # Dimension Min Actual Max
No OOT measurements found
" & Server.HTMLEncode(rsOOT("eventtime") & "") & "" & Server.HTMLEncode(rsOOT("machinenumber") & "") & "" & Server.HTMLEncode(rsOOT("partnumber") & "") & "" & Server.HTMLEncode(rsOOT("dimid") & "") & " - " & Server.HTMLEncode(rsOOT("description") & "") & "" & rsOOT("minval") & "" & rsOOT("actualval") & "" & rsOOT("maxval") & "
Best Performing Machines (Lowest OOT Rates)
<% ' Get best performing machines (lowest OOT rate, min 10 parts) Dim rsBestMach, bestRate, bestStyle, qualityWidth, bestPartsWithOOT strSQL2 = "SELECT s.machinenumber, COUNT(*) as partsrun, " & _ "SUM(CASE WHEN p.ootcount > 0 THEN 1 ELSE 0 END) as partswithoot, " & _ "ROUND(SUM(CASE WHEN p.ootcount > 0 THEN 1 ELSE 0 END)/COUNT(*)*100, 2) as ootrate " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " GROUP BY s.machinenumber HAVING COUNT(*) >= 10 ORDER BY ootrate ASC, partsrun DESC, s.machinenumber ASC LIMIT 10" Set rsBestMach = objConn.Execute(strSQL2) If rsBestMach.EOF Then Response.Write("") Else Do While Not rsBestMach.EOF bestPartsWithOOT = CLng("0" & rsBestMach("partswithoot")) bestRate = CDbl("0" & rsBestMach("ootrate")) qualityWidth = 100 - Int(bestRate) If qualityWidth < 0 Then qualityWidth = 0 If qualityWidth > 100 Then qualityWidth = 100 If bestRate = 0 Then bestStyle = "background-color:#28a745; color:#fff;" ElseIf bestRate < 5 Then bestStyle = "background-color:#20c997; color:#fff;" Else bestStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsBestMach.MoveNext Loop End If rsBestMach.Close Set rsBestMach = Nothing %>
Machine Parts Run OOT Count OOT Rate Quality Bar
No machine data found (min 10 parts required)
" & Server.HTMLEncode(rsBestMach("machinenumber") & "") & "" & rsBestMach("partsrun") & "" & bestPartsWithOOT & "" & bestRate & "%
" id="timing">
Timing Analysis
Manual Response Time by Operator
<% ' Get manual response time by operator Dim rsManualOp, manAvg, manMax strSQL2 = "SELECT p.badgenumber, COUNT(*) as requests, " & _ "AVG(mr.responseseconds) as avgresponse, " & _ "MAX(mr.responseseconds) as maxresponse " & _ "FROM udcmanualrequests mr " & _ "JOIN udcparts p ON mr.partrunid = p.partrunid " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " AND p.badgenumber IS NOT NULL AND p.badgenumber != ''" & shiftFilter & _ " GROUP BY p.badgenumber ORDER BY avgresponse ASC, p.badgenumber ASC" Set rsManualOp = objConn.Execute(strSQL2) If rsManualOp.EOF Then Response.Write("") Else Do While Not rsManualOp.EOF If Not IsNull(rsManualOp("avgresponse")) Then manAvg = FormatNumber(CDbl(rsManualOp("avgresponse")), 0) Else manAvg = "-" End If manMax = CLng("0" & rsManualOp("maxresponse")) Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsManualOp.MoveNext Loop End If rsManualOp.Close Set rsManualOp = Nothing %>
Badge # Requests Avg Response (sec) Max Response (sec)
No manual request data found
" & Server.HTMLEncode(rsManualOp("badgenumber") & "") & "" & rsManualOp("requests") & "" & manAvg & "" & manMax & "
Slowest Manual Responses
<% ' Get slowest manual responses Dim rsSlow, rowStyle strSQL2 = "SELECT mr.requesttime, s.machinenumber, p.badgenumber, mr.description, mr.responseseconds " & _ "FROM udcmanualrequests mr " & _ "JOIN udcparts p ON mr.partrunid = p.partrunid " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & shiftFilter & _ " ORDER BY mr.responseseconds DESC LIMIT 25" Set rsSlow = objConn.Execute(strSQL2) If rsSlow.EOF Then Response.Write("") Else Do While Not rsSlow.EOF If CLng("0" & rsSlow("responseseconds")) > 300 Then rowStyle = "background-color:#dc3545; color:#fff;" ElseIf CLng("0" & rsSlow("responseseconds")) > 120 Then rowStyle = "background-color:#ffc107; color:#333;" Else rowStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsSlow.MoveNext Loop End If rsSlow.Close Set rsSlow = Nothing %>
Request Time Machine Badge Description Response Time (sec)
No manual requests found
" & Server.HTMLEncode(rsSlow("requesttime") & "") & "" & Server.HTMLEncode(rsSlow("machinenumber") & "") & "" & Server.HTMLEncode(rsSlow("badgenumber") & "") & "" & Server.HTMLEncode(rsSlow("description") & "") & "" & rsSlow("responseseconds") & "
Fastest Responses (Top Performers)
<% ' Get fastest manual responses Dim rsFast, fastStyle strSQL2 = "SELECT mr.requesttime, s.machinenumber, p.badgenumber, mr.description, mr.responseseconds " & _ "FROM udcmanualrequests mr " & _ "JOIN udcparts p ON mr.partrunid = p.partrunid " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & shiftFilter & _ " AND mr.responseseconds > 0 ORDER BY mr.responseseconds ASC LIMIT 25" Set rsFast = objConn.Execute(strSQL2) If rsFast.EOF Then Response.Write("") Else Do While Not rsFast.EOF If CLng("0" & rsFast("responseseconds")) < 30 Then fastStyle = "background-color:#28a745; color:#fff;" ElseIf CLng("0" & rsFast("responseseconds")) < 60 Then fastStyle = "background-color:#20c997; color:#fff;" Else fastStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsFast.MoveNext Loop End If rsFast.Close Set rsFast = Nothing %>
Request Time Machine Badge Description Response Time (sec)
No manual requests found
" & Server.HTMLEncode(rsFast("requesttime") & "") & "" & Server.HTMLEncode(rsFast("machinenumber") & "") & "" & Server.HTMLEncode(rsFast("badgenumber") & "") & "" & Server.HTMLEncode(rsFast("description") & "") & "" & rsFast("responseseconds") & "
" id="activitylog">
Activity Log

Badge changes and item crossing violations recorded during part runs.

Item Crossing Violations

When operators modify item crossing values during a program run.

<% ' Get recent violations Dim rsViolations, violWhereClause, violPrev, violCurr, violChange, violStyle violWhereClause = " WHERE eventtime >= '" & Replace(filterStart, "'", "''") & "' " & _ " AND eventtime <= '" & Replace(filterEnd, "'", "''") & " 23:59:59'" If filterMachine <> "" Then violWhereClause = violWhereClause & " AND machinenumber = '" & Replace(filterMachine, "'", "''") & "'" End If If filterBU <> "" Then violWhereClause = violWhereClause & " AND machinenumber IN (SELECT machinenumber FROM machines WHERE businessunitid = " & CLng(filterBU) & ")" End If If filterBadge <> "" Then violWhereClause = violWhereClause & " AND badgenumber = '" & Replace(filterBadge, "'", "''") & "'" End If strSQL2 = "SELECT eventtime, machinenumber, badgenumber, crossingdesc, itemno, previousval, currentval " & _ "FROM udcviolations " & violWhereClause & _ " ORDER BY eventtime DESC LIMIT 50" Set rsViolations = objConn.Execute(strSQL2) If rsViolations.EOF Then Response.Write("") Else Do While Not rsViolations.EOF violPrev = CDbl("0" & rsViolations("previousval")) violCurr = CDbl("0" & rsViolations("currentval")) violChange = violCurr - violPrev ' Color code based on change magnitude If Abs(violChange) > 10 Then violStyle = "background-color:#dc3545; color:#fff;" ElseIf Abs(violChange) > 1 Then violStyle = "background-color:#ffc107; color:#333;" Else violStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") If violChange > 0 Then Response.Write("") ElseIf violChange < 0 Then Response.Write("") Else Response.Write("") End If Response.Write("") rsViolations.MoveNext Loop End If rsViolations.Close Set rsViolations = Nothing %>
Time Machine Badge Crossing Item# Previous Current Change
No item violations found in date range
" & Server.HTMLEncode(rsViolations("eventtime") & "") & "" & Server.HTMLEncode(rsViolations("machinenumber") & "") & "" & Server.HTMLEncode(rsViolations("badgenumber") & "") & "" & Server.HTMLEncode(rsViolations("crossingdesc") & "") & "" & Server.HTMLEncode(rsViolations("itemno") & "") & "" & FormatNumber(violPrev, 2) & "" & FormatNumber(violCurr, 2) & "+" & FormatNumber(violChange, 2) & "" & FormatNumber(violChange, 2) & "0
Violations by Machine
<% ' Get violations summary by machine Dim rsViolMach, violMachStyle strSQL2 = "SELECT machinenumber, COUNT(*) as cnt, COUNT(DISTINCT crossingdesc) as crossings, MAX(eventtime) as lasttime " & _ "FROM udcviolations " & violWhereClause & _ " GROUP BY machinenumber ORDER BY cnt DESC, machinenumber ASC LIMIT 10" Set rsViolMach = objConn.Execute(strSQL2) If rsViolMach.EOF Then Response.Write("") Else Do While Not rsViolMach.EOF If CLng("0" & rsViolMach("cnt")) > 100 Then violMachStyle = "background-color:#dc3545; color:#fff;" ElseIf CLng("0" & rsViolMach("cnt")) > 25 Then violMachStyle = "background-color:#ffc107; color:#333;" Else violMachStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsViolMach.MoveNext Loop End If rsViolMach.Close Set rsViolMach = Nothing %>
Machine Total Violations Unique Crossings Last Violation
No violations found
" & Server.HTMLEncode(rsViolMach("machinenumber") & "") & "" & rsViolMach("cnt") & "" & rsViolMach("crossings") & "" & Server.HTMLEncode(rsViolMach("lasttime") & "") & "
Badge Changes

Operator badge scans and changes during part runs.

<% ' Get recent badge changes Dim rsBadgeChanges, badgeWhereClause badgeWhereClause = " WHERE eventtime >= '" & Replace(filterStart, "'", "''") & "' " & _ " AND eventtime <= '" & Replace(filterEnd, "'", "''") & " 23:59:59'" If filterMachine <> "" Then badgeWhereClause = badgeWhereClause & " AND machinenumber = '" & Replace(filterMachine, "'", "''") & "'" End If If filterBU <> "" Then badgeWhereClause = badgeWhereClause & " AND machinenumber IN (SELECT machinenumber FROM machines WHERE businessunitid = " & CLng(filterBU) & ")" End If If filterBadge <> "" Then badgeWhereClause = badgeWhereClause & " AND badgenumber = '" & Replace(filterBadge, "'", "''") & "'" End If strSQL2 = "SELECT eventtime, machinenumber, badgenumber, details, description " & _ "FROM udcheaderupdates " & badgeWhereClause & _ " ORDER BY eventtime DESC LIMIT 50" Set rsBadgeChanges = objConn.Execute(strSQL2) If rsBadgeChanges.EOF Then Response.Write("") Else Do While Not rsBadgeChanges.EOF Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsBadgeChanges.MoveNext Loop End If rsBadgeChanges.Close Set rsBadgeChanges = Nothing %>
Time Machine Badge Details
No badge changes found in date range
" & Server.HTMLEncode(rsBadgeChanges("eventtime") & "") & "" & Server.HTMLEncode(rsBadgeChanges("machinenumber") & "") & "" & Server.HTMLEncode(rsBadgeChanges("badgenumber") & "") & "" & Server.HTMLEncode(rsBadgeChanges("description") & "") & "
Badge Activity by Operator
<% ' Get badge activity summary Dim rsBadgeSum strSQL2 = "SELECT badgenumber, COUNT(*) as cnt, COUNT(DISTINCT machinenumber) as machines, MAX(eventtime) as lasttime " & _ "FROM udcheaderupdates " & badgeWhereClause & _ " AND badgenumber IS NOT NULL AND badgenumber != '' " & _ " GROUP BY badgenumber ORDER BY cnt DESC, badgenumber ASC LIMIT 15" Set rsBadgeSum = objConn.Execute(strSQL2) If rsBadgeSum.EOF Then Response.Write("") Else Do While Not rsBadgeSum.EOF Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsBadgeSum.MoveNext Loop End If rsBadgeSum.Close Set rsBadgeSum = Nothing %>
Badge # Badge Scans Machines Used Last Activity
No badge activity found
" & Server.HTMLEncode(rsBadgeSum("badgenumber") & "") & "" & rsBadgeSum("cnt") & "" & rsBadgeSum("machines") & "" & Server.HTMLEncode(rsBadgeSum("lasttime") & "") & "
" id="toolhealth">
Tool Health

Tool offset measurements and wear tracking.

Tool Measurements by Machine
<% ' Get tool data summary by machine Dim rsToolMach, toolWhereClause, toolMachStyle toolWhereClause = " WHERE t.eventtime >= '" & Replace(filterStart, "'", "''") & "' " & _ " AND t.eventtime <= '" & Replace(filterEnd, "'", "''") & " 23:59:59'" If filterMachine <> "" Then toolWhereClause = toolWhereClause & " AND s.machinenumber = '" & Replace(filterMachine, "'", "''") & "'" End If If filterBU <> "" Then toolWhereClause = toolWhereClause & " AND s.machinenumber IN (SELECT machinenumber FROM machines WHERE businessunitid = " & CLng(filterBU) & ")" End If strSQL2 = "SELECT s.machinenumber, COUNT(*) as cnt, COUNT(DISTINCT t.toolnumber) as tools, " & _ "SUM(t.oot) as ootcount, MAX(t.eventtime) as lasttime " & _ "FROM udctooldata t " & _ "JOIN udcsessions s ON t.sessionid = s.sessionid " & _ toolWhereClause & _ " GROUP BY s.machinenumber ORDER BY cnt DESC, s.machinenumber ASC LIMIT 15" Set rsToolMach = objConn.Execute(strSQL2) If rsToolMach.EOF Then Response.Write("") Else Do While Not rsToolMach.EOF If CLng("0" & rsToolMach("ootcount")) > 0 Then toolMachStyle = "background-color:#ffc107; color:#333;" Else toolMachStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsToolMach.MoveNext Loop End If rsToolMach.Close Set rsToolMach = Nothing %>
Machine Measurements Unique Tools OOT Count Last Measurement
No tool data found in date range
" & Server.HTMLEncode(rsToolMach("machinenumber") & "") & "" & rsToolMach("cnt") & "" & rsToolMach("tools") & "") If CLng("0" & rsToolMach("ootcount")) > 0 Then Response.Write("" & rsToolMach("ootcount") & "") Else Response.Write("0") End If Response.Write("" & Server.HTMLEncode(rsToolMach("lasttime") & "") & "
<% If filterMachine <> "" Then %>
Most Used Tools on Machine <%=Server.HTMLEncode(filterMachine)%>
<% ' Get tool usage by tool number for this specific machine Dim rsToolNum, toolNumStyle, avgDev strSQL2 = "SELECT t.toolnumber, MAX(t.description) as description, COUNT(*) as cnt, " & _ "AVG(ABS(t.deviation)) as avgdev, SUM(t.oot) as ootcount " & _ "FROM udctooldata t " & _ "JOIN udcsessions s ON t.sessionid = s.sessionid " & _ toolWhereClause & _ " AND t.toolnumber IS NOT NULL " & _ " GROUP BY t.toolnumber ORDER BY cnt DESC, t.toolnumber ASC LIMIT 20" Set rsToolNum = objConn.Execute(strSQL2) If rsToolNum.EOF Then Response.Write("") Else Do While Not rsToolNum.EOF If CLng("0" & rsToolNum("ootcount")) > 0 Then toolNumStyle = "background-color:#ffc107; color:#333;" Else toolNumStyle = "" End If If Not IsNull(rsToolNum("avgdev")) Then avgDev = FormatNumber(CDbl(rsToolNum("avgdev")), 4) Else avgDev = "-" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsToolNum.MoveNext Loop End If rsToolNum.Close Set rsToolNum = Nothing %>
Tool # Description Measurements Avg Deviation OOT Count
No tool data found
Tool " & rsToolNum("toolnumber") & "" & Server.HTMLEncode(Trim(rsToolNum("description") & "")) & "" & rsToolNum("cnt") & "" & avgDev & "") If CLng("0" & rsToolNum("ootcount")) > 0 Then Response.Write("" & rsToolNum("ootcount") & "") Else Response.Write("0") End If Response.Write("
<% End If ' filterMachine %>
Recent Tool Measurements
<% ' Get recent tool measurements Dim rsToolRecent, toolRecentStyle strSQL2 = "SELECT t.eventtime, s.machinenumber, t.toolnumber, t.description, " & _ "t.minval, t.actualval, t.maxval, t.oot " & _ "FROM udctooldata t " & _ "JOIN udcsessions s ON t.sessionid = s.sessionid " & _ toolWhereClause & _ " ORDER BY t.eventtime DESC LIMIT 30" Set rsToolRecent = objConn.Execute(strSQL2) If rsToolRecent.EOF Then Response.Write("") Else Do While Not rsToolRecent.EOF If CLng("0" & rsToolRecent("oot")) > 0 Then toolRecentStyle = "background-color:#dc3545; color:#fff;" Else toolRecentStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") If CLng("0" & rsToolRecent("oot")) > 0 Then Response.Write("") Else Response.Write("") End If Response.Write("") rsToolRecent.MoveNext Loop End If rsToolRecent.Close Set rsToolRecent = Nothing %>
Time Machine Tool # Description Min Actual Max Status
No tool measurements found
" & Server.HTMLEncode(rsToolRecent("eventtime") & "") & "" & Server.HTMLEncode(rsToolRecent("machinenumber") & "") & "Tool " & rsToolRecent("toolnumber") & "" & Server.HTMLEncode(rsToolRecent("description") & "") & "" & rsToolRecent("minval") & "" & rsToolRecent("actualval") & "" & rsToolRecent("maxval") & "OOTOK
" id="uptime">
Machine Uptime

Runtime calculated from actual part cycle times within the selected date range.

<% ' Calculate uptime summary Dim rsUptimeSummary, totalRuntimeHours, totalMachines, avgUtilization strSQL2 = "SELECT COUNT(DISTINCT s.machinenumber) as machines, " & _ "ROUND(SUM(p.cycletime)/3600, 1) as total_hours, " & _ "ROUND(AVG(p.cycletime)/60, 1) as avg_cycle " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " AND p.cycletime IS NOT NULL AND p.cycletime > 0" Set rsUptimeSummary = objConn.Execute(strSQL2) If Not rsUptimeSummary.EOF Then totalMachines = CLng("0" & rsUptimeSummary("machines")) If Not IsNull(rsUptimeSummary("total_hours")) Then totalRuntimeHours = FormatNumber(CDbl(rsUptimeSummary("total_hours")), 1) Else totalRuntimeHours = "0" End If Else totalMachines = 0 totalRuntimeHours = "0" End If rsUptimeSummary.Close Set rsUptimeSummary = Nothing %>

<%=totalRuntimeHours%>

Total Runtime Hours

<%=totalMachines%>

Active Machines

<%=totalParts%>

Parts Produced
Runtime by Machine
<% ' Get uptime by machine Dim rsUptime, uptimeHours, uptimeCycle, uptimeDays, uptimeUtil, uptimeUtilClass strSQL2 = "SELECT s.machinenumber, " & _ "ROUND(SUM(p.cycletime)/3600, 1) as runtime_hours, " & _ "COUNT(*) as parts_run, " & _ "ROUND(AVG(p.cycletime)/60, 1) as avg_cycle_min, " & _ "DATEDIFF(MAX(p.programend), MIN(p.programstart)) + 1 as days_active, " & _ "MIN(p.programstart) as first_run, " & _ "MAX(p.programend) as last_run " & _ "FROM udcparts p " & _ "JOIN udcsessions s ON p.sessionid = s.sessionid " & _ whereClause & _ " AND p.cycletime IS NOT NULL AND p.cycletime > 0 " & _ "GROUP BY s.machinenumber ORDER BY runtime_hours DESC" Set rsUptime = objConn.Execute(strSQL2) If rsUptime.EOF Then Response.Write("") Else Do While Not rsUptime.EOF If Not IsNull(rsUptime("runtime_hours")) Then uptimeHours = FormatNumber(CDbl(rsUptime("runtime_hours")), 1) Else uptimeHours = "0" End If If Not IsNull(rsUptime("avg_cycle_min")) Then uptimeCycle = FormatNumber(CDbl(rsUptime("avg_cycle_min")), 1) Else uptimeCycle = "-" End If uptimeDays = CLng("0" & rsUptime("days_active")) If uptimeDays < 1 Then uptimeDays = 1 ' Calculate utilization (runtime hours / (days * 16 hours for 2 shifts) * 100) If uptimeDays > 0 And Not IsNull(rsUptime("runtime_hours")) Then uptimeUtil = Round((CDbl(rsUptime("runtime_hours")) / (uptimeDays * 16)) * 100, 1) If uptimeUtil > 100 Then uptimeUtil = 100 Else uptimeUtil = 0 End If ' Color code utilization If uptimeUtil >= 70 Then uptimeUtilClass = "badge badge-success" ElseIf uptimeUtil >= 40 Then uptimeUtilClass = "badge badge-warning" Else uptimeUtilClass = "badge badge-danger" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsUptime.MoveNext Loop End If rsUptime.Close Set rsUptime = Nothing %>
Machine Runtime (hrs) Parts Run Avg Cycle (min) Days Active Utilization
No uptime data found
" & Server.HTMLEncode(rsUptime("machinenumber") & "") & "" & uptimeHours & "" & rsUptime("parts_run") & "" & uptimeCycle & "" & uptimeDays & "" & uptimeUtil & "%
" id="itdiagnostics">
IT Diagnostics
Error Summary by Type
<% ' Get error summary by type Dim rsErrSummary, errWhereClause, errRowStyle errWhereClause = " WHERE eventtime >= '" & Replace(filterStart, "'", "''") & "' " & _ " AND eventtime <= '" & Replace(filterEnd, "'", "''") & " 23:59:59'" If filterMachine <> "" Then errWhereClause = errWhereClause & " AND machinenumber = '" & Replace(filterMachine, "'", "''") & "'" End If If filterBU <> "" Then errWhereClause = errWhereClause & " AND machinenumber IN (SELECT machinenumber FROM machines WHERE businessunitid = " & CLng(filterBU) & ")" End If strSQL2 = "SELECT errortype, COUNT(*) as cnt, COUNT(DISTINCT machinenumber) as machines, MAX(eventtime) as lasttime " & _ "FROM udcerrors " & errWhereClause & _ " GROUP BY errortype ORDER BY cnt DESC, errortype ASC LIMIT 10" Set rsErrSummary = objConn.Execute(strSQL2) If rsErrSummary.EOF Then Response.Write("") Else Do While Not rsErrSummary.EOF If CLng("0" & rsErrSummary("cnt")) > 50 Then errRowStyle = "background-color:#dc3545; color:#fff;" ElseIf CLng("0" & rsErrSummary("cnt")) > 10 Then errRowStyle = "background-color:#ffc107; color:#333;" Else errRowStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsErrSummary.MoveNext Loop End If rsErrSummary.Close Set rsErrSummary = Nothing %>
Error Type Count Machines Affected Last Occurrence
No errors found in date range
" & Server.HTMLEncode(rsErrSummary("errortype") & "") & "" & rsErrSummary("cnt") & "" & rsErrSummary("machines") & "" & Server.HTMLEncode(rsErrSummary("lasttime") & "") & "
Errors by Machine
<% ' Get errors by machine Dim rsErrMach, errMachStyle strSQL2 = "SELECT machinenumber, COUNT(*) as cnt, COUNT(DISTINCT errortype) as types, MAX(eventtime) as lasttime " & _ "FROM udcerrors " & errWhereClause & _ " GROUP BY machinenumber ORDER BY cnt DESC, machinenumber ASC LIMIT 10" Set rsErrMach = objConn.Execute(strSQL2) If rsErrMach.EOF Then Response.Write("") Else Do While Not rsErrMach.EOF If CLng("0" & rsErrMach("cnt")) > 100 Then errMachStyle = "background-color:#dc3545; color:#fff;" ElseIf CLng("0" & rsErrMach("cnt")) > 25 Then errMachStyle = "background-color:#ffc107; color:#333;" Else errMachStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsErrMach.MoveNext Loop End If rsErrMach.Close Set rsErrMach = Nothing %>
Machine Total Errors Error Types Last Error
No errors found
" & Server.HTMLEncode(rsErrMach("machinenumber") & "") & "" & rsErrMach("cnt") & "" & rsErrMach("types") & "" & Server.HTMLEncode(rsErrMach("lasttime") & "") & "
Recent Errors
<% ' Get recent errors Dim rsRecentErr, recentErrStyle strSQL2 = "SELECT eventtime, machinenumber, errortype, errormessage " & _ "FROM udcerrors " & errWhereClause & _ " ORDER BY eventtime DESC LIMIT 25" Set rsRecentErr = objConn.Execute(strSQL2) If rsRecentErr.EOF Then Response.Write("") Else Do While Not rsRecentErr.EOF If InStr(1, rsRecentErr("errortype") & "", "Exception", 1) > 0 Then recentErrStyle = "background-color:#dc3545; color:#fff;" Else recentErrStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsRecentErr.MoveNext Loop End If rsRecentErr.Close Set rsRecentErr = Nothing %>
Time Machine Type Message
No errors found
" & Server.HTMLEncode(rsRecentErr("eventtime") & "") & "" & Server.HTMLEncode(rsRecentErr("machinenumber") & "") & "" & Server.HTMLEncode(rsRecentErr("errortype") & "") & "" & Server.HTMLEncode(Left(rsRecentErr("errormessage") & "", 100)) & "
Connection Events by Machine
<% ' Get connection events by machine Dim rsConnMach, connWhereClause connWhereClause = " WHERE eventtime >= '" & Replace(filterStart, "'", "''") & "' " & _ " AND eventtime <= '" & Replace(filterEnd, "'", "''") & " 23:59:59'" If filterMachine <> "" Then connWhereClause = connWhereClause & " AND machinenumber = '" & Replace(filterMachine, "'", "''") & "'" End If If filterBU <> "" Then connWhereClause = connWhereClause & " AND machinenumber IN (SELECT machinenumber FROM machines WHERE businessunitid = " & CLng(filterBU) & ")" End If strSQL2 = "SELECT machinenumber, COUNT(*) as cnt, COUNT(DISTINCT comport) as ports, MAX(eventtime) as lasttime " & _ "FROM udcconnections " & connWhereClause & _ " GROUP BY machinenumber ORDER BY cnt DESC, machinenumber ASC LIMIT 10" Set rsConnMach = objConn.Execute(strSQL2) If rsConnMach.EOF Then Response.Write("") Else Do While Not rsConnMach.EOF Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsConnMach.MoveNext Loop End If rsConnMach.Close Set rsConnMach = Nothing %>
Machine Total Events COM Ports Used Last Event
No connection events found
" & Server.HTMLEncode(rsConnMach("machinenumber") & "") & "" & rsConnMach("cnt") & "" & rsConnMach("ports") & "" & Server.HTMLEncode(rsConnMach("lasttime") & "") & "
Recent Connection Events
<% ' Get recent connection events Dim rsRecentConn, connStyle strSQL2 = "SELECT eventtime, machinenumber, eventtype, comport, details " & _ "FROM udcconnections " & connWhereClause & _ " ORDER BY eventtime DESC LIMIT 25" Set rsRecentConn = objConn.Execute(strSQL2) If rsRecentConn.EOF Then Response.Write("") Else Do While Not rsRecentConn.EOF If rsRecentConn("eventtype") & "" = "OPEN" Then connStyle = "background-color:#28a745; color:#fff;" ElseIf rsRecentConn("eventtype") & "" = "CLOSE" Then connStyle = "background-color:#6c757d; color:#fff;" Else connStyle = "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsRecentConn.MoveNext Loop End If rsRecentConn.Close Set rsRecentConn = Nothing %>
Time Machine Event COM Port Details
No connection events found
" & Server.HTMLEncode(rsRecentConn("eventtime") & "") & "" & Server.HTMLEncode(rsRecentConn("machinenumber") & "") & "" & Server.HTMLEncode(rsRecentConn("eventtype") & "") & "" & Server.HTMLEncode(rsRecentConn("comport") & "") & "" & Server.HTMLEncode(rsRecentConn("details") & "") & "
" id="trends">
Historical Data: This data comes from daily summaries and includes all historical data beyond the 90-day retention period. Individual measurements are aggregated into daily/weekly/monthly totals.
Monthly Measurement Trend (12 Months)
Monthly OOT Rate Trend
Monthly Production Trend (Parts)
Monthly Avg Response Time (seconds)
Weekly Measurement Trend (26 Weeks)
All-Time Machine Comparison (Top 15)
Monthly Parameter Violations (CLM)
Monthly Avg Changeover Time (minutes)
Violations by Machine (All Time Top 10)
CLM Data Notes

Parameter Violations: Tracked when operators change machine parameters outside allowed limits during CLM runs. High violation counts may indicate calibration issues or training needs.

Changeover Time: Time between consecutive part runs on the same machine. Helps identify efficiency opportunities and scheduling patterns.

Note: CLM data comes from JSON files in CLM_Data folder. Violations and changeover times are only tracked for CLM sessions, not UDC log sessions.

Monthly Summary Data
<% Dim rsMonthlySummary strSQL2 = "SELECT yearmonth, SUM(measurement_count) as total_meas, SUM(oot_count) as total_oot, " & _ "ROUND(SUM(oot_count)*100.0/NULLIF(SUM(measurement_count),0), 2) as oot_rate " & _ "FROM vwudcmeasurements_monthly " If filterMachine <> "" Then strSQL2 = strSQL2 & "WHERE machinenumber = '" & Replace(filterMachine, "'", "''") & "' " End If strSQL2 = strSQL2 & "GROUP BY yearmonth ORDER BY yearmonth DESC LIMIT 24" Set rsMonthlySummary = objConn.Execute(strSQL2) Do While Not rsMonthlySummary.EOF Dim ootRateVal If IsNull(rsMonthlySummary("oot_rate")) Then ootRateVal = "0.00" Else ootRateVal = rsMonthlySummary("oot_rate") & "" End If Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") rsMonthlySummary.MoveNext Loop rsMonthlySummary.Close Set rsMonthlySummary = Nothing %>
Month Total Measurements OOT Count OOT Rate
" & Server.HTMLEncode(rsMonthlySummary("yearmonth") & "") & "" & Server.HTMLEncode(FormatNumber(rsMonthlySummary("total_meas"), 0)) & "" & Server.HTMLEncode(FormatNumber(rsMonthlySummary("total_oot"), 0)) & "" & Server.HTMLEncode(ootRateVal) & "%
<% objConn.Close %>