Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create mapper template #14

Closed
sailorvii opened this issue Apr 8, 2021 · 3 comments · Fixed by #41
Closed

Create mapper template #14

sailorvii opened this issue Apr 8, 2021 · 3 comments · Fixed by #41

Comments

@sailorvii
Copy link
Collaborator

Create a template for a customized mapper to ease the mapper development.

@sailorvii
Copy link
Collaborator Author

sailorvii commented Apr 9, 2021

Target:
The user specifies the new mapper's name, then automatically creates a folder accordingly to the name. The User needs to write several functions, then the mapper works.

Detailed design:

  1. Template files.
    The file tree is like that:
- <nameOfNewMapper>
   - main.go
   - Dockerfile ---- Combine building code and container image.
   - deployment.yaml
   - config.yaml  
   - driver     ---- This is for reading/writing devices.  
     - client.go    -----  Fill in the functions like getting register/setting register.
   - device    ---- Device management. Such as reading the device configuration and create the data structure accordingly, connecting the devices, and reading/writing device registers.
     - device.go  ---- Almost need not much change except the initialization of driver client and customized visitor parsing.
     - devstatus.go
     - twindata.go
  - configmap
    - type.go   ---- Add the mapper-specific data structure.
    - parse.go
  - globals  ---- Global definitions.
    - globals.go
  1. Tool to create the code.
    Use a shell script to get inputted mapper name, copy the template files to a new folder named as input. Replace the related file name, also replace some characters as input.

@ttlv
Copy link
Member

ttlv commented Apr 12, 2021

well, this template is just for some protocols which are suppotted C/S,if some protocols are not suppotted C/S,the file client.go is useless.

@sailorvii
Copy link
Collaborator Author

If not the C/S structure, the client.go is also for getting/setting the device. For example, in modbus rtu mode, the client is to open serial devices and get/set them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants