Esempio n. 1
0
    public FileLogger(string path)
    {
        _startupPoint = TimePoint.Now;
        _writer       = new StreamWriter(path, false, Encoding.UTF8);

        AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
    }
Esempio n. 2
0
        private static TimePeriod AnnotateToTimePeriod(string str)
        {
            int p1 = str.IndexOf("{");

            if (p1 == -1)
            {
                return(new TimePeriod());
            }
            int       p2     = str.IndexOf("}", p1 + 1);
            string    expr1  = str.Substring(p1 + 1, p2 - p1 - 1);
            TimePoint point1 = AnnotateToTimePoint(expr1);

            if (point1 == null)
            {
                point1 = new TimePoint();
            }

            p1 = str.IndexOf("{", p2 + 1);
            if (p1 == -1)
            {
                return(new TimePeriod(point1, point1));
            }
            p2 = str.IndexOf("}", p1 + 1);
            string    expr2  = (p2 == -1)? "" : str.Substring(p1 + 1, p2 - p1 - 1);
            TimePoint point2 = AnnotateToTimePoint(expr2);

            if (point2 == null)
            {
                return(new TimePeriod(point1, point1));
            }
            else
            {
                return(new TimePeriod(point1, point2));
            }
        }
    public void TestRender()
    {
        var startTime = TimePoint.Now;
        var target    = CameraCenter + new Vector3(300, 0, 300);

        var effect = new CallLightningEffect(
            _renderer,
            startTime,
            target
            );

        void Render(int timeSinceStart)
        {
            TimePoint.SetFakeTime(startTime + TimeSpan.FromMilliseconds(timeSinceStart));
            effect.Render(Viewport);
        }

        var frames = RenderFrameSequence(36, Render, new [] { target }, interval: 25);

        AttachVideo("call_lightning.mp4", frames);

        // Assert against reference images at certain intervals
        // Points are chosen where arcs become visible/invisible.
        CompareReferenceFrames(frames, "Core/Systems/Vfx/CallLightning", 0, 150, 200, 500, 800);
    }
    public void TestTimeSpanAddition()
    {
        var tp = new TimePoint(TimePoint.TicksPerMillisecond * 1000);
        var ts = TimeSpan.FromMilliseconds(250);

        (tp + ts).Milliseconds.Should().Be(1250);
    }
Esempio n. 5
0
        public TimePoint LagrangeInterpolatePoint(double time, ObservableCollection <TimePoint> points)
        {
            TimePoint resultPoint = null;

            if (points.Count > 0)
            {
                double[] timeValues = points.Select(p => p.Time).ToArray();

                double[] xValues = points.Select(p => p.X).ToArray();
                double[] yValues = points.Select(p => p.Y).ToArray();
                double   x = 0, y = 0;
                int      i, j;

                for (i = 0; i < points.Count; i++)
                {
                    double basicsPol = 1;
                    for (j = 0; j < points.Count; j++)
                    {
                        if (j != i)
                        {
                            basicsPol *= (time - timeValues[j]) / (timeValues[i] - timeValues[j]);
                        }
                    }
                    x += basicsPol * xValues[i];
                    y += basicsPol * yValues[i];
                }

                resultPoint = new TimePoint(time, x, y);
            }
            return(resultPoint);
        }
    public void TestTimeSpanDelta()
    {
        var tp1 = new TimePoint(TimePoint.TicksPerMillisecond * 1250);
        var tp2 = new TimePoint(TimePoint.TicksPerMillisecond * 4000);

        (tp2 - tp1).TotalMilliseconds.Should().Be(2750);
    }
