Exemplo n.º 1
0
        public Integrator(double h, double maxTime, AWP awp = null)
        {
            _editPause = new ManualResetEvent (true);
            _h = h;
            _stepper = new RungeKuttaStepper (_h);
            //_stepper = new EulerStepper(_h);
            _calculating = false;

            _maxTime = maxTime;
            int capacity = (int)(maxTime / h) + 5;
            _list = new TimeList<Complex[]> (ChooseClosest.Distant, capacity);
            _triggerRange = 10;

            if (awp != null) {
                _awp = awp.Clone ();
            } else {
                Complex[] y0 = new Complex[100];

                for (int i = 0; i < y0.Length; i++) {
                    //y0 [i] = new Complex(1, rnd.NextDouble() * 2 - 1);
                    //y0 [i] = new Complex (1, i < y0.Length / 2 ? -1 : 1);
                    y0 [i] = Complex.FromPolarCoordinates(1, _rnd.NextDouble() * 2 * Math.PI);
                    //y0 [i] = Complex.FromPolarCoordinates(1, i < y0.Length / 2 ? Math.PI / 2 : Math.PI * 3 / 2);
                }
                _awp = new AWP (100, 4, 1, 2, 14, 0, y0);
            }
            _awp.Changed+= delegate(object sender, EventArgs e) {
                _changed = true;
                Recalc ();
            };
            _changed = true;
            Recalc ();
        }
        public void DrawHist(TimeList<Complex[]> list, double t)
        {
            using (Context context = new Context(Surface)) {

                context.Rectangle(0, 0, Width, Height);
                context.Color = Background;
                context.Fill();

                int index = list.Index (t);
                int times = 30;

                double xl = (double)(Width - 60) / N;
                double yl = (double)Height / times;

                Complex[] points;
                Color c;
                int ii;
                for (int i = index; i >= Math.Max(0, index - times); i--) {
                    points = list.Get (i);
                    N = points.Length;
                    ii = index - i;
                    for (int j = 0; j < points.Length; j++) {
                        DrawHistArea (context, xl, yl, ii, j, _valueExtractor(points [j]));
                    }
                }
            }

            DrawExpose (null, null);
        }
Exemplo n.º 3
0
        public RealTime Index()
        {
            var result = new RealTime();

            try
            {
                bool enableSearch = Configuration.GetValue <bool>("ApiFlag:EnableSearch");

                if (!enableSearch)
                {
                    result.Succeed  = false;
                    result.ErrorMsg = "Currently the system is set off.";
                    return(result);
                }

                var item = new TimeList();
                item.Refresh();
                result.TimeList = item;
                result.Succeed  = true;
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message + " - " + ex.InnerException;
            }

            return(result);
        }
        public IActionResult Create(TimeList manageClient)

        {
            var find = manageClient.StationName;

            var result = serviceDestantionTable.GetAll().Where(x => x.DestinationName == find).FirstOrDefault();

            manageClient.DestinationId = result.Id;
            try
            {
                if (ModelState.IsValid)
                {
                    if (manageClient.Id == 0)
                    {
                        servicetimeList.Insert(manageClient);
                        return(Json("1"));
                    }

                    else
                    {
                        servicetimeList.Update(manageClient);
                        return(Json("1"));
                    }
                }
            }
            catch (Exception e)
            {
                String S1 = e.ToString();
            }
            return(View(manageClient));
        }
Exemplo n.º 5
0
        public IActionResult Index()
        {
            var item = new TimeList();

            item.Refresh();
            return(View(item));
        }
Exemplo n.º 6
0
 private static IEnumerable <double> GetTimes(ICurve1 curve, double tinc)
 {
     if (curve is MultiCurve1)
     {
         TimeList    times = new TimeList();
         MultiCurve1 multi = (MultiCurve1)curve;
         for (int i = 0; i < multi.NumSegments; i++)
         {
             double tmin = multi.GetTMin(i);
             double tmax = multi.GetTMax(i);
             double t    = tmin;
             while (t < tmax)
             {
                 times.Add(t);
                 t += tinc;
             }
             times.Add(tmax);
         }
         return(times.GetTimes());
     }
     else
     {
         TimeList times = new TimeList();
         double   tmin  = curve.TMin;
         double   tmax  = curve.TMax;
         double   t     = tmin;
         while (t < tmax)
         {
             times.Add(t);
             t += tinc;
         }
         times.Add(tmax);
         return(times.GetTimes());
     }
 }
