Product/components used and version/fix level:
Comulocity IoT
Detailed explanation of the problem:
Dear support team,
I am Yuanfeng Tian, a master student of Computational Engineering at TU Darmstadt. I am working as the research assistant (Hiwi after Yumao Liu) at the Institute PLCM. I need to get information like “True” from nodes to make a custom verify widget.
Refers Question: (https://tech.forums.softwareag.com/t/how-to-read-live-nodes-values-from-opc-ua-server/265130)
I write some codes like below
Code in Component.ts (readnode function,which will be used in html) :
readnode(ns: number, i: number) {
let formData = `{
"deviceId": "replaceID",
"c8y_ua_command_ReadValue":
{"nodes": ["ns=replacens;i=replacei"],
"timestampsToReturn" : "Both"},
"description": "Read value from node"
}`;
formData = formData.replace("replaceID", this.deviceID)
formData = formData.replace("replacens", String(ns))
formData = formData.replace("replacei", String(i))
let formDataJSON = JSON.parse(formData)
// let formDataJSON = eval("("+formData+")");
this.http.post(this.url, formDataJSON, this.options).subscribe(res => {
// Parse the JSON string in the 'result' field.
const result = JSON.parse(res['c8y_Command']['result']);
// Extract the value of the node.
const nodeValue = result['results']['ns=2;i=47']['13']['value']['value'];
this.showContent = true //(nodeValue == 'true');
this.loginfailed = !this.showContent;
console.log(res);
console.log(nodeValue);
});
alert(this.message);
}
HTML:
<div *ngIf="showContent; else loginTemplate">
<p>Welcome to my widget!</p>
<ng-template #loginTemplate>
<p *ngIf="loginFailed">Invalid username or password.</p>
<div class="container">
<label class="u-label">Check authentication: </label>
<button class="button" [disabled]="canClick" (click)="readnode(2,47)">Check</button>
</div>
</ng-template>
It looks like below:
<ng-template #loginTemplate>
Invalid username or password.
In component.ts, in order to test the function, i set the ‘showcontent’ to true when i click “check” button. But it doesn’t work and show the error like below. Failure reason is ‘GOOD’ but status failed and I can not get the information from this node. Could you tell me how to fix it?
Best regards,
Tian,Yuanfeng
Error messages / full error message screenshot / log file:
Question related to a free trial, or to a production (customer) instance?
We are IoTEP user. This is our tenat ID: bulut-dik-2021