Via code I would need to find the resource on a system based on a DVE that represents the equipment.
For example I have a Main Element using the iControl connector. This element generates a DVE per output (iControl.EXT-A, iControl.EXT-B ...)
For each of these outputs a (function)resource is created on the system.
Via an automation script, I now need to find this function resource starting from the (equipment) DVE dmaId/elementId
Can you please share me a code example?
Hi Mieke,
You can get the function resource from the equipment DVE.
You do need the Primary Key and Table ID from the DVE table of the main.
Then, you can search on function resources with filter on Function ID, Main DataMinerID, Main ElementID and table entry:
Tuple<int, string> = <Table ID, Primary Key of equipment DVE> from the Main.
Normally, it will result in 1 function resource.
Assumption: you can use general parameter 65100 "[Generic DVE Table]" on the main element, because some interesting data is stored there as well.
Both DVE Name and the Resource ID are stored in the [Generic DVE table]; therefore you should be able to access resource Id from DVE name using data available in that table.
Alternative is to use the ResourceManagerHelper and an appropriate filter:
FilterElement<Resource> filter = ResourceExposers.DmaID.Equal(fctDve.DmaId).AND(ResourceExposers.ElementID.Equal(fctDve.ElementId));
var fctResource = RMHelper.GetResources(filter).OfType<FunctionResource>().First();
Hi Mieke,
If you want the exact function resource (pseudo code):
var functionID = Guid.NewGuid(); var dveElement = new LiteElementInfoEvent(); //server filter FilterElement<Resource> dveFunctionFilter = FunctionResourceExposers.FunctionGUID.Equal(functionID).AND( FunctionResourceExposers.MainDVEDmaID.Equal(dveElement.DveParentDmaId).AND( FunctionResourceExposers.MainDVEElementID.Equal(dveElement.DveParentElementId).AND( ResourceExposers.DmaID.Equal(dveElement.DataMinerID).AND( ResourceExposers.ElementID.Equal(dveElement.ElementID))))); //client filter Predicate<Resource> dveFunctionPredicate = r => { return r is FunctionResource fr && fr.FunctionGUID == functionID && fr.MainDVEElementID == dveElement.DveParentDmaId && fr.MainDVEElementID == dveElement.DveParentElementId && fr.DmaID == dveElement.DataMinerID && fr.ElementID == dveElement.ElementID; };
If you want the entry point (pseudo code):
var count = 0; _config = new FunctionResource(); FunctionEntryPoint[] entryPoints = new Skyline.DataMiner.Net.Messages.ProtocolFunctionHelper().GetFunctionEntryPoints(_config.FunctionGUID, _config.MainDVEDmaID, _config.MainDVEElementID).ToArray(); bool IsSameEntryPoint(EntryPointData entry) { return entry?.Element != null && entry.Element.DataMinerID == _config.DmaID && entry.Element.EID == _config.ElementID; } while (count < entryPoints.Length && wrapper == null) { if (entryPoints[count] is FunctionEntryPoint data && data.Data is EntryPointData[] arrayData) { var dataCount = 0; while (dataCount < arrayData.Length && wrapper == null) { if (arrayData[dataCount] is EntryPointData entry && IsSameEntryPoint(entry)) { wrapper = new EntryPointWrapper(entry, data.ParameterID); } dataCount++; } } count++; }