Ejemplo n.º 1
0
        public bool Evaluate(IAgAsHpopPluginResultEval ResultEval)
        {
            try
            {
                if (m_Enabled)
                {
                    m_EvalCntr++;
                    DebugMsg(m_EvalCntr,
                             m_EvalMsgInterval,
                             m_Name + ".Evaluate() called the " + m_EvalCntr + "th time");
                }
            }
            catch (Exception ex)
            {
                m_Enabled = false;

                Message(AgEUtLogMsgType.eUtLogMsgAlarm,
                        m_Name + ".Init(): Exception Message( " + ex.Message + " )");

                Message(AgEUtLogMsgType.eUtLogMsgAlarm,
                        m_Name + ".Init(): Exception StackTr( " + ex.StackTrace + " )");
            }
            finally
            {
            }

            return(m_Enabled);
        }
Ejemplo n.º 2
0
        public void EvaluateSRPArea(IAgAsHpopPluginResultEval ResultEval)
        {
            if (!m_SrpIsOn)
            {
                return;
            }

            // may not have obtained a vector to do the SRP Area computation
            if (this.m_CCV == null)
            {
                return;
            }

            try
            {
                if (this.m_EvalCntr % this.m_EvalMsgInterval == 0)
                {
                    Debug.WriteLine("--> Entered", this.m_Name + ".EvaluateSRPArea( " + this.m_EvalCntr + " )");
                }
                #region Local Variables

                bool Result = false;

                double VecX = 0.0;
                double VecY = 0.0;
                double VecZ = 0.0;

                double PosX = 0.0;
                double PosY = 0.0;
                double PosZ = 0.0;

                double VelX = 0.0;
                double VelY = 0.0;
                double VelZ = 0.0;

                double VecPosDotProd = 0.0;
                double VecMag        = 0.0;
                double PosMag        = 0.0;
                double Theta         = 0.0;

                #endregion

                //========================================
                // 1. Get the "User Choosen" Vector XYZ
                // 2. Get the Position Vector XYZ in
                //    Central Body Inertial Frame ( CBI )
                //========================================
                if (ResultEval != null)
                {
                    ResultEval.PosVel(AgEUtFrame.eUtFrameInertial, ref PosX, ref PosY, ref PosZ, ref VelX, ref VelY, ref VelZ);
                    Result = this.m_CCV.CurrentValue(ResultEval, ref VecX, ref VecY, ref VecZ);

                    if (Result)
                    {
                        //===============================================================
                        // Calculate the angle (Theta in radians) between the two vectors
                        // 1. Calculate the Dot Product
                        // 2. Calculate the
                        //================================================================
                        VecPosDotProd = ((VecX * PosX) + (VecY * PosY) + (VecZ * PosZ));
                        VecMag        = Math.Sqrt((Math.Pow(VecX, 2) + Math.Pow(VecY, 2) + Math.Pow(VecZ, 2)));
                        PosMag        = Math.Sqrt((Math.Pow(PosX, 2) + Math.Pow(PosY, 2) + Math.Pow(PosZ, 2)));
                        Theta         = Math.Acos(VecPosDotProd / (VecMag * PosMag));

                        //===============================================
                        // Calculate the new SRP area based on the Theta
                        //===============================================

                        // SRP must be on else this will throw an exception
                        ResultEval.SRPArea = ((this.m_SRPArea / 4.0) * (3 - Math.Sin(Theta)));

                        if (this.m_UPS != null && this.m_MsgStatus)
                        {
                            if (this.m_EvalCntr % this.m_EvalMsgInterval == 0)
                            {
                                double ThetaDeg = Theta * 57.2957795130823208767;

                                this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".EvaluateSRPArea( " + this.m_EvalCntr + " ): VecX( " + VecX + " ), VecY( " + VecY + " ), VecZ( " + VecZ + " ) meters/sec");
                                this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".EvaluateSRPArea( " + this.m_EvalCntr + " ): PosX(" + PosX + " ), PosY( " + PosY + " ), PosZ( " + PosZ + " ) meters");
                                this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".EvaluateSRPArea( " + this.m_EvalCntr + " ): VelX(" + VelX + " ), VelY( " + VelY + " ), VelZ(" + VelZ + " ) meters/sec");
                                this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".EvaluateSRPArea( " + this.m_EvalCntr + " ): SRPArea(" + ResultEval.SRPArea + " m^2), Theta( " + ThetaDeg + " deg)");
                            }
                        }
                    }
                    else
                    {
                        if (this.m_UPS != null && this.m_MsgStatus)
                        {
                            if (this.m_EvalCntr % this.m_EvalMsgInterval == 0)
                            {
                                this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".EvaluateSRPArea( " + this.m_EvalCntr + " ): Result( " + Result + " )");
                            }
                        }
                    }
                }
                else
                {
                    if (this.m_UPS != null && this.m_MsgStatus)
                    {
                        this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgWarning, this.m_Name + ".Crdn Configured Vector or Result Eval was null");
                    }
                }
            }
            catch (Exception ex)
            {
                this.m_Enabled = false;

                if (this.m_UPS != null)
                {
                    this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".EvaluateSRPArea(): Exception Message( " + ex.Message + " )");
                    this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".EvaluateSRPArea(): Exception StackTr( " + ex.StackTrace + " )");
                }
                Debug.WriteLine("Exception Message( " + ex.Message + " )", this.m_Name + ".EvaluateSRPArea()");
                Debug.WriteLine("Exception StackTr( " + ex.StackTrace + " )", this.m_Name + ".EvaluateSRPArea()");
            }
            finally
            {
                if (this.m_EvalCntr % this.m_EvalMsgInterval == 0)
                {
                    Debug.WriteLine("<-- Exited", this.m_Name + ".EvaluateSRPArea( " + this.m_EvalCntr + " )");
                }
            }
        }
