checkZero() 공개 정적인 메소드

public static checkZero ( float value ) : float
value float
리턴 float
예제 #1
0
 public static void setZOpp(float value)
 {
     value = Validation.checkZero(value);
     ZOpp  = value;
 }
예제 #2
0
 public static void setAlphaRotationPercentageZ(float value)
 {
     value = Validation.checkZero(value);
     alphaRotationPercentageZ = value;
 }
예제 #3
0
 public static void setY(float value)
 {
     value = Validation.checkZero(value);
     Y     = value;
 }
예제 #4
0
 public static void setDRadRatio(float value)
 {
     value     = Validation.checkZero(value);
     DRadRatio = value;
 }
예제 #5
0
 public static void setAccuracy(float value)
 {
     value    = Validation.checkZero(value);
     accuracy = value;
 }
예제 #6
0
 public static void setOffsetZ(float value)
 {
     value   = Validation.checkZero(value);
     offsetZ = value;
 }
예제 #7
0
 //set
 public static void setCenter(float value)
 {
     value  = Validation.checkZero(value);
     center = value;
 }
예제 #8
0
 public static void setZProbe(float value)
 {
     value  = Validation.checkZero(value);
     zProbe = value;
 }
예제 #9
0
 public static void setHRadius(float value)
 {
     value   = Validation.checkZero(value);
     HRadius = value;
 }
예제 #10
0
 public static void setZMaxLength(float value)
 {
     value      = Validation.checkZero(value);
     zMaxLength = value;
 }
예제 #11
0
 public static void setTempSPM(float value)
 {
     value   = Validation.checkZero(value);
     tempSPM = value;
 }
예제 #12
0
 //set
 public static void setSPM(float value)
 {
     value      = Validation.checkZero(value);
     stepsPerMM = value;
 }
