public VisualMessage(string description, List <string> positiveMessages, List <string> negativeMessages, Tension type) { this.description = description; this.positiveMessages = positiveMessages; this.negativeMessages = negativeMessages; this.type = type; }
private void FillVisualCodes() { flagCodes.Clear(); TextAsset codesJSON = Resources.Load <TextAsset>("FlagCodes"); JSONNode codesFromJSON; codesFromJSON = JSON.Parse(codesJSON.ToString()); for (int i = 0; i < codesFromJSON.Count; i++) { string nCode = codesFromJSON[i]["MESSAGE CODE"]; string nDesc = codesFromJSON[i]["DESCRIPTION"]; var arrayJSON = codesFromJSON[i]["POSITIVE"].AsArray; List <string> nPosit = new List <string>(); for (int j = 0; j < arrayJSON.Count; ++j) { nPosit.Add(arrayJSON[j]); } var arrayNJSON = codesFromJSON[i]["NEGATIVE"].AsArray; List <string> nNeg = new List <string>(); for (int k = 0; k < arrayNJSON.Count; ++k) { nNeg.Add(arrayNJSON[k]); } Tension nTension = (Tension)int.Parse(codesFromJSON[i]["TYPE"]); flagCodes.Add(nCode, new VisualMessage(nDesc, nPosit, nNeg, nTension)); } }
public void ManageVisualFeedback() { if (lastTension != GameManager.currentEnemyTension) { switch (GameManager.currentEnemyTension) { case Tension.PEACEFUL: shipHoleAnimator.SetBool("hasHole", false); break; case Tension.LOW: shipHoleAnimator.SetBool("hasHole", true); shipBaseAnimator.SetBool("hasBase", false); break; case Tension.MEDIUM: shipBaseAnimator.SetBool("hasBase", true); shipCannonAnimator.SetBool("hasCannon", false); break; case Tension.DANGER: shipCannonAnimator.SetBool("hasCannon", true); break; case Tension.THREAT: gameManager.ExecuteFinal(2); break; case Tension.NONE: break; } lastTension = GameManager.currentEnemyTension; } }
public void TestingXForces() { //double weight = 10; double T1Angle = 56; double T2Angle = 60; double angleDegreesXT1 = T1Angle * Math.PI / 180; double angleDegreesXT2 = T2Angle * Math.PI / 180; var tension = new Tension(); double T1XActual = tension.T1X; double T2XActual = tension.T2X; Assert.AreEqual(angleDegreesXT1, T1XActual); Assert.AreEqual(angleDegreesXT2, T2XActual); }
public static Double GetCorriente(Componente componente, Circuito circuito, Tension tension) { if (!(componente is Motor)) { return(0); } HPItem SelectedMotor = TabalimApp.Motores.First(x => x.HP == componente.Potencia.HP); switch (circuito.Polos.Length) { case 1: return(tension.TensionAlNeutro <= 127 ? SelectedMotor.I_1_127 : SelectedMotor.I_1_230); case 2: return(tension.Value <= 220 ? SelectedMotor.I_2_230 : SelectedMotor.I_2_460); case 3: return(tension.Value <= 208 ? SelectedMotor.I_3_208 : tension.Value <= 220 ? SelectedMotor.I_3_230 : SelectedMotor.I_3_460); } return(1); }
static void Main(string[] args) { #region Spänning and stuffs #region Uppgift 1 { var area = Area.FromMilliMeters(200); var force = Force.FromNewtons(30000); var drag = Drag.FromForceOverArea(force, area); Console.WriteLine("Uppgift 1 | Drag: " + drag); } #endregion #region Uppgift 1* { var area = Area.FromMilliMeters(100); var force = Force.FromNewtons(20000); var drag = Drag.FromForceOverArea(force, area); Console.WriteLine("Uppgift 1* | Drag: " + drag); } #endregion #region Uppgift 2 { var square = Square.FromSideLength(Length.FromMilli(20)); var force = Force.FromNewtons(50000); var drag = Drag.FromForceOverArea(force, square.Area); Console.WriteLine("Uppgift 2 | Drag: " + drag); } #endregion #region Uppgift 2* { var circle = Circle.FromDiameter(Length.FromMilli(1000)); var force = Force.FromNewtons(5 * Math.Pow(10, 6)); var drag = Drag.FromForceOverArea(force, circle.Area); Console.WriteLine("Uppgift 2* | Drag: " + Math.Round(drag.Value, 1) + " " + Drag.Unit); } #endregion #region Uppgift 3 { var rect = Rectangle.FromSides( Length.FromMilli(50), Length.FromMilli(100)); var drag = Drag.FromDragArea(9, rect.Area); Console.WriteLine("Uppgift 3 | Force: " + drag.Force); } #endregion #region Uppgift 3* { var circle = Circle.FromDiameter(Length.FromMilli(100)); var drag = Drag.FromDragArea(100, circle.Area); Console.WriteLine("Uppgift 3 | Force: " + Math.Round(drag.Force * 2 / 1000, 1) + " " + SIPrefix.Kilo.Symbol + "N"); } #endregion #region Uppgift 4 { var force = Force.FromNewtons(40000); var drag = Drag.FromForceOverDrag(force, drag: 120); var circle = Circle.FromArea(drag.Area); Console.WriteLine("Uppgift 4 | Diameter: " + Math.Round(circle.Diameter * 1000, 1) + " mm"); } #endregion // hoppa över 5 #region Uppgift 5* { var originalLength = Length.FromMilli(5000); var strechedLength = Length.FromMilli(5100); var tension = Tension.FromLengths(originalLength, strechedLength); Console.WriteLine("Uppgift 5* | Tension: " + tension); } #endregion // hoppa över 7, 8 Console.WriteLine(); #region Uppgift 8* { double sträckgräns = 380; double brottgräns = 480; double elasticitetsModul = 300 / 0.0032; Console.WriteLine("Uppgift 8*"); Console.WriteLine("a) " + nameof(sträckgräns) + ": " + sträckgräns + " " + Drag.Unit); Console.WriteLine("b) " + nameof(brottgräns) + ": " + brottgräns + " " + Drag.Unit); Console.WriteLine("c) " + nameof(elasticitetsModul) + ": " + elasticitetsModul + " " + Drag.Unit); Console.WriteLine(); } #endregion #region Uppgift 9 { double kpUnit = 9.80665; Console.WriteLine("Uppgift 9"); Console.WriteLine("a) aluminum: " + 75_000 * 0.05 / 100 + " " + Drag.Unit); Console.WriteLine("b) stål: " + 210_000 * 0.0013 + " " + Drag.Unit); Console.WriteLine("c) " + Math.Round(21 * kpUnit / 0.001) + " " + Drag.Unit); Console.WriteLine("d) " + Math.Round(150 / (0.073 / 100)) + " " + Drag.Unit); Console.WriteLine("e) " + Math.Round(100 / 120_000d * 100, 3) + "% " + Drag.Unit); Console.WriteLine(); } #endregion const double stålElasticitetsModul = 210_000; #region Uppgift 10 { // sökt: spänning // givet: töjning, elasticitetsmodul var tension = Tension.FromLengthExtension(Length.FromMeters(2), Length.FromMilli(2)); Console.WriteLine("Uppgift 10: " + tension.Value * stålElasticitetsModul + " " + Drag.Unit); } #endregion #region Uppgift 11 { // sökt: elasticitetsmodul // givet: // diameter=10mm, // längd=100mm, // längdökning=0.1mm, // kraft = 9500N var area = Circle.FromDiameter(Length.FromMilli(10)).Area; var tension = Tension.FromLengthExtension(Length.FromMilli(100), Length.FromMilli(0.1)); var drag = Drag.FromForceOverArea(Force.FromNewtons(9500), area); Console.WriteLine("Uppgift 11: E = " + Math.Round(drag.Value / tension.Value)); } #endregion const double kopparElasticitetsModul = 120_000; #region Uppgift 12 { Console.WriteLine("Uppgift 12"); // sökt: förlängning // givet: // kraft = 10_000N // stor diameter = 30mm // liten diameter = 10mm // stor längd = 40mm // liten längd = 20mm var force = Force.FromNewtons(10_000); var storArea = Circle.FromDiameter(Length.FromMilli(30)).Area; var storDrag = Drag.FromForceOverArea(force, storArea); double storTension = storDrag.Value / kopparElasticitetsModul; var storLength = Length.FromMilli(40); var storExtension = Length.FromMilli(storLength * storTension); Console.WriteLine( "Stor-förlängning = " + Math.Round(storExtension.Micro) + " " + SIPrefix.Micro.Symbol + "m"); var litenArea = Circle.FromDiameter(Length.FromMilli(10)).Area; var litenDrag = Drag.FromForceOverArea(force, litenArea); double litenTension = litenDrag.Value / kopparElasticitetsModul; var litenLength = Length.FromMilli(20); var litenExtension = Length.FromMilli(litenLength * litenTension); Console.WriteLine( "Liten-förlängning = " + Math.Round(litenExtension.Micro) + " " + SIPrefix.Micro.Symbol + "m"); var totalExtensionDeci = Math.Round((storExtension + litenExtension).Micro); Console.WriteLine("Total förlängning = " + totalExtensionDeci + " " + SIPrefix.Micro.Symbol + "m"); Console.WriteLine(); } #endregion const double aluminiumElasticitetsModul = 70_000; #region Uppgift 12* { Console.WriteLine("Uppgift 12"); // sökt: förlängning // givet: // kraft = 10_000N // dellängd = 300mm // alum diameter = 80mm // stål diameter = 40mm var force = Force.FromNewtons(10_000); var partLength = Length.FromMilli(300); var alumArea = Circle.FromDiameter(Length.FromMilli(80)).Area; var alumDrag = Drag.FromForceOverArea(force, alumArea); double alumTension = alumDrag.Value / aluminiumElasticitetsModul; var alumExtension = Length.FromMilli(partLength * alumTension); Console.WriteLine( "Alum-förlängning = " + Math.Round(alumExtension.Micro) + " " + SIPrefix.Micro.Symbol + "m"); var stålArea = Circle.FromDiameter(Length.FromMilli(40)).Area; var stålDrag = Drag.FromForceOverArea(force, stålArea); double stålTension = stålDrag.Value / stålElasticitetsModul; var stålExtension = Length.FromMilli(partLength * stålTension); Console.WriteLine( "Stål-förlängning = " + Math.Round(stålExtension.Micro) + " " + SIPrefix.Micro.Symbol + "m"); var totalExtensionDeci = Math.Round((alumExtension + stålExtension).Micro); Console.WriteLine("Total förlängning = " + totalExtensionDeci + " " + SIPrefix.Micro.Symbol + "m"); Console.WriteLine(); } #endregion const double konstantanElasticitetsModul = 110_000; #region Uppgift 13 { Console.WriteLine("Uppgift 13"); // sökt: diameter (mm) // givet: // kraft = 100N // längd = 8mm // förlängning = 0.06mm var length = Length.FromMilli(8); var extension = Length.FromMilli(0.06); double tension = Tension.FromLengthExtension(length, extension).Value; double drag = tension * konstantanElasticitetsModul; var force = Force.FromNewtons(100); var area = Drag.FromForceOverDrag(force, drag).Area; Console.WriteLine(Circle.FromArea(area).Diameter.ToString()); } #endregion #endregion Console.WriteLine(); #region Skjuvning const double härdplastLimDragMax = 15; // N/mm^2 #region Uppgift 36 { var area = Rectangle.FromSides(Length.FromMilli(50), Length.FromMilli(90)).Area; var skjuv = Drag.FromDragArea(härdplastLimDragMax, area); Console.WriteLine("Uppgift 36 | " + skjuv.Force + " innan limmet släpper"); } #endregion #region Uppgift 36* { double maxLimDrag = 10; // N/mm^2 var force = Force.FromKiloNewtons(50); var area = Drag.FromForceOverDrag(force, maxLimDrag).Area; var length = area / Length.FromMilli(60); Console.WriteLine("Uppgift 36* | " + Length.FromMilli(Math.Ceiling(length.Milli))); } #endregion #region Uppgift 37 { var bredd = Length.FromMilli(30); var längd = Length.FromMilli(100); var skärArea = Rectangle.FromSides(bredd, längd).Area; var limMaxSpänning = Drag.FromDragArea(härdplastLimDragMax, skärArea); var vänsterHöjd = Length.FromMilli(2); var vänsterArea = Rectangle.FromSides(bredd, vänsterHöjd).Area; var vänsterMaxAluminiumSpänning = Drag.FromDragArea(150, vänsterArea); var högerHöjd = Length.FromMilli(3); var högerArea = Rectangle.FromSides(bredd, högerHöjd).Area; var högerMaxAluminiumSpänning = Drag.FromDragArea(150, högerArea); var lowestForce = Drag.GetLowestForce( limMaxSpänning, vänsterMaxAluminiumSpänning, högerMaxAluminiumSpänning); Console.WriteLine("Uppgift 37 | " + lowestForce); } #endregion #region Uppgift 38 { var a = Length.FromMilli(3); var length = Length.FromMilli(20); var area = Rectangle.FromSides(a, length * 2).Area; var spänning = Drag.FromDragArea(200, area); Console.WriteLine("Uppgift 38 | " + spänning.Force); } #endregion #region Uppgift 38* { var force = Force.FromNewtonsPow(10, 5); double skärSpänning = 150; var area = Drag.FromForceOverDrag(force, skärSpänning).Area; var svetsLängd = Length.FromMilli(150); var längd = area / svetsLängd; Console.WriteLine("Uppgift 38* | " + längd); } #endregion #region Uppgift 39 { var omkrets = Circle.FromDiameter(Length.FromMilli(30)).Circumference; var svetsArea = Rectangle.FromSides(omkrets, Length.FromMilli(5)).Area; var sänktTillåtenSpänning = 100 / 2d; var spänning = Drag.FromDragArea(sänktTillåtenSpänning, svetsArea); Console.WriteLine("Uppgift 39 | " + spänning.Force); } #endregion #region Uppgift 40 { var kraft = Force.FromKiloNewtons(20); double skärSpänning = 100; var skärArea = Drag.FromForceOverDrag(kraft, skärSpänning).Area; //Console.WriteLine(Math.Sqrt(skärArea.MilliMeters / 5 / 2)); Console.WriteLine("Uppgift 40 | " + "TODO"); // a * L } #endregion #region Uppgift 41 { var nitArea = Circle.FromDiameter(Length.FromMilli(10)).Area; double tillåtenSpänning = 80; var kraft = Force.FromNewtons(nitArea.MilliMeters * tillåtenSpänning); Console.WriteLine("Uppgift 41 | " + kraft); } #endregion #region Uppgift 42 { var kraft = Force.FromKiloNewtons(10); double tillåtenSpänning = 90; var area = Drag.FromForceOverDrag(kraft, tillåtenSpänning).Area; var areaFörNit = area / 4; var nitDiameter = Circle.FromArea(areaFörNit).Diameter; Console.WriteLine("Uppgift 42 | " + nitDiameter); } #endregion #region Uppgift 43 { var kraft = Force.FromKiloNewtons(50); double tillåtenSkärSpänning = 100; var totalNitArea = Drag.FromForceOverDrag(kraft, tillåtenSkärSpänning).Area; var areaFörNit = totalNitArea / 4; var nitDiameter = Circle.FromArea(areaFörNit).Diameter; double ssStål_1312_00__tillåtenSpänning = 220; double säkerhetsFaktor = 1.0 / 3; double säkerTillåtenSpänning = ssStål_1312_00__tillåtenSpänning * säkerhetsFaktor; var plåtSpänningsArea = Drag.FromForceOverDrag(kraft, säkerTillåtenSpänning).Area; var totalSkärLängd = plåtSpänningsArea / Length.FromMilli(10); var skärLängd = totalSkärLängd + nitDiameter * 2; Console.WriteLine("Uppgift 43 | d = " + nitDiameter + ", b = " + skärLängd); } #endregion #region Uppgift på tavlan :| { var tjocklek = Length.FromMilli(7); var circle = Circle.FromDiameter(12); var area = (Area)(circle.Circumference * tjocklek); double brottGräns = 360; var kraft = Drag.FromDragArea(brottGräns, area).Force; //Console.WriteLine("Uppgift 44 | " + kraft); } #endregion #region Uppgift 44 { } #endregion #endregion }
private void CheckTension(bool isAlly) { if (!isAlly) //ENEMY { Tension lastTension = currentEnemyTension; if (tensionEnemyValue < 2f) { currentEnemyTension = Tension.PEACEFUL; } else if (tensionEnemyValue < 3f) { currentEnemyTension = Tension.LOW; } else if (tensionEnemyValue < 4f) { currentEnemyTension = Tension.MEDIUM; } else if (tensionEnemyValue < 5f) { currentEnemyTension = Tension.DANGER; } else { currentEnemyTension = Tension.THREAT; } if (currentEnemyTension > lastTension) { radarController.GoToNextCheckpoint(isAlly, false); } if (currentEnemyTension < lastTension) { radarController.GoToNextCheckpoint(isAlly, true); } } else //ALLY { Tension lastTension = currentAllyTension; if (tensionAllyValue < 2f) { currentAllyTension = Tension.PEACEFUL; } else if (tensionAllyValue < 3f) { currentAllyTension = Tension.LOW; } else if (tensionAllyValue < 4f) { currentAllyTension = Tension.MEDIUM; } else if (tensionAllyValue < 5f) { currentAllyTension = Tension.DANGER; } else { currentAllyTension = Tension.THREAT; } if (currentAllyTension > lastTension) { radarController.GoToNextCheckpoint(isAlly, true); } if (currentAllyTension < lastTension) { radarController.GoToNextCheckpoint(isAlly, false); } } }
private void ParseDataString(string data) { if (string.IsNullOrEmpty(data)) { return; } string code = data.Substring(0, DeviceCodes.CODE_LENGTH); double[] values = GetValuesFromString(data.Substring(DeviceCodes.CODE_LENGTH) .Split(DeviceCodes.CODE_SEPARATOR)); #if DEBUG Console.WriteLine("Recieved string: " + data); #endif //DeviceState newState = this.state; bool validCode = true; switch (code) { case DeviceCodes.CODE_RESET: this.state = DeviceState.Reset; ArrowTaken?.Invoke(CurrentArrow); NewArrow(); break; case DeviceCodes.CODE_CONNECTED: ConnectionManager.instance.SetConnectionState(DeviceState.Connected); break; case DeviceCodes.CODE_LOADED: ConnectionManager.instance.SetConnectionState(DeviceState.Ready); break; case DeviceCodes.CODE_FACTORY: Factory.GetStandardData(values); //0-2 Model.GetStandardData(values); //3-4 Factory.GetAdditionalData(values, 5); //5-6 break; case DeviceCodes.CODE_SCALE: //TODO: scaled is override by connected code below. Change it? this.state = DeviceState.Scaled; Settings.GetStandardData(values); //0-2 Settings.GetAdditionalData(values, 3); //3-4 //ConnectionManager.instance.SetConnectionState(DeviceState.Connected); break; case DeviceCodes.CODE_TENSION_UNITS: this.state = DeviceState.Tension; Tension.GetData(values); break; case DeviceCodes.CODE_WEIGHT_TEST: this.state = DeviceState.WeightTest; TensionSaved.GetData(values); CurrentArrow.Tension = TensionSaved.Total; break; case DeviceCodes.CODE_WEIGHT: this.state = DeviceState.WeightTestDone; CurrentArrow.Weight.Set(values); break; case DeviceCodes.CODE_WEIGHT_CALIBRATION: this.state = DeviceState.WeightCalibration; TensionSaved.GetData(values); break; case DeviceCodes.CODE_SPINE_TEST: this.state = DeviceState.SpineTest; TensionSaved.GetData(values); CurrentArrow.Tension = TensionSaved.Total; break; case DeviceCodes.CODE_SPINE: this.state = DeviceState.SpineTestDone; CurrentArrow.Spine.Set(values); break; case DeviceCodes.CODE_STRAIGHTNESS: this.state = DeviceState.StraightnessTestDone; CurrentArrow.Straightness.Set(values); break; default: validCode = false; break; } if (validCode) { DataRecieved?.Invoke(this.state, values); } }
private void линейноеРастяжениеToolStripMenuItem_Click(object sender, EventArgs e) { Filters filter = new Tension(); backgroundWorker1.RunWorkerAsync(filter); }