DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to replace units of a channel through scripts%3F

Solved!
Go to solution

 

Hi,

 

I have few queries regarding the manipulation of the channel property 'unit' by scripts.

 

 

Case 1: If the unit of the channel is not specified in the properties, what command should be used to add the unit in it?

 

Case 2: When I create channel using 'Call.Root.ChannelGroups(1).Channels.Add("name", DataTypeFloat64,1)', the unit space being empty, what other command can be used which has the provision for units within?

 

Case 3: Consider I have channel (Channel A) with unit already defined (x), How can I replace the unit with another one (y)? (Units x and y belong to different physical quantities, so the ChnUnitConvert) 

 

 

Pls let me know if you nee more clarifications on the same.

 

Regards,

Fazil Shah.

 

0 Kudos
Message 1 of 3
(7,818 Views)
Solution
Accepted by topic author faz_shah

Hi Fazil,

The key word for units in DIAdem SCRIPT is "unit_string". If you open SCRIPT and open the channel property list you can select the unit property and drag & drop it into the SCRIPT editor. This creates the script code for the property.

Case 1
You have tow options: a full quallified assignment or a channel object variable (if you have more settings for the channel the second variant is better)

Data.Root.ChannelGroups(1).Channels("MyChannel").Properties("unit_string").Value = "MyUnit"

or

dim oChn
set oChn = Data.Root.ChannelGroups(x).Channels("MyChannel")
oChn.Properties("unit_string").Value = "MyUnit"

case 2
You need to add the unit after creating the channel

set oChn = Data.Root.ChannelGroups(x).Channels.Add("MyChannel", DataTypeChnFloat64)
oChn.Properties("unit_string").Value = "MyUnit"

case 3
This is the same like case 1 or if you would like to use the unit of an already existing channel it can looks like this

oChnA.Properties("unit_string").Value = oChnB.Properties("unit_string").Value

I hope this answers your questions

 

Greetings

Walter

 

0 Kudos
Message 2 of 3
(7,807 Views)

 

Hi Walter,

 

It worked. Thanks a lot.

 

Regards,

Fazil Shah.

0 Kudos
Message 3 of 3
(7,797 Views)