public static SymbolicExpression CreateDiffTimeMatrix(this REngine engine, TimeSpan[,] data)
        {
            var numeric = data.FromTimeSpan();
            var sexp    = engine.CreateNumericMatrix(numeric);

            return(sexp.AddDiffTimeAttributes());
        }
        public void WriteAndReadTimespanDataset()
        {
            string filename = Path.Combine(folder, "testTimespan.H5");
            var    times    = new TimeSpan[10, 5];
            var    offset   = new TimeSpan(1, 0, 0, 0, 0);

            for (var i = 0; i < 10; i++)
            {
                for (var j = 0; j < 5; j++)
                {
                    times[i, j] = offset.Add(new TimeSpan(i + j * 5, 0, 0));
                }
            }

            try
            {
                var fileId = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                Hdf5.WriteDataset(fileId, "/test", times);

                TimeSpan[,] timesRead = (TimeSpan[, ])Hdf5.ReadDataset <TimeSpan>(fileId, "/test").result;
                CompareDatasets(times, timesRead);

                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }
Example #3
0
 /// <summary>
 /// add the data that was handed over by the user
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button_Click(object sender, RoutedEventArgs e)
 {
     bool[] NeedsNanny = { (bool)Sunday.IsChecked, (bool)Monday.IsChecked, (bool)Tuesday.IsChecked, (bool)Wednesday.IsChecked, (bool)Thursday.IsChecked, (bool)Friday.IsChecked };
     TimeSpan[,] workHours = { { TimeSpan.FromHours(Convert.ToDouble(SunHour.Text) + (Convert.ToDouble(SunMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(SunHour2.Text) + (Convert.ToDouble(SunMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(MonHour.Text) + (Convert.ToDouble(MonMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(MonHour2.Text) + (Convert.ToDouble(MonMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(TuesHour.Text) + (Convert.ToDouble(TuesMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(TuesHour2.Text) + (Convert.ToDouble(TuesMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(WedHour.Text) + (Convert.ToDouble(WedMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(WedHour2.Text) + (Convert.ToDouble(WedMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(ThuHour.Text) + (Convert.ToDouble(ThuMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(ThuHour2.Text) + (Convert.ToDouble(ThuMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(FriHour.Text) + (Convert.ToDouble(FriMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(FriHour2.Text) + (Convert.ToDouble(FriMin2.Text) / 60)) } };
     try
     {
         BE.Mother mother;
         if (SearchArea.Text == "")
         {
             mother = new BE.Mother(ID.Text, First.Text, Last.Text, Phone.Text, Address.Text, Address.Text, NeedsNanny, workHours, Comments.Text);
         }
         else
         {
             mother = new BE.Mother(ID.Text, First.Text, Last.Text, Phone.Text, Address.Text, SearchArea.Text, NeedsNanny, workHours, Comments.Text);
         }
         GetBL.bl.AddMother(mother);
         PotentialNannyWin potentialNannyWin = new PotentialNannyWin();
         potentialNannyWin.Show();
         Thread.Sleep(500);
         Close();
     }
     catch (Exception str)
     {
         MessageBox.Show(str.Message, str.Message, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #4
0
        /// <summary>
        /// Continously asks for a time until the user entered time is valid
        /// </summary>
        /// <param name="prompt">An optional prompt to display before prompting</param>
        /// <returns>The user entered time</returns>
        static TimeSpan LoopReadTimeSpan(string prompt, TimeSpan[,] timetable, Stations?endAt)
        {
            bool     valid = false;
            TimeSpan value = default(TimeSpan);

            TimeSpan min = timetable[(int)endAt, 0];
            TimeSpan max = TimeSpan.FromTicks(TimeSpan.TicksPerDay - 1); // 1 day - 1 "tick"

            if (prompt != null)
            {
                Console.WriteLine(prompt);
            }

            while (!valid)
            {
                Console.Write("> ");

                // Attempt parsing as 24-hour time
                valid = TimeSpan.TryParseExact(Console.ReadLine(), "g", CultureInfo.CurrentCulture, out value);

                if (valid && (value < min || value > max))
                {
                    Console.WriteLine("You cannot catch any train to arrive by {0} at {1}", ConvertTimeSpanToString(value), endAt);
                    Console.WriteLine();

                    valid = false;
                }
            }

            Console.WriteLine();

            return(value);
        }
Example #5
0
        /// <summary>
        /// copy constructor
        /// </summary>
        /// <param name="mother"></param>
        public Mother(Mother mother)
        {
            if (IDCheck(mother.id))
            {
                id = mother.id;
            }
            else
            {
                throw new Exception("Wrong ID Number");
            }
            lastName  = mother.lastName;
            firstName = mother.firstName;
            bool flag = true;

            foreach (char c in mother.phoneNumber)
            {
                if (c < '0' || c > '9')
                {
                    flag = false;
                }
            }
            if (!flag)
            {
                throw new Exception("Phone number must to be with only digits!!");
            }
            phoneNumber     = mother.phoneNumber;
            address         = mother.address;
            searchingArea   = mother.searchingArea;
            needsNanny      = mother.needsNanny;
            needsNannyHours = mother.needsNannyHours;
            comments        = mother.comments;
        }
Example #6
0
        /// <summary>
        /// constructor by everything
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="first_name"></param>
        /// <param name="last_name"></param>
        /// <param name="phone_number"></param>
        /// <param name="address_"></param>
        /// <param name="searching_area"></param>
        /// <param name="needs_nanny"></param>
        /// <param name="needs_nanny_hours"></param>
        /// <param name="comments_"></param>
        public Mother(string ID, string first_name, string last_name, string phone_number, string address_, string searching_area,
                      bool[] needs_nanny, TimeSpan[,] needs_nanny_hours, string comments_)
        {
            if (IDCheck(ID))
            {
                id = ID;
            }
            else
            {
                throw new Exception("Wrong ID Number");
            }
            lastName  = last_name;
            firstName = first_name;
            bool flag = true;

            foreach (char c in phone_number)
            {
                if (c < '0' || c > '9')
                {
                    flag = false;
                }
            }
            if (!flag)
            {
                throw new Exception("Phone number must to be with only digits!!");
            }
            phoneNumber     = phone_number;
            address         = address_;
            searchingArea   = searching_area;
            needsNanny      = needs_nanny;
            needsNannyHours = needs_nanny_hours;
            comments        = comments_;
        }
 public College(string name, int[,] time)
 {
     CollegeName = name;
     course      = new TimeSpan[time.GetLength(0) / 2, 2];
     for (int i = 0; i < time.GetLength(0); ++i)
     {
         course[i / 2, i % 2] = new TimeSpan(time[i, 0], time[i, 1], 0);
     }
 }
Example #8
0
 /// <summary>
 /// Given a starting and ending station, with a time index, present the user with their departure time
 /// </summary>
 /// <param name="timetable">The timetable</param>
 /// <param name="startingStation">The starting station</param>
 /// <param name="endingStation">The ending station</param>
 /// <param name="timeIndex">The offset into the station times</param>
 static void DisplayDepartureTime(TimeSpan[,] timetable, TimeSpan latestArrivalTime, Stations?startingStation, Stations?endingStation, int timeIndex)
 {
     Console.WriteLine(
         "To arrive at {0} by {1}, you need to catch the train from {2} at {3}.",
         endingStation,
         ConvertTimeSpanToString(latestArrivalTime),
         startingStation,
         ConvertTimeSpanToString(timetable[(int)startingStation, timeIndex])
         );
 }
Example #9
0
        double matchingHours(TimeSpan[,] nanny, TimeSpan[,] mother)
        {
            int sumMatchingHours = 0;

            for (int i = 0; i < 6; i++)
            {
                sumMatchingHours += Math.Min(nanny[i, 1].Hours, mother[i, 1].Hours) -
                                    Math.Max(nanny[i, 0].Hours, mother[i, 0].Hours);
            }
            return(sumMatchingHours);
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="timetable">The timetable</param>
        /// <param name="station">The station</param>
        /// <param name="latestTime">The latest time the user can arrive at the station</param>
        /// <returns></returns>
        static int GetStationArrivalTimeIndex(TimeSpan[,] timetable, Stations?station, TimeSpan latestTime)
        {
            int lastTimeIndex = timetable.GetLength(1) - 1;

            while (lastTimeIndex > 0 && timetable[(int)station, lastTimeIndex] >= latestTime)
            {
                --lastTimeIndex;
            }

            return(lastTimeIndex);
        }
        public VideoGridMakerTask(string fileName, VideoGridParameters parameters, Stream outputStream, OutputFormat outputFormat)
        {
            _uid = Guid.NewGuid();

            _fileName     = fileName;
            _parameters   = parameters;
            _outputStream = outputStream;
            _outputFormat = outputFormat;

            _grid  = new BitmapImage[parameters.XCount, parameters.YCount];
            _times = new TimeSpan[parameters.XCount, parameters.YCount];
        }
Example #12
0
 public static double[,] FromTimeSpanMatrix(TimeSpan[,] values)
 {
     double[,] result = new double[values.GetLength(0), values.GetLength(1)];
     for (int rowindex = 0; rowindex < values.GetLength(0); ++rowindex)
     {
         for (int columnindex = 0; columnindex < values.GetLength(1); ++columnindex)
         {
             result[rowindex, columnindex] = FromTimeSpanScalar(values[rowindex, columnindex]);
         }
     }
     return(result);
 }
Example #13
0
 //Mother c-tor
 public Mother(int id1, string lastName1, string name1, int phoneNumber1, string address1, string nannysAddress1, bool[] momWorkDays1, TimeSpan[,] nannysHours1, string remarks1)
 {
     Id            = id1;
     LastName      = lastName1;
     Name          = name1;
     PhoneNumber   = phoneNumber1;
     Address       = address1;
     NannysAddress = nannysAddress1;
     MomWorkDays   = momWorkDays1;
     NannysHours   = nannysHours1;
     Remarks       = remarks1;
 }
Example #14
0
 /// <summary>
 /// default constructor
 /// </summary>
 public Mother()
 {
     id              = null;
     lastName        = null;
     firstName       = null;
     phoneNumber     = null;
     address         = null;
     searchingArea   = null;
     needsNanny      = null;
     needsNannyHours = null;
     comments        = null;
 }
Example #15
0
        static void Main()
        {
            // ********** Do not remove the following statement ******************
            timeTable = Timetables.CreateTimeTable();

            //*********** Start your code for Main below this line  ******************

            TimeSpan[,] timespanTimetable = ConvertTimetableToTimeSpans(timeTable);

            // Get the starting station, exit on user request
            Stations?startingStation = GetStartingStation();

            if (startingStation == null)
            {
                ExitProgram();

                return;
            }

            // Get the ending station, exit on user request
            Stations?endingStation = GetEndingStation();

            if (endingStation == null)
            {
                ExitProgram();

                return;
            }

            // Check if journey is possible
            if (!AreStationsValid(startingStation, endingStation))
            {
                ExitProgram();

                return;
            }

            // Calculate journey
            string timePrompt = String.Format("Latest time to arrive at {0} (24-hour format):", endingStation);

            TimeSpan latestArrivalTime = LoopReadTimeSpan(timePrompt, timespanTimetable, endingStation);

            // The index of the arrival time will be the index of the departure time, with different stations
            int prevStationArrivalTimeIndex = GetStationArrivalTimeIndex(timespanTimetable, endingStation, latestArrivalTime);

            DisplayDepartureTime(timespanTimetable, latestArrivalTime, startingStation, endingStation, prevStationArrivalTimeIndex);

            ExitProgram();

            return;
        }// end Main
Example #16
0
        /// <summary>
        /// constructor by everything
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="first_name"></param>
        /// <param name="last_name"></param>
        /// <param name="birth_date"></param>
        /// <param name="address_"></param>
        /// <param name="phone_number"></param>
        /// <param name="is_elevator"></param>
        /// <param name="floor_"></param>
        /// <param name="experience_"></param>
        /// <param name="max_children"></param>
        /// <param name="min_age"></param>
        /// <param name="max_age"></param>
        /// <param name="if_hour_paid"></param>
        /// <param name="pay_for_hour"></param>
        /// <param name="pay_for_month"></param>
        /// <param name="vacation_check"></param>
        /// <param name="recommendation_"></param>
        /// <param name="is_working"></param>
        /// <param name="work_hours"></param>
        public Nanny(string ID, string first_name, string last_name, DateTime birth_date, string address_, string phone_number, bool is_elevator,
                     int floor_, int experience_, int max_children, int min_age, int max_age, bool if_hour_paid, double pay_for_hour, double pay_for_month,
                     bool vacation_check, string recommendation_, bool[] is_working, TimeSpan[,] work_hours)
        {
            if (IDCheck(ID))
            {
                id = ID;
            }
            else
            {
                throw new Exception("Wrong ID Number");
            }
            lastName  = last_name;
            firstName = first_name;
            if (birth_date > DateTime.Now)
            {
                throw new Exception("Wrong Birth Date");
            }
            else
            {
                birthDate = birth_date;
            }
            bool flag = true;

            foreach (char c in phone_number)
            {
                if (c < '0' || c > '9')
                {
                    flag = false;
                }
            }
            if (!flag)
            {
                throw new Exception("Phone number must to be with only digits!!");
            }
            phoneNumber    = phone_number;
            address        = address_;
            isElevator     = is_elevator;
            floor          = floor_;
            experience     = experience_;
            maxChildren    = max_children;
            minAge         = min_age;
            maxAge         = max_age;
            ifHourPaid     = if_hour_paid;
            payForHour     = pay_for_hour;
            payForMonth    = pay_for_month;
            vacationCheck  = vacation_check;
            recommendation = recommendation_;
            isWorking      = is_working;
            workHours      = work_hours;
        }
Example #17
0
        public static void PrintResults(TimeSpan[,] times)
        {
            Console.WriteLine("Tests Results Are:");

            Console.WriteLine("Sorting By   | BubbleSort     | QuickSort     | BucketSort");
            Console.WriteLine($"Color Asc    | {times[0, 0].TotalMilliseconds.ToString(),-10}  ms | {times[1, 0].TotalMilliseconds.ToString(),-10}  ms | {times[2, 0].TotalMilliseconds.ToString(),-10} ms");
            Console.WriteLine($"Color Desc   | {times[0, 1].TotalMilliseconds.ToString(),-10}  ms | {times[1, 1].TotalMilliseconds.ToString(),-10}  ms | {times[2, 1].TotalMilliseconds.ToString(),-10} ms");
            Console.WriteLine($"Size  Asc    | {times[0, 2].TotalMilliseconds.ToString(),-10}  ms | {times[1, 2].TotalMilliseconds.ToString(),-10}  ms | {times[2, 2].TotalMilliseconds.ToString(),-10} ms");
            Console.WriteLine($"Size Desc    | {times[0, 3].TotalMilliseconds.ToString(),-10}  ms | {times[1, 3].TotalMilliseconds.ToString(),-10}  ms | {times[2, 3].TotalMilliseconds.ToString(),-10} ms");
            Console.WriteLine($"Fabric Asc   | {times[0, 4].TotalMilliseconds.ToString(),-10}  ms | {times[1, 4].TotalMilliseconds.ToString(),-10}  ms | {times[2, 4].TotalMilliseconds.ToString(),-10} ms");
            Console.WriteLine($"Fabric Desc  | {times[0, 5].TotalMilliseconds.ToString(),-10}  ms | {times[1, 5].TotalMilliseconds.ToString(),-10}  ms | {times[2, 5].TotalMilliseconds.ToString(),-10} ms");
            Console.WriteLine($"Multiple Asc | {times[0, 6].TotalMilliseconds.ToString(),-10}  ms | {times[1, 6].TotalMilliseconds.ToString(),-10}  ms | {times[2, 6].TotalMilliseconds.ToString(),-10} ms");
            Console.WriteLine($"Multiple Desc| {times[0, 7].TotalMilliseconds.ToString(),-10}  ms | {times[1, 7].TotalMilliseconds.ToString(),-10}  ms | {times[2, 7].TotalMilliseconds.ToString(),-10} ms");
        }
Example #18
0
        /// <summary>
        /// copy constructor
        /// </summary>
        /// <param name="nanny"></param>
        public Nanny(Nanny nanny)
        {
            if (IDCheck(nanny.id))
            {
                id = nanny.id;
            }
            else
            {
                throw new Exception("Wrong ID Number");
            }
            lastName  = nanny.lastName;
            firstName = nanny.firstName;
            if (nanny.birthDate > DateTime.Now)
            {
                throw new Exception("Wrong Birth Date");
            }
            else
            {
                birthDate = nanny.birthDate;
            }
            bool flag = true;

            foreach (char c in nanny.phoneNumber)
            {
                if (c < '0' || c > '9')
                {
                    flag = false;
                }
            }
            if (!flag)
            {
                throw new Exception("Phone number must to be with only digits!!");
            }
            phoneNumber    = nanny.phoneNumber;
            address        = nanny.address;
            isElevator     = nanny.isElevator;
            floor          = nanny.floor;
            experience     = nanny.experience;
            maxChildren    = nanny.maxChildren;
            minAge         = nanny.minAge;
            maxAge         = nanny.maxAge;
            ifHourPaid     = nanny.ifHourPaid;
            payForHour     = nanny.payForHour;
            payForMonth    = nanny.payForMonth;
            vacationCheck  = nanny.vacationCheck;
            recommendation = nanny.recommendation;
            isWorking      = nanny.isWorking;
            workHours      = nanny.workHours;
        }
        public static double[,] FromTimeSpan(this TimeSpan[,] timespans)
        {
            var nbRow = timespans.GetLength(0);
            var nbCol = timespans.GetLength(1);

            var result = new double[nbRow, nbCol];

            for (var i = 0; i < nbRow; i++)
            {
                for (var j = 0; j < nbCol; j++)
                {
                    result[i, j] = timespans[i, j].TotalSeconds;
                }
            }
            return(result);
        }
Example #20
0
 public void update_mother(int id, int attribute, bool[] b, TimeSpan[,] t)
 {
     foreach (var item in DataSource.Mothers_List)
     {
         if (id == item.Id)
         {
             Mother temp = new Mother();
             temp = item;
             temp.Needs_On_Day = b;
             temp.Needs_Hours  = t;
             DataSource.Mothers_List.Remove(item);
             DataSource.Mothers_List.Add(temp);
             return;
         }
     }
 }
Example #21
0
 public void update_nanny(int id, int attribute, bool[] b, TimeSpan[,] t)
 {
     foreach (var item in DataSource.Nannys_List)
     {
         if (id == item.Id)
         {
             Nanny temp = new Nanny();
             temp = item;
             temp.Works_On_Day = b;
             temp.Work_Hours   = t;
             DataSource.Nannys_List.Remove(item);
             DataSource.Nannys_List.Add(temp);
             return;
         }
     }
 }
Example #22
0
 /// <summary>
 /// add the data that was handed over by the user
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button_Click(object sender, RoutedEventArgs e)
 {
     bool[] workingDays = { (bool)Sunday.IsChecked, (bool)Monday.IsChecked, (bool)Tuesday.IsChecked, (bool)Wednesday.IsChecked, (bool)Thursday.IsChecked, (bool)Friday.IsChecked };
     TimeSpan[,] workHours = { { TimeSpan.FromHours(Convert.ToDouble(SunHour.Text) + (Convert.ToDouble(SunMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(SunHour2.Text) + (Convert.ToDouble(SunMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(MonHour.Text) + (Convert.ToDouble(MonMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(MonHour2.Text) + (Convert.ToDouble(MonMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(TuesHour.Text) + (Convert.ToDouble(TuesMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(TuesHour2.Text) + (Convert.ToDouble(TuesMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(WedHour.Text) + (Convert.ToDouble(WedMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(WedHour2.Text) + (Convert.ToDouble(WedMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(ThuHour.Text) + (Convert.ToDouble(ThuMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(ThuHour2.Text) + (Convert.ToDouble(ThuMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(FriHour.Text) + (Convert.ToDouble(FriMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(FriHour2.Text) + (Convert.ToDouble(FriMin2.Text) / 60)) } };
     try
     {
         BE.Nanny nanny = new BE.Nanny(ID.Text, First.Text, Last.Text, (DateTime)datePicker.SelectedDate, Address.Text, Phone.Text, (bool)Elevator.IsChecked, Convert.ToInt32(Floor.Text), Convert.ToInt32(Exp.Text), Convert.ToInt32(MaxChild.Text), Convert.ToInt32(MinAge.Text), Convert.ToInt32(MaxAge.Text), (bool)HourPayment.IsChecked, Convert.ToDouble(PayHour.Text), Convert.ToDouble(PayMonth.Text), (bool)TMT.IsChecked, Recommendation.Text, workingDays, workHours);
         GetBL.bl.AddNanny(nanny);
         Thread.Sleep(500);
         Close();
     }
     catch (Exception str)
     {
         MessageBox.Show(str.Message, str.Message, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 public Mother(string ID, string LN, string FN, string PN, string addr, string area, bool[] need,
               TimeSpan[,] hours, string nt)
 {
     if (!MyFunctions.CheckID(ID))
     {
         throw new Exception("Invalid ID");
     }
     if (!MyFunctions.CheckName(LN))
     {
         throw new Exception("Invalid name");
     }
     if (!MyFunctions.CheckName(FN))
     {
         throw new Exception("Invalid name");
     }
     if (!MyFunctions.CheckPhoneNumber(PN))
     {
         throw new Exception("Invalid phone number");
     }
     if (!MyFunctions.CheckAddress(addr))
     {
         throw new Exception("Invalid address");
     }
     if (!MyFunctions.CheckAddress(area))
     {
         throw new Exception("Invalid address");
     }
     if (!MyFunctions.CheckArraySize1(need))
     {
         throw new Exception("Invalid arrays sizes");
     }
     if (!MyFunctions.CheckArraySize2(hours))
     {
         throw new Exception("Invalid arrays sizes");
     }
     id          = ID.Trim(); //DELETE spare space
     lastName    = LN.Trim(); //DELETE spare space
     firstName   = FN.Trim(); //DELETE spare space
     phoneNumber = PN.Trim();
     address     = addr;
     areaNanny   = area;
     needNanny   = new bool[6];
     needNanny   = need;
     workHours   = new TimeSpan[6, 2];
     workHours   = hours;
     notes       = nt;
 }
Example #24
0
 /// <summary>
 /// default constructor
 /// </summary>
 public Nanny()
 {
     id             = null;
     lastName       = null;
     firstName      = null;
     birthDate      = DateTime.Now;
     phoneNumber    = null;
     address        = null;
     isElevator     = false;
     floor          = 0;
     experience     = 0;
     maxChildren    = 0;
     minAge         = 0;
     maxAge         = 0;
     ifHourPaid     = false;
     payForHour     = 0;
     payForMonth    = 0;
     vacationCheck  = false;
     recommendation = null;
     isWorking      = null;
     workHours      = null;
 }
 //Nanny c-tor
 public Nanny(int id1, string lastName1, string name1, DateTime dateOfBirth1, int phoneNumber1, string address1, bool isElevator1, int buildingFloor1, int yearsOfExperience1, int maxChildren1, int minAge1, int maxAge1, bool perHour1, int perWorkHour1, int perWorkMonth1, bool[] nannyWorkDays1, TimeSpan[,] workHourPerDay1, bool isDaysOff1, string recommendations1, int numChildren1, bool isCriminalRecord1)
 {
     Id                = id1;
     LastName          = lastName1;
     Name              = name1;
     DateOfBirth       = dateOfBirth1;
     PhoneNumber       = phoneNumber1;
     Address           = address1;
     IsElevator        = isElevator1;
     BuildingFloor     = buildingFloor1;
     YearsOfExperience = yearsOfExperience1;
     MaxChildren       = maxChildren1;
     MinAge            = minAge1;
     MaxAge            = maxAge1;
     PerHour           = perHour1;
     PerWorkHour       = perWorkHour1;
     PerWorkMonth      = perWorkMonth1;
     NannyWorkDays     = nannyWorkDays1;
     WorkHourPerDay    = workHourPerDay1;
     IsDaysOff         = isDaysOff1;
     Recommendations   = recommendations1;
     NumChildren       = numChildren1;
     IsCriminalRecored = isCriminalRecord1;
 }
        protected virtual TestResult[] PostProcessResults(Delegate[] testCases, TimeSpan[,] results, string[,] ErrTxt)
        {
            Int32 numberTestCases = results.GetLength(0);

            TestResult[] retVal       = new TestResult[numberTestCases];
            TimeSpan     lowestMedian = TimeSpan.MaxValue;

            for (int i = 0; i < numberTestCases; ++i)
            {
                retVal[i]                  = new TestResult();
                retVal[i].TestResults      = new TimeSpan[_numberRuns];
                retVal[i].ErrorDescription = new string[_numberRuns];
                for (int j = 0; j < _numberRuns; ++j)
                {
                    retVal[i].TestResults[j]      = results[i, j];
                    retVal[i].ErrorDescription[j] = ErrTxt[i, j];
                }
                retVal[i].TestName = testCases[i].Method.Name;
                TimeSpan min, max;
                TimeSpan cumTotal      = TimeSpan.Zero;
                double   cumTotalSqred = 0.0;
                min = max = results[i, 0];
                for (int j = 0; j < _numberRuns; ++j)
                {
                    min            = min > results[i, j]? results[i, j] : min;
                    max            = max < results[i, j]? results[i, j] : max;
                    cumTotal      += results[i, j];
                    cumTotalSqred += (results[i, j].TotalMilliseconds) * (results[i, j].TotalMilliseconds);
                }
                retVal[i].Mean = TimeSpan.FromMilliseconds(cumTotal.TotalMilliseconds / _numberRuns);
                retVal[i].Min  = min;
                retVal[i].Max  = max;

                TimeSpan[] sortedResults = new TimeSpan[_numberRuns];
                retVal[i].TestResults.CopyTo(sortedResults, 0);
                Array.Sort(sortedResults);
                if (_numberRuns == 1)
                {
                    retVal[i].Median = sortedResults[0];
                }
                else if (_numberRuns == 2)
                {
                    retVal[i].Median = TimeSpan.FromMilliseconds(sortedResults[0].TotalMilliseconds / 2
                                                                 + sortedResults[1].TotalMilliseconds / 2);
                }
                else if (_numberRuns % 2 == 0)
                {
                    retVal[i].Median = TimeSpan.FromMilliseconds(sortedResults[_numberRuns / 2].TotalMilliseconds / 2
                                                                 + sortedResults[_numberRuns / 2 + 1].TotalMilliseconds / 2);
                }
                else
                {
                    retVal[i].Median = sortedResults[_numberRuns / 2];
                }
                if (lowestMedian > retVal[i].Median)
                {
                    lowestMedian = retVal[i].Median;
                }

                double stddevSqrd = ((_numberRuns * cumTotalSqred -
                                      ((cumTotal.TotalMilliseconds) * (cumTotal.TotalMilliseconds))) / (_numberRuns * (_numberRuns - 1)));
                retVal[i].StdDev = TimeSpan.FromMilliseconds(Math.Sqrt(stddevSqrd));
            }
            for (int i = 0; i < numberTestCases; ++i)
            {
                retVal[i].NormalizedTestDuration = (float)(retVal[i].Median.TotalMilliseconds) / (float)(lowestMedian.TotalMilliseconds);
            }
            return(retVal);
        }
 public Mother()
 {
     needNanny = new bool[6];
     workHours = new TimeSpan[6, 2];
 }
        private void Tab2Init()
        {
            int i, j;
            Tab2LogPathText.Text = "C:";
            Tab2DataViewMode = DataMode.Text;
            Tab2ViewTextOp.Checked = true;
            Tab2RunOneTimeMode.Checked = true;
            Auto_Save = 0;

            // init time check value
            Tab2_Start = new DateTime[totalPort];
            Tab2_First_Send = new DateTime[totalPort];
            Tab2_Last_Send = new DateTime[totalPort];
            Tab2_Curr_Send = new DateTime[totalPort];
            Tab2_First_Receive = new DateTime[totalPort];
            Tab2_Last_Receive = new DateTime[totalPort];
            Tab2_Curr_Receive = new DateTime[totalPort];
            Tab2_Stop = new DateTime[totalPort];
            First_Receive = new bool[totalPort];
            Has_data = new bool[totalPort];
            FileOut = new StreamWriter[totalPort];

            Tab2_RCT = new DateTime[totalPort];
            Tab2_TCT = new DateTime[totalPort];

            Tab2_Expect_Respond = new string[totalPort, MAX_RESOURCE];
            Tab2_Wait_Respond = new string[totalPort, MAX_RESOURCE];
            Tab2_Expect_Send = new string[totalPort, MAX_RESOURCE];
            Tab2_Wait_Send = new string[totalPort, MAX_RESOURCE];
            Expect_Cnt = new int[totalPort];
            Wait_Cnt = new int[totalPort];

            // Check frame
            Tab2_Frame_Receive = new byte[totalPort, MAX_BUF_LEN];
            Tab2_FReceive_Len = new int[totalPort];
            Tab2_Receive_Buf = new byte[totalPort][];
            Tab2_Receive_index = new int[totalPort];
            Frame_Expect_Cnt = new int[totalPort];
            Check_Frame_Ena = new bool[totalPort];
            Collect_Frame = new bool[totalPort];
            Pream_Cnt = new int[totalPort];
            Tab2_XMODEM = new XMODEM[totalPort];
            // init global value
            for (i = 0; i < totalPort; i++)
            {
                Tab2_XMODEM[i] = new XMODEM();
                Tab2_XMODEM[i].X_Timer.Tag = i;
                Tab2_XMODEM[i].X_Timer.Tick += new EventHandler(XMODEM_Timer_ISR);
            }

            // Goto Function
            Tab2_LBL = new int[totalPort, MAX_RESOURCE];

            // Init for Serial Test Tool
            Tab2_TSV = new DateTime[totalPort, MAX_RESOURCE];
            Tab2_TimeSpend = new TimeSpan[totalPort, MAX_RESOURCE];
            Tab2_SSV = new string[totalPort, MAX_RESOURCE];
            Tab2_SendCnt = new long [totalPort];
            Pass_Cnt = new long[totalPort];
            Fail_Cnt = new long[totalPort];
            Tab2_Status = new Tab2Stauts [totalPort];
            Tab2_Run_Step = new int[totalPort];
            Delay_Value = new int[totalPort];

            // init global value
            for (i = 0; i < totalPort; i++)
            {
                First_Receive[i] = true;
                Has_data[i] = false;
                Tab2_FReceive_Len[i] = 0;
                Tab2_Receive_Buf[i] = new byte[MAX_BUF_LEN];
                Tab2_Receive_index[i] = 0;
                Tab2_Status[i] = Tab2Stauts.Init;
                FileOut[i] = null;

                // Check Frame
                Check_Frame_Ena[i] = false;
                Collect_Frame[i] = false;
                Pream_Cnt[i] = 0;

                Tab2_Run_Step[i] = 0;
                Wait_Cnt[i] = 0;
                Expect_Cnt[i] = 0;
                for (j = 0; j < MAX_RESOURCE; j++)
                {
                    Tab2_Expect_Respond[i, j] = "";
                    Tab2_Wait_Respond[i, j] = "";
                    Tab2_Expect_Send[i, j] = "";
                    Tab2_Wait_Send[i, j] = "";
                    Tab2_LBL[i, j] = 0;
                }
            }
            Tab2_Update_Status(Tab2Stauts.Init);
        }
Example #29
0
 public static TimeSpan[,] ReturnsNativeType(TimeSpan[,] x) => x;
Example #30
0
 public DataStructureTimeTestHandler()
 {
     iDataStructureTimeTests = new IDataStructureTimeTest[3];
     testsResults            = new TimeSpan[4, 3];
 }
Example #31
0
        public Mother(int motherId, string firstN, string lastN, int phone, string motherAddress, string requestedAddress, bool[] needNannyDays, TimeSpan[,] houresNeeds, string note)
        {
            id                    = motherId;
            firstName             = firstN;
            lastName              = lastN;
            phoneNumber           = phone;
            address               = motherAddress;
            nannyRequestedAddress = requestedAddress;

            for (int i = 0; i < 6; i++)
            {
                isNeedNannyToday[i] = needNannyDays[i];
            }

            for (int i = 0; i < 6; i++)
            {
                neededHours[0, i] = houresNeeds[0, i];
                neededHours[1, i] = houresNeeds[1, i];
            }
            notes = note;
            {
            }
        }