Esempio n. 7
0
        public void ComparisonOperators()
        {
            var tp1 = new TimePoint(100);
            var tp2 = new TimePoint(100);
            var tp3 = new TimePoint(200);

#pragma warning disable CS1718 // Comparison made to same variable
            Assert.False(tp1 < tp1);
            Assert.False(tp1 < tp2);
            Assert.True(tp1 < tp3);
            Assert.False(tp3 < tp1);

            Assert.True(tp1 <= tp1);
            Assert.True(tp1 <= tp2);
            Assert.True(tp1 <= tp3);
            Assert.False(tp3 <= tp1);

            Assert.False(tp1 > tp1);
            Assert.False(tp1 > tp2);
            Assert.False(tp1 > tp3);
            Assert.True(tp3 > tp1);

            Assert.True(tp1 >= tp1);
            Assert.True(tp1 >= tp2);
            Assert.False(tp1 >= tp3);
            Assert.True(tp3 >= tp1);
#pragma warning restore CS1718 // Comparison made to same variable
        }
Esempio n. 8
0
        public void RemoveTimePointCommand_MultiTimePoint_ClearsTimePointViewModelCollection()
        {
            // Arrange
            var pvm = GetPresetViewModel();

            var timePoint1 = new TimePoint("0:00:02", TimePointKinds.Relative, 9);

            pvm.AddingTimePoint.CopyFrom(timePoint1);

            pvm.AddTimePointCommand.Execute(null);

            var timePoint2 = new TimePoint("0:00:04", TimePointKinds.Relative, 10);

            pvm.AddingTimePoint.CopyFrom(timePoint2);

            pvm.AddTimePointCommand.Execute(null);

            var timePoint3 = new TimePoint("0:00:06", TimePointKinds.Relative, 9);

            pvm.AddingTimePoint.CopyFrom(timePoint3);

            pvm.AddTimePointCommand.Execute(null);

            var coll = pvm.TimePointVmCollection.Where(t => t.GetType() == typeof(TimePointViewModel))
                       .Select(t => t.TimePoint).OrderBy(t => t.Id).ToArray();

            // Action
            pvm.RemoveTimePoint(coll[0]);
            pvm.RemoveTimePoint(coll[1]);
            pvm.RemoveTimePoint(coll[2]);

            // Assert
            Assert.IsTrue(pvm.TimePointVmCollection.Count == 0);
        }
Esempio n. 9
0
        public void Equals_EqualTimePoints_ReturnsTrue()
        {
            TimePointViewModelBase tpvmb = GetTimePointViewModel(TimePoint.GetAbsoluteTimePoint());
            var tp = tpvmb.TimePoint;

            Assert.That(tpvmb.Equals(tp));
        }
Esempio n. 10
0
    public void SetMapId(int mapId)
    {
        if (mapId == 5000)
        {
            _scrollMainMenuRefPoint = TimePoint.Now;
            _mainMenuScrollState    = 0;
        }

        _currentLimits = _mapLimits.GetValueOrDefault(mapId, MapLimits.Default);

        var screenSize = ScreenSize;

        // This is a TemplePlus extension:
        if (mapId != 5000)
        {
            var deltaW = _currentLimits.Left - _currentLimits.Right;
            var deltaH = _currentLimits.Top - _currentLimits.Bottom;
            if (deltaW < screenSize.Width + 100)
            {
                _currentLimits.Left  += (screenSize.Width - deltaW) / 2 + 50;
                _currentLimits.Right -= (screenSize.Width - deltaW) / 2 + 50;
            }

            if (deltaH < screenSize.Height + 100)
            {
                _currentLimits.Top    += (screenSize.Height - deltaH) / 2 + 50;
                _currentLimits.Bottom -= (screenSize.Height - deltaH) / 2 + 50;
            }
        }
    }
Esempio n. 11
0
    public Task PerformFade(ref FadeArgs fadeArgs)
    {
        _activeTask?.TrySetCanceled();
        _activeTask = new TaskCompletionSource <bool>();

        _currentFade = fadeArgs;

        _timeOverflow  = 0;
        _fadeStepsDone = -1;
        if (!fadeArgs.flags.HasFlag(FadeFlag.FadeIn))
        {
            Logger.Info("gfade fade out");
        }
        else
        {
            Logger.Info("gfade fade in");
        }

        _lastFadeTime = TimePoint.Now;
        AdvanceTime(_lastFadeTime);
        // If transition time is 0, this might actually complete _immediately_!
        if (_activeTask == null)
        {
            return(Task.CompletedTask);
        }
        return(_activeTask.Task);
    }
