DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Modify channel properties

Hello:

 

I have a dataset where most of the channels are unit-less. There is one channel that I want to define it's Unit properties as meters (m) in vbscript. Sounds simple, but not having much luck.

 

Tried this:

Call ChnPropSet("[4]/DTC", "/DTC", "m") '...Set Units

 

...And this

Call ChnPropValSet("[4]/DTC", "unit_string", "m") '...Set Unit

 

...Also

Call RootPropValSet("Unit", "m") '...Don't see where a channel is defined

 

I can manually set the unit to meters in the Data Portal with no trouble.

 

Thanks!

Steve

0 Kudos
Message 1 of 6
(1,732 Views)

Hello Steve,

At the channel the unit can be set by using the property "unit_string".
Therefore your second expression should be OK.

Here are some variants for the channel also with using the data API (uses the Channel "Geschwindigkeit" of the example file):

Call ChnPropValSet("[1]/Geschwindigkeit", "unit_string", "km/h")
Call ChnPropSet("[1]/Geschwindigkeit", "unit_string", "m/s")


Dim oChn : Set oChn = Data.Root.ChannelGroups(1).Channels("Geschwindigkeit")
oChn.UnitSymbol="km/h"
oChn.Properties("unit_string").Value="m/s"


The older commands like ChnPropValSet() are obsolete. Please use the object-oriented interface of the internal data instead like oChn.Properties().Value etc.

RootPropValSet("Unit", "m") modifies properties only at the root (top level) and does not affect the unit at the channel. There is no channel reference here.

The methods mentioned above only modify the value of the unit property "unit_string".
To convert the channel values from one unit into another unit (m/s -> km/h) use this:

Set ChnResult = ChnConvertUnit("[1]/Geschwindigkeit", "[1]/Geschwindigkeit", "km/h")

Hope the explanations help.

Greetings
Thomas

0 Kudos
Message 2 of 6
(1,702 Views)

Thank you Thomas, I will give it a try. I am using an old version of Diadem, 2010.

 

Best Regards,

Steve

Houston, TX

0 Kudos
Message 3 of 6
(1,681 Views)

To set, simply:

Data.Root.ChannelGroups(4).Channels("DTC").UnitSymbol = "m"

To convert:

ChnUnitConvert("[4]/DTC", "[4]/DTC", "m")
0 Kudos
Message 4 of 6
(1,675 Views)

Thanks for the reply, gskylr.

 

Tried this:

Data.Root.ChannelGroups(4).Channels("DTC").UnitSymbol="m"
Call ChnUnitConvert("[4]/DTC","[4]/DTC","m") '... Y,E,TargetUnit

 

I still get the error "The input channel does not have a unit"

 

Is there a way that I can assign the unit when I create the channel? Here is where the channel is created:

Call Data.Root.ChannelGroups(4).Channels.Add("DTC",DataTypeFloat64,5)

 

The only property that I have been successful in changing is with this:

'Call ChnPropValSet("[4]/DTC", "unit", "km/h") ' Adds Property called Unit

But it will not put a value in that property.

 

Best Regards,

Steve

0 Kudos
Message 5 of 6
(1,664 Views)

Which line of code errors out?

Can I see the error message?

What type of channel is that?

 

I just don't know how to reproduce the error, maybe attach example data and script that makes the error?

0 Kudos
Message 6 of 6
(1,648 Views)