public virtual void test_term()
 {
     assertEquals(TERM.Period, Period.ofYears(10_000));
     assertEquals(TERM.Term, true);
     assertEquals(TERM.ToString(), "Term");
     assertEquals(Frequency.parse("Term"), TERM);
     assertEquals(Frequency.parse("0T"), TERM);
     assertEquals(Frequency.parse("1T"), TERM);
 }
Exemplo n.º 2
0
        public ActionResult StudentGroupAndSubjects(int?term_id, int?group_id)
        {
            checkLogin();


            GroupSubjectViewModel GSVM = new GroupSubjectViewModel();

            GSVM.TermList = CP.termSelectList;
            GSVM.Teachers = CP.AllUser;

            TERM displayingTerm = term_id != null ? CP.termlist[(int)term_id] : CP.currentTerm;

            if (displayingTerm != CP.currentTerm)
            {
                GSVM.Groups       = DBS.findActiveRecordsBySingleParm <STUDENT_GROUP>("TERM", displayingTerm.ID);
                GSVM.SelectedTerm = displayingTerm.ID;
            }
            else
            {
                GSVM.Groups       = Session["currentStudentGroups"] != null? (List <STUDENT_GROUP>)Session["currentStudentGroups"]: DBS.findActiveCurrentRecords <STUDENT_GROUP>();
                GSVM.SelectedTerm = CP.currentTerm.ID;
            }

            List <GroupAndSubject>            GnSs    = new List <GroupAndSubject>();                                                                                                                                               //subject with bool list
            List <SUBJECT>                    subject = DBS.findActiveRecordsBySingleParm <SUBJECT>("TERM", displayingTerm.ID);                                                                                                     // get subject per term
            List <STUDENT_GROUP_SUBJECT_LIST> Map     = group_id != null && group_id > 0? DBS.findActiveRecordsBySingleParm <STUDENT_GROUP_SUBJECT_LIST>("STUDENT_GROUP", (int)group_id) : new List <STUDENT_GROUP_SUBJECT_LIST>(); //get group subject map

            if (subject != null && subject.Any())
            {
                for (int s = 0; s < subject.Count; s++) //check each subject if they mapped to chosen group
                {
                    GroupAndSubject GS = new GroupAndSubject();
                    GS.SubjectID    = subject[s].ID;
                    GS.EBD_CODE     = subject[s].EDB_CODE;
                    GS.Subject_Name = subject[s].NAME;
                    GS.GroupID      = group_id != null? (int)group_id: 0;
                    if (Map != null && Map.Any() && Map.Exists(m => (m.SUBJECT == subject[s].ID) && (m.STUDENT_GROUP == (int)group_id))) // check if any map record matches chosen group
                    {
                        GS.Contain = true;
                        GS.MapID   = Map.Where(m => (m.SUBJECT == subject[s].ID) && (m.STUDENT_GROUP == (int)group_id)).FirstOrDefault().ID;
                    }
                    GnSs.Add(GS);
                }
            }
            GSVM.GSs = GnSs;

            ModelState.Clear();
            ViewData["SelectedTerm"] = GSVM.SelectedTerm;
            return(View(GSVM));
        }
Exemplo n.º 3
0
        public ActionResult Term()
        {
            checkLogin();

            TERM previousT = TermService.GetPreviousTerm();
            TERM currentT  = TermService.GetCurrentTerm();
            TERM nextT     = TermService.GetNextTerm();

            Session["previousT"] = previousT;
            Session["currentT"]  = currentT;
            Session["nextT"]     = nextT;


            return(View(new TermViewModel(previousT, currentT, nextT)));
        }
Exemplo n.º 4
0
        public ActionResult Classes(int?id)  // term id
        {
            checkLogin();

            TERM displayingTerm = id != null?TermService.GetTerm((int)id) : CP.currentTerm;

            ClassViewModel CVM = new ClassViewModel()
            {
                classes      = ClassService.getClassViews(displayingTerm.ID),
                SelectedTerm = displayingTerm.ID,
                TermList     = CP.termSelectList,
                teachers     = CP.teacherSelectList,
                newClass     = new QE_CLASS()
            };

            ModelState.Clear();
            return(View(CVM));
        }