Esempio n. 12
0
    private void ProcessScrollButter(TimePoint time)
    {
        if (_mapScrollX != 0 || _mapScrollY != 0)
        {
            var elapsedTime = (float)(time - _timeLastScroll).TotalSeconds;
            _timeLastScroll = time;

            if (elapsedTime > 0.1f)
            {
                elapsedTime = 0.1f;
            }

            var deltaX = (int)(_mapScrollX * elapsedTime);
            var deltaY = (int)(_mapScrollY * elapsedTime);
            ScrollBy(_currentViewport, deltaX, deltaY);
            _mapScrollX -= deltaX;
            _mapScrollY -= deltaY;

            var timeSinceManualScroll = (float)(time - _timeLastScrollDirectionChange).TotalMilliseconds;
            if (timeSinceManualScroll > FullDecelerationTime)
            {
                timeSinceManualScroll = FullDecelerationTime;
            }

            var decayFactor = timeSinceManualScroll * timeSinceManualScroll / FullDecelerationTimeSquared;
            if (timeSinceManualScroll < FullDecelerationTimeHalf)
            {
                decayFactor = 1.0f - decayFactor;
            }

            _mapScrollX = (int)(_mapScrollX * decayFactor);
            _mapScrollY = (int)(_mapScrollY * decayFactor);
        }
    }
Esempio n. 13
0
    private void ProcessMainMenuScrolling(IGameViewport viewport)
    {
        var elapsedSeconds = (TimePoint.Now - _scrollMainMenuRefPoint).TotalSeconds;

        if (elapsedSeconds < 1.0f)
        {
            _mainMenuScrollState += (float)elapsedSeconds;
        }

        var amountToScroll = _mainMenuScrollState;

        if (amountToScroll < 0.0f)
        {
            amountToScroll       = 0.0f;
            _mainMenuScrollState = amountToScroll;
        }
        else
        {
            while (amountToScroll > 100.0f)
            {
                amountToScroll -= 100.0f;
            }
        }

        var screenHeight       = (int)viewport.Camera.GetViewportHeight();
        var targetTranslationX = 1400 - (int)(amountToScroll * 53.599998);
        var targetTranslationY = screenHeight / 2 - 13726;

        GameSystems.Location.AddTranslation(
            targetTranslationX - GameSystems.Location.LocationTranslationX,
            targetTranslationY - GameSystems.Location.LocationTranslationY
            );
        _scrollMainMenuRefPoint = TimePoint.Now;
    }
    public void TestRender()
    {
        var startTime = TimePoint.Now;
        var from      = CameraCenter - new Vector3(300, 0, -250);
        var targets   = new List <ChainLightningTarget>()
        {
            new(CameraCenter + new Vector3(300, 0, -250)),
            new(CameraCenter + new Vector3(300, 0, 250)),
            new(CameraCenter + new Vector3(500, 0, 0))
        };
        var locations = new[] { from }.Concat(targets.Select(t => t.Location)).ToArray();

        var effect = new ChainLightningEffect(
            _renderer,
            startTime,
            from,
            targets
            );

        void Render(int timeSinceStart)
        {
            TimePoint.SetFakeTime(startTime + TimeSpan.FromMilliseconds(timeSinceStart));
            effect.Render(Viewport);
        }

        var frames = RenderFrameSequence(45, Render, locations);

        ScreenshotCommandWrapper.AttachVideo("chain_lightning.mp4", frames);

        // Assert against reference images at certain intervals
        // Points are chosen where arcs become visible/invisible.
        CompareReferenceFrames(frames, "Core/Systems/Vfx/ChainLightning", 0, 300, 550, 1800, 2200);
    }
