Hi,
We are trying to develop MIP Plugin,
Now, we decide to separate the plugin into 2 Plugins:
1. manage Item Configuration
2. manage Run-Time process and events
the 1’st plugin design to mange the Controller items configuration that include a lot of sub items in one UI with few tabs in it (without using a tree hierarchy with few branch level)
however it save all sub-items as properties of main item.
so far its OK, now, when we save this “big” item with all his properties we want to create (in behind) all the run-time items which belong to the second plugin, so we can update item status in run-time.
we fail to create this run-time item, I don’t know how create the item with proper kind and FQID and parent it fail on Configuration.Instance.SaveItemConfiguration
if you have a sample code it prefers.
sample code:
Assuming that plugin 2 will be installed and run somewhere else than on Management Client (most likely Event Server?) you should in the Init method of your plugin definition in this plugin assign a different hierarchy of ItemNodes than the one you provide in the management client version.
This hierarchy should reflect the actual structure you want (with the big items and many children) and therefore you need to implement special ItemManagers for each of your node types (kinds).
The ItemManager for your “big item” type should be pretty standard (similar to what you will find for the Controller type in the SensorMonitor sample), but the other one for the property based children need to be a bit different. In this one you should implement the various GetItem and GetItems methods so that they will generate the items on the fly (based on information read from the properties of the parent) instead of loading them from the database.
You should then not call SaveItemConfiguration on these child items at all as that will add them as items in the database.
We unfortunately do not have any sample demonstrating this kind of implementation.
Can you please write more details about the part:
" In this one you should implement the various GetItem and GetItems methods so that they will generate the items on the fly (based on information read from the properties of the parent) instead of loading them from the database"
what you mean by “generate the items on the fly”? any best practices?
how can we create item not in the database and still be able to see them in the smart client map?
if we want to create the item in the DB any way, why this is failing in the sample code that i added in the post.
What is available for the Map in Smart Client depends on what is returned by the ItemManager in the Event Server plugin. Therefore if you make an ItemManager in your Event Server plugin that creates the Items when requested, but without adding them to database that will make them available for the Map.
However, if you want all items stored in the database I misunderstood you. You wrote that you wanted them based on Properties stored on the parent item, so I assumed that meant you did not want them in the database.
The reason why your SaveItemConfiguration fails is most likely that you create and empty FQID. The FQID needs to be filled in with proper ID, parent, Kind, Name, etc.
Also the Kind must be defined in the system. This is typically done in a Management Client plugin (see e.g. SensorMonitor sample), but you can also define it using the MIPKind class. We do - however - not have an example of this as it is not the recommended approach.
Hi Peter,
As you wrote in prev message “What is available for the Map in Smart Client depends on what is returned by the ItemManager in the Event Server plugin. Therefore if you make an ItemManager in your Event Server plugin that creates the Items when requested”
we have some issues:
- how to make/create an ItemManager in our Event Server plugin that creates/returns all ‘on the fly’ Items ,Do you have any sample? is it under the background section in the code?
- Is it possible that above ItemManager handle all Kinds of Items or we need Item manager per each Kind?
- As we saw ‘On The Fly’ Items not associate with plugin, but even so because the ItemManager manage GetItems it should show them in the Map Correct?
- How to create an On The Fly Items which has parent, kind, so then we may add them to our internal items list?
BR
we prefer to use on the fly items without database items.
now you wrote:
“Therefore if you make an ItemManager in your Event Server plugin that creates the Items when requested, but without adding them to database that will make them available for the Map.”
what do you mean by this, how we create the items?
do we need change only the method “GetItem” and GetItmes" in the item managers?
Basically yes. And make sure that your Items are created with proper FQIDs (see previous answer) and that you have all necessary information available so that you can consistently recreate the same Items on each request.
Can you give a code sample for creating a FQID with Kind, Parent, PluginID.
and a sample code to create items on the fly.
something simple that we can understand what we need to do.
You can see examples of this in i.e. the “Bat file execution from rule action” and “PlatformFileServer / PlatformFileView” plug-in samples.