--- name: eae-adapter description: > Create Adapter types in EAE for reusable bidirectional interfaces (socket/plug pattern). license: MIT compatibility: Designed for EcoStruxure Automation Expert 25.0+, Python 3.8+, PowerShell (Windows) metadata: version: "2.0.0" author: Claude domain: industrial-automation parent-skill: eae-skill-router user-invocable: true platform: EcoStruxure Automation Expert standard: IEC-61499 --- # EAE Adapter Creation Create or modify Adapter types for reusable bidirectional interfaces. > **CRITICAL RULE:** ALWAYS use this skill for ANY operation on Adapter files. > - Creating new Adapters > - Modifying existing Adapters (adding events, variables, service sequences) > - NEVER directly edit `.adp` files outside of this skill **Adapter = Bidirectional Interface Pattern** - Socket side: sees interface as defined - Plug side: sees interface reversed - Used for standard communication patterns **Adapter Key Differences:** - Uses `` root element (NOT FBType) - Uses `.adp` extension (NOT `.fbt`) - Uses `Standard="61499-1"` (NOT 61499-2) - Has `` element defining communication sequences ## Quick Start ``` User: Create an adapter for request/response communication Claude: [Creates IEC61499/MyAdapter.adp with service sequences] ``` ## Triggers - `/eae-adapter` - `/eae-adapter --register-only` - Register existing Adapter (used by eae-fork orchestration) - "create adapter" - "modify adapter" - "add event to adapter" - "create interface adapter" - "socket plug interface" --- ## Register-Only Mode (for eae-fork Orchestration) When called with `--register-only`, this skill skips file creation and only performs dfbproj registration. This mode is used by **eae-fork** to complete the fork workflow after file transformation. ``` /eae-adapter --register-only {AdapterName} {Namespace} ``` **What --register-only does:** 1. **Registers in dfbproj** - Adds ItemGroup entries for Adapter visibility **What --register-only does NOT do:** - Create IEC61499 files (.adp, etc.) - already done by eae-fork - Update namespaces - already done by eae-fork ### Usage ```bash # Register a forked Adapter python ../eae-skill-router/scripts/register_dfbproj.py IMyAdapter SE.ScadapackWWW --type adapter # Verify registration python ../eae-skill-router/scripts/register_dfbproj.py IMyAdapter SE.ScadapackWWW --type adapter --verify ``` --- ## Modification Workflow When modifying an existing Adapter: 1. Read the existing `.adp` file to understand current structure 2. Identify what needs to be added/changed 3. Generate new hex IDs for any new Events or VarDeclarations 4. Update the InterfaceList (events, variables) if needed 5. Update the Service element with new ServiceSequences if needed 6. Ensure service transactions match the new events/data --- ## Files Generated | File | Purpose | |------|---------| | `{Name}.adp` | Main adapter (NOT .fbt!) | | `{Name}.doc.xml` | Documentation | **Note:** No `.meta.xml` for adapters. Location: `IEC61499/` --- ## Critical Rules | Rule | Value | |------|-------| | Root Element | `` (NOT FBType) | | DOCTYPE | `` | | Standard | `` | | Extension | `.adp` (NOT `.fbt`) | | Service Element | Required | --- ## Adapter Template ```xml ``` --- ## Socket vs Plug | Side | Sees Interface As | Usage | |------|------------------|-------| | **Socket** | As defined | Provider/Server side | | **Plug** | Reversed | Consumer/Client side | ### Example in FBNetwork ```xml ``` --- ## Service Sequences The `` element defines communication patterns: ### Request-Confirm Pattern Client sends request, server confirms: ```xml ``` ### Indication-Response Pattern Server sends indication, client responds: ```xml ``` --- ## Standard Event Names | Event | Direction | Purpose | |-------|-----------|---------| | REQ | Socket → Plug | Request | | CNF | Plug → Socket | Confirmation | | IND | Plug → Socket | Indication | | RSP | Socket → Plug | Response | --- ## dfbproj Registration ```xml {Name}.adp Adapter ``` --- ## Using Adapters in FBs ### In InterfaceList ```xml ``` ### Connecting Adapters In FBNetwork, adapter connections use special syntax: ```xml ``` --- ## Common Rules See [common-rules.md](../eae-skill-router/references/common-rules.md) for: - ID generation - dfbproj registration patterns --- ## Troubleshooting | Issue | Solution | |-------|----------| | Adapter won't load | Use `.adp` extension, not `.fbt` | | Standard error | Use `Standard="61499-1"`, not `61499-2` | | Missing Service | Adapters require `` element | | Wrong root element | Use ``, not `` | --- ## Example: Command Adapter ```xml ``` --- ## Validation After creating an Adapter, validate it: ```bash python ../eae-skill-router/scripts/validate_block.py --type adapter MyAdapter.adp ``` Generate IDs: ```bash python ../eae-skill-router/scripts/generate_ids.py --hex 8 --guid 1 ``` --- ## Integration with Validation Skills ### Naming Validation Use [eae-naming-validator](../eae-naming-validator/SKILL.md) to ensure compliance with SE Application Design Guidelines: **Key Naming Rules for Adapter:** - Adapter name: **IPascalCase** with uppercase 'I' prefix (e.g., `IPv`, `IAnalogValue`, `IMotorControl`) - Events: SNAKE_CASE (e.g., `REQ`, `CNF`, `IND`, `RSP`) - Variables: PascalCase (e.g., `CommandCode`, `Parameter`, `Result`) **Validate naming before creation:** ```bash # Validate adapter name (must have 'I' prefix) python ../eae-naming-validator/scripts/validate_names.py \ --app-dir IEC61499 \ --artifact-type Adapter \ --name IMyAdapter ``` **Reference:** EAE_ADG EIO0000004686.06, Section 1.5 (Adapter Naming Convention) --- ## Best Practices from EAE ADG ### 1. Naming Conventions (SE ADG Section 1.5) **Adapter Naming:** - **ALWAYS use IPascalCase** with uppercase 'I' prefix - The 'I' denotes "Interface" (socket/plug pattern) - Examples: `IPv`, `IAnalogValue`, `IMotorControl`, `ICommandInterface` **Variable Naming:** - Use PascalCase for all adapter variables: `CommandCode`, `Parameter`, `Result` - Use descriptive names (avoid `Data1`, `Var1`) - Include data types in complex names: `PositionValue`, `ErrorCode`, `StatusText` **Event Naming:** - Use standard IEC 61499 event names: `REQ`, `CNF`, `IND`, `RSP` - For custom events, use SNAKE_CASE: `START_COMMAND`, `ABORT_REQUEST` - Avoid generic names: `E1`, `DO1`, `OUTPUT` **Reference:** EAE_ADG EIO0000004686.06, Section 1.5 ### 2. Service Sequence Design **Communication Patterns:** - Use Request-Confirm for client-initiated operations - Use Indication-Response for server-initiated notifications - Keep service sequences simple (2-4 transactions typical) - Document the protocol flow in comments **Service Transaction Guidelines:** - Always pair InputPrimitive with OutputPrimitive - Match Parameters in both Socket and Plug sides - Use semantic names for ServiceSequence (e.g., `execute_command`, not `seq1`) ### 3. Adapter Reusability **Design for Reuse:** - Keep adapters generic (avoid application-specific logic) - Use standard data types (BOOL, INT, REAL, STRING) - Define clear interface contracts in comments - Provide example usage in .doc.xml **When to Create New Adapter:** - Standardize repeated communication patterns - Define reusable interfaces across FB types - Separate concerns between provider and consumer - Enable plug-and-play component replacement --- ## Anti-Patterns ### 1. Naming Anti-Patterns ❌ **Missing 'I' Prefix** ```xml ``` ✅ **Correct IPascalCase** ```xml ``` ❌ **Lowercase 'i' Prefix** ```xml ``` ❌ **Generic Variable Names** ```xml ``` ✅ **Descriptive Variable Names** ```xml ``` ### 2. Structure Anti-Patterns ❌ **Wrong Root Element** ```xml ``` ✅ **Correct Root Element** ```xml ``` ❌ **Wrong Standard** ```xml ``` ✅ **Correct Standard** ```xml ``` ❌ **Wrong File Extension** ``` IMyAdapter.fbt ❌ Wrong extension ``` ✅ **Correct File Extension** ``` IMyAdapter.adp ✅ Correct extension ``` ❌ **Missing Service Element** ```xml ... ``` ✅ **Service Element Required** ```xml ... ... ``` ### 3. Service Sequence Anti-Patterns ❌ **Unmatched Parameters** ```xml ``` ✅ **Matched Parameters** ```xml ``` ❌ **Overly Complex Service Sequences** ```xml ``` ✅ **Simple, Clear Service Sequences** ```xml ... ... ``` ### 4. Reusability Anti-Patterns ❌ **Application-Specific Adapter** ```xml ``` ✅ **Generic, Reusable Adapter** ```xml ``` ❌ **Using Custom Data Types in Adapters** ```xml ``` ✅ **Using Standard Data Types** ```xml ``` --- ## Verification Checklist Before committing your Adapter: **Naming (run eae-naming-validator):** - [ ] Adapter name uses IPascalCase with uppercase 'I' prefix - [ ] All variables use PascalCase - [ ] Events use SNAKE_CASE or standard names (REQ, CNF, IND, RSP) **Structure:** - [ ] Root element is `` (NOT ``) - [ ] File extension is `.adp` (NOT `.fbt`) - [ ] Uses `Standard="61499-1"` (NOT `61499-2`) - [ ] `` element is present with at least one ServiceSequence **Service Sequences:** - [ ] All InputPrimitive/OutputPrimitive pairs have matching Parameters - [ ] ServiceSequence names are descriptive (not `seq1`, `seq2`) - [ ] Sequences are simple (2-4 transactions typical) **Reusability:** - [ ] Adapter name is generic (not application-specific) - [ ] Uses standard data types (BOOL, INT, REAL, STRING) - [ ] Interface contract documented in comments **Registration:** - [ ] Registered in .dfbproj with `IEC61499Type="Adapter"` - [ ] .doc.xml file created and registered as DependentUpon **Validation:** - [ ] `python scripts/validate_adapter.py {Name}.adp` passes - [ ] `python ../eae-skill-router/scripts/validate_block.py --type adapter {Name}.adp` passes --- ## Scripts ### Validate Adapter Validate adapter files against EAE rules and SE ADG naming conventions: ```bash # Validate a single adapter python scripts/validate_adapter.py IEC61499/IMotorControl.adp # Validate all adapters in directory python scripts/validate_adapter.py IEC61499/ # JSON output for CI/CD python scripts/validate_adapter.py IEC61499/ --json # Strict mode (treat warnings as errors) python scripts/validate_adapter.py IEC61499/ --strict ``` **Validates:** - Root element is AdapterType (NOT FBType) - Standard is "61499-1" (NOT 61499-2) - File extension is .adp - IPascalCase naming with uppercase 'I' prefix - GUID is present - Service element and ServiceSequence consistency - Event and variable naming conventions **Exit codes:** - `0` - All validations passed - `1` - Error running validation - `10` - Validation warnings (non-blocking) - `11` - Validation errors (blocking) --- ## Related Skills | Skill | When to Use | |-------|-------------| | [eae-naming-validator](../eae-naming-validator/SKILL.md) | Validate adapter naming compliance (IPascalCase) | | [eae-basic-fb](../eae-basic-fb/SKILL.md) | Create FBs that use adapters | | [eae-composite-fb](../eae-composite-fb/SKILL.md) | Create composite FBs with adapter connections | | [eae-cat](../eae-cat/SKILL.md) | Create CAT blocks with adapters | --- ## Templates - [adapter.xml](../eae-skill-router/assets/templates/adapter.xml) - [doc.xml](../eae-skill-router/assets/templates/doc.xml)