1

Topic: Custom Device XML

I have developed XML files that create custom devices based on basic NWare blocks wired in custom configurations. I know that documentation on XML implementation is scarce...I have been running on trial and error thus far, with reasonably good results.

I am having trouble with one particular item that I need to resolve:

I create a .if.xml file that has a property which is used to populate the block title when used by the .pres.xml file. If I enter a value in the dialog box for this property, the property is correctly used to make the title text of the block. However, if I leave the default value, and then later directly edit the title of the block, when I run the device properties again, the property shows the default value, not the manually edited value.

How can I make the property pick up the edited value?  ...or, how can I make the .pres.xml utilize the block title as a text string to be used in an xml statement?

A related question, how can I use items of the device_type_identifier as text strings to be used in an xml statement in the pres.xml file?

Thanks!

Thanks!

Dave

2

Re: Custom Device XML

draudio,
  You're treading on lucrative, but uncharted territory here...  We'll get you answers to your specific questions in the next couple of days...

3

Re: Custom Device XML

So I've looked into this quite extensively, and what it is appearing to do is the following.

The text box in the device properties can be assigned to a variable name.
Variable names can be assigned to a member of the device.
The member of the device which shows the string on the block is called 'text'.
Editing the device properties causes the xml file to be run, essentially.
Editing the block properties does not, it just edits the member 'text's value.
Members can export their value into a global table, with a symbol name. (globally within the objects scope)
Members can import a value from the global table using a symbol name.
Variables cannot be put into the global table, they exist in a different context.

Putting this all together, it means you can't do what is trying to be achieved!

The closest you can get is to set the member 'text' using your variable from the device properties.
'text' will also be editied by bringing up the block properties and it will have the last value set to it. However, the value stored in the variable will be the one set in the device properties and this cannot be changed by editing the block properties which is where you got to with this.

As to the second question in this post I could not find a way to use device_type_identifiers, however there is a way to use the device_info as follows:

eg

(from interface definition file)
<device_info>
    <model_name>Automatic Gain Share Mixer</model_name>
</device_info>

(from presentation definition file)
<member name="text" value="model_name" rule="device_info" />

this sets the member text to the value of model_name inside the device_info block. Which could be a handy feature.

4

Re: Custom Device XML

Mat,

Re: text properties...So I understand that what I am currently doing is the best that I can do, and that I have to deal with the fact that the variable and the text property can/will get out of sync. Darn! Maybe this is something to put on the list for future releases...though I am sure that it is a low priority....

Re:Using device_info...Great!  This should do the trick. Thanks!

Thanks!

Dave

5

Re: Custom Device XML

Mat,

So I can use this now, and I find I really want to be able to concatenate several values into a single string...

Any ideas?

Thanks!

Thanks!

Dave

6

Re: Custom Device XML

Hi Dave

There are two ways to concatenate strings. Either prefix the xml attribute you want to have concatenated strings in with xpr: or use the xpp:evaluate element. Both of these invoke the expression evaluator, which is usually declared using the xpr namespace.

Example 1
<member name="text" xpr:value="my_variable + 'some predefined text' + my_other_variable" />

Example 2
<xpp:evaluate expression="calculated_variable = my_variable + 'some predefined text' + my_other_variable" />

7

Re: Custom Device XML

Mat,

I have no problems using concatenation with regular variables. I cannot however use the "rule" function in a concantenation successfully:

<member name="text" xpr:value='"My Model Name:" + model_name rule="device_info" />

doesn't work, nor does:

<xpp:evaluate expression="MyName = model_name" rule="device_info" />

If I drop the <rule="device_info"> it doesn't work either...

Thanks!

Dave

8

Re: Custom Device XML

Try

<member name="text" xpr:value='" 'My Model Name:' + model_name" rule="device_info" />