예제 #13
0
        /*
         * public void analyzeGeometry(float X, float XOpp, float Y, float YOpp, float Z, float ZOpp)
         * {
         *  int analyzeCount = 0;
         *
         *
         *  UserInterface.logConsole("Expect a slight inaccuracy in the geometry analysis; basic calibration.");
         * }
         */

        private static void towerOffsets(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            int   j          = 0;
            float accuracy   = UserVariables.calculationAccuracy;
            float tempX2     = X;
            float tempXOpp2  = XOpp;
            float tempY2     = Y;
            float tempYOpp2  = YOpp;
            float tempZ2     = Z;
            float tempZOpp2  = ZOpp;
            float offsetX    = EEPROM.offsetX;
            float offsetY    = EEPROM.offsetY;
            float offsetZ    = EEPROM.offsetZ;
            float stepsPerMM = EEPROM.stepsPerMM;

            while (j < 100)
            {
                if (Math.Abs(tempX2) > UserVariables.accuracy / 2 || Math.Abs(tempY2) > UserVariables.accuracy / 2 || Math.Abs(tempZ2) > UserVariables.accuracy / 2)
                {
                    offsetX += tempX2 * stepsPerMM * (1 / 0.60F);

                    tempXOpp2 += tempX2 * (0.5F / 0.60F);
                    tempY2    += tempX2 * (0.3F / 0.60F);
                    tempYOpp2 += tempX2 * (-0.25F / 0.60F);
                    tempZ2    += tempX2 * (0.3F / 0.60F);
                    tempZOpp2 += tempX2 * (-0.25F / 0.60F);
                    tempX2    += tempX2 / -1;

                    offsetY += tempY2 * stepsPerMM * (1 / 0.60F);

                    tempYOpp2 += tempY2 * (0.5F / 0.60F);
                    tempX2    += tempY2 * (0.3F / 0.60F);
                    tempXOpp2 += tempY2 * (-0.25F / 0.60F);
                    tempZ2    += tempY2 * (0.3F / 0.60F);
                    tempZOpp2 += tempY2 * (-0.25F / 0.60F);
                    tempY2    += tempY2 / -1;

                    offsetZ += tempZ2 * stepsPerMM * (1 / 0.60F);

                    tempZOpp2 += tempZ2 * (0.5F / 0.60F);
                    tempX2    += tempZ2 * (0.3F / 0.60F);
                    tempXOpp2 += tempZ2 * (-0.25F / 0.60F);
                    tempY2    += tempZ2 * (0.3F / 0.60F);
                    tempYOpp2 += tempZ2 * (-0.25F / 0.60F);
                    tempZ2    += tempZ2 / -1;

                    tempX2    = Validation.checkZero(tempX2);
                    tempY2    = Validation.checkZero(tempY2);
                    tempZ2    = Validation.checkZero(tempZ2);
                    tempXOpp2 = Validation.checkZero(tempXOpp2);
                    tempYOpp2 = Validation.checkZero(tempYOpp2);
                    tempZOpp2 = Validation.checkZero(tempZOpp2);

                    float tempComb    = tempX2 + tempY2 + tempZ2;
                    float tempCombAbs = Math.Abs(tempX2) + Math.Abs(tempY2) + Math.Abs(tempZ2);

                    if (Math.Abs(tempX2) <= UserVariables.accuracy && Math.Abs(tempY2) <= UserVariables.accuracy && Math.Abs(tempZ2) <= UserVariables.accuracy)
                    {
                        UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                        UserInterface.logConsole("No Drad correction");

                        float smallest = Math.Min(offsetX, Math.Min(offsetY, offsetZ));

                        offsetX -= smallest;
                        offsetY -= smallest;
                        offsetZ -= smallest;

                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);

                        X    = tempX2;
                        XOpp = tempXOpp2;
                        Y    = tempY2;
                        YOpp = tempYOpp2;
                        Z    = tempZ2;
                        ZOpp = tempZOpp2;

                        //round to the nearest whole number
                        EEPROM.offsetX = Convert.ToInt32(offsetX);
                        EEPROM.offsetY = Convert.ToInt32(offsetY);
                        EEPROM.offsetZ = Convert.ToInt32(offsetZ);

                        j = 100;
                    }
                    else if (j == 99)
                    {
                        UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                        float dradCorr = tempComb * -0.85F;

                        EEPROM.DA += dradCorr;
                        EEPROM.DB += dradCorr;
                        EEPROM.DC += dradCorr;

                        EEPROM.offsetX = 200;
                        EEPROM.offsetY = 200;
                        EEPROM.offsetZ = 200;

                        UserInterface.logConsole("Drad correction: " + dradCorr);
                        UserInterface.logConsole("DRad: " + EEPROM.DA.ToString() + ", " + EEPROM.DB.ToString() + ", " + EEPROM.DC.ToString());

                        j = 100;
                    }
                    else
                    {
                        j++;
                    }

                    //UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                    //UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                }
                else
                {
                    xyzOffset = false;
                    j         = 100;
                }
            }

            if (EEPROM.offsetX > 1000 || EEPROM.offsetY > 1000 || EEPROM.offsetZ > 1000)
            {
                UserInterface.logConsole("XYZ offset calibration error, setting default values.");
                UserInterface.logConsole("XYZ offsets before damage prevention: X" + offsetX + " Y" + offsetY + " Z" + offsetZ);
                offsetX = 0;
                offsetY = 0;
                offsetZ = 0;
            }
        }