Esempio n. 15
0
 public Notification(string message, TimePoint date, bool shouldStopProcessing, EntityId linkedEntityId)
 {
     Message = message;
     Date    = date;
     ShouldStopProcessing = shouldStopProcessing;
     LinkedEntityId       = linkedEntityId;
 }
Esempio n. 16
0
        public static DateTimeOffset GetTimeFrom(string strDate, string strTime)
        {
            TimePoint.ParseHour(strTime, out var hour, out var minute);
            var dateTime = FromLiteralDateName(strDate).SetTime(hour, minute, 0);

            return(dateTime);
        }
Esempio n. 17
0
        public void AddTimePoint_AutoUpdateIsTrueByDefaultRelativeTimePoints_UpdatesTimePointBaseTime()
        {
            // Arrange
            var timePoints = new TimePoint[]
            {
                new TimePoint {
                    Time = TimeSpan.Parse("1:00:00"), LoopNumber = 1
                },
                new TimePoint {
                    Time = TimeSpan.Parse("1:00:00"), LoopNumber = 3
                }
            };

            var addingTimePoint = new TimePoint {
                Time = TimeSpan.Parse("1:00:00"), LoopNumber = 2
            };

            // Action
            var preset = new Preset(timePoints);

            preset.AddTimePoint(addingTimePoint);

            // Assert
            Assert.AreEqual(TimeSpan.Parse("0:00:00"), timePoints[0].BaseTime);
            Assert.AreEqual(TimeSpan.Parse("1:00:00"), addingTimePoint.BaseTime);
            Assert.AreEqual(TimeSpan.Parse("2:00:00"), timePoints[1].BaseTime);
        }
Esempio n. 18
0
        public Vot <T> ReadVotList <T>(BitStream stream, int countSize, Func <T> read)
        {
            //Console.WriteLine($"VotList({typeof(T).Name}):");

            var list = new Vot <T>();

            bool exists = stream.ReadBool();

            if (exists)
            {
                uint count    = stream.ReadUInt(countSize);
                var  lastTime = new TimePoint(-1, BaseRange);

                for (var i = 0; i < count; i++)
                {
                    var time  = ReadTimePoint(stream);
                    var value = read();

                    if (time < lastTime)
                    {
                        throw new FormatException("Invalid parsing structure: time not ascending. This usually indicates that you've specified the wrong field size somewhere (either in this call or the previous).");
                    }

                    lastTime = time;

                    //Console.WriteLine($"    - {time:00.00}: {value}");
                    list.Add(time, value);
                }
            }

            return(list);
        }
Esempio n. 19
0
 public TimerEventArgs(TimePoint prevTimePoint, TimePoint nextTimePoint, TimeSpan lastTimeToNextChange, TimeSpan?prevTimePointNextBaseTime)
 {
     PrevTimePoint             = prevTimePoint;
     NextTimePoint             = nextTimePoint;
     LastTimeToNextChange      = lastTimeToNextChange;
     PrevTimePointNextBaseTime = prevTimePointNextBaseTime;
 }
Esempio n. 20
0
        /// <summary>
        /// Simulate a test population until all original people are deceased and use the
        /// final population distribution as a basis for distributing newly created populations.
        /// </summary>
        private static IReadOnlyList <double> GetDistributionRatios(RacialTemplate racialTemplate)
        {
            long testPopulation = 1000000;
            var  ageRange       = (double)racialTemplate.CohortTemplates.Sum(x => (x.PastEndAge - x.StartAge).TickOffset);
            var  pops           = racialTemplate.CohortTemplates
                                  .Select(cohortTemplate =>
            {
                var cohortAgeRange = (double)(cohortTemplate.PastEndAge - cohortTemplate.StartAge).TickOffset;
                return((long)((double)testPopulation * cohortAgeRange / ageRange));
            });
            var testCohorts = new CohortCollection(racialTemplate, pops);

            var maxDate = new TimePoint(0) + testCohorts.Cohorts.Last().PastEnd;

            for (var date = new TimePoint(0); date < maxDate; date += TimeOffset.OneTick)
            {
                testCohorts = new CohortCollection(racialTemplate, PopulationUtility.ProcessTick(testCohorts, out var _));
            }

            var finalTestPopulation = (double)testCohorts.TotalPopulation;

            return(testCohorts.Cohorts
                   .Select(x => (double)x.Population / finalTestPopulation)
                   .AsReadOnlyList());
        }
