Skip to content

Commit

Permalink
Fixes for IS plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishamm committed Sep 24, 2024
1 parent 1bae13b commit d96cc86
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 51 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"report": "vue-cli-service build --report"
},
"dependencies": {
"@duet3d/connectors": "~3.6.0-beta.11",
"@duet3d/connectors": "~3.6.0-beta.13",
"@duet3d/monacotokens": "^3.5.3",
"@duet3d/motionanalysis": "^3.4.0",
"@duet3d/objectmodel": "~3.6.0-alpha.1",
Expand Down
29 changes: 13 additions & 16 deletions src/plugins/InputShaping/InputShaping.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ th {
<div v-show="isInputShapingEnabled" class="content flex-grow-1 pa-2">
<input-shaping-chart :frequencies="currentFrequencies" :ringing-frequency="frequency"
:input-shapers="inputShapers" :input-shaper-frequency="frequency"
:input-shaper-damping="damping" :custom-amplitudes="customAmplitudes"
:custom-durations="customDurations" />
:input-shaper-damping="damping" />
</div>
</div>
</v-tab-item>
Expand Down Expand Up @@ -97,8 +96,6 @@ th {
:input-shapers="inputShapers"
:input-shaper-frequency="frequency"
:input-shaper-damping="damping"
:custom-amplitudes="customAmplitudes"
:custom-durations="customDurations"
:estimate-shaper-effect="estimateShaperEffect"
:show-values="showOriginalValues" />
</v-card>
Expand Down Expand Up @@ -162,7 +159,7 @@ th {
</td>
<td>
<v-text-field type="number" min="0" step="0.1"
:value="customDurations[index] * 1000"
:value="customDelays[index] * 1000"
@input="setCustomDuration(index, $event)" class="pt-0 mb-1"
hide-details />
</td>
Expand Down Expand Up @@ -270,23 +267,23 @@ export default {
set(value) {
if (this.customAmplitudes.length > value) {
this.customAmplitudes.splice(value);
this.customDurations.splice(value);
this.customDelays.splice(value);
} else {
for (let i = this.customAmplitudes.length; i < value; i++) {
this.customAmplitudes.push(0);
this.customDurations.push(0);
this.customDelays.push(0);
}
}
}
},
canConfigureCustom() {
return this.numCustomCoefficients > 0 && this.customAmplitudes.every(amplitude => amplitude > 0) && this.customDurations.every(duration => duration > 0);
return this.numCustomCoefficients > 0 && this.customAmplitudes.every(amplitude => amplitude > 0) && this.customDelays.every(duration => duration > 0);
},
customShaperCode() {
if (this.inputShapers.includes('custom') && this.canConfigureCustom) {
const amplitudes = this.customAmplitudes.map(amplitude => amplitude.toFixed(3)).reduce((a, b) => a + ':' + b);
const durations = this.customDurations.map(duration => duration.toFixed(4)).reduce((a, b) => a + ':' + b);
return `M593 P"custom" H${amplitudes} T${durations}`;
const delays = this.customDelays.map(duration => duration.toFixed(4)).reduce((a, b) => a + ':' + b);
return `M593 P"custom" H${amplitudes} T${delays}`;
}
return '';
},
Expand All @@ -304,7 +301,7 @@ export default {
inputShapers: [],
customAmplitudes: [],
customDurations: [],
customDelays: [],
customMenu: false,
configuringCustomShaper: false,
frequency: 0,
Expand Down Expand Up @@ -344,7 +341,7 @@ export default {
setCustomDuration(index, value) {
const val = parseFloat(value);
if (!isNaN(val) && val >= 0) {
Vue.set(this.customDurations, index, val / 1000);
Vue.set(this.customDelays, index, val / 1000);
}
},
copy() {
Expand Down Expand Up @@ -421,7 +418,7 @@ export default {
this.frequency = this.shaping.frequency;
this.damping = this.shaping.damping;
this.customAmplitudes = this.shaping.amplitudes.slice();
this.customDurations = this.shaping.durations.slice();
this.customDelays = this.shaping.delays.slice();
// Keep track of file changes
this.$root.$on(Events.filesOrDirectoriesChanged, this.filesOrDirectoriesChanged);
Expand All @@ -441,7 +438,7 @@ export default {
if (to === 'custom') {
this.customAmplitudes = this.shaping.amplitudes.slice();
this.customDurations = this.shaping.durations.slice();
this.customDelays = this.shaping.delays.slice();
}
}
},
Expand All @@ -453,11 +450,11 @@ export default {
}
}
},
'shaping.durations': {
'shaping.delays': {
deep: true,
handler(to) {
if (!this.inputShapers.includes('custom') || this.shaping.type === 'custom') {
this.customDurations = to.slice();
this.customDelays = to.slice();
}
}
},
Expand Down
18 changes: 9 additions & 9 deletions src/plugins/InputShaping/InputShapingChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export default {
inputShaperDamping: Number, // damping factor to use when computing input shaper damping curves
customAmplitudes: Array, // amplitudes for the computation of the custom input shaper
customDurations: Array, // durations for the computation of the custom input shaper
customDelays: Array, // delays for the computation of the custom input shaper
estimateShaperEffect: Boolean // show estimated shaper effect
},
computed: {
...mapState('settings', ['darkTheme']),
showReduction() { return ((this.amplitudes && this.durations) || (!!this.inputShapers && this.inputShapers.length > 0)) && !this.estimateShaperEffect; },
showReduction() { return ((this.amplitudes && this.delays) || (!!this.inputShapers && this.inputShapers.length > 0)) && !this.estimateShaperEffect; },
resolution() { return (this.frequencies && this.frequencies.length > 2) ? (this.frequencies[1] - this.frequencies[0]) : 0; },
lineAtPoint() {
let point = -1;
Expand Down Expand Up @@ -323,8 +323,8 @@ export default {
}
// Compute the damping curve for custom parameters
if (this.inputShapers.includes('custom') && this.frequencies && this.frequencies.length > 0 && this.customAmplitudes && this.customDurations && this.customAmplitudes.length > 0 && this.customDurations.length > 0) {
const damping = getInputShaperDamping(this.frequencies, this.customAmplitudes, this.customDurations);
if (this.inputShapers.includes('custom') && this.frequencies && this.frequencies.length > 0 && this.customAmplitudes && this.customDelays && this.customAmplitudes.length > 0 && this.customDelays.length > 0) {
const damping = getInputShaperDamping(this.frequencies, this.customAmplitudes, this.customDelays);
if (this.estimateShaperEffect) {
for (let key in this.value) {
const dataset = {
Expand Down Expand Up @@ -505,10 +505,10 @@ export default {
customAmplitudes: {
deep: true,
handler() {
if (this.customAmplitudes && this.customDurations) {
if (this.customAmplitudes && this.customDelays) {
for (let dataset in this.chart.data.datasets) {
if (dataset.isCustom) {
dataset.data = getInputShaperDamping(this.frequencies, this.customAmplitudes, this.customDurations);
dataset.data = getInputShaperDamping(this.frequencies, this.customAmplitudes, this.customDelays);
this.update();
return;
}
Expand All @@ -517,13 +517,13 @@ export default {
}
}
},
customDurations: {
customDelays: {
deep: true,
handler() {
if (this.customAmplitudes && this.customDurations) {
if (this.customAmplitudes && this.customDelays) {
for (let dataset in this.chart.data.datasets) {
if (dataset.isCustom) {
dataset.data = getInputShaperDamping(this.frequencies, this.customAmplitudes, this.customDurations);
dataset.data = getInputShaperDamping(this.frequencies, this.customAmplitudes, this.customDelays);
this.update();
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/InputShaping/RecordMotionProfileDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<li v-show="frequency !== null">Shaper Frequency: {{ frequency }}</li>
<li v-show="damping !== null">Damping Factor: {{ damping }}</li>
<li v-show="amplitudes !== null">Amplitudes: {{ amplitudes }}</li>
<li v-show="durations !== null">Durations: {{ durations }}</li>
<li v-show="delays !== null">Delays: {{ delays }}</li>
</ul>

<v-alert :value="accelerometers.length === 0" dense text type="error" class="my-3">
Expand Down Expand Up @@ -266,8 +266,8 @@ export default {
amplitudes() {
return (this.move.shaping.type === 'custom') ? this.move.shaping.amplitudes.map(amplitude => amplitude.toString()).reduce((a, b) => a + ', ' + b) : null;
},
durations() {
return (this.move.shaping.type === 'custom') ? this.move.shaping.durations.map(duration => (duration / 1000).toFixed(3) + 'ms').reduce((a, b) => a + ', ' + b) : null;
delays() {
return (this.move.shaping.type === 'custom') ? this.move.shaping.delays.map(duration => (duration / 1000).toFixed(3) + 'ms').reduce((a, b) => a + ', ' + b) : null;
},
allAxesHomed() { return !this.move.axes.some(axis => axis.visible && !axis.homed); },
accelerometers() {
Expand Down
18 changes: 0 additions & 18 deletions src/store/machine/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,6 @@ export default function (connector: BaseConnector | null): MachineModel {
}
},
mutations: {
addPlugin(state, plugin: Plugin) {
typedState.plugins.set(plugin.id, plugin);

const clonedPlugins = new Map<string, Plugin>();
for (const [key, value] of typedState.plugins) {
clonedPlugins.set(key, JSON.parse(JSON.stringify(value)));
}
Vue.set(state, "plugins", clonedPlugins);
},
removePlugin(state, plugin: Plugin) {
typedState.plugins.delete(plugin.id);

const clonedPlugins = new Map<string, Plugin>();
for (const [key, value] of typedState.plugins) {
clonedPlugins.set(key, JSON.parse(JSON.stringify(value)));
}
Vue.set(state, "plugins", clonedPlugins);
},
update(state, data: any) {
// Check for i18n actions
if (data.state instanceof Object) {
Expand Down

0 comments on commit d96cc86

Please sign in to comment.