A Possible Feature Enhancement

 
#1

@DJ Sures,

In EZ-Builder, could there be a "lock" added to controls (specifically scripts) that would require a user to unlock the control to make changes to it?

Here is my logic and why it might be a good idea. On custom robots like an InMoov, setting minimum and maximum servo positions is pretty critical. This is normally done in an init script. This lock would prevent someone from making changes to the script without expressly knowing that they are making changes to that script. It is kind of like changing settings in Linux or Mac OS. The user would unlock the script to make it editable.

I haven't had this issue recently but can see the following scenario. I will be taking my InMoov to shows and want people to be able to see and "mess with" the EZ-Builder project. The main concern that I have with doing this is someone changing the init script which would set the min and max positions for the servos, which then could be damaging to the robot. The lock wouldn't absolutely stop this from happening, but it would make it less likely.

The thought is that the lock would be unlocked by default, but the user could then lock the control using this feature. The same type of thing could be incorporated into other control settings, but I think scripts would be the most useful. Anyway, it is just a thought that I had this morning and thought I would bring it up.

#2

Ewww, I could totally see that being handy in demonstrations. Might be good in classrooms too to help instructors limit what code students can edit.

Not only a good idea, but it's also the LAW....

Law 3 of Robotics, "A robot must protect its own existence as long as such protection does not conflict with the First or Second Law." Winky

#3

I understand the reasoning of having people "fiddle" with EZ-Builder and locking some controls. However, that's really out of scope for EZ-Builder, unfortunately - specifically the amount of effort to implement into the GUI framework for an incredibly rare scenario.

What I can suggest is putting controls that people CAN interact with on the second or third desktop.

Or, if you have a initialization script or something that you don't want people to change the values, it might be worthwhile to create the script as a plugin. It would only be a few lines of code.

Such as...

Code:


using System;
using System.Windows.Forms;

namespace Lock_Init_Plugin {

public partial class FormLockedScript : EZ_Builder.UCForms.FormPluginMaster {

EZ_Builder.Scripting.Executor _executor;

public FormLockedScript() {

InitializeComponent();
}

private void FormLockedScript_Load(object sender, EventArgs e) {

// Bind an event to the ez-b's connection change when the plugin form is loaded
EZ_Builder.EZBManager.EZBs[0].OnConnectionChange += FormLockedScript_OnConnectionChange;

// Create an instance of the executor to run the script
_executor = new EZ_Builder.Scripting.Executor("My super secret script"Winky;
_executor.OnDone += _executor_OnDone;
_executor.OnStart += _executor_OnStart;
}

private void _executor_OnStart(string compilerName) {

EZ_Builder.EZBManager.Log("{0} started", compilerName);
}

private void _executor_OnDone(string compilerName, TimeSpan timeTook) {

EZ_Builder.EZBManager.Log("{0} stopped (took {1})", compilerName, timeTook);
}

private void FormLockedScript_FormClosing(object sender, FormClosingEventArgs e) {

// Disconnect the event from the connection change when the plugin is closed
EZ_Builder.EZBManager.EZBs[0].OnConnectionChange -= FormLockedScript_OnConnectionChange;
}

private void FormLockedScript_OnConnectionChange(bool isConnected) {

if (isConnected)
_executor.StartScriptASync(@"
SetServoMin(d0, 10)
SetServoMax(d0, 100)
Say(""I am connected "")
");
}
}
}

#4

Or, since you don't actually need to run a script if all you are doing is setting limits and init positions... You can do it directly in code like so in your plugin

Code:


using System;
using System.Windows.Forms;

namespace Lock_Init_Plugin {

public partial class FormLockedScript : EZ_Builder.UCForms.FormPluginMaster {

public FormLockedScript() {

InitializeComponent();
}

private void FormLockedScript_Load(object sender, EventArgs e) {

// Bind an event to the ez-b's connection change when the plugin form is loaded
EZ_Builder.EZBManager.EZBs[0].OnConnectionChange += FormLockedScript_OnConnectionChange;
}

private void FormLockedScript_FormClosing(object sender, FormClosingEventArgs e) {

// Disconnect the event from the connection change when the plugin is closed
EZ_Builder.EZBManager.EZBs[0].OnConnectionChange -= FormLockedScript_OnConnectionChange;
}

private void FormLockedScript_OnConnectionChange(bool isConnected) {

if (isConnected) {

// Set servo ranges
EZ_Builder.EZBManager.EZBs[0].Servo.SetServoMax(EZ_B.Servo.ServoPortEnum.D0, 10);
EZ_Builder.EZBManager.EZBs[0].Servo.SetServoMax(EZ_B.Servo.ServoPortEnum.D1, 100);

// Initialize servo positions
EZ_Builder.EZBManager.EZBs[0].Servo.SetServoPosition(EZ_B.Servo.ServoPortEnum.D0, 50);
}
}
}
}

#5

Thanks for considering it. I like the thought of making the script as a plugin and that solves the issue.

Thanks!

#6

Or a much lazier solution would be to add something like this to the top of any highly important script:

Code:


#************************************************
#*******************WARNING**********************
#**Editing any code in this script is forbidden**
#*******STOP NOW AND CLOSE THIS SCRIPT***********
#***If you break my robot, you will be forced****
#**********to build me a new one!****************
#************************************************



Tongue

#7

Hello everyone.

Fixing last bugs:



Feedback/Ideas are welcome.

#8

PTP,

Internet is down at the house. I will check this out when it comes back up.

#9

You, my friend, are the MAN! Awesome plugin!

The only thing that I can see that would be nice is if there were a way to see a list of everything that is locked or hidden. Not necessary, just a nice to have.

Thank you PTP and well done.

#10

@ptp Outstanding! Well done... One of the best plugins ever. I will definitely be using this plugin for most if not all of my projects...

Thanks Smile