Incorrect Data Type

Unified Architecture topics related to OPC UA Specification, compliant behavior and any technical issues of OPC UA, like Security, Information Model, Companion Specs DI, PLCopen, ADI, ...

Moderator: Support Team

Post Reply
JulianE
Jr. Member
Jr. Member
Posts: 2
Joined: 02 Feb 2022, 14:50

Incorrect Data Type

Post by JulianE »

Hello,

I created a simple Server in Python using FreeOPC Library . UaExpert can connect to the server and read the parameter just fine but the Datatype is incorrect. The server code just writes a simple random integer into a temperature variable but UA is interpreting it as Datetime. I know that my code is generating the data as an 'int' , ive pasted it below just for reference, is there anyway to specify for change the data type in UaExpert?

Code: Select all

from site import addsitepackages
from opcua import Server
from random import randint
import datetime
import time

server = Server()

#Define ip address and port number [xxx.xxx.x.xxx : xxxx]
#                [ip address:port]                  
url = "opc.tcp://170.168.215.37:4840"
server.set_endpoint(url)

#Set name and assign to address space
name = "OPCUA_Simulation_Server"
addspace = server.register_namespace(name)

#Root Node as defined in address space
node = server.get_objects_node()

#Store parameters in node, these are the values that the client will look at
param = node.add_object(addspace, "Parameters")
#Identify parameter or variable 
Temp = param.add_variable (addspace, "Temperature", 0)

#Making the Variables Writeable
Temp.set_writable()
Press.set_writable()
Time.set_writable()

#Start the server
server.start()
print("Server Started at {}".format(url))

#Assign Random Values to Variables While True
while True:

    Temperature  = randint(10,95)
    Temp.set_value(int(Temperature))

    print("Temperatue is:" ,        type(Temperature), Temperature)
  
    time.sleep(2)

JulianE
Jr. Member
Jr. Member
Posts: 2
Joined: 02 Feb 2022, 14:50

Re: Incorrect Data Type

Post by JulianE »

Solved! : This was python error

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Incorrect Data Type

Post by Support Team »

Hi, thank you for directly reporting back.

for all others reading this:

whenever you experience any potential error shown in UaExpert, considering the UaExpert is the one and only reference UA Client, which is on the market since almost 10 years now, professionally maintained throughout all those years by a commercial software company doing nothing else than OPC UA ever,... and on the other hand using something you programmed yourself (especially when based on an open source library or any other "young" implementation), the likelihood that root cause of the experienced error or some overseen major bug is in the UaExpert should be considered rather small.

Not saying that UaExpert is error free software, just talking about likelihood of error location.
Best regards
Unified Automation Support Team

Post Reply