The basic of the edgefountry framework uses the loading process of Profile file and device

Posted by BrentonHale on Wed, 02 Feb 2022 04:51:54 +0100

1.profile file

Required items:

1.name is used to identify the name of a profile. Name only exists in the device.

2. Optional items: the following four items are similar to remarks, and there will be no error in deletion.

manufacturer: "Dent Instruments"
model: "PS3037"
description: "Power Scout Meter"
labels:
  - "modbus"
  - "powerscout"

3.deviceResources device resources

This module is very important. It is mainly used to describe the point information of microservices.

How to create a new point information

-		
    name: "Current"	
    description: "Average current of all phases"
    attributes:
      { primaryTable: "HOLDING_REGISTERS", startingAddress: "9" }
    properties:
      value:
        { type: "UINT16", scale: "1"}
      units:
        { type: "String", readWrite: "R", defaultValue: "min"}

(1) - / / start with this to distinguish a point information

(2) Name / / used to identify the unique location information in this profile. All subsequent references to this location information use name

(3) Description / / description information can be ignored

(4) attributes / / describes the details of a point. primaryTable register type startingAddress point address

(5) properties / / defines the type of the node and the read permission

4. Device commands can be used to read multiple points in batch

-
    name: "Current"
    get:
      - { index: "1", operation: "get", deviceResource: "Current" }

It can also be written as:

 get:
      - { index: "1", operation: "get", deviceResource: "Energy" }
      - { index: "2", operation: "get", deviceResource: "Power" }
      - { index: "3", operation: "get", deviceResource: "Voltage" }
    set:
      - { index: "1", operation: "set", deviceResource: "LineFrequency" }
      - { index: "2", operation: "set", deviceResource: "DemandWindowSize" }

5.coreCommands is used to define the request and return value of a command

- 
name: "Current" 
get: path: "/api/v1/device/{deviceId}/Current" 
responses: 
- code: "200" 
description: "Get the Current" expectedValues: ["Current"]
- code: "500" 
description: "internal server error" expectedValues: []

The name defined in the devicecommand is requested in the path

corecommand the name here is the content displayed on the page.

 

2.device device

device add page

Click from the corresponding micro service to generate the device interface

Click the plus sign to create a new device.

1. It corresponds to the name of the corresponding microservice, that is, if the device is created by clicking from modbus, it can also be modified into other microservices here. After successful creation, this device will belong to the new corresponding microservice.

2. Step 2 corresponds to the name and description of the new device. (this name is the unique identifier of the device.).

3.deviceprofile, you can select the previously imported profile file, which affects the style of the displayed command interface and the point information requested and set when entering the command from device., It will not be detected here, but when clicking the request, the corresponding request information will be sent to the corresponding microservice and parsed by the corresponding microservice.

4.deviceaddress is the address of the corresponding device connected. It will not be detected here. If it is an incorrect address, it will be reported that the address cannot be connected when it is sent through the restfulapi interface command.

3. Adding process of profile file and device

When core metadata is started, it will execute two functions, loadDeviceProfileRoutes and loadDeviceRoutes. The function of these two functions is to register multiple corresponding restful API request formats in PUT, GET, DELETE and POST at startup. Each format corresponds to a callback function. Then, when the corresponding restful request comes, the corresponding function will be executed.

For example:

① Query all profile files

Request URL: http://192.168.133.132:4000/core-metadata/api/v1/deviceprofile?_=1623390356674
Request Method: GET
Status Code: 200 OK
Remote Address: 192.168.133.132:4000
Referrer Policy: strict-origin-when-cross-origin

The callback function executed by matching the regular "/ + DEVICEPROFILE +" "is restGetAllDeviceProfiles

The same is true for other commands. You can refer to the request on the page in combination with the code