Is there a way to create a custom config?

Find and share HowTos to various installations / configurations!
Search

Post Reply
10 posts • Page 1 of 1
eladsa
Posts: 10
Joined: Tue Dec 31, 2024 6:57 pm

Is there a way to create a custom config?

Post by eladsa »

HI,

Is there a way to create a custom config, such as the "Default value" config? Instead of setting a default value in the online value, I'd like to make a function (via code) that takes the original value and sets the online value accordingly.

I appreciate any help you can provide.
Elad

User avatar
hpuchegger
Posts: 86
Joined: Fri Oct 08, 2021 10:38 am

Re: Is there a way to create a custom config?

Post by hpuchegger »

DId you already try our WinCC OA AI Assistant? It gives me following information:

In WinCC OA, you can create custom configurations similar to the "Default value" configuration by implementing a function in your code that sets the online value based on the original value. This can be achieved using the Control language (CTRL) or through the WinCC OA API.

To set the online value programmatically, you can define a custom function that retrieves the original value and applies your logic to set the online value accordingly. This can be done using the setValue() function or similar methods available in the API.

For example, you might create a CTRL script that looks something like this:

Code: Select all

main() {
    // Retrieve the original value
    originalValue = getValue("YourDataPointName:_original.._value");
    
    // Apply your custom logic
    onlineValue = originalValue * 2; // Example logic
    
    // Set the online value
    setValue("YourDataPointName:_online.._value", onlineValue);
}
This script would need to be executed in the appropriate context, such as a control loop or triggered by an event.

Maybe you can try if this works for you.

Br, Herbert

gschijndel
Posts: 373
Joined: Tue Jan 15, 2019 3:12 pm

Re: Is there a way to create a custom config?

Post by gschijndel »

If you do not mind adding an extra datapoint element, then you should look at the DP function.

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

Re: Is there a way to create a custom config?

Post by leoknipp »

If you want to set a value for a DP element you can only set the _original.._value.
The _online.._value is in the domain of the Event Manager as an read only config and cannot be modified by an external source.

Why do you want to modify the "_online.._value"?

Best Regards
Leopold Knipp
Senior Support Specialist

eladsa
Posts: 10
Joined: Tue Dec 31, 2024 6:57 pm

Re: Is there a way to create a custom config?

Post by eladsa »

Herbert, unfortunately, the AI assistant sometimes invents things :) You can't do a dpSet on the online value.

gschijndel, I'm trying to avoid the extra DP element.

Leopold, I want to set the online value since I'm getting a value as the original, and I want to change it using some logic. For example, a mapping function, where I receive 2, and I want to set it as 3, I get 4 and I want to set it as 2, etc.

User avatar
adaneau
Posts: 310
Joined: Tue Feb 21, 2012 9:49 am

Re: Is there a way to create a custom config?

Post by adaneau »

Hey,

Are those values coming through a driver? If yes maybe you could use msg conversion?

BR
Alex

eladsa
Posts: 10
Joined: Tue Dec 31, 2024 6:57 pm

Re: Is there a way to create a custom config?

Post by eladsa »

Thank you, Alex.

Some of them are coming via a driver, and the msg config is an option for those. However, with a msg config I lose the option to see the source\raw value, which I want to be able to.

And, this does not work for non-driver values.

Elad

gschijndel
Posts: 373
Joined: Tue Jan 15, 2019 3:12 pm

Re: Is there a way to create a custom config?

Post by gschijndel »

As a last resort it is possible to use the _general config

eladsa
Posts: 10
Joined: Tue Dec 31, 2024 6:57 pm

Re: Is there a way to create a custom config?

Post by eladsa »

gschijndel, I will have to check. There are other limitations for this config.

Thanks!

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

Re: Is there a way to create a custom config?

Post by leoknipp »

The _general config will be no option in this case from my point of view.
Using the _general config will have the following disadvantages:
-- No archiving of _general config attributes
-- No possibility to do an alarming for the values written to the _general config

Best Regards
Leopold Knipp
Senior Support Specialist

Post Reply
10 posts • Page 1 of 1