Exemplo n.º 7
0
        public void TimeList_TimeUpdate()
        {
            DateTime now = new DateTime(2000, 3, 3, 3, 3, 3);
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >(now);

            list.Add(11, now);
            Assert.AreEqual(list.SecondsAt(0), 0);

            list.Add(11, now.AddSeconds(5));
            Assert.AreEqual(list.SecondsAt(0), 5);

            list.Add(11, now.AddSeconds(6));
            Assert.AreEqual(list.SecondsAt(0), 6);

            list.Add(11, now.AddSeconds(9));
            Assert.AreEqual(list.SecondsAt(0), 9);

            list.Add(22, now.AddSeconds(15));
            Assert.AreEqual(list.SecondsAt(0), 15);
            Assert.AreEqual(list.SecondsAt(1), 0);

            list.Add(22, now.AddSeconds(16));
            Assert.AreEqual(list.SecondsAt(0), 15);
            Assert.AreEqual(list.SecondsAt(1), 1);

            list.Add(22, now.AddSeconds(20));
            Assert.AreEqual(list.SecondsAt(0), 15);
            Assert.AreEqual(list.SecondsAt(1), 5);

            list.Add(33, now.AddSeconds(26));
            Assert.AreEqual(list.SecondsAt(0), 15);
            Assert.AreEqual(list.SecondsAt(1), 11);
            Assert.AreEqual(list.SecondsAt(2), 0);
        }
Exemplo n.º 8
0
        public void TimeList_CorrectValues()
        {
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >();

            list.Add(11);
            list.Add(11);
            list.Add(22);
            list.Add(22);
            list.Add(22);
            list.Add(33);
            list.Add(44);
            list.Add(55);
            list.Add(55);
            list.Add(55);
            list.Add(66);
            list.Add(66);
            list.Add(11);

            Assert.AreEqual(list[0], 11);
            Assert.AreEqual(list[1], 22);
            Assert.AreEqual(list[2], 33);
            Assert.AreEqual(list[3], 44);
            Assert.AreEqual(list[4], 55);
            Assert.AreEqual(list[5], 66);
            Assert.AreEqual(list[6], 11);
        }
        public IActionResult DeleteConfirmed(TimeList manage)
        {
            var id = manage.Id;

            servicetimeList.Delete(id);
            //return RedirectToAction(nameof(Index));
            return(Json("1"));
        }
Exemplo n.º 10
0
 public IActionResult AddPersonalTraining()
 {
     ViewData["Trainers"]   = GetTrainerList();
     ViewData["DayOfWeeks"] = DayOfWeeks;
     ViewData["TimeRanges"] = TimeList.Select(x => new SelectListItem {
         Text = x.ToString(), Value = x.ToString()
     });
     return(View());
 }
Exemplo n.º 11
0
        public void AddWorkPlanElement()
        {
            IsWorkPlanElementEditVisible = true;
            EditedWorkPlanElement        = new WorkPlanElement();
            PrepareLists();

            EditedWorkPlanElement.StartTime = TimeList.First();
            EditedWorkPlanElement.EndTime   = TimeList.ElementAt(1);
            _selectedOperation = CrudOperation.Create;
        }
Exemplo n.º 12
0
 public void Clear()
 {
     if (TimeList != null)
     {
         Modified |= TimeList.Count > 0;
         TimeList.Clear();
     }
     CountDailyWorkingHours        = 0;
     CountDailyPlannedWorkingHours = 0;
 }
        public IActionResult Create(int id = 0)
        {
            TimeList model = new TimeList();

            if (id > 0)
            {
                model = servicetimeList.GetById(id);
            }
            model.DestantionTableList = serviceDestantionTable.GetAll().ToList();
            return(View(@"~/Areas/Admin/Views/TimeList/Create.cshtml", model));
        }
Exemplo n.º 14
0
 public void CancelReservation()
 {
     //reset set variables
     Direction            = null;
     _userReservationTime = null;
     _userReservationDate = null;
     SelectedDate         = DateTime.Today;
     TimeList.Clear();
     IsTimeListEnabled     = false;
     IsCreateButtonEnabled = false;
 }
Exemplo n.º 15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string[] nametime = new string[] { "ללא הגבלה", "10 שניות", "20 שניות", "30 שניות" };
     for (int i = 0; i < nametime.Length; i++)
     {
         ListItem li = new ListItem();
         li.Text  = nametime[i];
         li.Value = i.ToString();
         TimeList.Items.Add(li);
     }
     TimeList.DataBind();
 }
Exemplo n.º 16
0
        private TimeList<Complex[]> CalcSingle(Ode ode, Complex[] y0, double t_max)
        {
            TimeList<Complex[]> solve = new TimeList<Complex[]> ();
            Complex[] y = y0;

            for(double t = 0; t < t_max; t += _step.Stepsize) {
                y = _step.NextStep (ode, t, y);
                solve.Add (t, y);
            }

            return solve;
        }
Exemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        TimeList timeList = new TimeList();
        //GridView1.DataSource = timeList.getTimeList();
        //GridView1.DataBind();

        string s = "";
        for (int i = 0; i < 60; i++)
        {
            if(i%5==0)s+= "\n<asp:ListItem Value=\"" + i.ToString() + "\">" + i.ToString() + "</asp:ListItem>";
        }
        TextBox1.Text = s;
    }
        public void AddWorkPlanElement()
        {
            IsWorkPlanElementEditVisible = true;
            EditedWorkPlanElement        = new WorkPlanElement();
            PrepareLists();

            EditedWorkPlanElement.Room      = RoomList.FirstOrDefault();
            EditedWorkPlanElement.Class     = ClassList.FirstOrDefault();
            EditedWorkPlanElement.StartTime = TimeList.First();
            EditedWorkPlanElement.EndTime   = TimeList.ElementAt(1);
            EditedWorkPlanElement.Worker    = Workers.FirstOrDefault();
            _selectedOperation = CrudOperation.Create;
        }
Exemplo n.º 19
0
        public void TimeList_AddBoolean()
        {
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >();

            Assert.IsTrue(list.Add(11));
            Assert.IsFalse(list.Add(11));
            Assert.IsTrue(list.Add(22));
            Assert.IsFalse(list.Add(22));
            Assert.IsFalse(list.Add(22));
            Assert.IsTrue(list.Add(33));
            Assert.IsTrue(list.Add(44));
            Assert.IsTrue(list.Add(55));
            Assert.IsFalse(list.Add(55));
        }
Exemplo n.º 20
0
        public IActionResult RequestAbonement()
        {
            var currentClient = context.Client.Single(x => x.Email == User.Identity.Name);

            ViewData["MyRequests"] = context.RequestAbonement.Where(x => x.IdClient == currentClient.Id).ToList();
            ViewData["TermList"]   = TermList.Select(x => new SelectListItem {
                Text = x.ToString(), Value = x.ToString()
            });
            ViewData["TimeList"] = TimeList.Select(x => new SelectListItem {
                Text = x.ToString(@"hh\:mm"), Value = x.ToString()
            });

            return(View(Roles.Client));
        }
Exemplo n.º 21
0
        public void TimeList_AdjacentDifferent()
        {
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >();

            Random r = new Random();

            for (int i = 0; i < 10000; i++)
            {
                int n = r.Next(1, 10);
                list.Add(n);
            }

            Assert.IsTrue(list.ValidateAdjacentDifferent());
        }
Exemplo n.º 22
0
        public void TimeList_GetSecondsList()
        {
            DateTime now = new DateTime(2000, 3, 3, 3, 3, 3);
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >(now);

            list.Add(11, now.AddSeconds(5));
            list.Add(22, now.AddSeconds(6));
            list.Add(33, now.AddSeconds(11));

            List <long> seconds = list.GetSecondsList(now.AddSeconds(17));

            Assert.AreEqual(seconds[0], 1);
            Assert.AreEqual(seconds[1], 5);
            Assert.AreEqual(seconds[2], 6);
        }
