As part of a larger motor control program I have a switching statement that takes the current motor's id number and assigns a name. Basically, the user enters a new name into a textbox and clicks the button(code below), and the default setting for a motor name is changed. There is a chain of motors with sequential id numbers (0 refers to all motors).
Logically (at least with my limited knowledge of C#) if the 'Conversation.Device.DeviceNumber' value is 1, the switch should go to case 1 and execute the command, and then break.
What seems to be happening, though, is that, for a given chain of motors, attempting to change the name for any of the lower numbered motors has no effect, and changing the name of the highest number changes all of the motor names. After fiddling around with the program for a while and making no progress, I'm just assuming I'm missing something obvious. Help would be awesome. As a note, I have tested the 'Conversation.Device.DeviceNumber' result, and it is giving me the correct number for each selected motor. Thanks.
private void motorRenameButton_Click(object sender, EventArgs e)
{
string newName = newNameTextBox.Text;
switch (Conversation.Device.DeviceNumber)
{
case 0:
MessageBox.Show("You have selected all motors. The name of this property cannot be changed.");
break;
case 1:
Zaber.Settings1.Default.name1 = newName;
break;
case 2:
Zaber.Settings1.Default.name2 = newName;
break;
case 3:
Zaber.Settings1.Default.name3 = newName;
break;
default:
Zaber.Settings1.Default.name6 = newName;
break;
}
Zaber.Settings1.Default.Save();
}