Esempio n. 1
0
        /// <summary>
        /// Adds the Scatter Group Communication operator to the communication group.
        /// </summary>
        /// <typeparam name="T">The type of messages that operators will send</typeparam>
        /// <param name="configurations">The configuration for the scatter operator</param>
        /// <param name="operatorName">The name of the scatter operator</param>
        /// <param name="senderId">The sender id</param>
        /// <param name="topologyType">type of topology used in the operaor</param>
        /// <returns>The same CommunicationGroupDriver with the added Scatter operator info</returns>
        public ICommunicationGroupDriver AddScatter <T>(string operatorName, string senderId,
                                                        TopologyTypes topologyType, params IConfiguration[] configurations)
        {
            if (_finalized)
            {
                throw new IllegalStateException("Can't add operators once the spec has been built.");
            }

            var spec = new ScatterOperatorSpec(senderId, configurations);

            ITopology <T> topology;

            if (topologyType == TopologyTypes.Flat)
            {
                topology = new FlatTopology <T>(operatorName, _groupName, spec.SenderId, _driverId,
                                                spec);
            }
            else
            {
                topology = new TreeTopology <T>(operatorName, _groupName, spec.SenderId, _driverId,
                                                spec,
                                                _fanOut);
            }
            _topologies[operatorName]    = topology;
            _operatorSpecs[operatorName] = spec;

            return(this);
        }
Esempio n. 2
0
 /// <summary>
 /// Adds the Scatter Group Communication operator to the communication group with default Int message type
 /// </summary>
 /// <param name="operatorName">The name of the scatter operator</param>
 /// <param name="senderId">The sender id</param>
 /// <param name="topologyType">type of topology used in the operaor</param>
 /// <returns>The same CommunicationGroupDriver with the added Scatter operator info</returns>
 public ICommunicationGroupDriver AddScatter(string operatorName, string senderId,
                                             TopologyTypes topologyType = TopologyTypes.Flat)
 {
     return(AddScatter <int>(operatorName, senderId, topologyType, GetDefaultConfiguration()));
 }
Esempio n. 3
0
 /// <summary>
 /// Creates a new Topology from users input of the name, description, type
 /// and selected entities in the drawing file
 /// </summary>
 /// <param name="name">[in] Topology name.</param>
 /// <param name="description">[in] Topology description.</param>
 /// <param name="topologyType">[in] Topology type.</param>
 /// <param name="polygonsCentroIdCollection">[in] Collection of Polygons Centroids' Object ID.</param>
 /// <param name="linkCollection">[in] Collection of Links' Object ID.</param>
 /// <param name="nodeCollection">[in] Collection of Nodes' Object ID.</param>
 private void CreateMapTopology(string name, 
     string description, 
     TopologyTypes topologyType,
     ObjectIdCollection polygonsCentroIdCollection, 
     ObjectIdCollection linkCollection,
     ObjectIdCollection nodeCollection)
 {
     TopologyModel topo = null;
     MapApplication mapApp = HostMapApplicationServices.Application;
     Topologies topos = mapApp.ActiveProject.Topologies;
     try
     {
         topos.Create(name, linkCollection, nodeCollection, polygonsCentroIdCollection, topologyType);
         topo = topos[name];
         topo.Open(Autodesk.Gis.Map.Topology.OpenMode.ForWrite);
         topo.Description = description;
         topo.Close();
     }
     catch (MapException expt)
     {
         Utility.AcadEditor.WriteMessage(string.Format("\nException throwed containing the error code: {0}", expt.ErrorCode));
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Adds the Broadcast Group Communication operator to the communication group. Default to Int message type
 /// </summary>
 /// <param name="operatorName">The name of the broadcast operator</param>
 /// <param name="masterTaskId">The master task id in broadcast operator</param>
 /// <param name="topologyType">The topology type for the operator</param>
 /// <returns>The same CommunicationGroupDriver with the added Broadcast operator info</returns>
 public ICommunicationGroupDriver AddBroadcast(string operatorName, string masterTaskId, TopologyTypes topologyType = TopologyTypes.Flat)
 {
     return(AddBroadcast <int>(operatorName, masterTaskId, topologyType, GetDefaultConfiguration()));
 }
Esempio n. 5
0
        /// <summary>
        /// Adds selected entities to the new topology object
        /// </summary>
        /// <param name="mapTopology">[in] Map topology object.</param>
        /// <param name="topologyType">[in] The type of topology.</param>
        /// <returns>  
        /// Returns true if successful.
        /// </returns>
        private bool SelectTopologyEntities(TopologyModel mapTopology, TopologyTypes  topologyType)
        {
            ObjectIdCollection edgeObjIds = new ObjectIdCollection();
            ObjectIdCollection nodeObjIds = new ObjectIdCollection();

            // Get the required selection sets
            switch (topologyType)
            {
                case TopologyTypes.Polygon:
                case TopologyTypes.Linear:
                    Utility.AcadEditor.WriteMessage("\nSelect links to add to the new topology: ");
                    if (HelperFunctions.SelectIds(edgeObjIds) == PromptStatus.Cancel)
                    {
                        return false;
                    }
                    // Convert the selection sets to arrays of object ids
                    break;
                case TopologyTypes.Point:
                    Utility.AcadEditor.WriteMessage("\nSelect nodes to add to the new topology: ");
                    if (HelperFunctions.SelectIds(nodeObjIds) == PromptStatus.Cancel)
                    {
                        return false;
                    }
                    break;
            }

            // Open the topology for Write
            try
            {
                mapTopology.Open(Autodesk.Gis.Map.Topology.OpenMode.ForWrite);
            }
            catch (MapException e)
            {
                Utility.AcadEditor.WriteMessage(String.Format("\nERROR: Unable to open Topology {0} for write with error code: {1}.",mapTopology.Name , e.ErrorCode));
                return false;
            }

            if (topologyType == TopologyTypes.Polygon)
            {
                // This is polygon topology, add edges to the topology.
                if (edgeObjIds.Count > 0)
                {
                    try
                    {
                        mapTopology.AddPolygons(edgeObjIds);
                    }
                    catch (MapException e)
                    {
                        mapTopology.Close();
                        Utility.AcadEditor.WriteMessage(String.Format("\nERROR: Failed to add links to topology with error code: {0}.", e.ErrorCode));
                        return false;
                    }
                }
            }
            else if (topologyType == TopologyTypes.Linear)
            {
                // This is network topology, add edges to the topology.
                if (edgeObjIds.Count > 0)
                {
                    foreach (ObjectId objId in edgeObjIds)
                    {
                        FullEdge returnedEdge = null;

                        try
                        {
                            returnedEdge = mapTopology.AddCurveObject(objId);
                        }
                        catch (MapException e)
                        {
                            mapTopology.Close();
                            Utility.AcadEditor.WriteMessage(String.Format("\nERROR: Failed to add links to topology with error code: {0}.", e.ErrorCode));
                            return false;
                        }
                    }
                }
            }

            // The node objects could be added to Polygon/Netware/Node topology
            if ((topologyType == TopologyTypes.Polygon || topologyType == TopologyTypes.Linear) && edgeObjIds.Count > 0 ||
                topologyType == TopologyTypes.Point)
            {
                if (nodeObjIds.Count > 0)
                {
                    foreach (ObjectId objId in nodeObjIds)
                    {
                        Node returnedNode = null;
                        try
                        {
                            returnedNode = mapTopology.AddPointObject(objId);
                        }
                        catch (MapException e)
                        {
                            mapTopology.Close();
                            Utility.AcadEditor.WriteMessage(String.Format("\nERROR: Failed to add nodes to topology with error code: {0}.", e.ErrorCode));
                            return false;
                        }
                    }
                }
            }
            mapTopology.Close();

            return true;
        }