Exemplo n.º 23
0
        public override void Draw(TimeList<Complex[]> list, double t, DisplayMode mode)
        {
            Complex[] points = list [t];

            switch (mode) {
                case DisplayMode.Snapshot:

                DrawSingle (points);
                break;
                case DisplayMode.History:
                DrawHist (list, t);
                break;
                default:
                break;
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// Eager load data from database
 /// </summary>
 private void GetTimeKeepingList()
 {
     try
     {
         Logger.Info("GetTimeKeepingList Method");
         var timeList = DatabaseHelper.GetList <Timekeeping>();
         TimeList.Clear();
         foreach (var item in timeList)
         {
             TimeList.Add(item);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex, "Exception occured from getting timekeeping list");
     }
 }
Exemplo n.º 25
0
        private void SplitDataIntoDateAndTime(List <string> receiveDataList)
        {
            try
            {
                for (var i = 1; i < receiveDataList.Count - 1; i++)
                {
                    var dateTime = receiveDataList[i].Split(',');

                    DateList.Add(dateTime[0]);
                    TimeList.Add(dateTime[1]);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e + "Date Cannot be split into Date and Time");
                throw;
            }
        }
Exemplo n.º 26
0
 public int CompareTo(TimeList other)
 {
     if (Base != other.Base)
     {
         return(Base.CompareTo(other.Base));
     }
     if (Count != other.Count)
     {
         return(Count - other.Count);
     }
     for (int i = 0; i < Count; i++)
     {
         if (this[i] != other[i])
         {
             return(this[i].CompareTo(other[i]));
         }
     }
     return(0);
 }
Exemplo n.º 27
0
        public void TimeList_CorrectCount()
        {
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >();

            Assert.AreEqual(list.Count, 0);

            list.Add(0);
            Assert.AreEqual(list.Count, 1);

            list.Add(0);
            Assert.AreEqual(list.Count, 1);

            list.Add(1);
            Assert.AreEqual(list.Count, 2);

            list.Add(1);
            Assert.AreEqual(list.Count, 2);

            list.Add(2);
            Assert.AreEqual(list.Count, 3);
        }
Exemplo n.º 28
0
 private void BtnDisplay_Click(object sender, RoutedEventArgs e)
 {
     saveList.Clear();
     ReadFromXML();
     Applist.Clear();
     for (int i = 0; i < saveList.Count(); i++)
     {
         Patient   patient    = saveList[i].Patient;
         MyPatient newPatient = new MyPatient();
         newPatient.Age              = patient.Age;
         newPatient.Time             = patient.Time;
         newPatient.Gender           = patient.Gender;
         newPatient.MedicalCondition = patient.MedicalCondition;
         newPatient.CtXray           = patient.CtXray;
         newPatient.Treatment        = patient.Treatment;
         newPatient.CreditCard       = patient.CreditCard;
         Applist.Add(newPatient);
         TimeList.Remove(patient.Time);
     }
     MyGrid.ItemsSource = Applist;
 }
Exemplo n.º 29
0
        public void TimeList_TimeUpdateStart_NotFromZero()
        {
            DateTime now = new DateTime(2000, 3, 3, 3, 3, 3);
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >(now);

            list.Add(11, now.AddSeconds(10));
            Assert.AreEqual(list.SecondsAt(0), 0);

            list.Add(22, now.AddSeconds(14));
            Assert.AreEqual(list.SecondsAt(0), 4);
            Assert.AreEqual(list.SecondsAt(1), 0);

            list.Add(22, now.AddSeconds(15));
            Assert.AreEqual(list.SecondsAt(0), 4);
            Assert.AreEqual(list.SecondsAt(1), 1);

            list.Add(33, now.AddSeconds(17));
            Assert.AreEqual(list.SecondsAt(0), 4);
            Assert.AreEqual(list.SecondsAt(1), 3);
            Assert.AreEqual(list.SecondsAt(2), 0);
        }
Exemplo n.º 30
0
 private static IEnumerable <double> GetTimes(ICurve2 curve, double tinc)
 {
     if (curve is MultiCurve2)
     {
         TimeList    times = new TimeList();
         MultiCurve2 multi = (MultiCurve2)curve;
         for (int i = 0; i < multi.NumSegments; i++)
         {
             double tmin = multi.GetTMin(i);
             double tmax = multi.GetTMax(i);
             double t    = tmin;
             while (t < tmax)
             {
                 times.Add(t);
                 t += tinc;
             }
             times.Add(tmax);
         }
         return(times.GetTimes());
     }
     else if (curve is DisplacedCurve2)
     {
         DisplacedCurve2 displaced = (DisplacedCurve2)curve;
         return(MathUtils.ConcatSorted(GetTimes(displaced.Curve, tinc), GetTimes(displaced.Displacement, tinc)));
     }
     else
     {
         TimeList times = new TimeList();
         double   tmin  = curve.TMin;
         double   tmax  = curve.TMax;
         double   t     = tmin;
         while (t < tmax)
         {
             times.Add(t);
             t += tinc;
         }
         times.Add(tmax);
         return(times.GetTimes());
     }
 }
Exemplo n.º 31
0
        public void TimeList_CorrectTimeSimple()
        {
            DateTime now = new DateTime(2000, 3, 3, 3, 3, 3);
            TimeList <Nullable <int> > list = new TimeList <Nullable <int> >(now);

            list.Add(11, now);
            Assert.AreEqual(list.SecondsAt(0), 0);

            list.Add(22, now.AddSeconds(3));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 0);

            list.Add(33, now.AddSeconds(7));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 4);
            Assert.AreEqual(list.SecondsAt(2), 0);

            list.Add(44, now.AddSeconds(17));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 4);
            Assert.AreEqual(list.SecondsAt(2), 10);
            Assert.AreEqual(list.SecondsAt(3), 0);

            list.Add(55, now.AddSeconds(18));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 4);
            Assert.AreEqual(list.SecondsAt(2), 10);
            Assert.AreEqual(list.SecondsAt(3), 1);
            Assert.AreEqual(list.SecondsAt(4), 0);

            list.Add(66, now.AddSeconds(21));
            Assert.AreEqual(list.SecondsAt(0), 3);
            Assert.AreEqual(list.SecondsAt(1), 4);
            Assert.AreEqual(list.SecondsAt(2), 10);
            Assert.AreEqual(list.SecondsAt(3), 1);
            Assert.AreEqual(list.SecondsAt(4), 3);
            Assert.AreEqual(list.SecondsAt(5), 0);

            Assert.AreEqual(list.Count, 6);
        }
