Version: 10.2.1c and 10.2.1c SP3 |
ArcFM Engine Overview > ArcFM Engine Customizations > Custom Electric Trace Strategies > Electric Trace Code Sample |
This sample code demonstrates how to create a custom electric trace tool for ArcFM Viewer (ArcFM Engine). A custom electric trace requires two classes that inherit from a base class: trace strategy and user interface.
Trace Strategy
Set the using directives for Miner.Interop and Miner.Framework. TraceStrategies.
Inherit from the BaseElectricTraceStrategy class.
Override DoTrace.
Instantiate the trace to execute. In this example, MMFeederTracerClass is instantiated.
Create out variables (tracedJunctions and tracedEdges) that will contain the results.
Traced edges and junctions must be set on the base class in order to be displayed. Fill the out variables with the traced edges and junctions and pass them to the base class for display.
C# Sample - Trace Strategy |
Copy Code
|
---|---|
using System; using System.Windows.Forms; //1 using Miner.Interop; using Miner.Framework.TraceStrategies; using Esri.ArcGIS.Geodatabase; using Esri.ArcGIS.Carto; using Esri.ArcGIS.esriSystem; namespace Miner.DeveloperSamples.Engine { /// <summary> /// Summary description for TraceDownstream. /// </summary> //2 public sealed class TraceDownstream : BaseElectricTraceStrategy { #region Public Constructors public TraceDownstream() { } #endregion Public Methods #region Protected Overrides //3 protected override void DoTrace() { // create an instance of the Feeder Manager class // that performs electric tracing functions //4 IMMElectricTracingEx elecTrace = new MMFeederTracerClass(); IMMCurrentStatus cs = null; // the tracing results will be returned in these variables IMMTracedElements tracedJcts; IMMTracedElements tracedEdgs; //5 int[] barrierJncts = new int[0]; int[] barrierEdges = new int[0]; // call the tracing function elecTrace.TraceDownstream( CurrentGeometricNetwork, ElectricTraceSettings, cs, CurrentStartEID, esriElementType.esriETJunction, SetOfPhases.abc, mmDirectionInfo.establishBySourceSearch, 0, esriElementType.esriETEdge, barrierJncts, barrierEdges, false, out tracedJcts, out tracedEdgs); TraceUtils tu = new TraceUtils(); // pass back the trace results //6 TracedJunctions = tu.ConvertTracedElementsCollectionToEnumNetEid(tracedJcts, CurrentGeometricNetwork.Network); TracedEdges = tu.ConvertTracedElementsCollectionToEnumNetEid(tracedEdgs, CurrentGeometricNetwork.Network); } #endregion Protected Overrides } } |
User Interface
Set the using directives.
Inherit from the BaseElectricTraceTool class.
Set the constructor values.
C# Sample - User Interface |
Copy Code
|
---|---|
using System; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Drawing; using Miner.Interop; //1 using Miner.Framework.TraceStrategies; using Miner.FrameworkUI.TraceStrategies; using Esri.ArcGIS.Utility.BaseClasses; using Esri.ArcGIS.ControlCommands; using Esri.ArcGIS.Utility.CATIDs; namespace Miner.DeveloperSamples.Engine { /// <summary> /// Summary description for TraceDownstreamTool. /// </summary> [ComVisible(false)] //2 public sealed class TraceDownstreamTool : BaseElectricTraceTool { #region Public Constructors / Destructors public TraceDownstreamTool() : base(new TraceDownstream()) { //3 base.m_category = "ArcFM Developer Samples"; base.m_caption = "Dev: Downstream Trace"; base.m_message = "Dev: Downstream Trace"; base.m_toolTip = "Dev: Downstream Trace"; base.m_name = "Dev: Downstream Trace"; base.m_bitmap = new Bitmap(GetType().Assembly.GetManifestResourceStream(GetType().Namespace + ".Resources.ElecDownstreamTrace.bmp")); } #endregion Public Constructors / Destructors } } |