Ejemplo n.º 3
0
        public bool Evaluate(IAgAsHpopPluginResultEval ResultEval)
        {
            try
            {
                if (this.m_MsgCntr % this.m_MsgInterval == 0)
                {
                    Debug.WriteLine("--> Entered", this.m_Name + ".Evaluate( " + this.m_MsgCntr + " )");
                }

                if (m_Enabled)
                {
                    // if illumination is zero, there isn't any contribution anyway, so do nothing

                    // SRP must be on else this call throws an exception
                    double illum = ResultEval.SolarIntensity;

                    if (illum == 0.0)
                    {
                        return(m_Enabled);
                    }

                    double cr = ResultEval.Cr;
                    // SRP must be on else this call throws an exception
                    double solarFlux = ResultEval.SolarFlux;                                    // L /(4 * pi * R_sun^2)

                    Tuple3 r      = new Tuple3();
                    Tuple3 v      = new Tuple3();
                    Tuple3 sunPos = new Tuple3();

                    ResultEval.PosVel(AgEUtFrame.eUtFrameInertial, ref r.x, ref r.y, ref r.z, ref v.x, ref v.y, ref v.z);

                    // SRP must be on else this call throws an exception because of AgEUtSunPosType.eUtSunPosTypeSRP
                    ResultEval.SunPosition(AgEUtSunPosType.eUtSunPosTypeSRP, AgEUtFrame.eUtFrameInertial, ref sunPos.x, ref sunPos.y, ref sunPos.z);

                    Tuple3 sailingSRP = new Tuple3();

                    computeSRP(illum, cr, solarFlux, r, v, sunPos, ref m_SunlightSRP, ref sailingSRP);

                    // For OD to be able to estimate Cr, we need HPOP to compute SRP itself (i.e., the sunlight portion)
                    // but of course we want HPOP to compute the value that we just computed
                    //
                    // THUS, for the sunlight portion, we'll modify the SRPArea to make this happen

                    double magnitude = dotProduct(m_SunlightSRP, m_SunlightSRP);
                    magnitude = Math.Sqrt(magnitude);

                    ResultEval.SRPArea = magnitude / (cr * solarFlux * illum / (m_SpacecraftMass * m_SpeedOfLight));

                    // add sailing SRP contribution

                    ResultEval.AddAcceleration(AgEUtFrame.eUtFrameInertial, sailingSRP.x, sailingSRP.y, sailingSRP.z);
                }
            }
            catch (Exception ex)
            {
                this.m_Enabled = false;

                Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".Evaluate(): Exception Message( " + ex.Message + " )");
                Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".Evaluate(): Exception StackTr( " + ex.StackTrace + " )");

                Debug.WriteLine("Exception Message( " + ex.Message + " )", this.m_Name + ".Evaluate()");
                Debug.WriteLine("Exception StackTr( " + ex.StackTrace + " )", this.m_Name + ".Evaluate()");
            }
            finally
            {
                if (this.m_MsgCntr % this.m_MsgInterval == 0)
                {
                    Debug.WriteLine("<-- Exited", this.m_Name + ".Evaluate()");
                }
            }

            return(this.m_Enabled);
        }
Ejemplo n.º 4
0
        public bool Evaluate(IAgAsHpopPluginResultEval ResultEval)
        {
            try
            {
                if (this.m_EvalCntr % this.m_EvalMsgInterval == 0)
                {
                    Debug.WriteLine("--> Entered", this.m_Name + ".Evaluate( " + this.m_EvalCntr + " )");
                }

                this.m_EvalCntr++;

                if (this.m_UPS != null)
                {
                    if (this.m_Enabled)
                    {
                        this.EvaluateSRPArea(ResultEval);

                        ResultEval.AddAcceleration((AgEUtFrame)this.m_AccelRefFrame, this.m_AccelX, this.m_AccelY, this.m_AccelZ);

                        if (this.m_MsgStatus)
                        {
                            if (this.m_EvalCntr % this.m_EvalMsgInterval == 0)
                            {
                                this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".Evaluate( " + this.m_EvalCntr + " ):");
                            }
                        }
                    }
                    else
                    {
                        if (this.m_MsgStatus)
                        {
                            this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".Evaluate(): Disabled");
                        }
                    }
                }
                else
                {
                    throw new Exception("UtPluginSite was null");
                }
            }
            catch (Exception ex)
            {
                this.m_Enabled = false;

                if (this.m_UPS != null)
                {
                    this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".Evaluate(): Exception Message( " + ex.Message + " )");
                    this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".Evaluate(): Exception StackTr( " + ex.StackTrace + " )");
                }
                Debug.WriteLine("Exception Message( " + ex.Message + " )", this.m_Name + ".Evaluate()");
                Debug.WriteLine("Exception StackTr( " + ex.StackTrace + " )", this.m_Name + ".Evaluate()");
            }
            finally
            {
                if (this.m_EvalCntr % this.m_EvalMsgInterval == 0)
                {
                    Debug.WriteLine("<-- Exited", this.m_Name + ".Evaluate( " + this.m_EvalCntr + " )");
                }
            }

            return(this.m_Enabled);
        }