Exemplo n.º 32
0
        private TimeList<Complex[]> CalcThreaded(Ode ode, Complex[] y0, double t_max)
        {
            int ptr = 0;
            int N = ode.N;
            double t = 0;
            TimeList<Complex[]> solve = new TimeList<Complex[]> ();
            Complex[] y = new Complex[N];
            Complex[] lastY = y0;

            for (int thread = 0; thread < _threadCount; thread++) {
                ThreadPool.QueueUserWorkItem (new WaitCallback (delegate(object data) {
                    int c;
                    while (t < t_max) {
                        while ((c = Interlocked.Increment(ref ptr)) <= N) {
                            y[c - 1] = _step.NextStepComponent(c - 1, ode, t, lastY);
                        }
                        lock(syncLock) {
                            ((AutoResetEvent)data).Set();
                            Monitor.Wait(syncLock);
                        }
                    }

                }), _resets [thread]);
            }

            for (t = 0; t < t_max; t += _step.Stepsize) {
                WaitHandle.WaitAll (_resets);

                lock(syncLock) {
                    ptr = 0;
                    solve.Add(t, y);
                    lastY = y;
                    y = new Complex[N];
                    Monitor.PulseAll (syncLock);
                }
            }

            return solve;
        }
Exemplo n.º 33
0
        private TimeList GetLevelAwardTimeList(XmlNode levelInfoNode)
        {
            TimeList timelist = new TimeList();

            var awardList = levelInfoNode.ChildNodes;

            for (int awardId = 0; awardId < awardList.Count; ++awardId)
            {
                if (awardList[awardId].Attributes["id"].Value != awardId.ToString())
                {
                    throw new Exception("time level id not correspond necessary order");
                }
                timelist.Add(
                    new MyTime(
                        Convert.ToInt32(awardList[awardId].Attributes["minutes"].Value),
                        Convert.ToInt32(awardList[awardId].Attributes["seconds"].Value)
                        )
                    );
            }

            return(timelist);
        }
Exemplo n.º 34
0
 private async Task GetAvailableHoursForDateAndDirection()
 {
     await Task.Run(async() =>
     {
         if (SelectedDate != null && Direction != null && Direction != "")
         {
             CancellationToken token = new CancellationToken();
             List <ReservationResponse> reservations = await _reservationService.GetReservationsForDateAndDirections(pathDateAndDirections, Direction, SelectedDate, token);
             _userReservationDate       = _selectedDate.Date.ToString();
             List <string> allHoursList = _reservationService.GetAllHours(_direction);
             DateTime newSelectedDate   = new DateTime();
             UseTempDateTime(newSelectedDate);
             //ParseHourArrays(allHoursList);
             //RemoveReservedHours(allHoursList, reservations);
             Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
             {
                 TimeList.Clear();
                 allHoursList.ForEach(time => TimeList.Add(time));
                 IsTimeListEnabled = true;
             });
         }
     });
 }
Exemplo n.º 35
0
            public void CreateLists(List <Trip> trips)
            {
                var stopList = new StopList(this.Select(x => Tuple.Create(x.Item1, x.Item3)), Route);

                if (!StopLists.ContainsKey(stopList))
                {
                    StopLists.Add(stopList, stopList);
                }
                StopList = StopLists[stopList];

                var timeList = new TimeList(this.Select(x => x.Item2), StopList);

                if (!TimeLists.ContainsKey(timeList))
                {
                    TimeLists.Add(timeList, timeList);
                }
                else
                {
                    throw new InvalidOperationException();
                }
                TimeList       = TimeLists[timeList];
                TimeList.Trips = trips;
            }
Exemplo n.º 36
0
        private void BtnRegister_Click(object sender, RoutedEventArgs e)
        {
            bool flag = ValidateValues();

            if (slot <= appointmentArray.Length && flag == true)
            {
                if (appointmentArray[slot].Patient == null)
                {
                    appointmentError.Content            = "";
                    appointmentArray[slot].Patient      = CreateNewPatient();
                    appointmentArray[slot].Patient.Time = appointmentCombo.SelectedValue.ToString();
                    appointmentArray[slot].Time         = appointmentCombo.SelectedValue.ToString();
                    saveList.Add(appointmentArray[slot]);
                    saveList.Sort();
                }
                else if (appointmentArray[slot].Patient != null)
                {
                    appointmentError.Foreground = Brushes.Red;
                    appointmentError.Content    = "Slot Aready Taken";
                }
            }
            else
            {
                genralError.Foreground = Brushes.Red;
                genralError.Content    = "Error Registering Customer";
            }

            if (appointmentArray[slot].Patient != null)
            {
                Applist.Add(appointmentArray[slot].Patient);
                TimeList.RemoveAt(selectedIndex);
            }
            MyGrid.ItemsSource = Applist;

            //TimeList.Remove(appointmentCombo.SelectedValue.ToString());
        }
