protected override Polygon GetPistonView(PositionedCylinder _positionedCylinder, double _crankshaftRotation_deg) { double _cylinderRelativeCrankThrowRotation_deg = _positionedCylinder.GetCylinderRelativeCrankThrowRotation_deg(_crankshaftRotation_deg); double _offset_rad = Conversions.DegToRad(_positionedCylinder.Tilt_deg); double _cosOffset = Math.Cos(_offset_rad); double _TDC = (_cosOffset * _positionedCylinder.GetPhysicalHeightAbovePiston_mm(_cylinderRelativeCrankThrowRotation_deg)); double _BDC = (_cosOffset * _positionedCylinder.GetPhysicalHeightUnderPiston_mm(_cylinderRelativeCrankThrowRotation_deg)); double _rX = _positionedCylinder.Bore_mm / 2d * EngineDesigner.Media.Properties.Settings.Default.PistonVsCylinderClearance; double _rY = (Math.Abs(Math.Sin(_offset_rad) * _rX)); double _rTilt = _rX * Math.Sin(Conversions.DegToRad(_positionedCylinder.Tilt_deg)); Polygon _polygon = Polygon.Line( -_rX + _positionedCylinder.Offset_mm, _BDC, -_rX + _positionedCylinder.Offset_mm, _TDC); _polygon.Add(Polygon.Arc(_positionedCylinder.Offset_mm, _TDC, _rX, _rTilt, 0, 540, EngineDesigner.Media.Properties.Settings.Default.BasicEngineSketchArcPrecision)); _polygon.Add(Polygon.Line( _rX + _positionedCylinder.Offset_mm, _TDC, _rX + _positionedCylinder.Offset_mm, _BDC)); _polygon.Add(Polygon.Arc(_positionedCylinder.Offset_mm, _BDC, _rX, _rTilt, 180, 540, EngineDesigner.Media.Properties.Settings.Default.BasicEngineSketchArcPrecision)); return(_polygon); }
private void DrawPositionedCylinder(PositionedCylinder _positionedCylinder, double crankshaftRotation_deg) { Stroke _stroke = _positionedCylinder.GetStroke(crankshaftRotation_deg); Color _color; #region "določimo barvo glede na takt" if (_stroke.Equals(Stroke.Intake)) { _color = this.intakeColor; } else if (_stroke.Equals(Stroke.Compression)) { _color = this.compressionColor; } else if (_stroke.Equals(Stroke.Combustion)) { _color = this.combustionColor; } else if (_stroke.Equals(Stroke.Exhaust)) { _color = this.exhaustColor; } else if (_stroke.Equals(Stroke.WashCompression)) { _color = this.washCompressionColor; } else if (_stroke.Equals(Stroke.CombustionExhaust)) { _color = this.combustionExhaustColor; } else { _color = this.blackColor; } #endregion "določimo barvo glede na takt" double _crankThrowRotation_deg = _positionedCylinder.GetAbsoluteCrankThrowRotation_deg(crankshaftRotation_deg); _crankThrowRotation_deg = EngineDesigner.Common.Mathematics.GetAbsoluteAngle_deg(_crankThrowRotation_deg, true); base.DrawLine( _crankThrowRotation_deg, null, _color, false, this.lineThickness); base.DrawMarker( _crankThrowRotation_deg, _positionedCylinder.Position.ToString(), _color, false, MarkerStyle.Circle, this.lineThickness * 5); }
protected override Polygon GetCrankThrowView(PositionedCylinder _positionedCylinder, double _crankshaftRotation_deg) { double _absoluteCrankThrowRotation_deg = _positionedCylinder.GetAbsoluteCrankThrowRotation_deg(_crankshaftRotation_deg); double _absoluteCrankThrowRotation_rad = Conversions.DegToRad(_absoluteCrankThrowRotation_deg); return(Polygon.Line( 0d, 0d, Math.Sin(_absoluteCrankThrowRotation_rad) * _positionedCylinder.CrankThrow.CrankRotationRadius_mm, Math.Cos(_absoluteCrankThrowRotation_rad) * _positionedCylinder.CrankThrow.CrankRotationRadius_mm)); }
protected override Polygon GetCrankThrowView(PositionedCylinder _positionedCylinder, double _crankshaftRotation_deg) { double _TDC = (Math.Cos(Conversions.DegToRad(_positionedCylinder.GetAbsoluteCrankThrowRotation_deg(_crankshaftRotation_deg))) * _positionedCylinder.CrankThrow.CrankRotationRadius_mm); return(Polygon.Line( _positionedCylinder.Offset_mm, 0, _positionedCylinder.Offset_mm, _TDC)); }
protected override Polygon GetCrankshaftView(PositionedCylinder _positionedCylinder) { double _cylinderHalfBore = _positionedCylinder.Bore_mm / 2; double _left = _positionedCylinder.Offset_mm - _cylinderHalfBore; double _right = _positionedCylinder.Offset_mm + _cylinderHalfBore; return(Polygon.Line( _left, 0, _right, 0)); }
protected override Polygon GetPistonView(PositionedCylinder _positionedCylinder, double _crankshaftRotation_deg) { double _cylinderRelativeCrankThrowRotation_deg = _positionedCylinder.GetCylinderRelativeCrankThrowRotation_deg(_crankshaftRotation_deg); double _physicalHeightAbovePiston_mm = _positionedCylinder.GetPhysicalHeightAbovePiston_mm(_cylinderRelativeCrankThrowRotation_deg); double _physicalHeightUnderPiston_mm = _positionedCylinder.GetPhysicalHeightUnderPiston_mm(_cylinderRelativeCrankThrowRotation_deg); double _cylinderHalfBore = _positionedCylinder.Bore_mm / 2d * EngineDesigner.Media.Properties.Settings.Default.PistonVsCylinderClearance; double _offset_rad = Conversions.DegToRad(_positionedCylinder.Tilt_deg); double _sinOffset = Math.Sin(_offset_rad); double _cosOffset = Math.Cos(_offset_rad); //zgornja center točka bata double _xTDC = (_sinOffset * _physicalHeightAbovePiston_mm); double _yTDC = (_cosOffset * _physicalHeightAbovePiston_mm); //spodnja center točka bata double _xBDC = (_sinOffset * _physicalHeightUnderPiston_mm); double _yBDC = (_cosOffset * _physicalHeightUnderPiston_mm); //razlike od center do skrajnih točk double _x_ = (_cosOffset * _cylinderHalfBore); double _y_ = (_sinOffset * _cylinderHalfBore); //zgornje skrajne točke double _x1 = _xTDC - _x_; double _y1 = _yTDC + _y_; double _x2 = _xTDC + _x_; double _y2 = _yTDC - _y_; //spodnje skrajne točke double _x3 = _xBDC - _x_; double _y3 = _yBDC + _y_; double _x4 = _xBDC + _x_; double _y4 = _yBDC - _y_; return(Polygon.Rectangle(_x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4)); }
protected override Polygon GetConnectingRodView(PositionedCylinder _positionedCylinder, double _crankshaftRotation_deg) { double _absoluteCrankThrowRotation_deg = _positionedCylinder.GetAbsoluteCrankThrowRotation_deg(_crankshaftRotation_deg); double _absoluteCrankThrowRotation_rad = Conversions.DegToRad(_absoluteCrankThrowRotation_deg); double _cylinderRelativeCrankThrowRotation_deg = _positionedCylinder.GetCylinderRelativeCrankThrowRotation_deg(_crankshaftRotation_deg); double _pistonTravelFromCeter_mm = _positionedCylinder.GetPistonTravelFromCrankCenter_mm(_cylinderRelativeCrankThrowRotation_deg); double _offset_rad = Conversions.DegToRad(_positionedCylinder.Tilt_deg); //zgornja točka ojnice double _xTDC = (Math.Sin(_offset_rad) * _pistonTravelFromCeter_mm); double _yTDC = (Math.Cos(_offset_rad) * _pistonTravelFromCeter_mm); //spodnja točka ojnice double _xBDC = (Math.Sin(_absoluteCrankThrowRotation_rad) * _positionedCylinder.CrankThrow.CrankRotationRadius_mm); double _yBDC = (Math.Cos(_absoluteCrankThrowRotation_rad) * _positionedCylinder.CrankThrow.CrankRotationRadius_mm); return(Polygon.Line(_xTDC, _yTDC, _xBDC, _yBDC)); }
protected override Polygon GetCylinderView(PositionedCylinder _positionedCylinder) { double _physicalHeightAbovePiston_mm = _positionedCylinder.GetPhysicalHeightAbovePiston_mm(0); double _physicalHeightUnderPiston_mm = _positionedCylinder.GetPhysicalHeightUnderPiston_mm(Stroke.StrokeDuration_deg); double _cylinderHalfBore = _positionedCylinder.Bore_mm / 2; double _offset_rad = Conversions.DegToRad(_positionedCylinder.Tilt_deg); double _sinOffset = Math.Sin(_offset_rad); double _cosOffset = Math.Cos(_offset_rad); //zgornja center točka bata double _xTDC = (_sinOffset * _physicalHeightAbovePiston_mm); double _yTDC = (_cosOffset * _physicalHeightAbovePiston_mm); //spodnja center točka bata double _xBDC = (_sinOffset * _physicalHeightUnderPiston_mm); double _yBDC = (_cosOffset * _physicalHeightUnderPiston_mm); //razlike od center do skrajnih točk double _x_ = (_cosOffset * _cylinderHalfBore); double _y_ = (_sinOffset * _cylinderHalfBore); //zgornje skrajne točke double _x1 = _xTDC - _x_; double _y1 = _yTDC + _y_; double _x2 = _xTDC + _x_; double _y2 = _yTDC - _y_; //spodnje skrajne točke double _x3 = _xBDC - _x_; double _y3 = _yBDC + _y_; double _x4 = _xBDC + _x_; double _y4 = _yBDC - _y_; return(Polygon.Rectangle(_x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4)); }
protected override Polygon GetConnectingRodView(PositionedCylinder _positionedCylinder, double _crankshaftRotation_deg) { double _cylinderRelativeCrankThrowRotation_deg = _positionedCylinder.GetCylinderRelativeCrankThrowRotation_deg(_crankshaftRotation_deg); double _offset_rad = Conversions.DegToRad(_positionedCylinder.Tilt_deg); double _cosOffset = Math.Cos(_offset_rad); double _pistonTravelFromCeter_mm = _positionedCylinder.GetPistonTravelFromCrankCenter_mm(_cylinderRelativeCrankThrowRotation_deg); double _absoluteCrankThrowRotation_deg = _positionedCylinder.GetAbsoluteCrankThrowRotation_deg(_crankshaftRotation_deg); double _absoluteCrankThrowRotation_rad = Conversions.DegToRad(_absoluteCrankThrowRotation_deg); double _TDC = (_cosOffset * _pistonTravelFromCeter_mm); double _BDC = (Math.Cos(_absoluteCrankThrowRotation_rad) * _positionedCylinder.CrankThrow.CrankRotationRadius_mm); return(Polygon.Line( _positionedCylinder.Offset_mm, _TDC, _positionedCylinder.Offset_mm, _BDC)); }
protected override Polygon GetCrankshaftView(PositionedCylinder _positionedCylinder) { return(Polygon.Circle(0, 0, 1, EngineDesigner.Media.Properties.Settings.Default.BasicEngineSketchArcPrecision)); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker _backgroundWorker = (BackgroundWorker)sender; NewEngineWizardState _newEngineWizardState = (NewEngineWizardState)e.Argument; _backgroundWorker.ReportProgress(10); try { Engine _engine = null; List <PositionedCylinder> _positionedCylinders = new List <PositionedCylinder>(); foreach (NewEngineWizardState.CylinderLyout _cylinderLayout in _newEngineWizardState.CylinderLyouts) { #region "Piston" Piston _piston = Piston.FromParameters( _newEngineWizardState.Bore, _newEngineWizardState.PistonMass); #endregion "Piston" #region "ConnectingRod" double _rotatingDistributionPercentage = (100d - _newEngineWizardState.ConnectingRodMassAndDistanceDistributionPercentage) / 100d; double _reciprocatingDistributionPercentage = _newEngineWizardState.ConnectingRodMassAndDistanceDistributionPercentage / 100d; ConnectingRod _connectingRod = new ConnectingRod( _newEngineWizardState.ConnectingRodMass * _rotatingDistributionPercentage, _newEngineWizardState.ConnectingRodLength * _reciprocatingDistributionPercentage, _newEngineWizardState.ConnectingRodMass * _reciprocatingDistributionPercentage, _newEngineWizardState.ConnectingRodLength * _rotatingDistributionPercentage); #endregion "ConnectingRod" #region "CrankThrow" CrankThrow _crankThrow; if (_newEngineWizardState.BalancerMass > 0) { _crankThrow = CrankThrow.FromParameters( _newEngineWizardState.Stroke / 2d, _newEngineWizardState.BalancerMass, _newEngineWizardState.BalancerRotationRadius); } else { _crankThrow = CrankThrow.FromParameters(_newEngineWizardState.Stroke / 2d); } #endregion "CrankThrow" #region "Cylinder" Cylinder _cylinder = new Cylinder( _newEngineWizardState.Cycle, _piston, _connectingRod, _crankThrow); #endregion "Cylinder" #region "PositionedCylinder" double _offset = 0; double _tilt = 0; if (this.GetLayoutOffset(_newEngineWizardState) == 0d) //motor je inline { _offset = (_cylinderLayout.CylinderPosition - 1) * (_newEngineWizardState.Bore + (_newEngineWizardState.Bore / EngineDesigner.Machine.Properties.Settings.Default.DefaultOffsetDivisor)); } else { _tilt = _cylinderLayout.Tilt; if (Mathematics.IsOdd(_cylinderLayout.CylinderPosition)) { if (_positionedCylinders.Count > 0) { _offset = (_positionedCylinders[_positionedCylinders.Count - 1].Offset_mm + (_newEngineWizardState.Bore + (_newEngineWizardState.Bore / EngineDesigner.Machine.Properties.Settings.Default.DefaultOffsetDivisor))); } } else { _offset = _positionedCylinders[_positionedCylinders.Count - 1].Offset_mm; _offset += _crankThrow.CrankPinWidth_mm; } } PositionedCylinder _positionedCylinder = new PositionedCylinder( _cylinder, _cylinderLayout.CylinderPosition, _offset, _tilt, _cylinderLayout.FiringAngle); _positionedCylinders.Add(_positionedCylinder); //javimo progress (60% gre za ustvarjanje cilindrov, 10 je bilo že od prej) double _progressPercentage = 10d + (_cylinderLayout.CylinderPosition * 60d / _newEngineWizardState.CylinderLyouts.Length); _backgroundWorker.ReportProgress((int)_progressPercentage); #endregion "PositionedCylinder" } _engine = new Engine(_positionedCylinders.ToArray()); _engine.Flywheel.Mass_g = _newEngineWizardState.FlywheelMass; _engine.Flywheel.Diameter_mm = _newEngineWizardState.FlywheelDiameter; e.Result = _engine; } catch (Exception _exception) { e.Result = _exception; } finally { _backgroundWorker.ReportProgress(100); } }
private void DrawInertia(double _from, double _to, Color _color, double _rpm, PositionedCylinder _positionedCylinder) { List <XY> _points = new List <XY>(); for (double _a = _from; _a < _to; _a++) { double _alteredA = _positionedCylinder.GetCylinderRelativeCrankThrowRotation_deg(_a); double _x = _positionedCylinder.GetInertiaForceReciprocating_N(_a, _rpm); double _y = _positionedCylinder.GetInertiaForceRotating_N(_a, _rpm); _points.Add(new XY(_x, _y)); Console.WriteLine(string.Format( "X ({0}); Y ({1})", _x.ToString(), _y.ToString())); } Function _chart = Function.FromPoints(_points); this.functionChart1.DrawFunction(_chart, null, _color); }
private void PasteFromTemplate(GridItem _gridItem) { object _object = Clipboard.GetData(DataFormats.Serializable); if (_gridItem.Value is CustomList <PositionedCylinder> ) { CustomList <PositionedCylinder> _selectedItem = (CustomList <PositionedCylinder>)_gridItem.Value; PositionedCylinder _fromClipboard = (PositionedCylinder)_object; //NOTE: to je bilo po starem //@List<PositionedCylinder> _positionedCylinders = new @List<PositionedCylinder>(); //foreach (PositionedCylinder _existingPositionedCylinder in _selectedItem) //{ // PositionedCylinder _newPositionedCylinder = EngineDesigner.Common.Utility.CopyObject<PositionedCylinder>(_fromClipboard); // _newPositionedCylinder.Position = _existingPositionedCylinder.Position; //pozicije ne popravljamo! // _newPositionedCylinder.Offset_mm = _existingPositionedCylinder.Offset_mm; //offseta ne popravljamo! // _newPositionedCylinder.Tilt_deg = _existingPositionedCylinder.Tilt_deg; //offseta ne popravljamo! // _newPositionedCylinder.FiringAngle_deg = _existingPositionedCylinder.FiringAngle_deg; //kota vžiga ne popravljamo! // _positionedCylinders.Add(_newPositionedCylinder); //} //base.SetItemValue(_gridItem, _positionedCylinders); //NOTE: po novem ne spreminjamo več celega propetija, ker ni prav (in nima niti več setterja), ampak samo cilindre! for (int a = 0; a < _selectedItem.Count; a++) { int _position = _selectedItem[a].Position; double _offset_mm = _selectedItem[a].Offset_mm; double _tilt_deg = _selectedItem[a].Tilt_deg; double _firingAngle_deg = _selectedItem[a].FiringAngle_deg; _selectedItem[a] = EngineDesigner.Common.Utility.CopyObject <PositionedCylinder>(_fromClipboard); _selectedItem[a].Position = _position; //pozicije ne popravljamo! _selectedItem[a].Offset_mm = _offset_mm; //offseta ne popravljamo! _selectedItem[a].Tilt_deg = _tilt_deg; //offseta ne popravljamo! _selectedItem[a].FiringAngle_deg = _firingAngle_deg; //kota vžiga ne popravljamo! } } else if (_gridItem.Value is PositionedCylinder) { PositionedCylinder _selectedItem = (PositionedCylinder)_gridItem.Value; PositionedCylinder _fromClipboard = (PositionedCylinder)_object; PositionedCylinder _positionedCylinder = EngineDesigner.Common.Utility.CopyObject <PositionedCylinder>(_fromClipboard); _positionedCylinder.Position = _selectedItem.Position; //pozicije ne popravljamo! _positionedCylinder.Offset_mm = _selectedItem.Offset_mm; //offseta ne popravljamo! _positionedCylinder.Tilt_deg = _selectedItem.Tilt_deg; //offseta ne popravljamo! _positionedCylinder.FiringAngle_deg = _selectedItem.FiringAngle_deg; //kota vžiga ne popravljamo! base.SetItemValue(_gridItem, _positionedCylinder); } else if (_gridItem.Value is Cycle) { Cycle _fromClipboard = (Cycle)_object; base.SetItemValue(_gridItem, EngineDesigner.Common.Utility.CopyObject <Cycle>(_fromClipboard)); } else if (_gridItem.Value is Piston) { Piston _fromClipboard = (Piston)_object; base.SetItemValue(_gridItem, EngineDesigner.Common.Utility.CopyObject <Piston>(_fromClipboard)); } else if (_gridItem.Value is ConnectingRod) { ConnectingRod _fromClipboard = (ConnectingRod)_object; base.SetItemValue(_gridItem, EngineDesigner.Common.Utility.CopyObject <ConnectingRod>(_fromClipboard)); } else { throw new NotSupportedException(); } this.EditedPart.Validate(); }
protected virtual Polygon GetCrankshaftView(PositionedCylinder _positionedCylinder) { throw new NotImplementedException(); }
protected virtual Polygon GetCrankThrowView(PositionedCylinder _positionedCylinder, double _crankshaftRotation_deg) { throw new NotImplementedException(); }