Asked — Edited

A Possible Feature Enhancement

@DJ Sures,

In ARC, 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 ARC 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.


ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

#1  

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." ;)

PRO
Synthiam
#2  

I understand the reasoning of having people "fiddle" with ARC and locking some controls. However, that's really out of scope for ARC, 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...


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");
      _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 "")
            ");
    }
  }
}

PRO
Synthiam
#3  

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


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);
      }
    }
  }
}

#4  

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

Thanks!

#5  

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


#************************************************
#*******************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!****************
#************************************************

:P

PRO
USA
#6  

Hello everyone.

Fixing last bugs:

Feedback/Ideas are welcome.

#7  

PTP,

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

#8  

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.

#9  

@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 :)

PRO
Synthiam
#11  

Ptp, you're the man!

#12  

I tried to find this plugin is it for download yet? thanks for making this also!

#13  

PTP hasn't made it public yet. He was just demonstrating what he has been working on and will be making public soon.

PRO
USA
#14  

Thanks for the good words.

The plugin is out !

I did some last minute fixes... i hope i didn't make it worse.

Quote:

Murphy's Quantum Law: Anything that can, could have, or will go wrong, is going wrong, all at once. If there are two or more ways to do something, and one of those ways can result in a catastrophe or pregnancy, then someone will do it.

#15  

I love the quote.

Thanks PTP. I will be up all night doing IT work which is slow and boring. I will give it a thorough testing this evening in my boredom.

PRO
Synthiam
#16  

Taking the plugin to your bedroom on the first date, Dave? Tsk tsk :D

.... the quote makes sense now ...

PRO
Synthiam
#18  

Oh wait, you wrote "boredom"....

#19  

Let me start by saying that this is an amazing plugin that I would use in its current state without any complaints. Great job PTP!

Here are a couple of things that I found. These are just things that need to be understood with using the plugin and it is logical as to why it functions the way that it does.

The script manager seems to be an all or nothing thing. For example, if I hide one element of the script manager's list of scripts (for example the Edit button on one script) it hides the entire element, meaning that the list box of scripts is hidden. This is not a big deal, just informational

It makes since that the same thing happens in the settings of the Speech Recognition control for phrases and commands. If there are multiple items in a list, you can disable the list but not a single item in the list.

This definately solves the issue that I was having with the init script being modified and works great there.

Is there any way to make the "Okay" type buttons the default button? For example, when typing a password and pressing enter, can that execute the event for "lock" or "Unlock" type actions? I do like the work you put in to make things like the lock button disabled until a password is entered.

Another thing that I don't know if it happen exactly this way or not, but here is the sequence that I believe that I did. The first thing I did was change the passwords. I used the passwords of password and admin in their proper "current password" fields. I then added what I wanted my password to be in the new password and confirm password fields. From there I hit the Save button. It told me that my Lock password had been changed and then it came up and told me that my full screen password wasn't changed due to having the wrong password. I went back and tried the password of password again in the Current Password field in the Full Screen section of the Change Passwords form and hit Save. It told me again that I didn't have the correct password. I then tried my new password in this field and it told me that I had changed my password. It looks like it did save correctly the first time but then told me the Lock password was changed, but the Full Screen password hadn't been changed.

So far, these are the only things that I see that might be able to be changed to make it more polished. By the way, if you ever get a project from me, the password is going to be the same which is "Dang, PTP continues to prove to me why he is AWESOME!"

Thanks and again, I will use this as it is even if you never make another change to the plugin. Great job.

#20  

@ptp... It works great... Thanks again for this... :)

PRO
USA
#22  

Hey,

New version released.

David:

Quote:

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.

Added.

Quote:

The script manager seems to be an all or nothing thing.

I added support for GridView cells, bear in mind uses the Cell's Row,Col Index. The DataGridView cells are not real controls, to implement the same disable effect it's too much work plus is not a clean job. So the restriction is implemented by intercepting the click event and ignoring or rejecting a cell edit event for the Textbox cell.

Quote:

Is there any way to make the "Okay" type buttons the default button

Added. It was very annoying.

Quote:

Another thing that I don't know if it happen exactly this way or not, but here is the sequence that I believe that I did.

Fixed, it was a change password bug.

#23  

@PTP,

I just tested out the changes. They work great! Thanks for the plugin and also these additions. You have outdone yourself!