public ArrayList getPastPDUData(Int64 startTicks, Int64 endTicks)
        {
            ArrayList result = new ArrayList();

            DateTime startDate = new DateTime(startTicks);

            var start = startDate.Date;

            DateTime endDate = new DateTime(endTicks);

            var end = endDate.Date;

            SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            try
            {

                string connectionString = ConfigurationManager.ConnectionStrings["KnightWatchDBConnection"].ConnectionString;

                conn.ConnectionString = connectionString;

                conn.Open();


                String sqlQuery = "select module1_load1, module1_load2, module1_load3, module2_load1, module2_load2, module2_load3, " +
                                    "module3_load1, module3_load2, module3_load3, module4_load1, module4_load2, module4_load3, " +
                                    "module5_load1, module5_load2, module5_load3, module6_load1, module6_load2, module6_load3, entry_date, entry_time from PDU p where entry_date between @startDate and @endDate";

                SqlCommand command = new SqlCommand(sqlQuery, conn);

                SqlParameter start_d = command.Parameters.AddWithValue("@startDate", start);

                SqlParameter end_d = command.Parameters.AddWithValue("@endDate", end);

                using (SqlDataReader commandReader = command.ExecuteReader())
                {

                    while (commandReader.Read())
                    {
                        String dateOnly = commandReader["entry_date"].ToString();

                        String timeOnly = commandReader["entry_time"].ToString();

                        DateTime d = DateTime.Parse(dateOnly.Substring(0, dateOnly.IndexOf(" ")) + "  " + timeOnly);

                        if (DateTime.Compare(d, startDate) >= 0 && DateTime.Compare(d, endDate) <= 0)
                        {

                            PDU pdu = new PDU();

                            pdu.module1load1 = Double.Parse(commandReader["module1_load1"].ToString());

                            pdu.module1load2 = Double.Parse(commandReader["module1_load2"].ToString());

                            pdu.module1load3 = Double.Parse(commandReader["module1_load3"].ToString());

                            pdu.module2load1 = Double.Parse(commandReader["module2_load1"].ToString());

                            pdu.module2load2 = Double.Parse(commandReader["module2_load2"].ToString());

                            pdu.module2load3 = Double.Parse(commandReader["module2_load3"].ToString());

                            pdu.module3load1 = Double.Parse(commandReader["module3_load1"].ToString());

                            pdu.module3load2 = Double.Parse(commandReader["module3_load2"].ToString());

                            pdu.module3load3 = Double.Parse(commandReader["module3_load3"].ToString());

                            pdu.module4load1 = Double.Parse(commandReader["module4_load1"].ToString());

                            pdu.module4load2 = Double.Parse(commandReader["module4_load2"].ToString());

                            pdu.module4load3 = Double.Parse(commandReader["module4_load3"].ToString());

                            pdu.module5load1 = Double.Parse(commandReader["module5_load1"].ToString());

                            pdu.module5load2 = Double.Parse(commandReader["module5_load2"].ToString());

                            pdu.module5load3 = Double.Parse(commandReader["module5_load3"].ToString());

                            pdu.module6load1 = Double.Parse(commandReader["module6_load1"].ToString());

                            pdu.module6load2 = Double.Parse(commandReader["module6_load2"].ToString());

                            pdu.module6load3 = Double.Parse(commandReader["module6_load3"].ToString());

                            result.Add(pdu);
                        }
                    }

                }
            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
            }

            conn.Close();

            return result;
        }
        public PDU getCurrentPDUData()
        {
            PDU pdu = new PDU();

            SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            try
            {

                string connectionString = ConfigurationManager.ConnectionStrings["KnightWatchDBConnection"].ConnectionString;

                conn.ConnectionString = connectionString;

                conn.Open();


                String sqlQuery = "select module1_load1, module1_load2, module1_load3, module2_load1, module2_load2, module2_load3, "+
                                    "module3_load1, module3_load2, module3_load3, module4_load1, module4_load2, module4_load3, " +
                                    "module5_load1, module5_load2, module5_load3, module6_load1, module6_load2, module6_load3 from PDU p where entry_date = (select max(entry_date) from PDU) and entry_time = (select max(entry_time) from PDU p1 where p1.entry_date = p.entry_date)";

                SqlCommand command = new SqlCommand(sqlQuery, conn);

                SqlDataReader commandReader = command.ExecuteReader();

                while (commandReader.Read())
                {
                    pdu.module1load1 = Double.Parse(commandReader["module1_load1"].ToString());

                    pdu.module1load2 = Double.Parse(commandReader["module1_load2"].ToString());

                    pdu.module1load3 = Double.Parse(commandReader["module1_load3"].ToString());

                    pdu.module2load1 = Double.Parse(commandReader["module2_load1"].ToString());

                    pdu.module2load2 = Double.Parse(commandReader["module2_load2"].ToString());

                    pdu.module2load3 = Double.Parse(commandReader["module2_load3"].ToString());

                    pdu.module3load1 = Double.Parse(commandReader["module3_load1"].ToString());

                    pdu.module3load2 = Double.Parse(commandReader["module3_load2"].ToString());

                    pdu.module3load3 = Double.Parse(commandReader["module3_load3"].ToString());

                    pdu.module4load1 = Double.Parse(commandReader["module4_load1"].ToString());

                    pdu.module4load2 = Double.Parse(commandReader["module4_load2"].ToString());

                    pdu.module4load3 = Double.Parse(commandReader["module4_load3"].ToString());

                    pdu.module5load1 = Double.Parse(commandReader["module5_load1"].ToString());

                    pdu.module5load2 = Double.Parse(commandReader["module5_load2"].ToString());

                    pdu.module5load3 = Double.Parse(commandReader["module5_load3"].ToString());

                    pdu.module6load1 = Double.Parse(commandReader["module6_load1"].ToString());

                    pdu.module6load2 = Double.Parse(commandReader["module6_load2"].ToString());

                    pdu.module6load3 = Double.Parse(commandReader["module6_load3"].ToString());
                }

            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
            }

            conn.Close();

            return pdu;
        }