Exemplo n.º 37
0
        public void CreateAll(string path, TimeList<Complex[]> list, double t)
        {
            if(!Directory.Exists(path)) {
                Directory.CreateDirectory (path);
                //throw new ArgumentException("Directory already exists");
            }

            Complex[] points = list[t];
            int index = list.Index (t);
            int N = list.Get (index).Length;

            string name = Path.GetFileName (path);
            using(StreamWriter w = new StreamWriter(Path.Combine(path, name + "_single.dat"))) {
                for (int i = 0; i < N; i++) {
                    w.WriteLine ("{0} {1} {2} {3} {4}", i, points [i].Real.F(), points [i].Imaginary.F(), points [i].Magnitude.F(), points [i].Phase.F());
                }
                w.Flush ();
                w.Close ();
            }

            double times = 10;
            int firstTime;
            if(t - times <= 0) {
                firstTime = 0;
            } else {
                firstTime = list.Index (t - times);
            }

            double[] cmX = new double[N];
            double[] cmY = new double[N];

            using(StreamWriter w = new StreamWriter(Path.Combine(path, name + "_hist.dat"))) {
                for (int ti = firstTime; ti <= index; ti++) {
                    points = list.Get (ti);
                    w.Write (points[0].Real.F());
                    for (int j = 1; j < N; j++) {
                        w.Write(" ");
                        w.Write (points[j].Real.F());
                        cmX [j] += points [j].Real;
                    }
                    w.WriteLine ();

                    w.Write (points[0].Imaginary.F());
                    for (int j = 1; j < N; j++) {
                        w.Write(" ");
                        w.Write (points[j].Imaginary.F());
                        cmY [j] += points [j].Imaginary;
                    }
                    w.WriteLine ();

                    w.Write (points[0].Magnitude.F());
                    for (int j = 1; j < N; j++) {
                        w.Write(" ");
                        w.Write (points[j].Magnitude.F());
                    }
                    w.WriteLine ();
                }
                w.Flush ();
                w.Close ();
            }

            for (int i = 0; i < N; i++) {
                cmX [i] = cmX [i] / (index - firstTime);
                cmY [i] = cmY [i] / (index - firstTime);
            }

            using(StreamWriter w = new StreamWriter(Path.Combine(path, name + "_cm.dat"))) {
                for (int j = 0; j < N; j++) {
                    w.WriteLine ("{0} {1}", j, Math.Sqrt (cmX [j] * cmX [j] + cmY [j] * cmY [j]).F());
                }

                w.Flush ();
                w.Close ();
            }

            using(StreamWriter w = new StreamWriter(Path.Combine(path, name + ".plt"))) {
                w.WriteLine ("set terminal png");
                w.WriteLine ("set termopt enhanced");
                w.WriteLine ("set autoscale");

                w.WriteLine ("set output \"x.png\"");
                w.WriteLine ("set title \"Plot 1\"");
                w.WriteLine ("set xlabel \"j\"");
                w.WriteLine ("set ylabel \"x_j\"");
                w.WriteLine ("plot \"" + name + "_single.dat\" using 1:2 notitle");

                w.WriteLine ("set output \"y.png\"");
                w.WriteLine ("set title \"Plot 2\"");
                w.WriteLine ("set xlabel \"j\"");
                w.WriteLine ("set ylabel \"y_j\"");
                w.WriteLine ("plot \"" + name + "_single.dat\" using 1:3 notitle");

                w.WriteLine ("set output \"xy.png\"");
                w.WriteLine ("set title \"Plot 3\"");
                w.WriteLine ("set xlabel \"j\"");
                w.WriteLine ("set ylabel \"y_j, x_j\"");
                w.WriteLine ("plot \"" + name + "_single.dat\" using 1:2 title \"x\", \"" + name + "_single.dat\" using 1:3 title \"y\"");

                w.WriteLine ("set output \"r.png\"");
                w.WriteLine ("set title \"Plot 3\"");
                w.WriteLine ("set xlabel \"j\"");
                w.WriteLine ("set ylabel \"r_j\"");
                w.WriteLine ("plot \"" + name + "_single.dat\" using 1:4 notitle");

                w.WriteLine ("set output \"cm.png\"");
                w.WriteLine ("set title \"Massenschwerpunkt\"");
                w.WriteLine ("set xlabel \"j\"");
                w.WriteLine ("set ylabel \"r_{c.m.}\"");
                w.WriteLine ("plot \"" + name + "_cm.dat\" using 1:2 notitle");

                w.WriteLine ("set output \"Phasenraum.png\"");
                w.WriteLine ("set title \"Phasenraum\"");
                w.WriteLine ("set xlabel \"Realteil\"");
                w.WriteLine ("set ylabel \"Imaginärteil\"");
                w.WriteLine ("plot \"" + name + "_single.dat\" using 2:3 notitle");

                w.WriteLine ("set terminal png");
                w.WriteLine ("set autoscale fix");
                w.WriteLine ("set tics out nomirror");
                w.WriteLine ("set pm3d map interpolate 0,0");
                w.WriteLine ("set xlabel \"j\"");
                w.WriteLine ("set ylabel \"t\"");

                w.WriteLine ("set output \"hist_x.png\"");
                w.WriteLine ("set title \"x\"");
                w.WriteLine ("splot '" + name + "_hist.dat' every :3 matrix using 1:($2/" + ((t - list.TimeOf(firstTime)) * 30).F() + "):3 notitle");

                w.WriteLine ("set output \"hist_y.png\"");
                w.WriteLine ("set title \"y\"");
                w.WriteLine ("splot '" + name + "_hist.dat' every :3::1 matrix using 1:(($2 - 1)/" + ((t - list.TimeOf(firstTime)) * 30).F() + "):3 notitle");

                w.WriteLine ("set output \"hist_r.png\"");
                w.WriteLine ("set title \"r\"");
                w.WriteLine ("splot '" + name + "_hist.dat' every :3::2 matrix using 1:(($2 - 2)/" + ((t - list.TimeOf(firstTime)) * 30).F() + "):3 notitle");

                w.Flush ();
                w.Close ();
            }

            System.Diagnostics.Process proc = new System.Diagnostics.Process ();
            proc.EnableRaisingEvents = false;
            proc.StartInfo.CreateNoWindow = true;
            proc.StartInfo.WorkingDirectory = path;
            proc.StartInfo.FileName = "gnuplot";
            proc.StartInfo.Arguments = Path.Combine(path, name + ".plt");
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.Start ();
            proc.WaitForExit ();
            string output = proc.StandardOutput.ReadToEnd ();
            proc.Close ();
        }
 public override void Draw(TimeList<Complex[]> list, double t)
 {
     Complex[] points = list [t];
     _lastTime = t;
     Draw (points);
 }