Esempio n. 21
0
    // Update is called once per frame
    void Update()
    {
        try
        {
            delta += Time.deltaTime;
            if (delta > 0.1)
            {
                EQ_Left.MoveNext();
                TimePoint tp = EQ_Left.Current;
                TargetHandLeft.transform.position = new Vector3((float)tp.X, (float)tp.Y, (float)tp.Z);


                EQ_Right.MoveNext();
                TimePoint tpr = EQ_Right.Current;
                TargetHandRight.transform.position = new Vector3((float)tpr.X, (float)tpr.Y, (float)tpr.Z);

                //EQ_Head.MoveNext();
                //TimePoint tprt = EQ_Head.Current;
                //Head.transform.position = new Vector3((float)tprt.X, (float)tprt.Y, (float)tprt.Z);



                delta = 0;
            }
        }
        catch
        {
        }
    }
Esempio n. 22
0
        public static TimePoint Decode(XdrDataInputStream stream)
        {
            TimePoint decodedTimePoint = new TimePoint();

            decodedTimePoint.InnerValue = Uint64.Decode(stream);
            return(decodedTimePoint);
        }
Esempio n. 23
0
        private TimePoint GetAbsoluteTimePoint()
        {
            TimePoint.DefaultKind = TimePointKinds.Absolute;
            var timePoint = new TimePoint();

            return(timePoint);
        }
Esempio n. 24
0
        private TimePoint GetRelativeTimePoint(TimeSpan time)
        {
            TimePoint.DefaultKind = TimePointKinds.Relative;
            var timePoint = new TimePoint(time, TimePointKinds.Relative);

            return(timePoint);
        }
Esempio n. 25
0
        public void GetOrderedTimePoints_WhenCalled_ReturnsOrderedByLoopNumberThanByIdTimePoints()
        {
            // Arrange
            var timePoints = new TimePoint[]
            {
                new TimePoint {
                    Time = TimeSpan.Parse("1:00:00"), LoopNumber = 1
                },
                new TimePoint {
                    Time = TimeSpan.Parse("1:00:00"), LoopNumber = 3
                },
                new TimePoint {
                    Time = TimeSpan.Parse("1:00:00"), LoopNumber = 1
                },
                new TimePoint {
                    Time = TimeSpan.Parse("1:00:00"), LoopNumber = 2
                },
            };

            var preset = new Preset(timePoints);

            // Action
            var resArray = preset.GetOrderedTimePoints().ToArray();

            // Assert
            Assert.AreSame(timePoints[0], resArray[0]);
            Assert.AreSame(timePoints[2], resArray[1]);
            Assert.AreSame(timePoints[3], resArray[2]);
            Assert.AreSame(timePoints[1], resArray[3]);
        }
