Skip to content

Commit

Permalink
Code cleanup, file scoped usings
Browse files Browse the repository at this point in the history
  • Loading branch information
visose committed Dec 3, 2021
1 parent 657b595 commit d17f594
Show file tree
Hide file tree
Showing 119 changed files with 7,273 additions and 7,581 deletions.
21 changes: 12 additions & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -185,26 +185,26 @@ dotnet_naming_style.prefix_underscore.required_prefix = _

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

# RCS1018: Add accessibility modifiers.
Expand All @@ -220,4 +220,7 @@ dotnet_style_qualification_for_field=false:suggestion
dotnet_style_qualification_for_property=false:suggestion
dotnet_style_qualification_for_method=false:suggestion
dotnet_style_qualification_for_event=false:suggestion
dotnet_diagnostic.CA1715.severity=suggestion
dotnet_diagnostic.CA1715.severity=suggestion

# IDE0160: Convert to file-scoped namespace
csharp_style_namespace_declarations = file_scoped:warning
6 changes: 3 additions & 3 deletions build/Robots.Build/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static void Package()
Manifest.CreateAndSave(path);

// Build package
string yak = GetYakPath();
Run(yak, "build", PackageFolder);
string yak = GetYakPath();
Run(yak, "build", PackageFolder);
}

public static void Publish()
Expand All @@ -46,7 +46,7 @@ public static void Publish()

string packageFile = Path.GetFileName(packagePath);
string yak = GetYakPath();
Run(yak, $"push {packageFile}", PackageFolder);
Run(yak, $"push {packageFile}", PackageFolder);
}

static string GetYakPath()
Expand Down
80 changes: 39 additions & 41 deletions src/Robots.Grasshopper/Commands/CustomCommand.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
using System;
using Grasshopper.Kernel;
using Grasshopper.Kernel;

namespace Robots.Grasshopper.Commands
{
public class CustomCommand : GH_Component
{
public CustomCommand() : base("Custom command", "CustomCmd", "Custom command written in the manufacturer specific language", "Robots", "Commands") { }
public override GH_Exposure Exposure => GH_Exposure.primary;
public override Guid ComponentGuid => new Guid("{713A6DF0-6C73-477F-8CA5-2FE18F3DE7C4}");
protected override System.Drawing.Bitmap Icon => Properties.Resources.iconCustomCommand;
namespace Robots.Grasshopper.Commands;

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddTextParameter("Name", "N", "Name", GH_ParamAccess.item, "Custom command");
pManager.AddTextParameter("Manufacturer", "M", "Robot manufacturer, options: ABB, KUKA, UR, FANUC, Staubli, Other, All. If you select 'All', the command will always be included irrespective of the manufacturer.", GH_ParamAccess.item, "All");
pManager.AddTextParameter("Code", "C", "Command code", GH_ParamAccess.item);
pManager.AddTextParameter("Declaration", "D", "Variable declaration and assignment", GH_ParamAccess.item);
pManager[2].Optional = true;
pManager[3].Optional = true;
}
public class CustomCommand : GH_Component
{
public CustomCommand() : base("Custom command", "CustomCmd", "Custom command written in the manufacturer specific language", "Robots", "Commands") { }
public override GH_Exposure Exposure => GH_Exposure.primary;
public override Guid ComponentGuid => new("{713A6DF0-6C73-477F-8CA5-2FE18F3DE7C4}");
protected override System.Drawing.Bitmap Icon => Properties.Resources.iconCustomCommand;

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Command", "C", "Command", GH_ParamAccess.item);
}
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddTextParameter("Name", "N", "Name", GH_ParamAccess.item, "Custom command");
pManager.AddTextParameter("Manufacturer", "M", "Robot manufacturer, options: ABB, KUKA, UR, FANUC, Staubli, Other, All. If you select 'All', the command will always be included irrespective of the manufacturer.", GH_ParamAccess.item, "All");
pManager.AddTextParameter("Code", "C", "Command code", GH_ParamAccess.item);
pManager.AddTextParameter("Declaration", "D", "Variable declaration and assignment", GH_ParamAccess.item);
pManager[2].Optional = true;
pManager[3].Optional = true;
}

