-
Notifications
You must be signed in to change notification settings - Fork 0
Code Structure
Jason T Alborough edited this page Nov 4, 2024
·
1 revision
/// <summary>
/// Bridge Join Map for DeviceName
/// </summary>
public class DeviceNameBridgeJoinMap : JoinMapBaseAdvanced
{
#region Digital
[JoinName("FeatureName")]
public JoinDataComplete FeatureName = new JoinDataComplete(
new JoinData
{
JoinNumber = 1,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Clear description of what this join does",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Digital
});
#endregion
#region Analog
// Analog joins here
#endregion
#region Serial
// Serial joins here
#endregion
public DeviceNameBridgeJoinMap(uint joinStart)
: base(joinStart, typeof(DeviceNameBridgeJoinMap))
{
}
}-
Region Organization
- Always use #region for Digital, Analog, and Serial sections
- Keep regions in order: Digital, Analog, Serial
- No joins should exist outside these regions
-
Join Definitions
[JoinName("ExactFeatureName")] // Must match property name public JoinDataComplete FeatureName = new JoinDataComplete(...)
- Use consistent naming between JoinName attribute and property
- Property names should be PascalCase
- JoinName strings should match property names exactly
-
Join Numbers
- Start with join 1 (not 0)
- Keep sequential when possible
- Group related joins together
- Document any intentional gaps
-
Join Descriptions
Description = "Turns feature on/off. FB high when on",
- Be clear and concise
- Indicate if it's feedback (FB)
- Note any special behavior
- Include value ranges for analogs
- Document join spans
-
Join Capabilities
- Use correct eJoinCapabilities:
ToSIMPL // For feedback only FromSIMPL // For control only ToFromSIMPL // For both control and feedback
- Use correct eJoinCapabilities:
public class DeviceConfig
{
public const string MinimumEssentialsFrameworkVersion = "1.2.3"; // Must be defined exactly like this
}public class PluginFactory : EssentialsPluginDeviceFactory<PluginDevice>
{
public override void LoadTypesForPlugin()
{
TypeNames = new List<string>() {
"type1",
"type2"
};
}
}// Interfaces should be listed first, followed by base classes
public class DeviceName : EssentialsBridgeableDevice, IInterface1, IInterface2
{
// Implementation
}public class DeviceConfig
{
// Properties that should appear in config examples must be public
[JsonProperty("propertyName")]
public string PropertyName { get; set; }
// Private properties will be excluded from config examples
private string InternalProperty { get; set; }
}-
JoinMap Issues
// DON'T: Missing region tags public JoinDataComplete Join1 = new JoinDataComplete(...); // DON'T: Inconsistent naming [JoinName("one_name")] public JoinDataComplete DifferentName = new JoinDataComplete(...); // DO: Proper region and consistent naming #region Digital [JoinName("FeatureName")] public JoinDataComplete FeatureName = new JoinDataComplete(...); #endregion
-
Version Definition
// DON'T: Wrong property name public const string FrameworkVersion = "1.2.3"; // DON'T: Wrong format public const string MinimumEssentialsFrameworkVersion = "v1.2.3"; // DO: Correct property name and format public const string MinimumEssentialsFrameworkVersion = "1.2.3";
-
Type Names
// DON'T: Inconsistent casing TypeNames = new List<string>() { "Type_One", "typeTwo" }; // DO: Consistent casing TypeNames = new List<string>() { "type1", "type2" };
Before committing:
- Run the README automation script
- Verify all sections are generated correctly
- Check join numbers are sequential and grouped logically
- Verify descriptions are clear and formatted correctly
- Ensure config example includes all necessary fields
- Use semantic versioning (MAJOR.MINOR.PATCH)
- Don't include 'v' prefix
- Don't include build numbers
- Don't include prerelease tags in production code
Description = "Action/State description [FB high when condition]"Description = "Control description [Range: x-y] [FB mirrors input]"Description = "Data format description [Max length: n]"-
Digital Joins
- 1-10: Basic controls
- 11-20: Advanced features
- 21-30: Feedback
- 31+: Extended features
-
Analog Joins
- 1-10: Primary controls
- 11-20: Secondary controls
- 21+: Status and feedback
-
Serial Joins
- 1-10: Basic text/status
- 11+: Extended data