Example: Saving/Loading Configuration
In all plugins, there is a _cf variable which is provided by the inherited class which defines the Form. The _cf (configuration file) contains the data saved with your project. The _cf.STORAGE[key] is where your plugin configuration is kept. However, due to ARC providing the UCServoSelection user control, there is also a _cf.SERVOS[key] to store servo configuration.
The UCServoSelection user control is the common displayed control across all configuration screens in EZ-Builder. This user control allows configuration of servo ports, min and max distances. As well as multi servo support, etc.. So, if your plugin is to use the UCServoSelection, we highly recommend doing so. To move servos with UCServoSelection configuration data, the example source code in the above mentioned project should be reviewed. In short, it's easy to pass UCServoSelection.Config() data to the ARC.EZBManager.SetServoPosition(), which will take care of the magic - including relationship scaling between multiple servos, min, max and inverted options from UCServoSelection.
Configuration settings must be initialized with default values in the SetConfiguration override. This will ensure that when your plugin is loaded, there is some default configuration data assigned to the keys. Because the data is initialized using the _cf.STORAGE.AddIfNotExist(), the default data will only be added if the key doesn't exist. If the key does exist, following the user loading a project with saved configuration data, the default configuration will not be applied to the key. As demonstrated...
public override void SetConfiguration(EZ_Builder.Config.Sub.PluginV1 cf) {
cf.SERVOS.AddIfNotExist(ConfigurationDictionary._HORIZONTAL_SERVOS, new EZ_Builder.Config.Sub.ServoDescriptor[] { });
cf.SERVOS.AddIfNotExist(ConfigurationDictionary._VERTICAL_SERVOS, new EZ_Builder.Config.Sub.ServoDescriptor[] { });
cf.STORAGE.AddIfNotExist(ConfigurationDictionary._HORIZONTAL_DEGREES, 0.14m);
cf.STORAGE.AddIfNotExist(ConfigurationDictionary._VERTICAL_DEGREES, 0.14m);
cf.STORAGE.AddIfNotExist(ConfigurationDictionary._EDGE_ENABLED, true);
cf.STORAGE.AddIfNotExist(ConfigurationDictionary._EDGE_SIZE, 10);
base.SetConfiguration(cf);
}
The base.SetConfiguration in the above example is necessary to set the configuration with the inherited base. This ensures the initialized configuration is applied.
Also in the above example, the ConfigurationDictionary is a class which contains read-only static strings to reference the resource keys. We use these strings so the configuration data can be referenced without worrying about spelling mistakes where ever the data is to be accessed. Here is a look at the above example ConfigurationDictionary...
public class ConfigurationDictionary {
public static readonly string _HORIZONTAL_SERVOS = "horizontal servos";
public static readonly string _VERTICAL_SERVOS = "vertical servos";
public static readonly string _HORIZONTAL_DEGREES = "horizontal degrees";
public static readonly string _VERTICAL_DEGREES = "vertical degrees";
public static readonly string _EDGE_SIZE = "edge size";
public static readonly string _EDGE_ENABLED = "edge enabled";
}
Now to use the configuration data from the _cf in your project, simply cast the object from the _cf.STORAGE to the correct type. For _cf.SERVOS, pass the key result directly into the ARC.EZBManager helper methods. Like so...
if (Convert.ToBoolean(_cf.STORAGE[ConfigurationDictionary._EDGE_ENABLED])) {
int edgeSize = Convert.ToInt16(_cf.STORAGE[ConfigurationDictionary._EDGE_SIZE]);
var servosX = _cf.SERVOS[ConfigurationDictionary._HORIZONTAL_SERVOS];
var servosY = _cf.SERVOS[ConfigurationDictionary._VERTICAL_SERVOS];
if (_mousePoint.X _cameraControl.Camera.CaptureWidth - 10)
ARC.EZBManager.SetServoIncrement(servosX, 1);
if (_mousePoint.Y _cameraControl.Camera.CaptureHeight - 10)
ARC.EZBManager.SetServoIncrement(servosY, 1);
}
Any data in the _cf.STORAGE and _cf.SERVOS will be automatically saved with the users project. And when that project is loaded again in the future, the _cf data will be reloaded as well. This allows your plugin to save the custom configuration applied by the user.
The error cannot read the COM file, I downloaded it and when I follow the instructions, I get an error, while other files read normally. .
sorry for me but i tried many different ways but still show the error,I couldn't find EZ_B.dll file even though I downloaded it
None of the required references are in your list. Please follow the tutorial. It explains exactly how to click the browse button and navigate to the folder and select the files.
Sorry, but the reason I can't reference is because there is no file in the EZ_B folder and there is an error : this folder is empty , I am trying to solve it. I would like to thank DJ sure for answering my superfluous questions and I'm sorry for bothering you
I need to playback 5 Serial Bus servos in sequence.
What protocol is it? A "serial bus" is a generic term for anything using a UART that's chained together sharing the same RX line. Also, why did you add a photo with the question text added in your response?
Are you planning on making a skill control to do this? You wrote the question in the skill control thread in a comment - I'd like to make sure your question is in the right place to help you out.
To begin, I would recommend starting with servo Script control so you can make the serial bus protocol work - then consider making a skill control only if you're planning on distributing the effort to others: https://synthiam.com/Products/Controls/Scripting/Servo-Script-19068
He seems rather demanding as well. I guess he needs the benefit of the doubt as English may not be his native language....
I have installed all the software dependencies and still ARC does not detect that I have Visual Studio installed. OS is Windows 10, .NET 4.8 or newer, Visual Studio Community 2019.