trying to fix microsteps fix
This commit is contained in:
@@ -122,7 +122,20 @@ module.exports = {
|
|||||||
attached: function() {
|
attached: function() {
|
||||||
// Sync all state values with motor config when component mounts
|
// Sync all state values with motor config when component mounts
|
||||||
// This ensures UI shows correct values even if rotary was toggled on another page
|
// This ensures UI shows correct values even if rotary was toggled on another page
|
||||||
|
|
||||||
|
// Debug: Log current state values before sync
|
||||||
|
console.log(`DEBUG: Motor ${this.index} state values on mount:`);
|
||||||
|
console.log(` current_step_angle (${this.index}sa):`, this.current_step_angle);
|
||||||
|
console.log(` current_microsteps (${this.index}mi):`, this.current_microsteps);
|
||||||
|
console.log(` current_travel_per_rev (${this.index}tr):`, this.current_travel_per_rev);
|
||||||
|
|
||||||
this.syncStateToConfig();
|
this.syncStateToConfig();
|
||||||
|
|
||||||
|
// Debug: Log motor config values after sync
|
||||||
|
console.log(`DEBUG: Motor ${this.index} config values after sync:`);
|
||||||
|
console.log(` motor step-angle:`, this.motor['step-angle']);
|
||||||
|
console.log(` motor microsteps:`, this.motor['microsteps']);
|
||||||
|
console.log(` motor travel-per-rev:`, this.motor['travel-per-rev']);
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
@@ -217,42 +230,62 @@ module.exports = {
|
|||||||
|
|
||||||
const motor_axes = ["X", "Y", "Z", "A", "B", "C"];
|
const motor_axes = ["X", "Y", "Z", "A", "B", "C"];
|
||||||
|
|
||||||
// Sync all motor properties that have corresponding state values
|
// Define mapping between state properties and motor config properties
|
||||||
if (this.current_axis !== undefined && motor_axes[this.current_axis] !== this.motor['axis']) {
|
const stateToMotorMapping = [
|
||||||
this.motor['axis'] = motor_axes[this.current_axis];
|
{
|
||||||
|
stateKey: 'current_axis',
|
||||||
|
motorKey: 'axis',
|
||||||
|
transform: (value) => motor_axes[value]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stateKey: 'current_max_velocity',
|
||||||
|
motorKey: 'max-velocity'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stateKey: 'current_max_soft_limit',
|
||||||
|
motorKey: 'max-soft-limit'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stateKey: 'current_min_soft_limit',
|
||||||
|
motorKey: 'min-soft-limit'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stateKey: 'current_max_accel',
|
||||||
|
motorKey: 'max-accel'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stateKey: 'current_max_jerk',
|
||||||
|
motorKey: 'max-jerk'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stateKey: 'current_step_angle',
|
||||||
|
motorKey: 'step-angle'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stateKey: 'current_travel_per_rev',
|
||||||
|
motorKey: 'travel-per-rev'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stateKey: 'current_microsteps',
|
||||||
|
motorKey: 'microsteps'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// Sync all properties using the mapping
|
||||||
|
stateToMotorMapping.forEach(({ stateKey, motorKey, transform }) => {
|
||||||
|
const stateValue = this[stateKey];
|
||||||
|
|
||||||
|
if (stateValue === undefined) {
|
||||||
|
return; // Skip if state value is not defined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.current_max_velocity !== undefined && this.current_max_velocity !== this.motor['max-velocity']) {
|
const transformedValue = transform ? transform(stateValue) : stateValue;
|
||||||
this.motor['max-velocity'] = this.current_max_velocity;
|
const currentMotorValue = this.motor[motorKey];
|
||||||
}
|
|
||||||
|
|
||||||
if (this.current_max_soft_limit !== undefined && this.current_max_soft_limit !== this.motor['max-soft-limit']) {
|
if (transformedValue !== currentMotorValue) {
|
||||||
this.motor['max-soft-limit'] = this.current_max_soft_limit;
|
this.motor[motorKey] = transformedValue;
|
||||||
}
|
|
||||||
|
|
||||||
if (this.current_min_soft_limit !== undefined && this.current_min_soft_limit !== this.motor['min-soft-limit']) {
|
|
||||||
this.motor['min-soft-limit'] = this.current_min_soft_limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.current_max_accel !== undefined && this.current_max_accel !== this.motor['max-accel']) {
|
|
||||||
this.motor['max-accel'] = this.current_max_accel;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.current_max_jerk !== undefined && this.current_max_jerk !== this.motor['max-jerk']) {
|
|
||||||
this.motor['max-jerk'] = this.current_max_jerk;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.current_step_angle !== undefined && this.current_step_angle !== this.motor['step-angle']) {
|
|
||||||
this.motor['step-angle'] = this.current_step_angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.current_travel_per_rev !== undefined && this.current_travel_per_rev !== this.motor['travel-per-rev']) {
|
|
||||||
this.motor['travel-per-rev'] = this.current_travel_per_rev;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.current_microsteps !== undefined && this.current_microsteps !== this.motor['microsteps']) {
|
|
||||||
this.motor['microsteps'] = this.current_microsteps;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -740,6 +740,19 @@ class RotaryHandler(bbctrl.APIHandler):
|
|||||||
# Force a complete reload to ensure all values are properly encoded and sent to frontend
|
# Force a complete reload to ensure all values are properly encoded and sent to frontend
|
||||||
config.reload()
|
config.reload()
|
||||||
|
|
||||||
|
# Debug: Log the current state values for motor 2 to verify they're being set
|
||||||
|
log.info(f"DEBUG: After reload - Motor 2 state values:")
|
||||||
|
log.info(f" 2sa (step-angle): {ctrl.state.get('2sa')}")
|
||||||
|
log.info(f" 2mi (microsteps): {ctrl.state.get('2mi')}")
|
||||||
|
log.info(f" 2tr (travel-per-rev): {ctrl.state.get('2tr')}")
|
||||||
|
|
||||||
|
# TARGETED FIX: Explicitly ensure microsteps gets sent to state
|
||||||
|
# This addresses potential issues with microsteps being treated as machine variable
|
||||||
|
motor_2_final = motors[2]
|
||||||
|
ctrl.state.set('2mi', motor_2_final.get('microsteps'))
|
||||||
|
ctrl.state.set('2sa', motor_2_final.get('step-angle'))
|
||||||
|
ctrl.state.set('2tr', motor_2_final.get('travel-per-rev'))
|
||||||
|
|
||||||
# Explicitly trigger state notification to ensure frontend gets updates
|
# Explicitly trigger state notification to ensure frontend gets updates
|
||||||
# This forces immediate WebSocket notification of all state changes
|
# This forces immediate WebSocket notification of all state changes
|
||||||
ctrl.state._notify()
|
ctrl.state._notify()
|
||||||
|
|||||||
Reference in New Issue
Block a user