protected override void SolveInstance(IGH_DataAccess DA)
{
string? name = null;
string? manufacturerText = null;
string? code = null, declaration = null;
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Command", "C", "Command", GH_ParamAccess.item);
}

if (!DA.GetData(0, ref name) || name is null) { return; }
if (!DA.GetData(1, ref manufacturerText) || manufacturerText is null) { return; }
DA.GetData(2, ref code);
DA.GetData(3, ref declaration);
protected override void SolveInstance(IGH_DataAccess DA)
{
string? name = null;
string? manufacturerText = null;
string? code = null, declaration = null;

var command = new Robots.Commands.Custom(name);
if (!DA.GetData(0, ref name) || name is null) { return; }
if (!DA.GetData(1, ref manufacturerText) || manufacturerText is null) { return; }
DA.GetData(2, ref code);
DA.GetData(3, ref declaration);

if(!Enum.TryParse<Manufacturers>(manufacturerText, out var manufacturer))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $" Manufacturer '{manufacturerText}' not valid.");
return;
}
var command = new Robots.Commands.Custom(name);

command.AddCommand(manufacturer, code, declaration);
DA.SetData(0, new GH_Command(command));
if (!Enum.TryParse<Manufacturers>(manufacturerText, out var manufacturer))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $" Manufacturer '{manufacturerText}' not valid.");
return;
}

command.AddCommand(manufacturer, code, declaration);
DA.SetData(0, new GH_Command(command));
}
}
}
52 changes: 24 additions & 28 deletions src/Robots.Grasshopper/Commands/Group.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Grasshopper.Kernel;
using Grasshopper.Kernel;

namespace Robots.Grasshopper.Commands
namespace Robots.Grasshopper.Commands;

public class Group : GH_Component
{
public class Group : GH_Component
{
public Group() : base("Group command", "GroupCmd", "Group of commands", "Robots", "Commands") { }
public override GH_Exposure Exposure => GH_Exposure.primary;
public override Guid ComponentGuid => new Guid("{17485955-818B-4D0E-9986-26264E1F86DC}");
protected override System.Drawing.Bitmap Icon => Properties.Resources.iconGroupCommand;
public Group() : base("Group command", "GroupCmd", "Group of commands", "Robots", "Commands") { }
public override GH_Exposure Exposure => GH_Exposure.primary;
public override Guid ComponentGuid => new("{17485955-818B-4D0E-9986-26264E1F86DC}");
protected override System.Drawing.Bitmap Icon => Properties.Resources.iconGroupCommand;

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Commands", "C", "Group of commands", GH_ParamAccess.list);
}
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Commands", "C", "Group of commands", GH_ParamAccess.list);
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Command", "C", "Command", GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Command", "C", "Command", GH_ParamAccess.item);
}

protected override void SolveInstance(IGH_DataAccess DA)
{
var commands = new List<GH_Command>();
protected override void SolveInstance(IGH_DataAccess DA)
{
var commands = new List<GH_Command>();

if (!DA.GetDataList(0, commands)) { return; }
if (!DA.GetDataList(0, commands)) { return; }

var command = new Robots.Commands.Group();
command.AddRange(commands.Select(x => x.Value));
DA.SetData(0, new GH_Command(command));
}
var command = new Robots.Commands.Group();
command.AddRange(commands.Select(x => x.Value));
DA.SetData(0, new GH_Command(command));
}
}
}
48 changes: 23 additions & 25 deletions src/Robots.Grasshopper/Commands/Message.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
using System;
using Grasshopper.Kernel;
using Grasshopper.Kernel;

namespace Robots.Grasshopper.Commands
namespace Robots.Grasshopper.Commands;

