Skip to main content
1-Visitor
May 19, 2021
Solved

Sinusoid simulation value returns 0 on first read

  • May 19, 2021
  • 2 replies
  • 3231 views

Hello! I wonder if someone can explain the behaviour of KepServer described below. I couldn't find anything similar online.

 

Context:

I'm building a POC of an application with an OPC UA client in it. For that I'm using node-opcua opensource product. 

I'm using KEPServerEX 6.10 as an OPC UA server.

 

Use case:

I have a basic script that reads a value attribute from the server. The node is pre-configured and comes out of the box with Kepware Server. Node ID is ns=2;s=Simulation Examples.Functions.Sine1.

The script establishes a connection with the server, creates a session, reads a values, closes the session, disconnects from the server.

 

Expected behaviour:

Each script invocation should return a simulated sinusoid value.

 

Actual behaviour:

First script invocation returns 0 (zero) value. Response status code is 0 (Good). Subsequent request if it happens within 5 seconds, returns a legit sinusoid value, e.g. 0.20106108486652374. I figured "Tag Cache Timeout (s)" in KepServer Project Settings is relevant. It is set to 5 seconds by default.

 

Question: 

How do I make initial data read return a valid value and not a zero?

 

Best answer by PaiChung

Look at the Channel Properties / Tag properties or the Remote Binding Properties

To be honest, by default it should behave the way you are expecting it to, so I'm not sure why it is always starting with 0 when you do your first read.

But if you plot your data over time, you should probably see a confirmation that potentially when you connect it always starts from 0, it may be that is how the simulator works, not sure.

Ideally there is the scan rate on the kepware side and then a 'push on changed value' and on the ThingWorx side it should do a 'Read from Cache'

 

2 replies

22-Sapphire I
May 20, 2021

Wouldn't 0 be the first value of a sinusoid?

1-Visitor
May 20, 2021

Hi @PaiChung 

 

From what I understand the value is constantly changing (with the default KepServer parameters it flows from -39.999... to 39.999... and back repeatedly). Any read should result in a value in that range, no matter if it's a first read or subsequent read.

How come first read always returns 0? Am I getting it wrong and is it that the first read "kick starts" the sinusoid and the initial value is returned?

22-Sapphire I
May 20, 2021

It is potentially possible that the 'read' request generates the value and that would mean first read is always 0

check your tag 'read/refresh' settings .

Unfortunately a tat outside my area of expertise.

Community Manager
June 3, 2021

Hi @MI_9934026

 

Since you found a solution, please mark the appropriate response as the Accepted Solution, for the benefit of others with the same question.

 

Regards.

 

--Sharon