Exemplo n.º 5
0
        public ActionResult Subject(int?id)  // term id
        {
            checkLogin();

            //if user choose term or not
            TERM displayingTerm = id != null && id != CP.currentTerm.ID? CP.termlist[(int)id] : CP.currentTerm;

            SubjectViewModel ViewModel = new SubjectViewModel();

            ViewModel.TermList                 = CP.termSelectList;
            ViewModel.SelectedTerm             = displayingTerm.ID;
            ViewModel.SubjectList              = SubjectService.GetSelectList(displayingTerm.ID);
            Session["subjectSelectList"]       = ViewModel.SubjectList;
            ViewModel.SubjectAndSSubjects      = SubjectService.getSubjectAndSSubjectsList(displayingTerm.ID);
            Session["SubjectAndSSubjectsList"] = ViewModel.SubjectAndSSubjects;

            ModelState.Clear();
            return(View(ViewModel));
        }
Exemplo n.º 6
0
        //     /* --------------------- */
        //     /* The series for s+XY/2 */
        //     /* --------------------- */
        //struct TERM{
        //   public int[] nfa = new int[8];    /* coefficients of l,l',F,D,Om,LVe,LE,pA */
        //   public double s, c;                /* sine and cosine coefficients */
        //};

        /// <summary>
        /// The CIO locator s, positioning the Celestial Intermediate Origin on
        /// the equator of the Celestial Intermediate Pole, given the CIP's X,Y
        /// coordinates.  Compatible with IAU 2006/2000A precession-nutation.
        /// </summary>
        ///
        /// <remarks>
        /// World Wide Astronomy - WWA
        /// Set of C# algorithms and procedures that implement standard models used in fundamental astronomy.
        ///
        /// This program is derived from the International Astronomical Union's
        /// SOFA (Standards of Fundamental Astronomy) software collection.
        /// http://www.iausofa.org
        ///
        /// The WWA code does not itself constitute software provided by and/or endorsed by SOFA.
        /// This version is intended to retain identical functionality to the SOFA library, but
        /// made distinct through different function names (prefixes) and C# language specific
        /// modifications in code.
        ///
        /// Contributor
        /// Attila Abrudán
        ///
        /// Please read the ReadMe.1st text file for more information.
        /// </remarks>
        /// <param name="date1">TT as a 2-part Julian Date (Note 1)</param>
        /// <param name="date2">TT as a 2-part Julian Date (Note 1)</param>
        /// <param name="x">CIP coordinates (Note 3)</param>
        /// <param name="y">CIP coordinates (Note 3)</param>
        /// <returns>the CIO locator s in radians (Note 2)</returns>
        public static double wwaS06(double date1, double date2, double x, double y)
        {
            /* Time since J2000.0, in Julian centuries */
            double t;

            /* Miscellaneous */
            int    i, j;
            double a, w0, w1, w2, w3, w4, w5;

            /* Fundamental arguments */
            double[] fa = new double[8];

            /* Returned value */
            double s;

            /* Polynomial coefficients */
            double[] sp = new double[] {
                /* 1-6 */
                94.00e-6,
                3808.65e-6,
                -122.68e-6,
                -72574.11e-6,
                27.98e-6,
                15.62e-6
            };

            /* Terms of order t^0 */
            TERM[] s0 = new TERM[] {
                /* 1-10 */
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 1, 0, 0, 0 }, s = -2640.73e-6, c = 0.39e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 2, 0, 0, 0 }, s = -63.53e-6, c = 0.02e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 3, 0, 0, 0 }, s = -11.75e-6, c = -0.01e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 1, 0, 0, 0 }, s = -11.21e-6, c = -0.01e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 2, 0, 0, 0 }, s = 4.57e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 3, 0, 0, 0 }, s = -2.02e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 1, 0, 0, 0 }, s = -1.98e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 3, 0, 0, 0 }, s = 1.72e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 0, 0, 1, 0, 0, 0 }, s = 1.41e-6, c = 0.01e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 0, 0, -1, 0, 0, 0 }, s = 1.26e-6, c = 0.01e-6
                },

                /* 11-20 */
                new TERM {
                    nfa = new int[] { 1, 0, 0, 0, -1, 0, 0, 0 }, s = 0.63e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 0, 0, 1, 0, 0, 0 }, s = 0.63e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 2, -2, 3, 0, 0, 0 }, s = -0.46e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 2, -2, 1, 0, 0, 0 }, s = -0.45e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 4, -4, 4, 0, 0, 0 }, s = -0.36e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 1, -1, 1, -8, 12, 0 }, s = 0.24e-6, c = 0.12e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 0, 0, 0, 0 }, s = -0.32e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 2, 0, 0, 0 }, s = -0.28e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 2, 0, 3, 0, 0, 0 }, s = -0.27e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 2, 0, 1, 0, 0, 0 }, s = -0.26e-6, c = 0.00e-6
                },

                /* 21-30 */
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 0, 0, 0, 0 }, s = 0.21e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, -2, 2, -3, 0, 0, 0 }, s = -0.19e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, -2, 2, -1, 0, 0, 0 }, s = -0.18e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 0, 8, -13, -1 }, s = 0.10e-6, c = -0.05e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 2, 0, 0, 0, 0 }, s = -0.15e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 2, 0, -2, 0, -1, 0, 0, 0 }, s = 0.14e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 2, -2, 2, 0, 0, 0 }, s = 0.14e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 0, -2, 1, 0, 0, 0 }, s = -0.14e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 0, -2, -1, 0, 0, 0 }, s = -0.14e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 4, -2, 4, 0, 0, 0 }, s = -0.13e-6, c = 0.00e-6
                },

                /* 31-33 */
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 4, 0, 0, 0 }, s = 0.11e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, -2, 0, -3, 0, 0, 0 }, s = -0.11e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, -2, 0, -1, 0, 0, 0 }, s = -0.11e-6, c = 0.00e-6
                }
            };

            /* Terms of order t^1 */
            TERM[] s1 = new TERM[] {
                /* 1 - 3 */
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 2, 0, 0, 0 }, s = -0.07e-6, c = 3.57e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 1, 0, 0, 0 }, s = 1.73e-6, c = -0.03e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 3, 0, 0, 0 }, s = 0.00e-6, c = 0.48e-6
                }
            };

            /* Terms of order t^2 */
            TERM[] s2 = new TERM[] {
                /* 1-10 */
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 1, 0, 0, 0 }, s = 743.52e-6, c = -0.17e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 2, 0, 0, 0 }, s = 56.91e-6, c = 0.06e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 2, 0, 0, 0 }, s = 9.84e-6, c = -0.01e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 2, 0, 0, 0 }, s = -8.85e-6, c = 0.01e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 0, 0, 0, 0, 0, 0 }, s = -6.38e-6, c = -0.05e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 0, 0, 0, 0, 0, 0 }, s = -3.07e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 2, -2, 2, 0, 0, 0 }, s = 2.23e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 1, 0, 0, 0 }, s = 1.67e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 2, 0, 2, 0, 0, 0 }, s = 1.30e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, -2, 2, -2, 0, 0, 0 }, s = 0.93e-6, c = 0.00e-6
                },

                /* 11-20 */
                new TERM {
                    nfa = new int[] { 1, 0, 0, -2, 0, 0, 0, 0 }, s = 0.68e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 1, 0, 0, 0 }, s = -0.55e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, -2, 0, -2, 0, 0, 0 }, s = 0.53e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 2, 0, 0, 0, 0 }, s = -0.27e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 0, 0, 1, 0, 0, 0 }, s = -0.27e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, -2, -2, -2, 0, 0, 0 }, s = -0.26e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 0, 0, -1, 0, 0, 0 }, s = -0.25e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 2, 0, 1, 0, 0, 0 }, s = 0.22e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 2, 0, 0, -2, 0, 0, 0, 0 }, s = -0.21e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 2, 0, -2, 0, -1, 0, 0, 0 }, s = 0.20e-6, c = 0.00e-6
                },

                /* 21-25 */
                new TERM {
                    nfa = new int[] { 0, 0, 2, 2, 2, 0, 0, 0 }, s = 0.17e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 2, 0, 2, 0, 2, 0, 0, 0 }, s = 0.13e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 2, 0, 0, 0, 0, 0, 0, 0 }, s = -0.13e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 2, -2, 2, 0, 0, 0 }, s = -0.12e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 0, 0, 0, 0 }, s = -0.11e-6, c = 0.00e-6
                }
            };

            /* Terms of order t^3 */
            TERM[] s3 = new TERM[] {
                /* 1-4 */
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 1, 0, 0, 0 }, s = 0.30e-6, c = -23.42e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 2, 0, 0, 0 }, s = -0.03e-6, c = -1.46e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 2, 0, 0, 0 }, s = -0.01e-6, c = -0.25e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 2, 0, 0, 0 }, s = 0.00e-6, c = 0.23e-6
                }
            };

            /* Terms of order t^4 */
            TERM[] s4 = new TERM[] {
                /* 1-1 */
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 1, 0, 0, 0 }, s = -0.26e-6, c = -0.01e-6
                }
            };

            /* Number of terms in the series */
            //static const int NS0 = (int) (sizeof s0 / sizeof (TERM));
            //static const int NS1 = (int) (sizeof s1 / sizeof (TERM));
            //static const int NS2 = (int) (sizeof s2 / sizeof (TERM));
            //static const int NS3 = (int) (sizeof s3 / sizeof (TERM));
            //static const int NS4 = (int) (sizeof s4 / sizeof (TERM));
            int NS0 = s0.GetLength(0); // by AA
            int NS1 = s1.GetLength(0);
            int NS2 = s2.GetLength(0);
            int NS3 = s3.GetLength(0);
            int NS4 = s4.GetLength(0);

            /*--------------------------------------------------------------------*/

            /* Interval between fundamental epoch J2000.0 and current date (JC). */
            t = ((date1 - DJ00) + date2) / DJC;

            /* Fundamental Arguments (from IERS Conventions 2003) */

            /* Mean anomaly of the Moon. */
            fa[0] = wwaFal03(t);

            /* Mean anomaly of the Sun. */
            fa[1] = wwaFalp03(t);

            /* Mean longitude of the Moon minus that of the ascending node. */
            fa[2] = wwaFaf03(t);

            /* Mean elongation of the Moon from the Sun. */
            fa[3] = wwaFad03(t);

            /* Mean longitude of the ascending node of the Moon. */
            fa[4] = wwaFaom03(t);

            /* Mean longitude of Venus. */
            fa[5] = wwaFave03(t);

            /* Mean longitude of Earth. */
            fa[6] = wwaFae03(t);

            /* General precession in longitude. */
            fa[7] = wwaFapa03(t);

            /* Evaluate s. */
            w0 = sp[0];
            w1 = sp[1];
            w2 = sp[2];
            w3 = sp[3];
            w4 = sp[4];
            w5 = sp[5];

            for (i = NS0 - 1; i >= 0; i--)
            {
                a = 0.0;
                for (j = 0; j < 8; j++)
                {
                    a += (double)s0[i].nfa[j] * fa[j];
                }
                w0 += s0[i].s * Math.Sin(a) + s0[i].c * Math.Cos(a);
            }

            for (i = NS1 - 1; i >= 0; i--)
            {
                a = 0.0;
                for (j = 0; j < 8; j++)
                {
                    a += (double)s1[i].nfa[j] * fa[j];
                }
                w1 += s1[i].s * Math.Sin(a) + s1[i].c * Math.Cos(a);
            }

            for (i = NS2 - 1; i >= 0; i--)
            {
                a = 0.0;
                for (j = 0; j < 8; j++)
                {
                    a += (double)s2[i].nfa[j] * fa[j];
                }
                w2 += s2[i].s * Math.Sin(a) + s2[i].c * Math.Cos(a);
            }

            for (i = NS3 - 1; i >= 0; i--)
            {
                a = 0.0;
                for (j = 0; j < 8; j++)
                {
                    a += (double)s3[i].nfa[j] * fa[j];
                }
                w3 += s3[i].s * Math.Sin(a) + s3[i].c * Math.Cos(a);
            }

            for (i = NS4 - 1; i >= 0; i--)
            {
                a = 0.0;
                for (j = 0; j < 8; j++)
                {
                    a += (double)s4[i].nfa[j] * fa[j];
                }
                w4 += s4[i].s * Math.Sin(a) + s4[i].c * Math.Cos(a);
            }

            s = (w0 +
                 (w1 +
                  (w2 +
                   (w3 +
                    (w4 +
                     w5 * t) * t) * t) * t) * t) * DAS2R - x * y / 2.0;

            return(s);
        }