Esempio n. 26
0
        public void StartTimeSetter_AutoUpdateIsTrueRelativeTimePoints_UpdatesTimePointBaseTime()
        {
            var flag = Preset.AutoUpdateTimePointBaseTimes;

            Preset.AutoUpdateTimePointBaseTimes = true;

            // Arrange
            var timePoints = new TimePoint[]
            {
                new TimePoint(time: "1:00:00", kind: TimePointKinds.Relative, loopNumber: 1),
                new TimePoint(time: "1:00:00", kind: TimePointKinds.Relative, loopNumber: 2),
                new TimePoint(time: "1:00:00", kind: TimePointKinds.Relative, loopNumber: 3)
            };

            // ReSharper disable once UseObjectOrCollectionInitializer
            var preset = new Preset(timePoints);

            // Action
            preset.StartTime = TimeSpan.Parse("1:00:00");

            // Assert
            Assert.AreEqual(TimeSpan.Parse("1:00:00"), timePoints[0].BaseTime);
            Assert.AreEqual(TimeSpan.Parse("2:00:00"), timePoints[1].BaseTime);
            Assert.AreEqual(TimeSpan.Parse("3:00:00"), timePoints[2].BaseTime);

            Preset.AutoUpdateTimePointBaseTimes = flag;
        }
Esempio n. 27
0
        public void RemoveTimePoint_AutoUpdateIsTrueByDefaultAbsoluteTimePoints_UpdatesTimePointBaseTime()
        {
            // Arrange
            var timePoints = new TimePoint[]
            {
                new TimePoint {
                    Time = TimeSpan.Parse("1:00:00"), LoopNumber = 1
                },
                new TimePoint {
                    Time = TimeSpan.Parse("1:00:00"), LoopNumber = 3
                },
                new TimePoint {
                    Time = TimeSpan.Parse("1:00:00"), LoopNumber = 2
                }
            };

            var preset = new Preset(timePoints);

            var removingingTimePoint = timePoints[1];

            // Action
            preset.RemoveTimePoint(removingingTimePoint);

            // Assert
            Assert.AreEqual(TimeSpan.Parse("0:00:00"), timePoints[0].BaseTime);
            Assert.AreEqual(TimeSpan.Parse("1:00:00"), timePoints[2].BaseTime);
        }
Esempio n. 28
0
        public void GetDeepCopy_WhenCalled_CreatesDeepCopy()
        {
            // Arrage:
            TimePoint[] originTimePoints = new TimePoint[] { new TimePoint("1", new TimeSpan(1, 1, 1), TimePointKinds.Relative, 1) };

            var originPreset = new Preset(originTimePoints)
            {
                PresetName = "Origin",
                StartTime  = new TimeSpan(1, 1, 1),
                Tag        = "origin"
            };


            originPreset.SetInfiniteLoop();

            // Actoin:
            var deepPreset = originPreset.GetDeepCopy();

            // Assert:
            Assert.AreNotSame(originPreset, deepPreset);
            Assert.AreNotSame(originPreset.TimePointCollection, deepPreset.TimePointCollection);
            Assert.AreNotSame(originPreset.TimerLoopDictionary, deepPreset.TimerLoopDictionary);
            Assert.AreNotSame(originPreset.Tag, deepPreset.Tag);

            originPreset.PresetName = "Else";
            Assert.AreNotEqual(originPreset.PresetName, deepPreset.PresetName);

            originPreset.StartTime = new TimeSpan(2, 0, 0);
            Assert.AreNotEqual(originPreset.StartTime, deepPreset.StartTime);

            originPreset.ResetInfiniteLoop();
            Assert.AreNotEqual(originPreset.IsInfiniteLoop, deepPreset.IsInfiniteLoop);
        }