public class Message : GH_Component
{
public class Message : GH_Component
{
public Message() : base("Message", "Message", "Sends a text message to the teach pendant", "Robots", "Commands") { }
public override GH_Exposure Exposure => GH_Exposure.secondary;
public override Guid ComponentGuid => new Guid("{CFAABB24-CAEE-49FC-850F-BE9F70F070CA}");
protected override System.Drawing.Bitmap Icon => Properties.Resources.iconMessage;
public Message() : base("Message", "Message", "Sends a text message to the teach pendant", "Robots", "Commands") { }
public override GH_Exposure Exposure => GH_Exposure.secondary;
public override Guid ComponentGuid => new("{CFAABB24-CAEE-49FC-850F-BE9F70F070CA}");
protected override System.Drawing.Bitmap Icon => Properties.Resources.iconMessage;

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddTextParameter("Message", "M", "Message to display in teach pendant", GH_ParamAccess.item);
}
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddTextParameter("Message", "M", "Message to display in teach pendant", GH_ParamAccess.item);
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Command", "C", "Command", GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Command", "C", "Command", GH_ParamAccess.item);
}

protected override void SolveInstance(IGH_DataAccess DA)
{
string message = string.Empty;
protected override void SolveInstance(IGH_DataAccess DA)
{
string message = string.Empty;

if (!DA.GetData(0, ref message)) { return; }
if (!DA.GetData(0, ref message)) { return; }

var command = new Robots.Commands.Message(message);
DA.SetData(0, new GH_Command(command));
}
var command = new Robots.Commands.Message(message);
DA.SetData(0, new GH_Command(command));
}
}
}
54 changes: 26 additions & 28 deletions src/Robots.Grasshopper/Commands/PulseDO.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
using System;
using Grasshopper.Kernel;
using Grasshopper.Kernel;

namespace Robots.Grasshopper.Commands
namespace Robots.Grasshopper.Commands;

public class PulseDO : GH_Component
{
public class PulseDO : GH_Component
{
public PulseDO() : base("Pulse DO", "PulseDO", "Send a pulse to a digital output", "Robots", "Commands") { }
public override GH_Exposure Exposure => GH_Exposure.secondary;
public override Guid ComponentGuid => new Guid("{3CBDCD59-9621-4A0F-86BF-F4CC876E360D}");
protected override System.Drawing.Bitmap Icon => Properties.Resources.iconPulseDO;
public PulseDO() : base("Pulse DO", "PulseDO", "Send a pulse to a digital output", "Robots", "Commands") { }
public override GH_Exposure Exposure => GH_Exposure.secondary;
public override Guid ComponentGuid => new("{3CBDCD59-9621-4A0F-86BF-F4CC876E360D}");
protected override System.Drawing.Bitmap Icon => Properties.Resources.iconPulseDO;

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddIntegerParameter("DO", "D", "Digital output number", GH_ParamAccess.item);
pManager.AddNumberParameter("Time", "T", "Duration of pulse", GH_ParamAccess.item, 0.2);
}
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddIntegerParameter("DO", "D", "Digital output number", GH_ParamAccess.item);
pManager.AddNumberParameter("Time", "T", "Duration of pulse", GH_ParamAccess.item, 0.2);
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Command", "C", "Command", GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddParameter(new CommandParameter(), "Command", "C", "Command", GH_ParamAccess.item);
}

protected override void SolveInstance(IGH_DataAccess DA)
{
int DO = 0;
double length = 0;
protected override void SolveInstance(IGH_DataAccess DA)
{
int DO = 0;
double length = 0;

if (!DA.GetData(0, ref DO)) return;
if (!DA.GetData(1, ref length)) return;
if (!DA.GetData(0, ref DO)) return;
if (!DA.GetData(1, ref length)) return;

var command = new Robots.Commands.PulseDO(DO, length);
DA.SetData(0, new GH_Command(command));
}
var command = new Robots.Commands.PulseDO(DO, length);
DA.SetData(0, new GH_Command(command));
}
}
}
Loading

0 comments on commit d17f594

Please sign in to comment.