Exemplo n.º 7
0
        //     /* ----------------------------------------- */
        //     /* The series for the EE complementary terms */
        //     /* ----------------------------------------- */

        //typedef struct {
        //   int nfa[8];      /* coefficients of l,l',F,D,Om,LVe,LE,pA */
        //   double s, c;     /* sine and cosine coefficients */
        //} TERM;

        /// <summary>
        /// Equation of the equinoxes complementary terms, consistent with
        /// IAU 2000 resolutions.
        /// </summary>
        ///
        /// <remarks>
        /// World Wide Astronomy - WWA
        /// Set of C# algorithms and procedures that implement standard models used in fundamental astronomy.
        ///
        /// This program is derived from the International Astronomical Union's
        /// SOFA (Standards of Fundamental Astronomy) software collection.
        /// http://www.iausofa.org
        ///
        /// The WWA code does not itself constitute software provided by and/or endorsed by SOFA.
        /// This version is intended to retain identical functionality to the SOFA library, but
        /// made distinct through different function names (prefixes) and C# language specific
        /// modifications in code.
        ///
        /// Contributor
        /// Attila Abrudán
        ///
        /// Please read the ReadMe.1st text file for more information.
        /// </remarks>
        /// <param name="date1">TT as a 2-part Julian Date (Note 1)</param>
        /// <param name="date2">TT as a 2-part Julian Date (Note 1)</param>
        /// <returns>complementary terms (Note 2)</returns>
        public static double wwaEect00(double date1, double date2)
        {
            /* Time since J2000.0, in Julian centuries */
            double t;

            /* Miscellaneous */
            int    i, j;
            double a, s0, s1;

            /* Fundamental arguments */
            double[] fa = new double[14];

            /* Returned value. */
            double eect;

            /* Terms of order t^0 */
            TERM[] e0 = new TERM[] {
                /* 1-10 */
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 1, 0, 0, 0 }, s = 2640.96e-6, c = -0.39e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 2, 0, 0, 0 }, s = 63.52e-6, c = -0.02e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 3, 0, 0, 0 }, s = 11.75e-6, c = 0.01e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 1, 0, 0, 0 }, s = 11.21e-6, c = 0.01e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 2, 0, 0, 0 }, s = -4.55e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 3, 0, 0, 0 }, s = 2.02e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 1, 0, 0, 0 }, s = 1.98e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 3, 0, 0, 0 }, s = -1.72e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 0, 0, 1, 0, 0, 0 }, s = -1.41e-6, c = -0.01e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 0, 0, -1, 0, 0, 0 }, s = -1.26e-6, c = -0.01e-6
                },

                /* 11-20 */
                new TERM {
                    nfa = new int[] { 1, 0, 0, 0, -1, 0, 0, 0 }, s = -0.63e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 0, 0, 1, 0, 0, 0 }, s = -0.63e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 2, -2, 3, 0, 0, 0 }, s = 0.46e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 2, -2, 1, 0, 0, 0 }, s = 0.45e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 4, -4, 4, 0, 0, 0 }, s = 0.36e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 1, -1, 1, -8, 12, 0 }, s = -0.24e-6, c = -0.12e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 0, 0, 0, 0 }, s = 0.32e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 2, 0, 2, 0, 0, 0 }, s = 0.28e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 2, 0, 3, 0, 0, 0 }, s = 0.27e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 2, 0, 1, 0, 0, 0 }, s = 0.26e-6, c = 0.00e-6
                },

                /* 21-30 */
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 0, 0, 0, 0 }, s = -0.21e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, -2, 2, -3, 0, 0, 0 }, s = 0.19e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, -2, 2, -1, 0, 0, 0 }, s = 0.18e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 0, 8, -13, -1 }, s = -0.10e-6, c = 0.05e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 0, 2, 0, 0, 0, 0 }, s = 0.15e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 2, 0, -2, 0, -1, 0, 0, 0 }, s = -0.14e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 0, -2, 1, 0, 0, 0 }, s = 0.14e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 1, 2, -2, 2, 0, 0, 0 }, s = -0.14e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, 0, -2, -1, 0, 0, 0 }, s = 0.14e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 0, 0, 4, -2, 4, 0, 0, 0 }, s = 0.13e-6, c = 0.00e-6
                },

                /* 31-33 */
                new TERM {
                    nfa = new int[] { 0, 0, 2, -2, 4, 0, 0, 0 }, s = -0.11e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, -2, 0, -3, 0, 0, 0 }, s = 0.11e-6, c = 0.00e-6
                },
                new TERM {
                    nfa = new int[] { 1, 0, -2, 0, -1, 0, 0, 0 }, s = 0.11e-6, c = 0.00e-6
                }
            };

            /* Terms of order t^1 */
            TERM[] e1 = new TERM[] {
                new TERM {
                    nfa = new int[] { 0, 0, 0, 0, 1, 0, 0, 0 }, s = -0.87e-6, c = 0.00e-6
                }
            };

            /* Number of terms in the series */
            //const int NE0 = (int) (sizeof e0 / sizeof (TERM));
            //const int NE1 = (int) (sizeof e1 / sizeof (TERM));
            int NE0 = e0.GetLength(0); // by AA
            int NE1 = e1.GetLength(0); // by AA

            /*--------------------------------------------------------------------*/

            /* Interval between fundamental epoch J2000.0 and current date (JC). */
            t = ((date1 - DJ00) + date2) / DJC;

            /* Fundamental Arguments (from IERS Conventions 2003) */

            /* Mean anomaly of the Moon. */
            fa[0] = wwaFal03(t);

            /* Mean anomaly of the Sun. */
            fa[1] = wwaFalp03(t);

            /* Mean longitude of the Moon minus that of the ascending node. */
            fa[2] = wwaFaf03(t);

            /* Mean elongation of the Moon from the Sun. */
            fa[3] = wwaFad03(t);

            /* Mean longitude of the ascending node of the Moon. */
            fa[4] = wwaFaom03(t);

            /* Mean longitude of Venus. */
            fa[5] = wwaFave03(t);

            /* Mean longitude of Earth. */
            fa[6] = wwaFae03(t);

            /* General precession in longitude. */
            fa[7] = wwaFapa03(t);

            /* Evaluate the EE complementary terms. */
            s0 = 0.0;
            s1 = 0.0;

            for (i = NE0 - 1; i >= 0; i--)
            {
                a = 0.0;
                for (j = 0; j < 8; j++)
                {
                    a += (double)(e0[i].nfa[j]) * fa[j];
                }
                s0 += e0[i].s * Math.Sin(a) + e0[i].c * Math.Cos(a);
            }

            for (i = NE1 - 1; i >= 0; i--)
            {
                a = 0.0;
                for (j = 0; j < 8; j++)
                {
                    a += (double)(e1[i].nfa[j]) * fa[j];
                }
                s1 += e1[i].s * Math.Sin(a) + e1[i].c * Math.Cos(a);
            }

            eect = (s0 + s1 * t) * DAS2R;

            return(eect);
        }