Exemplo n.º 39
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        STD_ClassTime sTD_ClassTime = new STD_ClassTime ();

        bool is12PMIssueEnd = false;
        if (ddlEndHour.SelectedValue == "12" && ddlEndAMPM.SelectedValue == "PM")
        {
            is12PMIssueEnd = true;
            txtEndTime.Text = "0:" + ddlEndMin.SelectedValue + " " + ddlEndAMPM.SelectedValue;
        }
        else
        {
            txtEndTime.Text = ddlEndHour.SelectedValue + ":" + ddlEndMin.SelectedValue + " " + ddlEndAMPM.SelectedValue;
        }

        bool is12PMIssueStart = false;
        if (ddlStartHour.SelectedValue == "12" && ddlStartAMPM.SelectedValue == "PM")
        {
            is12PMIssueStart = true;
            txtStartTime.Text = "0:" + ddlStartMin.SelectedValue + " " + ddlStartAMPM.SelectedValue;
        }
        else
        {
            txtStartTime.Text = ddlStartHour.SelectedValue + ":" + ddlStartMin.SelectedValue + " " + ddlStartAMPM.SelectedValue;
        }
            //txtEndTime.Text = ddlEndHour.SelectedValue + ":" + ddlEndMin.SelectedValue + " " + ddlEndAMPM.SelectedValue;
        txtClassTimeName.Text = (is12PMIssueStart ? "12:" + txtStartTime.Text.ToString().Split(':')[1] : txtStartTime.Text.ToString()) + " - " + (is12PMIssueEnd ? "12:" + txtEndTime.Text.ToString().Split(':')[1] : txtEndTime.Text.ToString());

            TimeList timeList = new TimeList();
            List<Time> times = new List<Time>();
            times = timeList.getTimeList();
            foreach (Time t in times)
            {
                if (txtStartTime.Text == t.TimeName) txtExtraField1.Text = t.TimeID.ToString();
                if (txtEndTime.Text == t.TimeName) txtExtraField2.Text = t.TimeID.ToString();
            }
            txtDuration.Text = ((int.Parse(txtExtraField2.Text) - int.Parse(txtExtraField1.Text)) * 5).ToString();

        //Check in the group
            //DataSet classTimesAll = STD_ClassTimeManager.GetSTD_ClassTimeByClassTimeGroupID();
            DataSet classTimes = STD_ClassTimeManager.GetSTD_ClassTimeByClassTimeGroupID(int.Parse(ddlClassTimeGroupID.SelectedValue));
            bool isConfict = false;

            foreach (DataRow dr in classTimes.Tables[0].Rows)
            {
                if ((int.Parse(dr["ExtraField1"].ToString()) <= int.Parse(txtExtraField1.Text) && int.Parse(dr["ExtraField2"].ToString()) >= int.Parse(txtExtraField1.Text))
                    || (int.Parse(dr["ExtraField1"].ToString()) <= int.Parse(txtExtraField2.Text) && int.Parse(dr["ExtraField2"].ToString()) >= int.Parse(txtExtraField2.Text)))
                {
                    isConfict = true;
                    divNewRoutineTimeGourp.Visible = true;
                    lblMessage.Text = "</br>There is a conflict with the Class Time Group-<span style='color:red;'>" + ddlClassTimeGroupID.SelectedItem.Text + "</span>. Please change it<br/>OR<br/>Click on the following button to set # System Generated";
                    try
                    {
                        if (ddlClassTimeGroupID.SelectedValue != ddlClassTimeGroupID.Items[ddlClassTimeGroupID.Items.Count - 1].Value)
                        {
                            ddlClassTimeGroupID.SelectedValue = (int.Parse(ddlClassTimeGroupID.SelectedValue) + 1).ToString();
                            btnAdd_Click(this, new EventArgs());
                        }
                        else
                        {
                            btnAddWithNewTimeGroup_Click(this, new EventArgs());
                        }
                    }
                    catch (Exception ex)
                    {
                        btnAddWithNewTimeGroup_Click(this, new EventArgs());
                    }
                    return;
                }
            }

            foreach (DataRow dr in classTimes.Tables[1].Rows)
            {
                if ((int.Parse(dr["ExtraField1"].ToString()) <= int.Parse(txtExtraField1.Text) && int.Parse(dr["ExtraField2"].ToString()) >= int.Parse(txtExtraField1.Text))
                    || (int.Parse(dr["ExtraField1"].ToString()) <= int.Parse(txtExtraField2.Text) && int.Parse(dr["ExtraField2"].ToString()) >= int.Parse(txtExtraField2.Text)))
                {
                    txtExtraField3.Text += dr["ClassTimeID"].ToString() + ";";
                }
            }

            divNewRoutineTimeGourp.Visible = false;
            lblMessage.Text = "";

        //	sTD_ClassTime.ClassTimeID=  int.Parse(ddlClassTimeID.SelectedValue);
        sTD_ClassTime.ClassTimeName=  txtClassTimeName.Text;
        sTD_ClassTime.Duration=  decimal.Parse(txtDuration.Text);
        sTD_ClassTime.AddedBy=  Profile.card_id;
        sTD_ClassTime.AddedDate=  DateTime.Now;
        sTD_ClassTime.UpdatedBy=  Profile.card_id;
        sTD_ClassTime.UpdateDate=  DateTime.Now;
        sTD_ClassTime.Order=  int.Parse(txtOrder.Text);
        sTD_ClassTime.ClassTimeGroupID=  int.Parse(ddlClassTimeGroupID.SelectedValue);
        sTD_ClassTime.StartTime = (is12PMIssueStart ? "12:" + txtStartTime.Text.ToString().Split(':')[1] : txtStartTime.Text.ToString());
        sTD_ClassTime.EndTime = (is12PMIssueEnd ? "12:" + txtEndTime.Text.ToString().Split(':')[1] : txtEndTime.Text.ToString());
        sTD_ClassTime.ExtraField1=  txtExtraField1.Text;
        sTD_ClassTime.ExtraField2=  txtExtraField2.Text;
        sTD_ClassTime.ExtraField3=  txtExtraField3.Text;
        sTD_ClassTime.ExtraField4=  txtExtraField4.Text;
        sTD_ClassTime.ExtraField5=  txtExtraField5.Text;
        sTD_ClassTime.RowStatusID=  int.Parse(ddlRowStatusID.SelectedValue);
        int resutl =STD_ClassTimeManager.InsertSTD_ClassTime(sTD_ClassTime);
        Response.Redirect("AdminDisplaySTD_ClassTime.aspx");
    }
Exemplo n.º 40
0
 public virtual void Draw(TimeList<Complex[]> list, double t)
 {
     Clear ();
     DrawExpose (_draw, null);
 }
 public override void Draw(TimeList<Complex[]> list, double t)
 {
     Draw (list, t, _mode);
 }
 public virtual void Draw(TimeList<Complex[]> list, double t, DisplayMode mode)
 {
     base.Draw(list, t);
 }