当前位置:网站首页>Thingsboard create RCP widget
Thingsboard create RCP widget
2022-06-12 05:09:00 【Cocoa core】
One 、 Reference resources
Official RPC The firmware , Only fixed method and param, Because there are test requirements , Need web pages can be sent at will rpc command . Since I don't know much about the front end , Find the example that the corresponding boss did well
https://www.jianshu.com/p/0adc8965da45
Two 、 Create a widget
Create your own part library
Add a new part , Add respectively
HTML,JS,Set the architectureCode for
HTML<div class="tb-rpc-button" fxLayout="column"> <div fxFlex="20" class="title-container" fxLayout="row" fxLayoutAlign="center center" [fxShow]="showTitle"> <span class="button-title">{ { title}}</span> </div> <div fxFlex="{ {showTitle ? 80 : 100}}" [ngStyle]="{paddingTop: showTitle ? '5px': '10px'}" class="button-container" fxLayout="column" fxLayoutAlign="center center"> <div> <button mat-button (click)="sendCommand()" [class.mat-raised-button]="styleButton?.isRaised" [color]="styleButton?.isPrimary ? 'primary' : ''" [ngStyle]="customStyle"> { { buttonLable}} </button> </div> </div> <div class="error-container" [ngStyle]="{'background': error?.length ? 'rgba(255,255,255,0.25)' : 'none'}" fxLayout="row" fxLayoutAlign="center center"> <span class="button-error">{ { error }}</span> </div> </div>JS
self.onInit = function() { self.ctx.$scope.sendCommand = function() { var rpcMethod = self.ctx.$scope.rpcMethod; var rpcParams = self.ctx.$scope.rpcParams; var timeout = self.ctx.settings.requestTimeout; var oneWayElseTwoWay = self.ctx.settings.oneWayElseTwoWay ? true : false; var commandObservable; if (oneWayElseTwoWay) { commandObservable = self.ctx.controlApi.sendOneWayCommand(rpcMethod, rpcParams, timeout); } else { commandObservable = self.ctx.controlApi.sendTwoWayCommand(rpcMethod, rpcParams, timeout); } commandObservable.subscribe( function (response) { if (oneWayElseTwoWay) { self.ctx.$scope.rpcCommandResponse = "Command was successfully received by device.<br> No response body because of one way command mode."; } else { self.ctx.$scope.rpcCommandResponse = "Response from device:<br>"; self.ctx.$scope.rpcCommandResponse += JSON.stringify(response, undefined, 2); } self.ctx.detectChanges(); }, function (rejection) { self.ctx.$scope.rpcCommandResponse = "Failed to send command to the device:<br>" self.ctx.$scope.rpcCommandResponse += "Status: " + rejection.status + "<br>"; self.ctx.$scope.rpcCommandResponse += "Status text: '" + rejection.statusText + "'"; self.ctx.detectChanges(); } ); } }Set the architecture
{ "schema": { "type": "object", "title": "Settings", "properties": { "oneWayElseTwoWay": { "title": "Is One Way Command", "type": "boolean", "default": true }, "requestTimeout": { "title": "RPC request timeout", "type": "number", "default": 500 } }, "required": [] }, "form": [ "oneWayElseTwoWay", "requestTimeout" ]}
3、 ... and 、 Actually measured


边栏推荐
- LabVIEW关于TDMS和Binary存储速度
- The emergence of new ides and the crisis of programmers?
- Yolov5 realizes road crack detection
- [cjson] precautions for root node
- one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven
- LabVIEW about TDMS and binary storage speeds
- L1-066 cat is liquid (5 points)
- Differences between in and not in, exists and not exists in SQL and performance analysis
- How to deploy dolphin scheduler 1.3.1 on cdh5
- 12.24 day exercise -- Programming summation, 99 multiplication table, while loop and for loop exercises
猜你喜欢

How to deploy dolphin scheduler Apache dolphin scheduler 1.2.0 in cdh5.16.2

SQL injection upload one sentence Trojan horse (turn)

Qinglong wool - Kaka

Redis learning notes (continuously updating)
![[cjson] precautions for root node](/img/6c/4462bc8126935f00a5c64f18de13ea.png)
[cjson] precautions for root node

When the build When gradle does not load the dependencies, and you need to add a download path in libraries, the path in gradle is not a direct downloadable path

2022 "college entrance examination memory" has been packaged, please check!

Harris corner detection principle-

Longest palindrome string

Acquisition of Lai data, NPP data, GPP data and vegetation coverage data
随机推荐
[GIS tutorial] land use transfer matrix
Parallelization of accelerated training tf data. Dataset generator
【cjson】根节点注意事项
[backtracking] backtracking method to solve combinatorial problems
Understanding of day16 array create query static and dynamic array array array performance in memory
Microsoft announces that it will discontinue support for older versions of visual studio
Self implementation of a UI Library - UI core drawing layer management
CentOS compiling and installing mysql8.0
Google reinforcement learning framework seed RL environment deployment
1007- stair climbing
Map coordinate conversion of Baidu map API
Three. JS import model demo analysis (with notes)
Musk promotes the development of fascinating new products partners remind important questions
Force/release learning and sorting in IC Verification (6) research on the influence of wire type signals
According to aiqicha, keep went public in Hong Kong and hit the "first share of online fitness"
Shandong University network security range experimental platform -- team and project introduction
加速训练之并行化 tf.data.Dataset 生成器
Common MySQL date query
Pupanvr hardware and software board side development environment configuration (4)
PostgreSQL age XID maintenance prevents the database from being read-only