Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
How to add new Variable dynamically after OPC-UA has started from client side

I have an OPC-UA server up and running with some pre-configured tags, now I want to add a new Variable from my NodeJS OPC-UA client when my certain tag changes. For e.g.

import {
    OPCUAClient,
    MessageSecurityMode, SecurityPolicy,
    AttributeIds,
 } from "node-opcua-client";

const connectionStrategy = {
    initialDelay: 1000,
    maxRetry: 1
}

const options = {
    applicationName: "MyClient",
    connectionStrategy: connectionStrategy,
    securityMode: MessageSecurityMode.SignAndEncrypt,
    securityPolicy: SecurityPolicy.Basic256Sha256,
    endpointMustExist: false,
    
};
const client = OPCUAClient.create(options);
const endpointUrl = "{opc_url}";

try {
      // step 1 : connect to
      await client.connect(endpointUrl).then(res => console.log('connected!'))
    //   console.log("connected !");
  
      // step 2 : createSession
      await client.createSession({userName: "user_name", password: "password"}, async (err, session) => {
        if(err){
            console.log(err)
        }
        if(!err){
           // do something
        }
      }
    }

Above in the do something part I tried:

var nodeId = "nodeId";
var nodesToWrite = [{
                nodeId: nodeId,
                attributeId: AttributeIds.Value,
                value: /*new DataValue(*/{
                  value: {/* Variant */
                    dataType: 1,
                    value: false
                    }
                  }
                }];
session.write(nodesToWrite, (err, statusCodes) => {
    if(!err){
          console.log("success", statusCodes);
        } else {
          console.log(err, statusCodes)
        }
    }
); 

But since the nodeId doesn't exist so it will throw the error that it doesn't exist. I found a snippet example to add variables from the server-side, but is it possible to do it from the client's side as we want to add some variables based on the other variables which I am monitoring from the client's side.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Please see the link https://reference.opcfoundation.org/Core/docs/Part4/5.7.2/

And check with SDK/Server vendor, whether they support NodeManagement Service Set or not.

If yes, you can find a method in the session context like session.addNodes()

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda