Пример #1
0
    // Add a front node
    public bool AddFrontNode(UnitSystem unit, Order pathToThisNode)
    {
        if (unit == null) {
            // Return that it couldn't succesfully link the nodes
            Debug.Log("Error - " + this + " : LinkToFrontNode() called with no unit to start new node generation.");
            return false;
        }

        // Check if the path to the new node realy start from this node
        if(unit._lastNode != this) {
            // Return that it couldn't succesfully link the nodes
            Debug.Log("Error - " + this + " : LinkToFrontNode() called but the last node of the base unit isn't this node.");
            return false;
        }

        // Check if the path to the new is valide
        if (pathToThisNode._orderType == Order.OrderType.NULL) {
            // Return that it couldn't succesfully link the nodes
            Debug.Log("Error - " + this + " : LinkToFrontNode() called with an invalide order.");
            return false;
        }

        // Generate the new node game object
        GameObject newNodeGameObject = Instantiate(_nodePrefab);

        // Parameter the new node game object
        newNodeGameObject.name = "Node";
        newNodeGameObject.transform.parent = gameObject.transform.parent;
        Vector3 spawnPosition = unit.transform.position;
        spawnPosition.z = 0;
        newNodeGameObject.transform.position = spawnPosition;

        // Get the node system from the generated game object
        Node newNode = newNodeGameObject.GetComponent<Node>();

        // Put the unit on the new node
        newNode._unitOnNode = unit;

        // Set the current node on unit
        unit._currentNode = newNode;

        // Add a connection to this node
        _frontNodes.Add(new Connexion(newNode, pathToThisNode, unit._age));

        // Realculate relevant destination of the unit on this node
        if (IsOccupied()) {
            _relevantConnexionFound = CalculateRelevantConnexion(ref _relevantConnexion);
            if (!_relevantConnexionFound) {
                // No relevant destination has been found
            } else {
                // A relevant destination has been found
            }
        }

        // Sign & Feedback
        newNode.SetLinkFeedback(this, unit._age);

        return false;
    }
Пример #2
0
 public void UpdateUnitSystem(UnitSystem selectedUnitSystem)
 {
     if (mapControl.AdornmentOverlay.Layers.Contains("ScaleBar"))
     {
         ScaleBarAdornmentLayer scaleBarLayer = (ScaleBarAdornmentLayer)mapControl.AdornmentOverlay.Layers["ScaleBar"];
         scaleBarLayer.UnitFamily = selectedUnitSystem;
         mapControl.AdornmentOverlay.Refresh();
     }
 }
        public MainWindowViewModel(WpfMap map)
        {
            dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(5000);
            dispatcherTimer.Tick += AutoRefreshTimer_Tick;

            vehicles = new ObservableCollection<VehicleViewModel>();
            unitSystems = new Collection<UnitSystem>();
            unitSystems.Add(UnitSystem.Imperial);
            unitSystems.Add(UnitSystem.Metric);
            selectedUnitSystem = UnitSystem.Metric;
            autoRefreshMode = AutoRefreshMode.On;
            autoRefresh = true;
            drawFenceMode = DrawFenceMode.DrawNewFence;
            measureMode = MeasureMode.Line;
            mapMode = ControlMapMode.Pan;
            measurePanelVisibility = Visibility.Collapsed;
            editPanelVisibility = Visibility.Collapsed;

            MapControl = map;

            dispatcherTimer.Start();
        }
Пример #4
0
        public override string ToPrint()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append("Process Stream: ");
            sb.Append(this.ProcessStream.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(GetVariableName(this.ProcessStream.MassFlowRate, us));
            sb.Append(" = ");
            sb.Append(GetVariableValue(this.ProcessStream.MassFlowRate, us, nfs));
            if (this.ProcessStream.MassFlowRate.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(GetVariableName(this.ProcessStream.VolumeFlowRate, us));
            sb.Append(" = ");
            sb.Append(GetVariableValue(this.ProcessStream.VolumeFlowRate, us, nfs));
            if (this.ProcessStream.VolumeFlowRate.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(GetVariableName(this.ProcessStream.Pressure, us));
            sb.Append(" = ");
            sb.Append(GetVariableValue(this.ProcessStream.Pressure, us, nfs));
            if (this.ProcessStream.Pressure.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(GetVariableName(this.ProcessStream.Temperature, us));
            sb.Append(" = ");
            sb.Append(GetVariableValue(this.ProcessStream.Temperature, us, nfs));
            if (this.ProcessStream.Temperature.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(GetVariableName(this.ProcessStream.SpecificEnthalpy, us));
            sb.Append(" = ");
            sb.Append(GetVariableValue(this.ProcessStream.SpecificEnthalpy, us, nfs));
            if (this.ProcessStream.SpecificEnthalpy.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(GetVariableName(this.ProcessStream.SpecificHeat, us));
            sb.Append(" = ");
            sb.Append(GetVariableValue(this.ProcessStream.SpecificHeat, us, nfs));
            if (this.ProcessStream.SpecificHeat.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(GetVariableName(this.ProcessStream.Density, us));
            sb.Append(" = ");
            sb.Append(GetVariableValue(this.ProcessStream.Density, us, nfs));
            if (this.ProcessStream.Density.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            return(sb.ToString());
        }
Пример #5
0
    // Transmit the unit on this node toward the relevant connexion's node
    bool SendUnit(Connexion relevantConnexion)
    {
        // Check if there is a unit to send
        if (_unitOnNode == null) {
            // Otherwise,
            // Return that it couldn't succesfully send the inexisting unit
            Debug.Log("Error - " +this +" : SendUnit() called with no unit to send.");
            return false;
        }

        // Check if the unit can start traveling to the relevant node
        if (!_unitOnNode.IsReadyToExecuteOrder()) {
            // Otherwise,
            // Return that it couldn't succesfully send the inexisting unit
            Debug.Log("Error - " + this + " : SendUnit() called but the unit isnt't ready to travel to it's new destination.");
            return false;
        }

        // Transmit the unit on this node to the target node system
        if (!relevantConnexion._connectedNode.RecieveUnit(_unitOnNode)) {
            // If the target node couldn't recive the unit,
            // Return that it couldn't succesfully send the unit
            Debug.Log("Error - " + this + " : SendUnit() called but couldn't successfully transmit the unit to it's destination node.");
            return false;
        }

        // Make the unit travel to it's relevant node
        _unitOnNode.RecieveOrder(relevantConnexion._path);

        // Set the target node on unit
        _unitOnNode._currentNode = relevantConnexion._connectedNode;

        // Set the last node on unit
        _unitOnNode._lastNode = this;

        // Check if the unit has a child
        if (_unitOnNode._childCount > 0) {
            // If it does, spawn it on this node
            _unitOnNode._childCount--;
            _unitOnNode = SpawnUnitOnNode();
            // Calculate relevant destination
            _relevantConnexionFound = CalculateRelevantConnexion(ref _relevantConnexion);
        } else {
            // Otherwise, remove the stored unit from this node if it was sucessfully sent
            _unitOnNode = null;
            // Reset relevant connexion
            _relevantConnexionFound = false;
        }

        // Return that it succesfully send the unit
        return true;
    }
Пример #6
0
        public override string ToPrint()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append("Electrostatic Precipitator: ");
            sb.Append(this.ElectrostaticPrecipitator.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.GasPressureDrop, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.GasPressureDrop, us, nfs));
            if (this.ElectrostaticPrecipitator.GasPressureDrop.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.CollectionEfficiency, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.CollectionEfficiency, us, nfs));
            if (this.ElectrostaticPrecipitator.CollectionEfficiency.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.InletParticleLoading, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.InletParticleLoading, us, nfs));
            if (this.ElectrostaticPrecipitator.InletParticleLoading.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.OutletParticleLoading, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.OutletParticleLoading, us, nfs));
            if (this.ElectrostaticPrecipitator.OutletParticleLoading.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.ParticleCollectionRate, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.ParticleCollectionRate, us, nfs));
            if (this.ElectrostaticPrecipitator.ParticleCollectionRate.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.MassFlowRateOfParticleLostToGasOutlet, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.MassFlowRateOfParticleLostToGasOutlet, us, nfs));
            if (this.ElectrostaticPrecipitator.MassFlowRateOfParticleLostToGasOutlet.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.DriftVelocity, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.DriftVelocity, us, nfs));
            if (this.ElectrostaticPrecipitator.DriftVelocity.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.TotalSurfaceArea, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.TotalSurfaceArea, us, nfs));
            if (this.ElectrostaticPrecipitator.TotalSurfaceArea.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            return(sb.ToString());
        }
Пример #7
0
        /// <summary>
        /// Returns the distance in miles or kilometres of any two latitude / longitude points.
        /// </summary>
        /// <param name="origin">The start latitude and longitude </param>
        /// <param name="destination">The destination latitude and longitude </param>
        /// <param name="units">The unit system to use, default is metric</param>
        /// <returns>Distance in kilometres</returns>
        public static double DistanceHaversine(Coordinate origin, Coordinate destination, UnitSystem units = UnitSystem.Metric)
        {
            double phi1 = ConvertDegreesToRadians(origin.Latitude);
            double phi2 = ConvertDegreesToRadians(destination.Latitude);
            double deltaPhi = ConvertDegreesToRadians(destination.Latitude - origin.Latitude);
            double deltaLambda = ConvertDegreesToRadians(destination.Longitude - origin.Longitude);
            double h1 = (Math.Sin(deltaPhi / 2) * Math.Sin(deltaPhi / 2)) +
                (Math.Sin(deltaLambda / 2) * Math.Sin(deltaLambda / 2) * Math.Cos(phi1) * Math.Cos(phi2));
            double d = 2 * Math.Asin(Math.Min(1, Math.Sqrt(h1)));

            if (units == UnitSystem.Metric)
            {
                return d * EarthMeanRadiusKilometres;
            }
            else
            {
                return d * EarthMeanRadiusMiles;
            }
        }
Пример #8
0
        /// <summary>
        /// Destination point given distance and bearing from start point
        /// </summary>
        /// <param name="origin">the start point</param>
        /// <param name="distance">the given distance in km or m</param>
        /// <param name="bearing">the bearing in radians, clockwise from north</param>
        /// <param name="units">The unit system to use, default is metric</param>
        /// <returns>destination location as a Tuple(double lat, double lng)</returns>
        public static Coordinate Destination(Coordinate origin, double distance, double bearing, UnitSystem units = UnitSystem.Metric)
        {
            double phi1 = Maths.ConvertDegreesToRadians(origin.Latitude);
            double lambda1 = Maths.ConvertDegreesToRadians(origin.Longitude);
            bearing = Maths.ConvertDegreesToRadians(bearing);

            double angularDistance = 0;

            if (units == UnitSystem.Metric)
            {
                angularDistance = distance / Maths.EarthMeanRadiusKilometres;
            }
            else
            {
                distance = Maths.ConvertKilometresToMiles(distance);
                angularDistance = distance / Maths.EarthMeanRadiusMiles;
            }

            double phi2 = Math.Asin(Math.Sin(phi1) * Math.Cos(angularDistance) +
                Math.Cos(phi1) * Math.Sin(angularDistance) * Math.Cos(bearing));

            double lambda2 = lambda1 +
                Math.Atan2(
                Math.Sin(bearing) * Math.Sin(angularDistance) * Math.Cos(phi1),
                Math.Cos(angularDistance) - Math.Sin(phi1) * Math.Sin(phi2));

            return new Coordinate(Maths.ConvertRadiansToDegrees(phi2), Maths.ConvertRadiansToDegrees(lambda2));
        }
Пример #9
0
 /// <summary>
 /// Gets localized unit system name.  Uses current application locale id.
 /// </summary>
 /// <param name="units">The unit system.</param>
 /// <param name="capitalize">true if the name should be capitalized.</param>
 /// <param name="singular">true if the name is expressed for a singular element.</param>
 /// <param name="abbreviate">true if name should be the abbreviation.</param>
 /// <returns>The unit system name.</returns>
 public static string UnitSystemName(UnitSystem units, bool capitalize, bool singular, bool abbreviate)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoApp_UnitSystemName((int)units, capitalize, singular, abbreviate, pString);
     return sh.ToString();
   }
 }
 /// <summary>
 /// Gets a transformation from model coordinates to earth coordinates.
 /// This transformation assumes the model is small enough that
 /// the curvature of the earth can be ignored.
 /// </summary>
 /// <param name="modelUnitSystem">The model unit system.</param>
 /// <returns>
 /// Transform on success. Inalid Transform on error.
 /// </returns>
 /// <remarks>
 /// If M is a point in model coordinates and E = model_to_earth*M,
 /// then 
 ///   E.x = latitude in decimal degrees
 ///   E.y = longitude in decimal degrees
 ///   E.z = elevation in meters above mean sea level
 /// Because the earth is not flat, there is a small amount of error
 /// when using a linear transformation to calculate oblate spherical 
 /// coordinates.  This error is small.  If the distance from P to M
 /// is d meters, then the approximation error is
 /// latitude error  &lt;=
 /// longitude error &lt;=
 /// elevation error &lt;= 6379000*((1 + (d/6356000)^2)-1) meters
 /// 
 /// In particular, if every point in the model is within 1000 meters of
 /// the m_model_basepoint, then the maximum approximation errors are
 /// latitude error  &lt;=
 /// longitude error &lt;=
 /// elevation error &lt;= 8 centimeters.
 /// </remarks>
 public Transform GetModelToEarthTransform(UnitSystem modelUnitSystem)
 {
   Transform rc = Transform.Unset;
   IntPtr ptr_const_this = ConstPointer();
   UnsafeNativeMethods.ON_EarthAnchorPoint_GetModelToEarthTransform(ptr_const_this, (int)modelUnitSystem, ref rc);
   return rc;
 }
Пример #11
0
    void Feedback_UpdateDragColor(UnitSystem startUnit)
    {
        // Color
        Color startColor = Color.white;
        startColor.a = 0f;
        Color endColor = startUnit.Feedback_GetAgeColor();

        // Calculate alpha
        Vector3 startPosition = startUnit.transform.position;
        startPosition.z = 0;
        Vector3 endPosition = _debug_mainCamera.ScreenToWorldPoint(Input.mousePosition);
        endPosition.z = 0;
        float alpha = Mathf.Clamp(Vector3.Distance(startPosition, endPosition) - (startUnit.Feedback_GetAgeSize()), 0f, 1f);

        // Set alpha
        endColor.a = alpha;

        // Apply color
        _debug_lineDrag.SetColors(startColor, endColor);
    }
Пример #12
0
 /// <summary>Computes the scale factor for changing the measurements unit systems.</summary>
 /// <param name="from">The system to convert from.</param>
 /// <param name="to">The system to convert measurements into.</param>
 /// <returns>A scale multiplier.</returns>
 public static double UnitScale(UnitSystem from, UnitSystem to)
 {
   return UnsafeNativeMethods.ONC_UnitScale((int)from, (int)to);
 }
Пример #13
0
 private void DuhringLinesControl_CurrentUnitSystemChanged(UnitSystem unitSystem)
 {
     this.SetUnits(unitSystem);
 }
Пример #14
0
        public override string ToPrint()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append("Scrubber Condenser: ");
            sb.Append(this.ScrubberCondenser.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.GasPressureDrop, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.GasPressureDrop, us, nfs));
            if (this.ScrubberCondenser.GasPressureDrop.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.CollectionEfficiency, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.CollectionEfficiency, us, nfs));
            if (this.ScrubberCondenser.CollectionEfficiency.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.InletParticleLoading, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.InletParticleLoading, us, nfs));
            if (this.ScrubberCondenser.InletParticleLoading.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.OutletParticleLoading, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.OutletParticleLoading, us, nfs));
            if (this.ScrubberCondenser.OutletParticleLoading.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.ParticleCollectionRate, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.ParticleCollectionRate, us, nfs));
            if (this.ScrubberCondenser.ParticleCollectionRate.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.MassFlowRateOfParticleLostToGasOutlet, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.MassFlowRateOfParticleLostToGasOutlet, us, nfs));
            if (this.ScrubberCondenser.MassFlowRateOfParticleLostToGasOutlet.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.CoolingDuty, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.CoolingDuty, us, nfs));
            if (this.ScrubberCondenser.CoolingDuty.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.LiquidToGasRatio, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.LiquidToGasRatio, us, nfs));
            if (this.ScrubberCondenser.LiquidToGasRatio.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.LiquidRecirculationMassFlowRate, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.LiquidRecirculationMassFlowRate, us, nfs));
            if (this.ScrubberCondenser.LiquidRecirculationMassFlowRate.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ScrubberCondenser.LiquidRecirculationVolumeFlowRate, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ScrubberCondenser.LiquidRecirculationVolumeFlowRate, us, nfs));
            if (this.ScrubberCondenser.LiquidRecirculationVolumeFlowRate.IsSpecified)
            {
                sb.Append(" * ");
            }
            sb.Append("\r\n");

            return(sb.ToString());
        }
Пример #15
0
 private void UpdateSettings(GameSettings.GameplaySettings settings)
 {
     _unitSystem = settings.UnitSystem;
     _isVisible  = settings.ShowHud;
     UpdateVisibility();
 }
Пример #16
0
        public string ToPrintScoping()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append("Dryer Scoping:");
            sb.Append("\r\n");

            DryerScopingModel scopingModel = this.Dryer.ScopingModel;

            sb.Append(UI.GetVariableName(scopingModel.GasVelocity, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(scopingModel.GasVelocity, us, nfs));
            sb.Append("\r\n");

            string crossSectionTypeStr = "";

            if (this.Dryer.ScopingModel.CrossSectionType == CrossSectionType.Circle)
            {
                crossSectionTypeStr = "Circle";
            }
            else if (this.Dryer.ScopingModel.CrossSectionType == CrossSectionType.Rectangle)
            {
                crossSectionTypeStr = "Rectangle";
            }
            sb.Append("Cross Section Type");
            sb.Append(" = ");
            sb.Append(crossSectionTypeStr);
            sb.Append("\r\n");

            if (scopingModel.CrossSectionType == CrossSectionType.Circle)
            {
                sb.Append(UI.GetVariableName(scopingModel.Diameter, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(scopingModel.Diameter, us, nfs));
                sb.Append("\r\n");

                sb.Append(UI.GetVariableName(scopingModel.Length, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(scopingModel.Length, us, nfs));
                sb.Append("\r\n");

                sb.Append(UI.GetVariableName(scopingModel.LengthDiameterRatio, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(scopingModel.LengthDiameterRatio, us, nfs));
                sb.Append("\r\n");
            }
            else if (scopingModel.CrossSectionType == CrossSectionType.Rectangle)
            {
                sb.Append(UI.GetVariableName(scopingModel.Width, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(scopingModel.Width, us, nfs));
                sb.Append("\r\n");

                sb.Append(UI.GetVariableName(scopingModel.Length, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(scopingModel.Length, us, nfs));
                sb.Append("\r\n");

                sb.Append(UI.GetVariableName(scopingModel.Height, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(scopingModel.Height, us, nfs));
                sb.Append("\r\n");

                sb.Append(UI.GetVariableName(scopingModel.LengthWidthRatio, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(scopingModel.LengthWidthRatio, us, nfs));
                sb.Append("\r\n");

                sb.Append(UI.GetVariableName(scopingModel.HeightWidthRatio, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(scopingModel.HeightWidthRatio, us, nfs));
                sb.Append("\r\n");
            }

            return(sb.ToString());
        }
Пример #17
0
        public override string ToPrint()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append("Dryer: ");
            sb.Append(this.Dryer.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.GasPressureDrop, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.GasPressureDrop, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.HeatLoss, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.HeatLoss, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.HeatInput, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.HeatInput, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.WorkInput, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.WorkInput, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.HeatLossByTransportDevice, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.HeatLossByTransportDevice, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.MoistureEvaporationRate, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.MoistureEvaporationRate, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.SpecificHeatConsumption, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.SpecificHeatConsumption, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.ThermalEfficiency, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.ThermalEfficiency, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.FractionOfMaterialLostToGasOutlet, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.FractionOfMaterialLostToGasOutlet, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Dryer.GasOutletMaterialLoading, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Dryer.GasOutletMaterialLoading, us, nfs));
            sb.Append("\r\n");

            if (this.Dryer.ScopingModel != null)
            {
                sb.Append(this.ToPrintScoping());
            }

            return(sb.ToString());
        }
Пример #18
0
 /// <summary>
 /// Find the destination point given distance and bearing from start point
 /// </summary>
 /// <param name="distance">the given distance in km or m</param>
 /// <param name="bearing">the bearing in radians, clockwise from north</param>
 /// <param name="units">The unit system to use, default is metric</param>
 /// <returns>The destination location as a Coordinate</returns>
 public Coordinate Destination(double distance, double bearing, UnitSystem units = UnitSystem.Metric)
 {
     return(new Coordinate(Maths.Destination(this, distance, bearing, units)));
 }
Пример #19
0
    /* SIGN & FEEDBACK */
    void Feedback_SetDragColor(UnitSystem startUnit)
    {
        // Color
        Color startColor = Color.white;
        startColor.a = 0f;
        Color endColor = startUnit.Feedback_GetAgeColor();
        _debug_lineDrag.SetColors(startColor, endColor);

        // Size
        _debug_lineDrag.SetWidth(startUnit.Feedback_GetAgeSize()*2f, 0);
    }
Пример #20
0
        public ShapeDataForm(Shape shape, UnitSystem unitSystem) : this()
        {
            if (shape == null)
            {
                throw new ArgumentNullException();
            }

            this.unitSystem = unitSystem;

            txtName.Text   = shape.Name;
            lblParent.Text = shape.Parent == null ? "<none>" : string.IsNullOrEmpty(shape.Parent.Name) ? "<unnamed shape>" : shape.Parent.Name;

            UnitShape unit = shape as UnitShape;

            if (unit != null)
            {
                txtSize.Enabled = false;

                txtDirection.Tag      = unit.Direction;
                txtDirection.Text     = (unit.Direction * MathConst.RadiansToDegrees).ToString("0.##");
                txtSpeed.Tag          = unit.Speed;
                txtSpeed.Text         = ManeuveringBoard.GetSpeedString(unit.Speed, unitSystem);
                cmbType.SelectedIndex = (int)unit.Type;

                if (unit.Parent == null)
                {
                    chkRelative.Enabled = false;
                }
                else
                {
                    chkRelative.Checked = unit.IsMotionRelative;
                }
            }
            else
            {
                txtSpeed.Enabled    = false;
                chkRelative.Enabled = false;
                cmbType.Enabled     = false;

                LineShape line = shape as LineShape;
                if (line != null)
                {
                    double angle = ManeuveringBoard.AngleBetween(line.Start, line.End), length = line.Length;
                    txtDirection.Text = (angle * MathConst.RadiansToDegrees).ToString("0.##");
                    txtDirection.Tag  = angle;
                    txtSize.Text      = ManeuveringBoard.GetDistanceString(length, unitSystem);
                    txtSize.Tag       = length;
                }
                else
                {
                    CircleShape circle = shape as CircleShape;
                    if (circle != null)
                    {
                        txtDirection.Enabled = false;
                        txtSize.Text         = ManeuveringBoard.GetDistanceString(circle.Radius, unitSystem);
                        txtSize.Tag          = circle.Radius;
                        lblSize.Text         = "Radius";
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
            }

            // set these to false, since they may have been set to true by the programmatic changes above
            directionTextChanged = sizeTextChanged = speedTextChanged = false;
        }
Пример #21
0
 private void HumidityChartForm_CurrentUnitSystemChanged(UnitSystem unitSystem)
 {
     this.unitSystem = unitSystem;
     this.plotCtrl.InitializePlotControl(this);
 }
Пример #22
0
        public HumidityChartForm(Flowsheet flowsheet, PsychrometricChartModel psychrometricChartModel)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.Text       = "Humidity Chart " + psychrometricChartModel.SystemSuffixName;
            this.flowsheet  = flowsheet;
            this.unitSystem = UnitSystemService.GetInstance().CurrentUnitSystem;
            this.psychrometricChartModel = psychrometricChartModel;

            this.labelPressureName.InitializeVariable(this.psychrometricChartModel.Pressure);
            this.textBoxPressureValue.InitializeVariable(flowsheet.ApplicationPrefs, this.psychrometricChartModel.Pressure);

            this.hcCurrentStateEditor          = new HumidityChartCurrentStateEditor(this.flowsheet, psychrometricChartModel.StateStream);
            this.hcCurrentStateEditor.Location = new Point(0, 214);
            this.panel.Controls.Add(this.hcCurrentStateEditor);
            this.hcCurrentStateEditor.Visible = false;

            this.hcProcessEditor          = new HumidityChartProcessEditor(this.flowsheet, psychrometricChartModel.ProcessInputStream, psychrometricChartModel.ProcessOutputStream);
            this.hcProcessEditor.Location = new Point(0, 214);
            this.panel.Controls.Add(this.hcProcessEditor);
            this.hcProcessEditor.Visible = false;

            this.psychrometricChartModel.HumidityChartChanged += new HumidityChartChangedEventHandler(psychrometricChartModel_HumidityChartChanged);
            this.psychrometricChartModel.SolveComplete        += new SolveCompleteEventHandler(psychrometricChartModel_SolveComplete);

            UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(HumidityChartForm_CurrentUnitSystemChanged);

            this.flowsheet.ApplicationPrefs.NumericFormatStringChanged += new NumericFormatStringChangedEventHandler(ApplicationPrefs_NumericFormatStringChanged);

            //
            this.currentStateCtrl                  = new StateControl(this.plotCtrl.Graph);
            this.currentStateCtrl.Visible          = false;
            this.currentStateCtrl.MouseDown       += new MouseEventHandler(currentStateCtrl_MouseDown);
            this.currentStateCtrl.LocationChanged += new EventHandler(currentStateCtrl_LocationChanged);
            this.currentStateCtrl.MouseUp         += new MouseEventHandler(currentStateCtrl_MouseUp);
            this.plotCtrl.Graph.Controls.Add(this.currentStateCtrl);

            this.inStateCtrl                  = new StateControl(this.plotCtrl.Graph);
            this.inStateCtrl.Visible          = false;
            this.inStateCtrl.MouseDown       += new MouseEventHandler(inStateCtrl_MouseDown);
            this.inStateCtrl.LocationChanged += new EventHandler(inStateCtrl_LocationChanged);
            this.inStateCtrl.MouseUp         += new MouseEventHandler(inStateCtrl_MouseUp);
            this.plotCtrl.Graph.Controls.Add(this.inStateCtrl);

            this.outStateCtrl                  = new StateControl(this.plotCtrl.Graph);
            this.outStateCtrl.Visible          = false;
            this.outStateCtrl.MouseDown       += new MouseEventHandler(outStateCtrl_MouseDown);
            this.outStateCtrl.LocationChanged += new EventHandler(outStateCtrl_LocationChanged);
            this.outStateCtrl.MouseUp         += new MouseEventHandler(outStateCtrl_MouseUp);
            this.plotCtrl.Graph.Controls.Add(this.outStateCtrl);

            this.plotCtrl.Graph.NumericFormatString = this.flowsheet.ApplicationPrefs.NumericFormatString;
            this.plotCtrl.InitializePlotControl(this);

            this.psychrometricChartModel.HCTypeChanged += new HCTypeChangedEventHandler(psychrometricChartModel_HCTypeChanged);
            if (this.psychrometricChartModel.HCType == HCType.IsenthalpicProcess)
            {
                this.radioButtonProcess.Checked = true;
            }
            else if (this.psychrometricChartModel.HCType == HCType.GasState)
            {
                this.radioButtonState.Checked = true;
            }
            HumidityChartTypeChanged();

            this.ResizeEnd += new EventHandler(HumidityChartForm_ResizeEnd);
        }
Пример #23
0
        /// <summary>
        /// Constructs a default IFCUnit of a specific type.
        /// </summary>
        /// <param name="unitType">The unit type.</param>
        /// <param name="unitSystem">The unit system.</param>
        /// <param name="unitName">The unit name.</param>
        /// <remarks>This is only intended to create a unit container for units that are necessary for the file,
        /// but are not found in the file.  It should not be used for IfcUnit entities in the file.</remarks>
        public static IFCUnit ProcessIFCDefaultUnit(UnitType unitType, UnitSystem unitSystem, UnitName unitName, double? scaleFactor)
        {
            IFCUnit unit = new IFCUnit();

            unit.UnitType = unitType;
            unit.UnitName = unitName;
            unit.UnitSystem = unitSystem;
            if (scaleFactor.HasValue)
                unit.ScaleFactor = scaleFactor.Value;
            unit.OffsetFactor = 0.0;

            return unit;
        }
Пример #24
0
    // The unit on this node ask for exiting this node
    public bool AskExit(UnitSystem unit)
    {
        // Check if there is the unit asking for exit correspond to the unit on this node
        if (unit != _unitOnNode) {
            // Return that it couldn't succesfully exit the unit on this node
            Debug.Log("Error - " + this + " : AskExit() called but unit asking for exit isn't on this node.");
            return false;
        }

        // Set the current node on unit
        unit._currentNode = null;

        // Set the last node on unit
        unit._lastNode = this;

        // Check if the unit has a child
        if (_unitOnNode._childCount > 0) {
            // If it does, spawn it on this node
            _unitOnNode._childCount--;
            _unitOnNode = SpawnUnitOnNode();
            // Calculate relevant destination
            _relevantConnexionFound = CalculateRelevantConnexion(ref _relevantConnexion);
        } else {
            // Otherwise, remove the stored unit from this node if it was sucessfully sent
            _unitOnNode = null;
            // Reset relevant connexion
            _relevantConnexionFound = false;
        }

        return true;
    }
Пример #25
0
 /// <summary>
 /// Get a string version of a number in a given unit system / display mode.
 /// </summary>
 /// <param name="x">The number to format into a string.</param>
 /// <param name="units">The unit system for the number.</param>
 /// <param name="mode">How the number should be formatted.</param>
 /// <param name="precision">The precision of the number.</param>
 /// <param name="appendUnitSystemName">Adds unit system name to the end of the number.</param>
 /// <returns>The formatted number.</returns>
 public static string FormatNumber( double x, UnitSystem units, DistanceDisplayMode mode, int precision, bool appendUnitSystemName )
 {
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.RHC_RhinoFormatNumber(x, (int)units, (int)mode, precision, appendUnitSystemName, pString);
     return sh.ToString();
   }
 }
Пример #26
0
    // Recieve a unit as the unit on this node
    bool RecieveUnit(UnitSystem unit)
    {
        // Check if there is a unit to recieve
        if (unit == null) {
            // Return that it couldn't succesfully retrieve the unit
            Debug.Log("Error - " + this + " : RecieveUnit() called with no unit to recieve.");
            return false;
        }

        // Check if there isn't already any unit on this node
        if (_unitOnNode != null) {
            // Return that it couldn't succesfully recieve the unit
            Debug.Log("Error - " + this + " : RecieveUnit() called but a unit is already asociated with this node.");
            return false;
        }

        // Store the unit into this node
        _unitOnNode = unit;

        // Calculate relevant destination
        _relevantConnexionFound = CalculateRelevantConnexion(ref _relevantConnexion);
        if (!_relevantConnexionFound) {
            // No relevant destination has been found
        } else {
            // A relevant destination has been found
        }

        if(_treeNode != null) {
            _treeNode._askGrow = true;
        }

        // Return that it succesfully recieved the unit
        return true;
    }
Пример #27
0
        /// <summary>
        /// Returns the distance in miles or kilometres of any two latitude / longitude points.
        /// </summary>
        /// <param name="origin">The start latitude and longitude </param>
        /// <param name="destination">The destination latitude and longitude </param>
        /// <param name="units">The unit system to use, default is metric</param>
        /// <returns>Distance in kilometres</returns>
        public static double DistanceCosine(Coordinate origin, Coordinate destination, UnitSystem units = UnitSystem.Metric)
        {
            double phi1 = ConvertDegreesToRadians(origin.Latitude);
            double phi2 = ConvertDegreesToRadians(destination.Latitude);
            double deltaLamdba = ConvertDegreesToRadians(destination.Longitude - origin.Longitude);
            double d = Math.Acos((Math.Sin(phi1) * Math.Sin(phi2)) + (Math.Cos(phi1) * Math.Cos(phi2) * Math.Cos(deltaLamdba)));

            if (units == UnitSystem.Metric)
            {
                return d * EarthMeanRadiusKilometres;
            }
            else
            {
                return d * EarthMeanRadiusMiles;
            }
        }
Пример #28
0
    // Try to retrieve a unit that triggered this node's collider
    bool RetrieveUnit(UnitSystem unit)
    {
        // Check if there is a unit to retrieve
        if (unit == null) {
            // Return that it couldn't succesfully retrieve the unit
            Debug.Log("Error - " + this + " : RetrieveUnit() called with no unit to retrieve.");
            return false;
        }

        // Check if the unit isn't already trying to reach another node
        if (unit._currentNode != null) {
            // Return that it couldn't succesfully retrieve the unit
            return false;
        }

        // Check if not trying to retrieve a unit just expulsed
        if (unit._lastNode == this) {
            // Return that it couldn't succesfully retrieve the unit
            return false;
        }

        // Check if not trying to retrieve a unit just expulsed by a node overlapping this one
        if (unit._lastNode != null && Vector3.Distance(transform.position,unit._lastNode.transform.position) < _overlapingNodeRange) {
            // Return that it couldn't succesfully retrieve the unit
            return false;
        }

        // Check if there isn't already any unit on this node
        if (_unitOnNode != null) {
            // Return that it couldn't succesfully retrieve the unit
            return false;
        }

        // Recive unit
        if(!RecieveUnit(unit)) {
            // Return that it couldn't succesfully retrieve the unit
            Debug.Log("Error - " + this + " : RetrieveUnit() called but couldnt recieve the retrieved unit.");
            return false;
        }

        unit._currentNode = this;
        unit._orderState = UnitSystem.OrderState.FINALISING_BY_NODE;

        // Return that the unit was succesfully retrieved
        return true;
    }
Пример #29
0
 /// <summary>
 /// Returns the distance in miles or kilometres of any two latitude / longitude points.
 /// </summary>
 /// <param name="origin">The start latitude and longitude </param>
 /// <param name="destination">The destination latitude and longitude </param>
 /// <param name="units">The unit system to use, default is metric</param>
 /// <returns>Distance in kilometres</returns>
 public static double DistanceHaversine(dynamic origin, dynamic destination, UnitSystem units = UnitSystem.Metric)
 {
     return DistanceHaversine(new Coordinate(origin), new Coordinate(destination), units);
 }
Пример #30
0
 /// <summary>
 /// Gets the unit.
 /// </summary>
 /// <returns>An <see cref="IUnit"/>.</returns>
 protected IUnit GetUnit()
 {
     return(UnitSystem.GetUnitFrom(this.Unit, ParseSettings.DefaultInvariantCulture).Value);
 }