logo资料库

EdgeXFoundry详细说明文档英文.pdf

第1页 / 共309页
第2页 / 共309页
第3页 / 共309页
第4页 / 共309页
第5页 / 共309页
第6页 / 共309页
第7页 / 共309页
第8页 / 共309页
资料共309页,剩余部分请下载后查看
Welcome to the EdgeX Foundry documentation
1. Quick Start
1.1. Setup
1.2. Running EdgeX
1.3. Connecting a Device
1.4. Connecting an Application
1.5. Controlling the Device
1.6. Next Steps
2. Introduction
2.1. Definitions: “South Side” and “North Side”
2.2. EdgeX Foundry Architectural Tenets
2.3. EdgeX Foundry Service Layers
2.4. Core Services Layer
2.5. Supporting Services Layer
2.6. Export Services Layer
2.7. Device Services Layer
2.8. System Services Layer
3. EdgeX Foundry Microservices Architecture
3.1. Core Services Microservices
3.1.1. Configuration and Registry
3.1.1.1. Introduction
3.1.1.1.1. Configuration
3.1.1.1.1.1. Local Configuration
3.1.1.1.1.2. Seeding Configuration
3.1.1.1.1.3. Configuration Structure
3.1.1.1.1.4. Versioning
3.1.1.1.1.5. Readable vs Writable Settings
3.1.1.2. Registry
3.1.1.2.1. Introduction to Registry
3.1.1.2.2. Web User Interface
3.1.1.2.3. Running on Docker
3.1.1.2.4. Running on Local Machine
3.1.2. Core Data
3.1.2.1. Introduction
3.1.2.2. Core Data “Streaming”
3.1.2.3. Data Model
3.1.2.4. Data Dictionary
3.1.2.5. High Level Interaction Diagrams
3.1.3. Metadata
3.1.3.1. Introduction
3.1.3.1.1. Data Models
3.1.3.2. Data Dictionary
3.1.3.3. High Level Interaction Diagrams
3.1.4. Command
3.1.4.1. Introduction
3.1.4.2. Data Dictionary
3.1.4.3. High Level Interaction Diagrams
3.2. Supporting Services Microservices
3.2.1. Alerts & Notifications
3.2.1.1. Introduction
3.2.1.2. Data Model
3.2.1.3. Data Dictionary
3.2.1.4. High Level Interaction Diagrams
3.2.1.5. Configuration Properties
3.2.1.6. Configure Mail Server
3.2.1.6.1. Gmail
3.2.1.6.2. Yahoo Mail
3.2.2. Logging
3.2.2.1. Introduction
3.2.2.2. Minimum Product Feature Set
3.2.2.3. High Level Design Architecture
3.2.2.4. Configuration Properties
3.2.2.5. Logging Service Client Library for Go
3.2.2.6. EdgeX Logging Keys
3.2.3. Scheduling
3.2.3.1. Introduction
3.2.3.2. Data Dictionary
3.2.4. Rules Engine
3.2.4.1. Reference Implementation
3.2.4.2. Rules Engine as Export Service Client
3.2.4.3. Rules Engine Direct Connect to Core Data
3.2.4.4. Rules Client and High Level Interaction Diagram
3.2.4.5. Rules (Defined), and Data Model
3.2.4.6. Rules Engine Configuration
3.2.4.7. Data Dictionary
3.3. System Management
3.3.1. Introduction
3.3.2. The System Management Agent
3.3.3. Micro Service Management API
3.3.3.1. System Management Agent (SMA)
3.3.3.1.1. Introduction
3.3.3.1.2. Examples of API Calls
3.3.3.1.2.1. Metrics of a service
3.3.3.1.2.2. Configuration of a service
3.3.3.1.2.3. Start a service
3.3.3.1.2.4. Stop a service
3.3.3.1.2.5. Restart a service
3.3.3.1.2.6. Health check on a service
3.4. Security
3.4.1. Secret Store
3.4.1.1. Start the Secret Store
3.4.1.1.1. Troubleshooting steps
3.4.1.1.1.1. Clean-up
3.4.1.1.1.2. Start the first service: volume (platform volume initializations)
3.4.1.1.1.3. Start the second service: consul (Consul is Vault store backend)
3.4.1.1.1.4. Start the third service: config-seed (platform configuration initializations)
3.4.1.1.1.5. Start the fourth service: vault (Vault tool)
3.4.1.1.1.6. Start the fifth service: vault-worker (Vault init/unseal process and setups)
3.4.1.1.2. Using Consul Web UI
3.4.1.1.3. Shell Access to Consul Container and Using Consul CLI
3.4.1.2. Configuring the Secret Store
3.4.1.3. Using the Secret Store
3.4.1.3.1. 1st alternative: executing a shell session in the active Vault container to run Vault CLI commands.
3.4.1.3.2. 2nd alternative: using the Vault Web UI.
3.4.1.3.3. 3rd alternative: directly using the Vault HTTP API with cURL commands.
3.4.1.4. See also
3.4.2. API Gateway
3.4.2.1. Start the API Gateway
3.4.2.2. Configuring API Gateway
3.4.2.3. Using API Gateway
3.4.3. Access EdgeX REST resources
3.4.4. Starting security services within EdgeX
3.4.5. Security Issues
3.4.5.1. Security Announcements
3.4.5.2. Vulnerability Reporting
3.4.5.2.1. When to Report a Vulnerability?
3.4.5.2.2. When NOT to Report a Vulnerability?
3.4.5.3. Security Vulnerability Response
3.4.5.4. Public Disclosure Timing
3.5. Export Services Microservices
3.5.1. Client Registration
3.5.1.1. Introduction
3.5.1.2. Data Model
3.5.1.3. Data Dictionary
3.5.1.4. High Level Interaction Diagram
3.5.1.5. Client Registration Details
3.5.2. Distribution
3.5.2.1. Introduction
3.5.2.2. Client Registration and Distro Service Cooperation
3.5.2.3. High Level Interaction Diagram
3.5.2.4. Data Dictionary
3.5.2.5. The Pipe and Filter
3.5.3. Google IoT Core
3.6. Application Services Microservices
3.6.1. Application Services
3.6.1.1. Export Service Deficiencies
3.6.1.2. Application Service Improvements
3.6.1.3. Standard Functions
3.6.1.4. Examples
3.6.1.4.1. Unsupported existing export service functions
3.6.2. Application Functions SDK (GoLang)
3.6.2.1. Getting started
3.6.2.2. Triggers
3.6.2.3. Context API
3.6.2.4. Built-In Transforms/Functions
3.6.2.5. Configuration
3.6.2.6. Error Handling
3.6.2.2.1. Message Bus Trigger
3.6.2.2.1.1. Type and Topic Configuration
3.6.2.2.1.2. Message bus connection configuration
3.6.2.2.2. HTTP Trigger
3.7. Device Services Microservices
3.7.1. Virtual Device
3.7.1.1. Introduction
3.7.1.2. Virtual Resources Example
3.7.1.3. Special Configuration
3.7.1.4. System Architecture
3.7.1.5. Device Profile Definition
3.7.1.6. Data Model
3.7.1.7. Data Dictionary
3.7.2. Device Services SDK
3.7.2.1. Introduction to the SDK
3.7.2.2. Device Service Workflow
3.7.2.3. Writing a Device Service
3.7.3. Device Profile
4. Getting Started
4.1. Getting Started - Users
4.1.1. Introduction
4.1.2. Platform Requirements
4.1.3. Get & Run EdgeX Foundry
4.1.3.1. Install Docker & Docker Compose
4.1.3.2. Download the EdgeX Foundry Compose File
4.1.3.3. Run EdgeX Foundry
4.1.4. Stop and Remove EdgeX Foundry
4.1.5. Advanced EdgeX Foundry User Commands
4.1.6. Checking the Status of EdgeX Foundry
4.1.6.1. Docker Container Status Check
4.1.6.2. EdgeX Foundry Consul Registry
4.2. Getting Started - Developers
4.2.1. Introduction
4.2.2. What You Need
4.2.2.1. Get EdgeX Foundry - Go Developers
4.2.2.1.1. Introduction
4.2.2.1.2. What You Need For Go Development
4.2.2.1.3. Get the code
4.2.2.1.4. EdgeX Foundry’s Mongo Database
4.2.2.1.4.1. On Windows
4.2.2.1.4.2. On Linux
4.2.2.1.5. EdgeX Foundry in Go Land
4.2.2.1.6. Building from the Command Line
4.3. Writing a Device Service for EdgeX
4.3.1. Writing a Device Service in Go
4.3.1.1. Install dependencies
4.3.1.2. Get the EdgeX Device SDK for Go
4.3.1.3. Starting a new Device Service project
4.3.1.4. Build your Device Service
4.3.1.5. Customize your Device Service
4.3.1.6. Creating your Device Profile
4.3.1.7. Configuring your Device Service
4.3.1.8. Rebuild your Device Service
4.3.1.9. Run your Device Service
4.3.2. Writing a Device Service in C
4.3.2.1. Install dependencies
4.3.2.2. Get the EdgeX Device SDK for C
4.3.2.3. Starting a new Device Service project
4.3.2.4. Build your Device Service
4.3.2.5. Customize your Device Service
4.3.2.6. Creating your Device Profile
4.3.2.7. Configuring your Device Service
4.3.2.8. Rebuild your Device Service
4.3.2.9. Run your Device Service
4.4. Working in a Hybrid Environment
4.4.1. Get and Run the EdgeX Docker Containers
4.4.2. Get and Run the Code In Go Land
4.5. Getting Docker Images from Edgex Nexus Repository
5. EdgeX Demonstration API Walk Through
5.1. Setup up your environment
5.1.1. Install Docker & Docker Compose
5.1.2. Install Postman
5.2. Running EdgeX
5.2.1. Download the docker-compose file
5.2.2. Download the containers
5.2.3. Starting EdgeX
5.3. Example Use Case
5.4. Defining your data
5.4.1. Creating Reference Information in EdgeX
5.4.2. Addressables
5.4.3. Value Descriptors
5.5. Defining your device
5.5.1. Adding a Device Profile
5.5.2. Understanding Commands
5.5.3. Understanding Command Gets and Puts
5.5.4. Understanding Command Parameters
5.6. Register your Device Service
5.6.1. Register with Core Configuration and Registration
5.6.2. Create the Device Service
5.7. Provision a Device
5.7.1. Adding your device
5.7.2. Test the Setup
5.7.2.1. Check the Device Service
5.7.2.2. Check the Device
5.8. Calling commands
5.8.1. List the Commands
5.8.1.1. Check the Value Descriptors
5.8.2. Execute a Command
5.9. Sending events and reading data
5.9.1. Send an Event/Reading
5.9.2. Reading data
5.10. Exporting your device data
5.10.1. Export Clients
5.10.2. Register an Export Client
5.11. Building your own solutions
6. EdgeX Foundry Examples and Tutorials
6.1. Provison a Device - Modbus Example
6.2. Using the Virtual Device Service
6.2.1. Overview
6.2.2. Virtual Resource Table Schema
6.2.3. How to Use
6.2.3.1. GET command example
6.2.3.2. PUT command example - Assign a value to a resource
6.2.3.3. PUT command example - Enable/Disable the randomization of the resource
6.2.4. Manipulate Virtual Resources Using the command ql Tool
6.3. Modbus - Adding a Device to EdgeX
6.3.1. Environment
6.3.2. Modbus Device (Simulator)
6.3.3. Set Up Before Starting Services
6.3.3.1. Set Up Device Profile
6.3.3.2. Set Up Device Service Configuration
6.3.3.3. Add Device Service to docker-compose File
6.3.4. Start EdgeX Foundry on Docker
6.3.5. Set Up After Starting Services
6.3.6. Execute Commands
6.3.6.1. Find Executable Commands
6.3.6.2. Execute GET command
6.3.6.3. Execute PUT command
6.3.7. Schedule Job
6.4. SNMP - Adding a Device to EdgeX
6.4.1. Project Components Needed
6.5. MQTT - Adding a Device to EdgeX
6.5.1. Overview
6.5.2. Run an MQTT Broker
6.5.3. Run an MQTT Device Simulator
6.5.3.1. Setup
6.5.4. Device Profile (mqtt.test.device.profile.yml)
6.5.5. Device Service Configuration (configuration.toml)
6.5.6. Add Device Service to docker-compose File (docker-compose.yml)
6.5.6.1. Start EdgeX Foundry on Docker
6.5.6.2. Execute Commands
6.5.7. Find Executable Commands
6.5.8. Execute put Command
6.5.9. Execute get Command
6.5.10. Schedule Job
6.5.10.1. Async Device Reading
6.6. Random Integer Device Service Example
6.6.1. Running Commands
6.6.1.1. GET Command
6.6.1.2. PUT Command
6.7. Sending and Consuming Binary Data From EdgeX Device Services
6.7.1. Overview
6.7.2. DeviceService Implementation
6.7.2.1. Device Profile
6.7.2.2. Device Service
6.7.3. Calling Device Service Command
6.7.3.1. Parsing CBOR Encoded Events
6.7.3.2. Encoding Arbitrary Structures in Events
7. API Reference
Welcome to the EdgeX Foundry documentation
EdgeX Foundry documentation V1.1.0 Contents Welcome to the EdgeX Foundry documentation ...........................................................................................................1 1. Quick Start ...............................................................................................................................................................................9 1.1. Setup .............................................................................................................................................................................9 1.2. Running EdgeX ...........................................................................................................................................................9 1.3. Connecting a Device .............................................................................................................................................. 10 1.4. Connecting an Application ................................................................................................................................... 11 1.5. Controlling the Device ........................................................................................................................................... 12 1.6. Next Steps ................................................................................................................................................................ 15 2. Introduction.......................................................................................................................................................................... 16 2.1. Definitions: “South Side” and “North Side” ...................................................................................................... 16 2.2. EdgeX Foundry Architectural Tenets ................................................................................................................. 17 2.3. EdgeX Foundry Service Layers ............................................................................................................................ 17 2.4. Core Services Layer ................................................................................................................................................ 18 2.5. Supporting Services Layer .................................................................................................................................... 19 2.6. Export Services Layer ............................................................................................................................................. 20 2.7. Device Services Layer ............................................................................................................................................. 21 2.8. System Services Layer ............................................................................................................................................ 22 3. EdgeX Foundry Microservices Architecture.................................................................................................................. 24 3.1. Core Services Microservices¶ ........................................................................................................................................ 25 3.1.1. Configuration and Registry ........................................................................................................................................ 26 3.1.1.1. Introduction ....................................................................................................................................................... 26 3.1.1.1.1. Configuration ........................................................................................................................................ 26 3.1.1.2. Registry ............................................................................................................................................................... 29 3.1.1.2.1. Introduction to Registry ...................................................................................................................... 29 3.1.1.2.2. Web User Interface .............................................................................................................................. 30 3.1.1.2.3. Running on Docker .............................................................................................................................. 31 3.1.1.2.4. Running on Local Machine ................................................................................................................ 31 3.1.2. Core Data ....................................................................................................................................................................... 33 3.1.2.1. Introduction ....................................................................................................................................................... 33 3.1.2.2. Core Data “Streaming” .................................................................................................................................... 34 3.1.2.3. Data Model ........................................................................................................................................................ 34 3.1.2.4. Data Dictionary ................................................................................................................................................. 35 3.1.2.5. High Level Interaction Diagrams .................................................................................................................. 35 3.1.3. Metadata ........................................................................................................................................................................ 37 3.1.3.1. Introduction ....................................................................................................................................................... 37 3.1.3.1.1. Data Models .......................................................................................................................................... 40 3.1.3.2. Data Dictionary ................................................................................................................................................. 44 3.1.3.3. High Level Interaction Diagrams .................................................................................................................. 45 3.1.4. Command ...................................................................................................................................................................... 48 3.1.4.1. Introduction ....................................................................................................................................................... 48 3.1.4.2. Data Dictionary ................................................................................................................................................. 49 3.1.4.3. High Level Interaction Diagrams .................................................................................................................. 49 2 / 309
EdgeX Foundry documentation V1.1.0 3.2. Supporting Services Microservices .............................................................................................................................. 51 3.2.1. Alerts & Notifications .................................................................................................................................................. 52 3.2.1.1. Introduction ....................................................................................................................................................... 52 3.2.1.2. Data Model ........................................................................................................................................................ 54 3.2.1.3. Data Dictionary ................................................................................................................................................. 54 3.2.1.4. High Level Interaction Diagrams .................................................................................................................. 55 3.2.1.5. Configuration Properties ................................................................................................................................ 59 3.2.1.6. Configure Mail Server ..................................................................................................................................... 60 3.2.1.6.1. Gmail ....................................................................................................................................................... 60 3.2.1.6.2. Yahoo Mail ............................................................................................................................................. 61 3.2.2. Logging ........................................................................................................................................................................... 62 3.2.2.1. Introduction ....................................................................................................................................................... 62 3.2.2.2. Minimum Product Feature Set ...................................................................................................................... 62 3.2.2.3. High Level Design Architecture .................................................................................................................... 63 3.2.2.4. Configuration Properties ................................................................................................................................ 64 3.2.2.5. Logging Service Client Library for Go ......................................................................................................... 65 3.2.2.6. EdgeX Logging Keys ........................................................................................................................................ 67 3.2.3. Scheduling ..................................................................................................................................................................... 68 3.2.3.1. Introduction ....................................................................................................................................................... 68 3.2.3.2. Data Dictionary ................................................................................................................................................. 69 3.2.4. Rules Engine .................................................................................................................................................................. 70 3.2.4.1. Reference Implementation ............................................................................................................................ 70 3.2.4.2. Rules Engine as Export Service Client ......................................................................................................... 70 3.2.4.3. Rules Engine Direct Connect to Core Data ................................................................................................ 71 3.2.4.4. Rules Client and High Level Interaction Diagram .................................................................................... 72 3.2.4.5. Rules (Defined), and Data Model ................................................................................................................. 73 3.2.4.6. Rules Engine Configuration ........................................................................................................................... 76 3.2.4.7. Data Dictionary ................................................................................................................................................. 78 3.3. System Management ...................................................................................................................................................... 79 3.3.1. Introduction .......................................................................................................................................................... 79 3.3.2. The System Management Agent ..................................................................................................................... 80 3.3.3. Micro Service Management API ...................................................................................................................... 81 3.3.3.1. System Management Agent (SMA) ...................................................................................................................... 82 3.3.3.1.1. Introduction .................................................................................................................................................... 82 3.3.3.1.2. Examples of API Calls ................................................................................................................................... 82 3.3.3.1.2.1. Metrics of a service ........................................................................................................................... 82 3.3.3.1.2.2. Configuration of a service ............................................................................................................... 83 3.3.3.1.2.3. Start a service ..................................................................................................................................... 86 3.3.3.1.2.4. Stop a service ..................................................................................................................................... 86 3.3.3.1.2.5. Restart a service ................................................................................................................................ 87 3.3.3.1.2.6. Health check on a service ............................................................................................................... 88 3.4. Security............................................................................................................................................................................... 89 3.4.1. Secret Store ................................................................................................................................................................... 90 3.4.1.1. Start the Secret Store ...................................................................................................................................... 91 3 / 309
EdgeX Foundry documentation V1.1.0 3.4.1.1.1. Troubleshooting steps ........................................................................................................................ 92 3.4.1.1.2. Using Consul Web UI ........................................................................................................................ 101 3.4.1.1.3. Shell Access to Consul Container and Using Consul CLI .......................................................... 106 3.4.1.2. Configuring the Secret Store ....................................................................................................................... 106 3.4.1.3. Using the Secret Store .................................................................................................................................. 110 3.4.1.3.1. 1st alternative: executing a shell session in the active Vault container to run Vault CLI commands. ............................................................................................................................................................ 110 3.4.1.3.2. 2nd alternative: using the Vault Web UI. ...................................................................................... 114 3.4.1.3.3. 3rd alternative: directly using the Vault HTTP API with cURL commands............................ 116 3.4.1.4. See also ............................................................................................................................................................. 119 3.4.2. API Gateway ................................................................................................................................................................ 119 3.4.2.1. Start the API Gateway ................................................................................................................................... 119 3.4.2.2. Configuring API Gateway ............................................................................................................................. 121 3.4.2.3. Using API Gateway ......................................................................................................................................... 122 3.4.3. Access EdgeX REST resources ................................................................................................................................. 126 3.4.4. Starting security services within EdgeX ................................................................................................................. 126 3.4.5. Security Issues ............................................................................................................................................................. 127 3.4.5.1. Security Announcements ............................................................................................................................. 127 3.4.5.2. Vulnerability Reporting ................................................................................................................................. 127 3.4.5.2.1. When to Report a Vulnerability? .................................................................................................... 127 3.4.5.2.2. When NOT to Report a Vulnerability? .......................................................................................... 127 3.4.5.3. Security Vulnerability Response.................................................................................................................. 128 3.4.5.4. Public Disclosure Timing .............................................................................................................................. 128 3.5. Export Services Microservices ..................................................................................................................................... 129 3.5.1. Client Registration ...................................................................................................................................................... 130 3.5.1.1. Introduction ..................................................................................................................................................... 130 3.5.1.2. Data Model ...................................................................................................................................................... 133 3.5.1.3. Data Dictionary ............................................................................................................................................... 133 3.5.1.4. High Level Interaction Diagram .................................................................................................................. 134 3.5.1.5. Client Registration Details ............................................................................................................................ 134 3.5.2. Distribution .................................................................................................................................................................. 136 3.5.2.1. Introduction ..................................................................................................................................................... 136 3.5.2.2. Client Registration and Distro Service Cooperation .............................................................................. 137 3.5.2.3. High Level Interaction Diagram .................................................................................................................. 138 3.5.2.4. Data Dictionary ............................................................................................................................................... 139 3.5.2.5. The Pipe and Filter ......................................................................................................................................... 139 3.5.3. Google IoT Core ......................................................................................................................................................... 142 3.6. Application Services Microservices ........................................................................................................................... 145 3.6.1. Application Services ................................................................................................................................................... 146 3.6.1.1. Export Service Deficiencies .......................................................................................................................... 147 3.6.1.2. Application Service Improvements ............................................................................................................ 147 3.6.1.3. Standard Functions ........................................................................................................................................ 147 3.6.1.4. Examples .......................................................................................................................................................... 149 3.6.1.4.1. Unsupported existing export service functions .......................................................................... 149 4 / 309
EdgeX Foundry documentation V1.1.0 3.6.2. Application Functions SDK (GoLang) .................................................................................................................... 150 3.6.2.1. Getting started ................................................................................................................................................ 150 3.6.2.2. Triggers ............................................................................................................................................................. 153 3.6.2.3. Context API ...................................................................................................................................................... 153 3.6.2.4. Built-In Transforms/Functions .................................................................................................................... 154 3.6.2.5. Configuration .................................................................................................................................................. 155 3.6.2.6. Error Handling ................................................................................................................................................. 155 3.6.2.2.1. Message Bus Trigger .......................................................................................................................................... 156 3.6.2.2.1.1. Type and Topic Configuration .............................................................................................................. 156 3.6.2.2.1.2. Message bus connection configuration ............................................................................................. 156 3.6.2.2.2. HTTP Trigger ......................................................................................................................................................... 157 3.7. Device Services Microservices .................................................................................................................................... 158 3.7.1. Virtual Device .............................................................................................................................................................. 160 3.7.1.1. Introduction ..................................................................................................................................................... 160 3.7.1.2. Virtual Resources Example ........................................................................................................................... 162 3.7.1.3. Special Configuration .................................................................................................................................... 163 3.7.1.4. System Architecture ....................................................................................................................................... 164 3.7.1.5. Device Profile Definition ............................................................................................................................... 166 3.7.1.6. Data Model ...................................................................................................................................................... 166 3.7.1.7. Data Dictionary ............................................................................................................................................... 169 3.7.2. Device Services SDK .................................................................................................................................................. 170 3.7.2.1. Introduction to the SDK ................................................................................................................................ 170 3.7.2.2. Device Service Workflow .............................................................................................................................. 170 3.7.2.3. Writing a Device Service ............................................................................................................................... 171 3.7.3. Device Profile ..................................................................................................................................................... 172 4. Getting Started .................................................................................................................................................................. 174 4.1. Getting Started - Users ................................................................................................................................................ 174 4.1.1. Introduction ........................................................................................................................................................ 174 4.1.2. Platform Requirements .................................................................................................................................... 175 4.1.3. Get & Run EdgeX Foundry .............................................................................................................................. 176 4.1.3.1. Install Docker & Docker Compose .................................................................................................... 176 4.1.3.2. Download the EdgeX Foundry Compose File ................................................................................ 176 4.1.3.3. Run EdgeX Foundry .............................................................................................................................. 178 4.1.4. Stop and Remove EdgeX Foundry ................................................................................................................ 180 4.1.5. Advanced EdgeX Foundry User Commands .............................................................................................. 181 4.1.6. Checking the Status of EdgeX Foundry ....................................................................................................... 184 4.1.6.1. Docker Container Status Check ......................................................................................................... 184 4.1.6.2. EdgeX Foundry Consul Registry......................................................................................................... 187 4.2. Getting Started - Developers ..................................................................................................................................... 188 4.2.1. Introduction ........................................................................................................................................................ 188 4.2.2. What You Need ................................................................................................................................................. 189 4.2.2.1. Get EdgeX Foundry - Go Developers ................................................................................................................ 190 4.2.2.1.1. Introduction .................................................................................................................................................. 190 4.2.2.1.2. What You Need For Go Development .................................................................................................. 190 5 / 309
EdgeX Foundry documentation V1.1.0 4.2.2.1.3. Get the code ................................................................................................................................................ 191 4.2.2.1.4. EdgeX Foundry’s Mongo Database ........................................................................................................ 192 4.2.2.1.4.1. On Windows ..................................................................................................................................... 192 4.2.2.1.4.2. On Linux ............................................................................................................................................ 194 4.2.2.1.5. EdgeX Foundry in Go Land....................................................................................................................... 194 4.2.2.1.6. Building from the Command Line .......................................................................................................... 198 4.3. Writing a Device Service for EdgeX .......................................................................................................................... 199 4.3.1. Writing a Device Service in Go................................................................................................................................ 200 4.3.1.1. Install dependencies ...................................................................................................................................... 200 4.3.1.2. Get the EdgeX Device SDK for Go ............................................................................................................. 201 4.3.1.3. Starting a new Device Service project ....................................................................................................... 202 4.3.1.4. Build your Device Service ............................................................................................................................. 204 4.3.1.5. Customize your Device Service................................................................................................................... 205 4.3.1.6. Creating your Device Profile ........................................................................................................................ 207 4.3.1.7. Configuring your Device Service ................................................................................................................ 208 4.3.1.8. Rebuild your Device Service ........................................................................................................................ 208 4.3.1.9. Run your Device Service ............................................................................................................................... 209 4.3.2. Writing a Device Service in C .................................................................................................................................. 210 4.3.2.1. Install dependencies ...................................................................................................................................... 210 4.3.2.2. Get the EdgeX Device SDK for C ................................................................................................................ 210 4.3.2.3. Starting a new Device Service project ....................................................................................................... 211 4.3.2.4. Build your Device Service ............................................................................................................................. 211 4.3.2.5. Customize your Device Service................................................................................................................... 211 4.3.2.6. Creating your Device Profile ........................................................................................................................ 212 4.3.2.7. Configuring your Device Service ................................................................................................................ 213 4.3.2.8. Rebuild your Device Service ........................................................................................................................ 213 4.3.2.9. Run your Device Service ............................................................................................................................... 214 4.4. Working in a Hybrid Environment ............................................................................................................................. 215 4.4.1. Get and Run the EdgeX Docker Containers ................................................................................................ 215 4.4.2. Get and Run the Code In Go Land ................................................................................................................ 216 4.5. Getting Docker Images from Edgex Nexus Repository ........................................................................................ 219 5. EdgeX Demonstration API Walk Through .................................................................................................................. 221 5.1. Setup up your environment ........................................................................................................................................ 222 5.1.1. Install Docker & Docker Compose ................................................................................................................ 222 5.1.2. Install Postman ................................................................................................................................................... 222 5.2. Running EdgeX .............................................................................................................................................................. 223 5.2.1. Download the docker-compose file ............................................................................................................. 223 5.2.2. Download the containers ................................................................................................................................ 224 5.2.3. Starting EdgeX ................................................................................................................................................... 224 5.3. Example Use Case ......................................................................................................................................................... 226 5.4. Defining your data ........................................................................................................................................................ 228 5.4.1. Creating Reference Information in EdgeX................................................................................................... 228 5.4.2. Addressables ...................................................................................................................................................... 229 5.4.3. Value Descriptors .............................................................................................................................................. 230 6 / 309
EdgeX Foundry documentation V1.1.0 5.5. Defining your device ..................................................................................................................................................... 232 5.5.1. Adding a Device Profile ................................................................................................................................... 232 5.5.2. Understanding Commands ............................................................................................................................. 233 5.5.3. Understanding Command Gets and Puts.................................................................................................... 233 5.5.4. Understanding Command Parameters ........................................................................................................ 234 5.6. Register your Device Service ...................................................................................................................................... 235 5.6.1. Register with Core Configuration and Registration .................................................................................. 235 5.6.2. Create the Device Service ................................................................................................................................ 235 5.7. Provision a Device ......................................................................................................................................................... 237 5.7.1. Adding your device ........................................................................................................................................... 237 5.7.2. Test the Setup .................................................................................................................................................... 238 5.7.2.1. Check the Device Service..................................................................................................................... 238 5.7.2.2. Check the Device ................................................................................................................................... 238 5.8. Calling commands ......................................................................................................................................................... 239 5.8.1. List the Commands ........................................................................................................................................... 239 5.8.1.1. Check the Value Descriptors ............................................................................................................... 239 5.8.2. Execute a Command......................................................................................................................................... 240 5.9. Sending events and reading data ............................................................................................................................. 241 5.9.1. Send an Event/Reading.................................................................................................................................... 241 5.9.2. Reading data ...................................................................................................................................................... 242 5.10. Exporting your device data ....................................................................................................................................... 243 5.10.1. Export Clients ................................................................................................................................................... 243 5.10.2. Register an Export Client ............................................................................................................................... 244 5.11. Building your own solutions ..................................................................................................................................... 245 6. EdgeX Foundry Examples and Tutorials ...................................................................................................................... 246 6.1. Provison a Device - Modbus Example ..................................................................................................................... 247 6.2. Using the Virtual Device Service ................................................................................................................................ 248 6.2.1. Overview .............................................................................................................................................................. 248 6.2.2. Virtual Resource Table Schema ..................................................................................................................... 251 6.2.3. How to Use ......................................................................................................................................................... 251 6.2.3.1. GET command example ....................................................................................................................... 252 6.2.3.2. PUT command example - Assign a value to a resource ............................................................. 252 6.2.3.3. PUT command example - Enable/Disable the randomization of the resource ..................... 252 6.2.4. Manipulate Virtual Resources Using the command ql Tool ................................................................... 253 6.3. Modbus - Adding a Device to EdgeX ...................................................................................................................... 255 6.3.1. Environment........................................................................................................................................................ 255 6.3.2. Modbus Device (Simulator) ............................................................................................................................ 256 6.3.3. Set Up Before Starting Services ..................................................................................................................... 258 6.3.3.1. Set Up Device Profile ............................................................................................................................ 259 6.3.3.2. Set Up Device Service Configuration ................................................................................................ 260 6.3.3.3. Add Device Service to docker-compose File ................................................................................. 262 6.3.4. Start EdgeX Foundry on Docker .................................................................................................................... 263 6.3.5. Set Up After Starting Services ........................................................................................................................ 264 6.3.6. Execute Commands .......................................................................................................................................... 266 7 / 309
EdgeX Foundry documentation V1.1.0 6.3.6.1. Find Executable Commands ............................................................................................................... 266 6.3.6.2. Execute GET command ........................................................................................................................ 267 6.3.6.3. Execute PUT command ........................................................................................................................ 267 6.3.7. Schedule Job....................................................................................................................................................... 269 6.4. SNMP - Adding a Device to EdgeX .......................................................................................................................... 270 6.4.1. Project Components Needed ......................................................................................................................... 271 6.5. MQTT - Adding a Device to EdgeX .......................................................................................................................... 283 6.5.1. Overview .............................................................................................................................................................. 283 6.5.2. Run an MQTT Broker ........................................................................................................................................ 284 6.5.3. Run an MQTT Device Simulator..................................................................................................................... 284 6.5.3.1. Setup ........................................................................................................................................................ 285 6.5.4. Device Profile (mqtt.test.device.profile.yml) ................................................................................................ 286 6.5.5. Device Service Configuration (configuration.toml) ................................................................................... 289 6.5.6. Add Device Service to docker-compose File (docker-compose.yml) .................................................. 292 6.5.6.1. Start EdgeX Foundry on Docker ........................................................................................................ 293 6.5.6.2. Execute Commands .............................................................................................................................. 294 6.5.7. Find Executable Commands ........................................................................................................................... 294 6.5.8. Execute put Command .................................................................................................................................... 296 6.5.9. Execute get Command ..................................................................................................................................... 296 6.5.10. Schedule Job .................................................................................................................................................... 297 6.5.10.1. Async Device Reading ........................................................................................................................ 298 6.6. Random Integer Device Service Example ................................................................................................................ 300 6.6.1. Running Commands ......................................................................................................................................... 300 6.6.1.1. GET Command ....................................................................................................................................... 301 6.6.1.2. PUT Command ....................................................................................................................................... 302 6.7. Sending and Consuming Binary Data From EdgeX Device Services ................................................................ 305 6.7.1. Overview .............................................................................................................................................................. 305 6.7.2. DeviceService Implementation ....................................................................................................................... 305 6.7.2.1. Device Profile .......................................................................................................................................... 305 6.7.2.2. Device Service ........................................................................................................................................ 305 6.7.3. Calling Device Service Command ................................................................................................................. 306 6.7.3.1. Parsing CBOR Encoded Events........................................................................................................... 306 6.7.3.2. Encoding Arbitrary Structures in Events .......................................................................................... 307 7. API Reference .................................................................................................................................................................... 309 8 / 309
分享到:
收藏