Exemplo n.º 8
0
        public ActionResult TermPost(TERM next)
        {
            checkLogin();

            TERM previousT = Session["previousT"] != null? (TERM)Session["previousT"]: TermService.GetPreviousTerm();
            TERM currentT  = Session["currentT"] != null ? (TERM)Session["currentT"] : TermService.GetCurrentTerm();
            TERM nextT     = Session["nextT"] != null ? (TERM)Session["nextT"] : TermService.GetNextTerm();

            TermViewModel viewModel = new TermViewModel(previousT, currentT, nextT);

            TempData["showForm"]  = false;
            TempData["resultMsg"] = "";

            // fields checking
            if (!ModelState.IsValid)
            {
                TempData["showForm"] = true;
                return(View("Term", viewModel)); // redirect to form with data
            }
            // logic checking
            bool pass = true;

            if (TermService.GetTermByName(next.TERM_NAME).ID != 0 && TermService.GetTermByName(next.TERM_NAME).ID != next.ID)
            {
                TempData[Constant.msg_error] = "term name already in use";
                pass = false;
            }

            if (pass && next.TERM_START >= next.TERM_END)
            {
                TempData[Constant.msg_error] = "start date > end date";
                pass = false;
            }

            if (pass && next.TERM_START < DateTime.Now.Date)
            {
                TempData[Constant.msg_error] = "start date < today";
                pass = false;
            }

            if (pass && (currentT != null) && currentT.TERM_END >= next.TERM_START)
            {
                TempData[Constant.msg_error] = "current term end date > next term start date";
                pass = false;
            }

            if (!pass)
            {
                TempData["showForm"] = true;
                return(View("Term", viewModel));
            }// redirect to form with data

            next.ACTIVE = true;
            bool isSuccess = false;

            if (next.ID == Constant.DEF_INT)
            {
                isSuccess = DBS.addRecord(next);
            }
            else
            {
                isSuccess = DBS.updateRecord(next);
            }

            // some unkown error happened
            if (!isSuccess)
            {
                TempData[Constant.msg_error] = "Ops! something gone wrong.";
                TempData["showForm"]         = true;
                return(View("Term", viewModel)); // redirect to form with data
            }

            TempData[Constant.msg_success] = ((next.ID == Constant.DEF_INT) ? "New term has been created" : "Next term has been edited");

            //regen lists
            previousT = TermService.GetPreviousTerm();
            currentT  = TermService.GetCurrentTerm();
            nextT     = TermService.GetNextTerm();

            return(View(new TermViewModel(previousT, currentT, nextT))); // success
        }