예제 #14
0
        /*
         * public void analyzeGeometry(float X, float XOpp, float Y, float YOpp, float Z, float ZOpp)
         * {
         *  int analyzeCount = 0;
         *
         *
         *  UserInterface.logConsole("Expect a slight inaccuracy in the geometry analysis; basic calibration.");
         * }
         */

        private static void towerOffsets(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            int   j          = 0;
            float accuracy   = UserVariables.calculationAccuracy;
            float tempX2     = X;
            float tempXOpp2  = XOpp;
            float tempY2     = Y;
            float tempYOpp2  = YOpp;
            float tempZ2     = Z;
            float tempZOpp2  = ZOpp;
            float offsetX    = EEPROM.offsetX;
            float offsetY    = EEPROM.offsetY;
            float offsetZ    = EEPROM.offsetZ;
            float stepsPerMM = EEPROM.stepsPerMM;

            float towMain = UserVariables.offsetCorrection; //0.6
            float oppMain = UserVariables.mainOppPerc;      //0.5
            float towSub  = UserVariables.towPerc;          //0.3
            float oppSub  = UserVariables.oppPerc;          //-0.25

            while (j < 100)
            {
                if (Math.Abs(tempX2) > UserVariables.accuracy || Math.Abs(tempY2) > UserVariables.accuracy || Math.Abs(tempZ2) > UserVariables.accuracy)
                {
                    offsetX -= tempX2 * stepsPerMM * (1 / towMain);

                    tempXOpp2 -= tempX2 * (oppMain / towMain);
                    tempY2    -= tempX2 * (towSub / towMain);
                    tempYOpp2 -= tempX2 * (-oppSub / towMain);
                    tempZ2    -= tempX2 * (towSub / towMain);
                    tempZOpp2 -= tempX2 * (-oppSub / towMain);
                    tempX2    -= tempX2 / 1;

                    offsetY -= tempY2 * stepsPerMM * (1 / towMain);

                    tempYOpp2 -= tempY2 * (oppMain / towMain);
                    tempX2    -= tempY2 * (towSub / towMain);
                    tempXOpp2 -= tempY2 * (-oppSub / towMain);
                    tempZ2    -= tempY2 * (towSub / towMain);
                    tempZOpp2 -= tempY2 * (-oppSub / towMain);
                    tempY2    -= tempY2 / 1;

                    offsetZ -= tempZ2 * stepsPerMM * (1 / towMain);

                    tempZOpp2 -= tempZ2 * (oppMain / towMain);
                    tempX2    -= tempZ2 * (towSub / towMain);
                    tempXOpp2 += tempZ2 * (-oppSub / towMain);
                    tempY2    -= tempZ2 * (towSub / towMain);
                    tempYOpp2 -= tempZ2 * (-oppSub / towMain);
                    tempZ2    -= tempZ2 / 1;

                    tempX2    = Validation.checkZero(tempX2);
                    tempY2    = Validation.checkZero(tempY2);
                    tempZ2    = Validation.checkZero(tempZ2);
                    tempXOpp2 = Validation.checkZero(tempXOpp2);
                    tempYOpp2 = Validation.checkZero(tempYOpp2);
                    tempZOpp2 = Validation.checkZero(tempZOpp2);

                    if (Math.Abs(tempX2) <= UserVariables.accuracy && Math.Abs(tempY2) <= UserVariables.accuracy && Math.Abs(tempZ2) <= UserVariables.accuracy)
                    {
                        UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                        UserInterface.logConsole("No Hrad correction");

                        float smallest = Math.Min(offsetX, Math.Min(offsetY, offsetZ));

                        offsetX -= smallest;
                        offsetY -= smallest;
                        offsetZ -= smallest;

                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);

                        X    = tempX2;
                        XOpp = tempXOpp2;
                        Y    = tempY2;
                        YOpp = tempYOpp2;
                        Z    = tempZ2;
                        ZOpp = tempZOpp2;

                        //round to the nearest whole number
                        EEPROM.offsetX = Convert.ToInt32(offsetX);
                        EEPROM.offsetY = Convert.ToInt32(offsetY);
                        EEPROM.offsetZ = Convert.ToInt32(offsetZ);

                        j = 100;
                    }
                    else if (j == 99)
                    {
                        UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                        float dradCorr  = tempX2 * -1.25F;
                        float HRadRatio = UserVariables.HRadRatio;

                        EEPROM.HRadius += dradCorr;

                        EEPROM.offsetX = 0;
                        EEPROM.offsetY = 0;
                        EEPROM.offsetZ = 0;

                        //hradsa = dradcorr
                        //solve inversely from previous method
                        float HRadOffset = HRadRatio * dradCorr;

                        tempX2    -= HRadOffset;
                        tempY2    -= HRadOffset;
                        tempZ2    -= HRadOffset;
                        tempXOpp2 -= HRadOffset;
                        tempYOpp2 -= HRadOffset;
                        tempZOpp2 -= HRadOffset;

                        UserInterface.logConsole("Hrad correction: " + dradCorr);
                        UserInterface.logConsole("HRad: " + EEPROM.HRadius.ToString());

                        j = 0;
                    }
                    else
                    {
                        j++;
                    }

                    //UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                    //UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                }
                else
                {
                    j = 100;

                    UserInterface.logConsole("Tower Offsets and Delta Radii Calibrated");
                }
            }

            if (EEPROM.offsetX > 1000 || EEPROM.offsetY > 1000 || EEPROM.offsetZ > 1000)
            {
                UserInterface.logConsole("Tower offset calibration error, setting default values.");
                UserInterface.logConsole("Tower offsets before damage prevention: X" + offsetX + " Y" + offsetY + " Z" + offsetZ);
                offsetX = 0;
                offsetY = 0;
                offsetZ = 0;
            }
        }