Esempio n. 29
0
        private TimePoint GetTimePoint(TimePoint request)
        {
            var       id    = request?.Id;
            TimePoint ret   = null;
            var       query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <TimePoint>(currentUser, "TimePoint", request.Select);

            DocEntityTimePoint entity = null;

            if (id.HasValue)
            {
                entity = DocEntityTimePoint.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No TimePoint found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
Esempio n. 30
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void setTimePoint(Field field, com.alphatica.genotick.genotick.MainSettings settings, String value) throws IllegalAccessException
        private void setTimePoint(Field field, MainSettings settings, string value)
        {
            long?     l  = Convert.ToInt64(value);
            TimePoint tp = new TimePoint(l.Value);

            field.set(settings, tp);
        }
		public abstract void Add(TimePoint point);
 public void StartGroup(string name)
 {
     var group = new TimePoint()
     {
         Name = name,
         GroupStartTime = DateTime.Now,
         InternalPoints = new List<TimePoint>()
     };
     currentPointsList.Add(group);
     currentGroupLevels.Add(group);
     currentPointsList = group.InternalPoints;
 }
		public override void Add(TimePoint point)
		{
		}
Esempio n. 34
0
        static void Main(string[] args)
        {
            for(int i = 0; i < args.Length; i++)
            {
                switch(args[i])
                {
                    case "-n":
                        i++;
                        int n = Int32.Parse(args[i]);
                        if (n < 0)
                        {
                            System.Console.WriteLine("Error parsing arguments!");
                            return;
                        }
                        else
                        {
                            LiczbaWynajec = n;
                        }
                        break;
                    default:
                        break;
                }
            }

            LiczbaWynajecPojedynczegoPojazdu = (LiczbaWynajec * 3) / 2;
            LiczbaAdresow = 2 * LiczbaWynajec;
            LiczbaOddzialow = LiczbaAdresow / 20;
            LiczbaKierowcow = 5 * LiczbaOddzialow;
            LiczbaPojazdow = 2 * LiczbaKierowcow;

            LiczbaWynajecDodane = LiczbaWynajec / 100;

            LiczbaWynajecPojedynczegoPojazduDodane = (LiczbaWynajecDodane * 3) / 2;
            LiczbaAdresowDodane = 2 * LiczbaWynajecDodane;
            LiczbaOddzialowDodane = LiczbaAdresowDodane / 20;
            LiczbaKierowcowDodane = 5 * LiczbaOddzialowDodane;
            LiczbaPojazdowDodane = 3 * LiczbaKierowcowDodane;

            shKlienci.Name = "KlienciT1";
            shKlienci2.Name = "KlienciT2";
            /*
            try
            {
                make_sheets();
            }
            catch (Exception ex)
            {
                excel_destination.Quit();
            }
            System.Console.WriteLine("Skonczyl sie excel");
            */

            Adresy = new AdresPojedynczy[LiczbaAdresow];
            Pojazdy = new PojazdPojedynczy[LiczbaPojazdow];

            zajeteAdresy = new bool[Program.LiczbaAdresow];
            zajeciKierowcy = new bool[Program.LiczbaKierowcow];

            Encje = new Encja[LiczbaEncji];

            Encje[2] = new Kierowca(LiczbaKierowcow);
            Encje[0] = new Adres(LiczbaAdresow);
            Encje[1] = new Oddzial(LiczbaOddzialow);
            Encje[3] = new Pojazd(LiczbaPojazdow);
            Encje[4] = new Wynajem(LiczbaWynajec);
            Encje[5] = new WynajemPojedycznegoPojazdu(LiczbaWynajecPojedynczegoPojazdu);

            TablicaZajetosci = new List<int>[LiczbaWynajec];

            for (int i = 0; i < TablicaZajetosci.Length; i++)
            {
                TablicaZajetosci[i] = new List<int>();
            }

            FileWriter = new StreamWriter(PathToCreateSql);
            FileWriter.AutoFlush = true;

            FileWriterInsert = new StreamWriter(PathToInsertSql);
            FileWriterInsert.AutoFlush = true;

            FileWriterTwo = new StreamWriter(PathToSqlT2);
            FileWriterTwo.AutoFlush = true;

            FileWriter.WriteLine("CREATE DATABASE TransakcjeWynajmu");
            FileWriter.WriteLine("GO");
            FileWriter.WriteLine();
            FileWriter.WriteLine("USE TransakcjeWynajmu");
            FileWriter.WriteLine("GO");
            FileWriter.WriteLine();

            int u = 0;

            foreach (Encja e in Encje)
            {
                e.Create(FileWriter);

                if (e != Encje.Last())
                {
                    FileWriter.WriteLine("GO");
                    FileWriter.WriteLine();
                }
                else
                {
                    FileWriter.Write("GO");
                }
            }

            foreach (Encja e in Encje)
            {
                System.Console.WriteLine("Encja randomize {0}", u);
                u++;
                e.Randomize();
                System.Console.WriteLine();
            }
            if (JedenPlikWynikowy == true)
            {
                FileWriterInsert.WriteLine("USE TransakcjeWynajmu");
                FileWriterInsert.WriteLine("GO");
                FileWriterInsert.WriteLine();

                FileWriterInsert.WriteLine("SET ANSI_WARNINGS  OFF;");
                u = 0;
                foreach (Encja e in Encje)
                {
                    System.Console.WriteLine("Encja insert {0}", u);
                    u++;
                    e.Insert(FileWriterInsert);
                    System.Console.WriteLine();
                }

                FileWriterInsert.WriteLine("SET ANSI_WARNINGS  OFF;");
            }

            if (JedenPunktCzasowy == false)
            {

                PunktCzasowy = TimePoint.SecondTimePoint;

                Encja[] EncjeT2 = new Encja[LiczbaEncji];

                LiczbaKierowcow = LiczbaKierowcowDodane;
                zajeciKierowcy = new bool[LiczbaKierowcow];

                Adresy2 = new AdresPojedynczy[LiczbaAdresowDodane];
                Pojazdy2 = new PojazdPojedynczy[LiczbaPojazdowDodane];

                EncjeT2[2] = new Kierowca(LiczbaKierowcowDodane);
                EncjeT2[0] = new Adres(LiczbaAdresowDodane);
                EncjeT2[1] = new Oddzial(LiczbaOddzialowDodane);
                EncjeT2[3] = new Pojazd(LiczbaPojazdowDodane);
                EncjeT2[4] = new Wynajem(LiczbaWynajecDodane);
                EncjeT2[5] = new WynajemPojedycznegoPojazdu(LiczbaWynajecPojedynczegoPojazduDodane);
                foreach (Encja e in EncjeT2)
                {

                    e.Randomize();
                }

                FileWriterTwo.WriteLine("USE TransakcjeWynajmu");
                FileWriterTwo.WriteLine("GO");
                FileWriterTwo.WriteLine();

                foreach (Encja e in EncjeT2)
                {
                    e.Update(FileWriterTwo);
                }

                FileWriterTwo.WriteLine("GO");
                FileWriterTwo.WriteLine();

                foreach (Encja e in EncjeT2)
                {
                    e.Insert(FileWriterTwo);
                }
            }
            wb_dest.Save();
            excel_destination.Quit();
            wb_dest_data2.Save();
            excel_destination2.Quit();
        }
		public SingleTimePoints(TimePoint _)
		{
			_start = new[] {new TimePoint("-", DateTimeOffset.UtcNow, -1)};
		}
Esempio n. 36
0
    void FixupData()
    {
        int start_t = d.StartTime;
        int end_t = ((TimeData) d.Data [d.Data.Count - 1]).Time;
        int del_t = end_t - start_t;

        data = new ArrayList ();
        int size_threshold = (Profile.MaxSize / ysize) * 3;

        foreach (TimeData td in d.Data) {
            if (td.HeapSize < size_threshold)
                continue;

            TimePoint p = new TimePoint ();

            data.Add (p);

            p.Data = td;
            p.Time = td.Time;
            p.X = (td.Time - start_t) * xsize / del_t;
            p.OtherSize = td.OtherSize;
            p.TypeData = new int [tl.TypeIndexes.Length];
            p.HeapSize = td.HeapSize;

            for (int i = 0; i < tl.TypeIndexes.Length; i ++) {
                int ty = tl.TypeIndexes [i];

                if (td.TypeData [ty] < size_threshold) {
                    p.OtherSize += td.TypeData [ty];
                    continue;
                }

                p.TypeData [i] = td.TypeData [ty];
            }
        }
    }