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

opcua server not updating the value the second time #1547

Open
siddhartherat1997 opened this issue Sep 4, 2024 · 0 comments
Open

opcua server not updating the value the second time #1547

siddhartherat1997 opened this issue Sep 4, 2024 · 0 comments

Comments

@siddhartherat1997
Copy link

Hi , So I have been trying to do some simulation using opcua for powerfactory. the set_value() is working only once . The second time I am calling I am not able to send the value from opcua server to powerfactory. I am attaching the server code.

`from opcua import Server,ua
from datetime import datetime
import time
import matplotlib.pyplot as plt
import csv

Define global variables for the OPC UA server and variables

server = None

conv1_kq_set = None

class myServer:
def init(self):

    self.conv1_kq_set = None

 

    # Setup the OPC UA server
    self.server = Server()
    
    # Set endpoint for the server
    
def start_server(self):
    #global serverconv1_kq_set
    self.server.set_endpoint("opc.tcp://localhost:5300/freeopcua/server/")
    print("Server endpoint: {}".format(self.server.endpoint))
    
    # Setup the server namespace
    uri = "http://example.org"
    self.idx = self.server.register_namespace(uri)
    
    # Get the Objects node, this is where we should add our nodes
    self.objects = self.server.get_objects_node()
    
    # Create a new object in the server
    self.my_object = self.objects.add_object(self.idx, "MyObject")
    
    
    
    # Create variables in the new object
    self.conv1_kq_set = self.my_object.add_variable(self.idx, "CONV_1_KQ_SET", 0.00)
  
  
    # Set writable properties
   
    self.conv1_kq_set.set_writable()  # Readable and writable
 

    self.conv2_active_power.set_writable()
    self.conv2_kq_set.set_writable()  # Readable and writable
    self.conv2_reactive_power.set_writable()
    self.conv2_voltage_meas.set_writable()
    
    
    # Start the server
    self.server.start()
    print("Server started at {}".format(self.server.endpoint))


# Functions to get the current values of the variables

def set_conv1_kq_set(self,value):
    return self.conv1_kq_set.set_value(value)

`

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

No branches or pull requests

1 participant