viewof motorCount = Inputs.range([10, 500], {
label: "Number of Motors:",
step: 10,
value: 100
})
viewof avgReplacementCost = Inputs.range([5000, 50000], {
label: "Average Motor Replacement Cost ($):",
step: 1000,
value: 15000
})
viewof historicalFailures = Inputs.range([1, 50], {
label: "Historical Failures per Year:",
step: 1,
value: 8
})
viewof downtimeHours = Inputs.range([4, 72], {
label: "Average Downtime per Failure (hours):",
step: 4,
value: 12
})
viewof downtimeCost = Inputs.range([1000, 20000], {
label: "Downtime Cost per Hour ($):",
step: 1000,
value: 5000
})
viewof sensorCostPerMotor = Inputs.range([100, 1000], {
label: "Sensor Cost per Motor ($):",
step: 50,
value: 300
})
viewof softwareCost = Inputs.range([10000, 200000], {
label: "Software Platform Cost ($):",
step: 10000,
value: 50000
})
viewof integrationMultiplier = Inputs.range([1, 5], {
label: "Integration Cost Multiplier (x hardware):",
step: 0.5,
value: 2,
format: x => `${x}x`
})
viewof annualOperating = Inputs.range([10000, 100000], {
label: "Annual Operating Cost ($):",
step: 5000,
value: 36000
})
viewof predictionRate = Inputs.range([0.50, 0.95], {
label: "Expected share of failures prevented:",
step: 0.05,
value: 0.85,
format: x => `${(x * 100).toFixed(0)}%`
})
roiCalculation = {
// Current state costs
const replacementCosts = historicalFailures * avgReplacementCost;
const downtimeCosts = historicalFailures * downtimeHours * downtimeCost;
const annualFailureCost = replacementCosts + downtimeCosts;
// Investment costs
const hardwareCost = motorCount * sensorCostPerMotor;
const integrationCost = hardwareCost * integrationMultiplier;
const totalInvestment = hardwareCost + softwareCost + integrationCost;
// Savings
const preventedFailures = historicalFailures * predictionRate;
const savedReplacementCost = preventedFailures * avgReplacementCost;
const savedDowntimeCost = preventedFailures * downtimeHours * downtimeCost;
const annualSavings = savedReplacementCost + savedDowntimeCost;
const netAnnualSavings = annualSavings - annualOperating;
// ROI metrics
const paybackMonths = netAnnualSavings > 0 ? totalInvestment / netAnnualSavings * 12 : null;
const roi = (netAnnualSavings / totalInvestment) * 100;
const fiveYearNetBenefit = netAnnualSavings * 5 - totalInvestment;
return {
annualFailureCost,
totalInvestment,
annualSavings,
netAnnualSavings,
paybackMonths,
roi,
fiveYearNetBenefit,
preventedFailures
};
}
html`<div style="background: linear-gradient(135deg, #2C3E50 0%, #3498DB 100%); color: white; padding: 25px; border-radius: 10px; margin: 20px 0;">
<h3 style="margin-top: 0;">ROI Analysis Results</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-top: 20px;">
<div style="background: rgba(255,255,255,0.15); padding: 15px; border-radius: 8px;">
<div style="opacity: 0.9; font-size: 0.85em;">Annual Failure Cost (Current)</div>
<div style="font-size: 1.6em; font-weight: bold; margin-top: 5px;">
$${roiCalculation.annualFailureCost.toLocaleString()}
</div>
</div>
<div style="background: rgba(255,255,255,0.15); padding: 15px; border-radius: 8px;">
<div style="opacity: 0.9; font-size: 0.85em;">Total Investment</div>
<div style="font-size: 1.6em; font-weight: bold; margin-top: 5px;">
$${roiCalculation.totalInvestment.toLocaleString()}
</div>
</div>
<div style="background: rgba(255,255,255,0.15); padding: 15px; border-radius: 8px;">
<div style="opacity: 0.9; font-size: 0.85em;">Net Annual Savings</div>
<div style="font-size: 1.6em; font-weight: bold; margin-top: 5px; color: #16A085;">
$${roiCalculation.netAnnualSavings.toLocaleString()}
</div>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 15px;">
<div style="background: rgba(255,255,255,0.2); padding: 20px; border-radius: 8px;">
<div style="opacity: 0.9; font-size: 0.9em;">Payback Period</div>
<div style="font-size: 2.5em; font-weight: bold; margin-top: 5px;">
${roiCalculation.paybackMonths === null ? 'No payback at these assumptions' : roiCalculation.paybackMonths.toFixed(1) + ' mo'}
</div>
<div style="opacity: 0.8; font-size: 0.85em; margin-top: 5px;">
${roiCalculation.paybackMonths === null ? 'Annual net savings are non-positive' : (roiCalculation.paybackMonths / 12).toFixed(1) + ' years'}
</div>
</div>
<div style="background: rgba(255,255,255,0.2); padding: 20px; border-radius: 8px;">
<div style="opacity: 0.9; font-size: 0.9em;">ROI (First Year)</div>
<div style="font-size: 2.5em; font-weight: bold; margin-top: 5px; color: #16A085;">
${roiCalculation.roi.toFixed(0)}%
</div>
<div style="opacity: 0.8; font-size: 0.85em; margin-top: 5px;">
Return on investment
</div>
</div>
</div>
<div style="background: rgba(255,255,255,0.15); padding: 15px; border-radius: 8px; margin-top: 15px;">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div>
<div style="opacity: 0.9; font-size: 0.85em;">5-Year Undiscounted Net Benefit</div>
<div style="font-size: 1.8em; font-weight: bold; margin-top: 5px;">
$${roiCalculation.fiveYearNetBenefit.toLocaleString()}
</div>
</div>
<div style="text-align: right;">
<div style="opacity: 0.9; font-size: 0.85em;">Prevented Failures/Year</div>
<div style="font-size: 1.8em; font-weight: bold; margin-top: 5px;">
${roiCalculation.preventedFailures.toFixed(1)}
</div>
</div>
</div>
</div>
</div>`