Skip to content

Commit 267ab0e

Browse files
committed
Added MRR calculator
1 parent 9a8c131 commit 267ab0e

File tree

4 files changed

+59
-6
lines changed

4 files changed

+59
-6
lines changed

src/webviews/apps/calc/calc.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<vscode-panels aria-label="with Complex Content">
88
<vscode-panel-tab id="tab-1">SPEEDS</vscode-panel-tab>
99
<vscode-panel-tab id="tab-2">FEEDS</vscode-panel-tab>
10+
<vscode-panel-tab id="tab-3">MRR</vscode-panel-tab>
1011

1112
<vscode-panel-view id="view-1">
1213
<section class="row">
@@ -66,8 +67,18 @@ <h3>Chip Load</h3>
6667
<span class="units"></span>
6768
</section>
6869
</vscode-panel-view>
70+
<vscode-panel-view id="view-3">
71+
<section class="row">
72+
<section id="mrr" class="calculator">
73+
<vscode-text-field id="mrr-ap" placeholder="Axial Depth of Cut" size="15">A<sub>p</sub> - Axial Depth of Cut</vscode-text-field>
74+
<vscode-text-field id="mrr-ae" placeholder="Radial Depth of Cut" size="15">A<sub>e</sub> - Radial Depth of Cut</vscode-text-field>
75+
<vscode-text-field id="mrr-fr" placeholder="Feedrate" size="15">Feedrate</vscode-text-field>
76+
<label class="results">Metal Removal Rate</label><span id="mrr-results" class="results"></span>
77+
<vscode-button id="mrr-calc-btn">Calculate</vscode-button>
78+
</section>
79+
</section>
80+
</vscode-panel-view>
6981
</vscode-panels>
70-
7182
</div>
7283
{bootstrap}
7384
</body>

src/webviews/apps/calc/calc.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ span.results {
6868
padding: 5px;
6969
}
7070

71+
#mrr-results {
72+
width: 130px;
73+
}
74+
7175
section.calculator > vscode-button {
7276
margin-top: 1rem;
7377
}

src/webviews/apps/calc/calc.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,25 @@ export class CalcApp extends GWebviewApp {
6161
results: document.getElementById('fr-results') as HTMLSpanElement,
6262
};
6363

64+
// Populate Chipload Calculator
6465
this._calcDom.chipLoad = {
6566
btn: document.getElementById('cl-calc-btn') as HTMLElement,
66-
ipm: document.getElementById('cl-ipm')?.shadowRoot?.getElementById('control') as HTMLInputElement,
67+
feedRate: document.getElementById('cl-ipm')?.shadowRoot?.getElementById('control') as HTMLInputElement,
6768
rpm: document.getElementById('cl-rpm')?.shadowRoot?.getElementById('control') as HTMLInputElement,
6869
numFlutes: document
6970
.getElementById('cl-num-flutes')
7071
?.shadowRoot?.getElementById('control') as HTMLInputElement,
7172
results: document.getElementById('cl-results') as HTMLSpanElement,
7273
};
74+
75+
// Populate MRR Calculator
76+
this._calcDom.mrr = {
77+
btn: document.getElementById('mrr-calc-btn') as HTMLElement,
78+
axialDepth: document.getElementById('mrr-ap')?.shadowRoot?.getElementById('control') as HTMLInputElement,
79+
radialDepth: document.getElementById('mrr-ae')?.shadowRoot?.getElementById('control') as HTMLInputElement,
80+
feedRate: document.getElementById('mrr-fr')?.shadowRoot?.getElementById('control') as HTMLInputElement,
81+
results: document.getElementById('mrr-results') as HTMLSpanElement,
82+
};
7383
}
7484

7585
protected onMsgReceived(e: MessageEvent<WebviewMsg>): void {
@@ -165,20 +175,36 @@ export class CalcApp extends GWebviewApp {
165175

166176
case 'cl-calc-btn': {
167177
if (this._calcDom.chipLoad) {
168-
const ipm = Math.abs(Number(this._calcDom.chipLoad.ipm.value));
178+
const feedRate = Math.abs(Number(this._calcDom.chipLoad.feedRate.value));
169179
const rpm = Math.abs(Number(this._calcDom.chipLoad.rpm.value));
170180
const numFlutes = Math.abs(Number(this._calcDom.chipLoad.numFlutes.value));
171181

172-
this._calcDom.chipLoad.ipm.value = ipm ? ipm.toString() : '';
182+
this._calcDom.chipLoad.feedRate.value = feedRate ? feedRate.toString() : '';
173183
this._calcDom.chipLoad.rpm.value = rpm ? rpm.toString() : '';
174184
this._calcDom.chipLoad.numFlutes.value = numFlutes ? numFlutes.toString() : '';
175185

176-
result = this._calcChipLoad(ipm, rpm, numFlutes);
186+
result = this._calcChipLoad(feedRate, rpm, numFlutes);
177187

178188
this._displayResults(result, this._calcDom.chipLoad);
179189
}
180190
break;
181191
}
192+
193+
case 'mrr-calc-btn': {
194+
if (this._calcDom.mrr) {
195+
const axialDepth = Math.abs(Number(this._calcDom.mrr.axialDepth.value));
196+
const radialDepth = Math.abs(Number(this._calcDom.mrr.radialDepth.value));
197+
const feedRate = Math.abs(Number(this._calcDom.mrr.feedRate.value));
198+
199+
this._calcDom.mrr.axialDepth.value = axialDepth ? axialDepth.toString() : '';
200+
this._calcDom.mrr.radialDepth.value = radialDepth ? radialDepth.toString() : '';
201+
this._calcDom.mrr.feedRate.value = feedRate ? feedRate.toString() : '';
202+
203+
result = this._calcMRR(axialDepth, radialDepth, feedRate);
204+
205+
this._displayResults(result, this._calcDom.mrr);
206+
}
207+
}
182208
}
183209
}
184210
}
@@ -245,6 +271,10 @@ export class CalcApp extends GWebviewApp {
245271
private _calcChipLoad(feedRate: number, rpm: number, numFlutes: number): number | undefined {
246272
return feedRate / rpm / numFlutes;
247273
}
274+
275+
private _calcMRR(axialDepth: number, radialDepth: number, feedRate: number): number | undefined {
276+
return feedRate * radialDepth * axialDepth;
277+
}
248278
}
249279

250280
new CalcApp();

src/webviews/apps/calc/calc.types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,19 @@ export interface ICalcDom {
2929

3030
chipLoad?: {
3131
btn: HTMLElement;
32-
ipm: HTMLInputElement;
32+
feedRate: HTMLInputElement;
3333
rpm: HTMLInputElement;
3434
numFlutes: HTMLInputElement;
3535
results: HTMLSpanElement;
3636
};
37+
38+
mrr?: {
39+
btn: HTMLElement;
40+
axialDepth: HTMLInputElement;
41+
radialDepth: HTMLInputElement;
42+
feedRate: HTMLInputElement;
43+
results: HTMLSpanElement;
44+
};
3745
}
3846

3947
export type TCalcDom = ICalcDom[keyof ICalcDom];

0 commit comments

Comments
 (0)