Exemplo n.º 1
0
    public void testPods()
    {
        Pods p1 = new Pods();

        p1.i8  = 1;
        p1.i16 = 2;
        p1.i32 = 3;
        p1.i64 = 4;
        p1.u8  = 5;
        p1.u16 = 6;
        p1.u32 = 7;
        p1.u64 = 8;
        p1.f32 = 9.0f;
        p1.f64 = 1337.0;

        Pods p2 = DoTheRoundAbout(p1);

        Assert.AreEqual(p1.i8, p2.i8);
        Assert.AreEqual(p1.i16, p2.i16);
        Assert.AreEqual(p1.i32, p2.i32);
        Assert.AreEqual(p1.i64, p2.i64);
        Assert.AreEqual(p1.u8, p2.u8);
        Assert.AreEqual(p1.u16, p2.u16);
        Assert.AreEqual(p1.u32, p2.u32);
        Assert.AreEqual(p1.u64, p2.u64);
        Assert.AreEqual(p1.f32, p2.f32);
        Assert.AreEqual(p1.f64, p2.f64);
    }
Exemplo n.º 2
0
        private void LoadFavourites()
        {
            NoFavouritesVisibility = Visibility.Visible;
            FavouritePods          = new ObservableCollection <PodViewModel>();

            if (!IsolatedStorageSettings.ApplicationSettings.Contains("Favourites"))
            {
                IsolatedStorageSettings.ApplicationSettings.Add("Favourites", new List <string>());
            }

            var favourites = IsolatedStorageSettings.ApplicationSettings["Favourites"] as List <string>;

            if (favourites == null)
            {
                return;
            }

            foreach (var favourite in favourites)
            {
                var pod = Pods.FirstOrDefault(x => x.Name == favourite);
                if (pod != default(PodViewModel))
                {
                    AddFavourite(pod.Clone());
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Finalizes the instance.
        /// </summary>
        public void Flush()
        {
            // Set references to this object
            Compound.Instance = this;
            foreach (var instanceElement in
                     Bots.AsEnumerable <InstanceElement>()
                     .Concat(Pods.AsEnumerable <InstanceElement>())
                     .Concat(Elevators.AsEnumerable <InstanceElement>())
                     .Concat(InputStations.AsEnumerable <InstanceElement>())
                     .Concat(OutputStations.AsEnumerable <InstanceElement>())
                     .Concat(Waypoints.AsEnumerable <InstanceElement>())
                     .Concat(ItemDescriptions.AsEnumerable <InstanceElement>())
                     .Concat(ItemBundles.AsEnumerable <InstanceElement>()))
            {
                instanceElement.Instance = this;
            }

            //TODO:why is the code below commented out??

            //// Generate Waypointgraph
            //WaypointGraph = new WaypointGraph();
            //foreach (var waypoint in Waypoints)
            //{
            //    WaypointGraph.Add(waypoint);
            //}
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a pod with the given characteristics.
        /// </summary>
        /// <param name="id">The ID of the pod.</param>
        /// <param name="tier">The initial position (tier).</param>
        /// <param name="waypoint">The waypoint to place the pod at.</param>
        /// <param name="radius">The radius of the pod.</param>
        /// <param name="orientation">The initial orientation of the pod.</param>
        /// <param name="capacity">The capacity of the pod.</param>
        /// <returns>The newly created pod.</returns>
        public Pod CreatePod(int id, Tier tier, Waypoint waypoint, double radius, double orientation, double capacity)
        {
            // Consider override values
            if (SettingConfig.OverrideConfig != null && SettingConfig.OverrideConfig.OverridePodCapacity)
            {
                capacity = SettingConfig.OverrideConfig.OverridePodCapacityValue;
            }
            // Create the pod
            Pod pod = new Pod(this)
            {
                ID = id, Tier = tier, Radius = radius, X = waypoint.X, Y = waypoint.Y, Orientation = orientation, Capacity = capacity, Waypoint = waypoint
            };

            Pods.Add(pod);
            tier.AddPod(pod);
            _idToPods[pod.ID] = pod;
            // Set volatile ID
            SetVolatileIDForPod(pod);
            // Emulate setdown operation
            WaypointGraph.PodSetdown(pod, waypoint);
            // Notify listeners
            NewPod(pod);
            // Return it
            return(pod);
        }
Exemplo n.º 5
0
        public void updateClusterView(Pod pod)
        {
            // If the container image is "image:tag", strip the ":tag", otherwise leave it alone
            // not all images are tagged, so..
            if (pod.ContainerImage.Contains(':'))
            {
                pod.ContainerImage = pod.ContainerImage.Substring(0, pod.ContainerImage.IndexOf(':'));
            }

            if (Pods.Any(x => x.Name == pod.Name))
            {
                if (pod.Action == POD_DELETED_STATUS)
                {
                    RemovePod(pod);
                }
                else
                {
                    UpdatePod(pod);
                }
            }
            else
            {
                AddPod(pod);
            }

            Clients.All.SendAsync("clusterViewUpdated", Pods);
        }
Exemplo n.º 6
0
 public void AddPod(Pod pod)
 {
     if (!DeletedPods.Contains(pod.Name))
     {
         Pods.Add(pod);
     }
 }
Exemplo n.º 7
0
 public void UpdatePod(Pod pod)
 {
     Pods.First(x => x.Name == pod.Name).Name      = pod.Name;
     Pods.First(x => x.Name == pod.Name).Container = pod.Container;
     Pods.First(x => x.Name == pod.Name).NameSpace = pod.NameSpace;
     Pods.First(x => x.Name == pod.Name).Status    = pod.Status;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Type == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Type");
     }
     if (ContainerResource != null)
     {
         ContainerResource.Validate();
     }
     if (External != null)
     {
         External.Validate();
     }
     if (ObjectProperty != null)
     {
         ObjectProperty.Validate();
     }
     if (Pods != null)
     {
         Pods.Validate();
     }
     if (Resource != null)
     {
         Resource.Validate();
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Registers and returns a new ID for an object of the given type.
 /// </summary>
 /// <returns>A new unique ID that can be used to identify the object.</returns>
 public int RegisterPodID()
 {
     if (Pods.Any() && _podID <= Pods.Max(e => e.ID))
     {
         _podID = Pods.Max(e => e.ID) + 1;
     }
     return(_podID++);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Remove all pods from the instance. This is only usable for visualization purposes.
 /// </summary>
 public void VisClearPods()
 {
     Pods.Clear();
     foreach (var tier in Compound.Tiers)
     {
         tier.Pods.Clear();
     }
 }
Exemplo n.º 11
0
    IEnumerator SpawnSoldier(Pods newSoldier)
    {
        newSoldier.soldierRef          = Instantiate(soldierPrefab, this.transform.position + newSoldier.podPosition, Quaternion.identity, this.transform).GetComponent <Soldier>();
        newSoldier.soldierRef.barracks = this;
        yield return(new WaitForSeconds(spawnTimer));

        spawning = false;
        yield return(null);
    }
Exemplo n.º 12
0
        public async Task LoadPods()
        {
            Pods.Clear();
//            using(var pr = RepositoryProvider.Instance.PodRepository)
//            {
//                var allPods = await pr.GetActivePods();
//                foreach (var pod in allPods)
//                    Pods.Add(pod);
//            }
        }
Exemplo n.º 13
0
        private static void TryAllocatingForPendingOrders()
        {
            if (OrderProcessor.ordersQueue.Count == 0)
            {
                return;
            }

            if (OrderProcessor.ordersQueue.Count > 20) // If more than 20 pending orders create new pod;
            {
                var pod = new Pods(OrderProcessor.pods.Count);
                OrderProcessor.pods.Add(pod);
            }

            List <Order> orderList1 = OrderProcessor.ordersQueue.ToList();
            List <Order> orderList2 = new List <Order>();

            foreach (var order in orderList1)
            {
                var allocationStatus = false;
                foreach (var pod in OrderProcessor.pods)
                {
                    if (!pod.IsPodFull())
                    {
                        allocationStatus = pod.AssignOrderToPod(order.GetOrderId, order.GetLockerSize);
                    }
                    if (allocationStatus == true)
                    {
                        OrderProcessor.PrintPodStatusOnAllocation(pod.GetPodId);
                        OrderProcessor.orderStatus[order] = true;
                        orderList2.Add(order);
                        break;
                    }
                }
            }

            OrderProcessor.ordersQueue.Clear();


            foreach (var order in orderList2)
            {
                orderList1.Remove(order);
            }

            foreach (var order in orderList1)
            {
                OrderProcessor.ordersQueue.Enqueue(order);
            }
        }
Exemplo n.º 14
0
        private static Dictionary <Order, bool> orderStatus; // Checks if a order has been allocated a locker.

        #endregion

        #region Methods

        public static void SetupEnvironment(int numberOfPods, int numberOfCustomers)
        {
            OrderProcessor.pods = new List <Pods>();
            for (int i = 0; i < numberOfPods; i++)
            {
                var pod = new Pods(i);
                OrderProcessor.pods.Add(pod);
            }

            OrderProcessor.customers = new List <Customer>();
            for (int i = 0; i < numberOfCustomers; i++)
            {
                var customer = new Customer(i);
                OrderProcessor.customers.Add(customer);
            }
        }
Exemplo n.º 15
0
        private void AddPod(int strength, string name, string groupName, string uri, bool isDecaf, Color backgroundColour, CupSizeEnum cupSizes, string description)
        {
            var newModel = new PodViewModel()
            {
                Name             = name,
                Strength         = strength,
                GroupName        = groupName,
                ListImageUri     = new Uri("/Images/Small/" + uri, UriKind.Relative),
                DetailImageUri   = new Uri("/Images/Large/" + uri, UriKind.Relative),
                IsDecaf          = isDecaf,
                Description      = description,
                BackgroundColour = backgroundColour,
                CupSizes         = cupSizes
            };

            Pods.Add(newModel);
        }
Exemplo n.º 16
0
    // Update is called once per frame
    void Update()
    {
        Pods newSoldier = soldiers.Find(soldier => soldier.soldierRef == null);

        if (!spawning && newSoldier != null)
        {
            newSoldier.deployed = false;
            spawning            = true;
            StartCoroutine("SpawnSoldier", newSoldier);
        }

        //TODO: remove once done with testing
        if (testing == true && testingPosition != Vector3.zero && soldiers.Find(soldier => soldier.soldierRef != null) != null)
        {
            commandCenter.reportEvent.Invoke(testingPosition, 2);
            testingPosition = Vector3.zero;
        }
    }
Exemplo n.º 17
0
    public Soldier RequestSoldier(Order order = null)
    {
        if (soldiers != null)
        {
            Pods soldier = soldiers.Find(status => status.soldierRef != null && status.deployed == false);
            if (soldier != null)
            {
                if (order != null)
                {
                    soldier.soldierRef.CurrentOrder = order;
                }
                soldier.deployed            = true;
                soldier.soldierRef.Deployed = true;
                return(soldier.soldierRef);
            }
        }

        return(null);
    }
Exemplo n.º 18
0
        public MainWindow()
        {
            this.InitializeComponent();

            this.Activated += (s, e) => {
                if (_hasActivated)
                {
                    return;
                }
                _hasActivated = true;
                App.SetWindowSize(App.WindowHandle, 200, 200, 200, 200);

                Pods.Add(new TestPod());
                Pods.Add(new TestPod());
                Pods.Add(new TestPod());
                Pods.Add(new TestPod());
                Pods.Add(new TestPod());
                Pods.Add(new TestPod());
            };
        }
Exemplo n.º 19
0
        /// <summary>
        /// Creates a pod with the given characteristics.
        /// </summary>
        /// <param name="id">The ID of the pod.</param>
        /// <param name="tier">The initial position (tier).</param>
        /// <param name="x">The initial position (x-coordinate).</param>
        /// <param name="y">The initial position (y-coordinate).</param>
        /// <param name="radius">The radius of the pod.</param>
        /// <param name="orientation">The initial orientation of the pod.</param>
        /// <param name="capacity">The capacity of the pod.</param>
        /// <returns>The newly created pod.</returns>
        public Pod CreatePod(int id, Tier tier, double x, double y, double radius, double orientation, double capacity)
        {
            // Consider override values
            if (SettingConfig.OverrideConfig != null && SettingConfig.OverrideConfig.OverridePodCapacity)
            {
                capacity = SettingConfig.OverrideConfig.OverridePodCapacityValue;
            }
            // Create the pod
            Pod pod = new Pod(this)
            {
                ID = id, Tier = tier, Radius = radius, X = x, Y = y, Orientation = orientation, Capacity = capacity
            };

            Pods.Add(pod);
            tier.AddPod(pod);
            _idToPods[pod.ID] = pod;
            // Set volatile ID
            SetVolatileIDForPod(pod);
            // Notify listeners
            NewPod(pod);
            // Return it
            return(pod);
        }
Exemplo n.º 20
0
    public override Instruction EntityInteract(Entity entity)
    {
        Pods pod = soldiers.Find(soldierPod => soldierPod.soldierRef == entity);

        if (pod != null)
        {
            entity.HealToFull();
            pod.soldierRef.setCanAttack(true);
            pod.deployed              = false;
            pod.soldierRef.Deployed   = false;
            pod.soldierRef.SpookLevel = Soldier.ReportState.Patrolling;

            if (pod.soldierRef.ReportPosition != Vector3.zero)
            {
                commandCenter.reportEvent.Invoke(pod.soldierRef.ReportPosition, pod.soldierRef.NumberOfSoldiersToSend);
                Debug.Log("Last position saw:" + pod.soldierRef.ReportPosition);
                pod.soldierRef.ReportPosition         = Vector3.zero;
                pod.soldierRef.NumberOfSoldiersToSend = 0;
            }
            //Debug.Log(this.transform.position + pod.podPosition);
            return(new Goto(this.transform.position + pod.podPosition, 0, entity));
        }
        return(null);
    }
Exemplo n.º 21
0
 public void RemovePod(Pod pod)
 {
     Pods.Remove(Pods.First(x => x.Name == pod.Name));
     DeletedPods.Add(pod.Name);
 }
Exemplo n.º 22
0
 public void clearClusterView()
 {
     Pods.Clear();
     Clients.All.SendAsync("clusterViewUpdated", Pods);
 }
Exemplo n.º 23
0
        /// <summary>
        /// Removes all elements in scope from the instance.
        /// </summary>
        /// <param name="theTier">The tier to remove the elements from.</param>
        /// <param name="xMin">The min x-value of the scope.</param>
        /// <param name="xMax">The max x-value of the scope.</param>
        /// <param name="yMin">The min y-value of the scope.</param>
        /// <param name="yMax">The max y-value of the scope.</param>
        public void ModRemoveWaypoints(ITierInfo theTier, double xMin, double yMin, double xMax, double yMax)
        {
            Tier tier = theTier as Tier;
            // Remove waypoints
            List <Waypoint> remWaypoints = Waypoints.Where(w => w.Tier == tier && xMin <= w.X && w.X <= xMax && yMin <= w.Y && w.Y <= yMax).ToList();

            // Remove all of them
            foreach (var waypoint in remWaypoints)
            {
                // Remove the waypoint - the waypoint graph handles all cascading path removals
                waypoint.Tier.RemoveWaypoint(waypoint);
                // Remove all elements that were connected to the waypoint
                foreach (var guard in Semaphores.SelectMany(s => s.Guards).Where(guard => guard.From == waypoint || guard.To == waypoint).ToArray())
                {
                    guard.Semaphore.UnregisterGuard(guard);
                    if (guard.Semaphore.Guards.Count() == 0)
                    {
                        Semaphores.Remove(guard.Semaphore);
                    }
                }
                foreach (var station in InputStations.Where(s => s.Waypoint == waypoint).ToArray())
                {
                    station.Tier.RemoveInputStation(station);
                    InputStations.Remove(station);
                }
                foreach (var station in OutputStations.Where(s => s.Waypoint == waypoint).ToArray())
                {
                    station.Tier.RemoveOutputStation(station);
                    OutputStations.Remove(station);
                }
                foreach (var pod in Pods.Where(p => p.Waypoint == waypoint).ToArray())
                {
                    pod.Tier.RemovePod(pod);
                    Pods.Remove(pod);
                }
                foreach (var elevator in Elevators.Where(e => e.ConnectedPoints.Contains(waypoint)))
                {
                    elevator.UnregisterPoint(waypoint);
                    if (elevator.ConnectedPoints.Count == 0)
                    {
                        Elevators.Remove(elevator);
                    }
                }
                // Make sure it is not on the list of storage locations anymore
                if (waypoint.PodStorageLocation)
                {
                    ResourceManager.RemovePodStorageLocation(waypoint);
                }
                // Finally remove from the overall waypoint list
                Waypoints.Remove(waypoint);
            }
            // Also remove movables in scope
            List <Bot> remBots = Bots.Where(b => b.Tier == tier && xMin <= b.X && b.X <= xMax && yMin <= b.Y && b.Y <= yMax).ToList();

            foreach (var bot in remBots)
            {
                Bots.Remove(bot);
                bot.Tier.RemoveBot(bot);
            }
            List <Pod> remPods = Pods.Where(p => p.Tier == tier && xMin <= p.X && p.X <= xMax && yMin <= p.Y && p.Y <= yMax).ToList();

            foreach (var pod in remPods)
            {
                Pods.Remove(pod);
                pod.Tier.RemovePod(pod);
            }
        }
Exemplo n.º 24
0
 public string PodNames()
 {
     return(Pods != null?string.Join(", ", Pods.Select(pod => pod.SecondValue)) : string.Empty);
 }
Exemplo n.º 25
0
 public void LeavePod(Pod pod)
 {
     Pods.Remove(pod);
 }
Exemplo n.º 26
0
 public void ReceivePod(Pod pod)
 {
     Pods.Add(pod);
 }
Exemplo n.º 27
0
        public override bool Execute()
        {
            if (!base.Execute())
            {
                return(false);
            }

            // make sure we have POD available
            PodToolPath = LocateToolPath(PodToolPath, "pod", "--version");
            if (string.IsNullOrEmpty(PodToolPath))
            {
                return(false);
            }

            if (IsCancellationRequested)
            {
                Log.LogError("Task was canceled.");
                return(false);
            }

            // make sure we have xcodebuild available
            XCodeBuildToolPath = LocateToolPath(XCodeBuildToolPath, "xcodebuild", "-version");
            if (string.IsNullOrEmpty(XCodeBuildToolPath))
            {
                return(false);
            }

            if (IsCancellationRequested)
            {
                Log.LogError("Task was canceled.");
                return(false);
            }

            XCodeBuild = new XCodeBuildTool(XCodeBuildToolPath, Log, GetCancellationToken(), this);
            CocoaPods  = new CocoaPodsTool(PodToolPath, Log, GetCancellationToken(), this);

            var podfile = new Podfile
            {
                Platform        = PodfilePlatform,
                PlatformVersion = PlatformVersion,
                UseFrameworks   = UseFrameworks,
                TargetName      = "MSBuildTask",
                Pods            = Pods.Select(p =>
                                              new Pod
                {
                    Id      = p.ItemSpec,
                    Version = p.GetMetadata("Version")
                }).ToArray()
            };

            var podfileRoot    = BuildIntermediateOutputPath;
            var includeTargets = Pods.Select(p => p.ItemSpec).ToArray();

            if (!UseFrameworks)
            {
                // this extra step when building static archives is needed
                // in order to collect the resources that should be added
                //
                // here we just use the first architecture

                // create the podfile for the bundling build
                podfile.UseFrameworks = true;
                if (!CocoaPods.CreatePodfileXCodeProject(podfileRoot, podfile, true))
                {
                    return(false);
                }
                podfile.UseFrameworks = UseFrameworks;

                // build Pod-CocoaPodBuildTask as a framework
                var framework = BuildPodfileXCodeProject(podfileRoot, includeTargets, XCodeBuildParameters.SplitArchitecture(XCodeArchitectures).FirstOrDefault(), true);
                if (framework == null)
                {
                    return(false);
                }

                // TODO: if building as a static archive,
                // we need to manually include the resources.
            }

            // create the podfile for the real build
            if (!CocoaPods.CreatePodfileXCodeProject(podfileRoot, podfile, noRepoUpdate: true))
            {
                return(false);
            }

            // build Pod-CocoaPodBuildTask as requested
            var outputs = BuildPodfileXCodeProject(podfileRoot, includeTargets, XCodeArchitectures, UseFrameworks);

            if (outputs == null)
            {
                return(false);
            }

            // TODO this needs work - testing only
            var staticArchives = string.Join(" ", outputs.Select(to => $"'{to.ArchiveOutput.Path}'"));

            NewMtouchExtraArgs += $@" -gcc_flags "" {staticArchives} "" ";

            return(true);
        }