Start a Conversation

Unsolved

This post is more than 5 years old

981

April 19th, 2010 06:00

Dynamic model count devices by type

Hello!

I've defined a "Site" class using dynamic model and I'm using the following code to count the number of devices in the site (using ConsistsOf relationship):

interface Site:ICIM_Collection

"Site where a group of devices is located."
{

     computed attribute unsigned short NumberOfDevices

     "Total number of devices in the site."

     = | ConsistsOf |;

}

So, I was wondering, is it possible to count the number of devices by type? For example, I was looking to count the number of Routers in the Site.

interface Site:ICIM_Collection
"Site where a group of devices is located."

     computed attribute unsigned short NumberOfRouters

     "Total number of router in the site."

     //= ???;

}

Any help would be appreciated.

Thank you for your time.

Isabelle.

April 19th, 2010 07:00

Hi Isabelle,

you can do this, by intention, not extension (not dynamic) from what I know. Something like :

number = | ( ) |

in your case:

NumberOfRouters = | Router(ConsistsOf) |

HTH,

--Fred

== APG5 ReportPack4Event for Smarts can report on millions of notifications in seconds ==
Frederic Meunier
Solutions Watch4Net Inc
APG & Smarts InCharge integration
http://www.watch4net.com

April 19th, 2010 07:00

Hello Frederic,

I had tried the following code before:

interface Site:ICIM_Collection
"Site where a group of devices is located."
{

     computed attribute unsigned short NumberOfRouters

     "Total number of routers in the site."

     = | Router(ConsistsOf) | ;

}

And got the following errors;

dynmodel: "Site.mdl", line 119: Count can only be used for tables and relationship sets
dynmodel: "Site.mdl", line 119: error in lookup of symbol: Router
dynmodel: Site.mdl: found 2 errors
Compilation aborted due to errors.

I thought I might have done something wrong, but according to your answer the logic is correct. Do you have any idea what might be wrong (maybe a #pragma missing, or a different way of compiling)?

And what do you mean by "you can do this, by intention, not extension (not dynamic) from what I know" ?

Thank you very much for your time.

Cordially,

Isabelle.

April 19th, 2010 08:00

Hum ... right, this is because Router is not defined in your model. The syntax actually works, at least with new classes. I do use it.

What version are you running on ?

extension / intention :

http://www.britannica.com/EBchecked/topic/289860/intension

extension : you will need to add an attribute (total number) per class (not dynamic, a new class need a new attribute)

intention : you can get the class dynamicaly and associate a value with it (no need to change anything)

for your information : what you want to achieve here can be done, in "intention", using APG. Dynamically. Every new class in the relationship will appear with the right count.

HTH,

--Fred

== APG5 ReportPack4Event for Smarts can report on millions of notifications in seconds ==
Frederic Meunier
Solutions Watch4Net Inc
APG & Smarts InCharge integration
http://www.watch4net.com

52 Posts

May 27th, 2010 05:00

Simply include

refine Router {}

at the start and it will pass the syntax validation of dynamic model.

--Bill

No Events found!

Top